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.
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.
Share Improve this question asked Dec 9, 2016 at 17:38 Javid AsgarovJavid Asgarov 1,5321 gold badge18 silver badges33 bronze badges1 Answer
Reset to default 8This plugin still requires regeneratorRuntime. You need to install babel-polyfill and import it explicitly in your JS:
npm install --save-dev babel-polyfill
- Copy polyfill to your static scripts folder:
cp node_modules/babel-polyfill/dist/polyfill.min.js ./public/js
- Add polyfill script to the top of your html head
<script src="/public/js/polyfill.min.js"></script>