【发布时间】:2016-03-17 20:04:16
【问题描述】:
我已经使用 Stack 几个小时了。我正在使用 gulp,我正在尝试设置我的构建过程。
构建js看起来是这样的。
gulp.task('buildJS', function () {
browserify('./browser/js/main.js')
.transform('babelify',
{
presets: ["es2015", "react"],
plugins: ['transform-class-properties', "transform-object-rest-spread", "transform-decorators-legacy"]
})
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./dist'));
});
这最终给了我这个错误:
events.js:141
throw er; // Unhandled 'error' event
^
SyntaxError: Unexpected character '@'
我的 babelrc 是这样的:
{
"presets": ["es2015", "react"],
"plugins": ["transform-object-rest-spread","transform-class-properties", "transform-decorators-legacy"]
}
所以感觉像 transform-decorators-legacy 不起作用。
我正在使用“babel-core”:“^6.7.2”。
我已经安装了 "babel-plugin-transform-decorators-legacy": "^1.3.4",
我尝试使用 stage-x 预设只是为了获得Decorators are not supported yet in 6.x pending proposal update.
是否还有人在使用 transform-decarators-legacy 帖子更新时遇到问题?
【问题讨论】:
-
你安装了
babel-plugin-transform-decorators-legacy包吗? -
是的! "babel-plugin-transform-decorators-legacy": "^1.3.4",
-
那么抛出错误的文件是什么?
-
它是 events.js,在 gulp 的某个地方。我没有手动处理错误,这是这个 gulp 任务所必需的。有兴趣的请看下文。
标签: reactjs gulp browserify babeljs