I am not able to setup babel correctly for the usage of async / await.
I am using babel 7 and webpack 4.
I do not want to use babel-polyfill if possible!
My babelrc file:
{
"presets": [[
"@babel/env",
{"modules": false}
]],
"plugins": [
"syntax-dynamic-import",
"transform-async-to-generator"
]
}
Code:
async function init() {
const loaderData = await initLoader();
initCmp(loaderData)
.then(initApi(loaderData.key))
.catch();
}
init();
And Error:
refactor.main.js:18 Uncaught ReferenceError: regeneratorRuntime is not defined
at eval (refactor.main.js:18)
at eval (refactor.main.js:47)
at Object../client/refactor.main.js (cmp.bundle.js:312)
at __webpack_require__ (cmp.bundle.js:62)
at eval (main.js:6)
at Object../client/main.js (cmp.bundle.js:300)
at __webpack_require__ (cmp.bundle.js:62)
at cmp.bundle.js:179
at cmp.bundle.js:182
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…