吴角注释不巴贝尔工作 [英] Angular ng annotate does not work with babel
本文介绍了吴角注释不巴贝尔工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用browserify和巴贝尔编译我js文件,我想在NG注解插件太多,但它不工作,任何想法,为什么?
该一饮而尽任务:
browserify(config.js.src,{调试:真})
.transform(babel.configure({忽略:/供应商\\ //}))
。束()
.pipe(来源(config.js.mainFileName))
.pipe(缓冲液())
.pipe(sourcemaps.init({loadMaps:真}))
.pipe(ngAnnotate())
.pipe(sourcemaps.write(./))
.pipe(gulp.dest(config.js.dist));类HomeController的{
// @ngInject
构造函数($ HTTP){
this.name ='AVI';
}
}出口默认的HomeController;
解决方案
我觉得你的情况巴贝尔剥意见。 NG-注释工作编译ES5 code和必须以某种方式知道什么注释。您可以运行巴贝尔与评论:真正的
和紧凑:假
来preserve意见或使用字符串:
构造函数($ HTTP){
ngInject;
this.name ='AVI';
}
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;
解决方案
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';
}
这篇关于吴角注释不巴贝尔工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文