I have a very simple gulpfile.babel.js .
import 'babel-polyfill'
let y = ()=>{return Promise.resolve(true)}
async function awaitY() {
let m = await y()
console.log(m)
}
awaitY()
and the following dev dependencies in my package.json
"babel-core": "^6.7.4",
"babel-polyfill": "^6.7.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-stage-0": "^6.5.0"
and the following in my .babelrc
{
"presets": ["es2015","stage-0"]
}
When I run gulp, i get the following error...
MacBook-Pro-2:gulptest jschlesser$ gulp
[15:26:17] Requiring external module babel-core/register
/Users/jschlesser/Dropbox (Personal)/prj/cursive/spout/gulptest/gulpfile.babel.js:4
var ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
^
ReferenceError: regeneratorRuntime is not defined
at /Users/jschlesser/Dropbox (Personal)/prj/cursive/spout/gulptest/gulpfile.babel.js:4:31
at Object.<anonymous> (gulpfile.babel.js:5:16)
at Module._compile (module.js:435:26)
at loader (/Users/jschlesser/Dropbox (Personal)/prj/cursive/spout/gulptest/node_modules/babel-register/lib/node.js:126:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/jschlesser/Dropbox (Personal)/prj/cursive/spout/gulptest/node_modules/babel-register/lib/node.js:136:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Liftoff.handleArguments (/Users/jschlesser/.npm-packages/lib/node_modules/gulp/bin/gulp.js:116:3)
MacBook-Pro-2:gulptest jschlesser$
I would like to know what steps are needed to use async/await in a gulpfile. The error implies that gulp used a require hook to run the gulpfile through babel and it transformed the async function into a generator.
It says the error is on line 4.
var ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() { .
But it looks like its not injecting all of the right stuff into that compiled file to use the regeneratorRuntime.