Rim*_*ian 1 javascript angularjs ecmascript-6 gulp gulp-traceur
我正在使用[gulp-traceur] [1]在我的angularjs应用程序(1.x)中将es6编译为js.当我尝试编译for循环时,我收到错误:
ReferenceError: $traceurRuntime is not defined
Run Code Online (Sandbox Code Playgroud)
看起来我需要将$ traceurRuntime注入我的控制器或其他东西.谁能帮我吗?
$traceurRuntime是全局范围内的对象,而不是Angular注射器.此对象来自traceur-runtime.js应用程序中包含traceur运行时脚本文件().确保包含traceur.RUNTIME_PATH所以gulp任务知道在编译期间在哪里找到它并包含它.
假设你的gulpfile看起来像这样:
// gulpfile.js
var traceur = require('gulp-traceur');
// ...
gulp.task('build', function() {
return gulp.src([
traceur.RUNTIME_PATH, // <-- add this
'src/**/*.*'
])
.pipe(traceur({ /* traceur config */ })
.pipe(gulp.dest('/dist'));
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2576 次 |
| 最近记录: |