Reputation: 1532
I use Gulp for transpiling ES6, but with generator it gives the error of: "Uncaught ReferenceError: regeneratorRuntime is not defined".
I have found that I need babel-polyfill for this and documentations suggests uses for Node / Browserify / Webpack.
Can't I fix this in Gulp without webpack? I didn't find how. I installd babel-plugin-transform-regenerator and did this in my gulpfile.js:
gulp.task('scripts', function() {
return gulp.src('src/js/*.js')
.pipe(plumber())
.pipe(babel({
presets: ['es2015', 'stage-3'],
plugins: ["transform-regenerator"]
}))
.pipe(uglify())
.pipe(gulp.dest('src/js/result'))
.pipe(browserSync.stream());
});
But it didn't help.
Upvotes: 2
Views: 2760
Reputation: 1233
This plugin still requires regeneratorRuntime. You need to install babel-polyfill and import it explicitly in your JS:
npm install --save-dev babel-polyfill
cp node_modules/babel-polyfill/dist/polyfill.min.js ./public/js
<script src="/public/js/polyfill.min.js"></script>
Upvotes: 8