Reputation:
I am using browserify and babel to compile my js files and i want the ng annotate plugin too but it is not working, any ideas why?
The gulp task:
browserify(config.js.src, { debug: true })
.transform(babel.configure({ ignore: /vendor\// }))
.bundle()
.pipe(source(config.js.mainFileName))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(ngAnnotate())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(config.js.dist));
class HomeController {
// @ngInject
constructor($http) {
this.name = 'avi';
}
}
export default HomeController;
Upvotes: 2
Views: 2965
Reputation: 633
I think in your case Babel is stripping comments. Ng-annotate works with compiled es5 code and have to somehow know what to annotate. You can either run babel with comments: true
and compact: false
to preserve comments or use string literals:
constructor($http) {
"ngInject";
this.name = 'avi';
}
Upvotes: 3