Babel7 ES and async/await

I’m trying to use async/await with a fresh project with aurelia cli (babel7, es, and the new aurelia bundler…)

But I’m getting the nasty "ReferenceError: regeneratorRuntime is not define ".

Looking out there in the docs of babel I have added to .babelrc.js plugins:

return {
“plugins”: [
[’@babel/plugin-transform-runtime’,
{
“corejs”: false,
“helpers”: true,
“regenerator”: true,
“useESModules”: false
}]

but it’s not working…any ideas?

Did you try to add babel polyfill? A google for "ReferenceError: regeneratorRuntime is not define" shows a lot of results related to missing babel polyfill

Not sure how to do it in au CLI but here is an example with webpack. Perhaps that can give you a clue…

Hi, in your main.js or main.ts file, add
import ‘babel-polyfill’;

Regards,

With babel7, it is import '@babel/polyfill';.

Hey guys, thank you all for the answers… but none of them worked for me.

I have left it for the moment because I have other priorities … and in the end I will also convert all the code to typescript.

@jrogalan would you mind to open an issue in cli github repo? I will try to fix the skeleton after my vacation.

1 Like

Awesome @huochunpeng ,

Thanks!

3 Likes

Hi @jrogalan,
I managed to get async await working with by adding this to prepend in aurelia.json

aurelia.json


“name”: “vendor-bundle.js”,
“prepend”: [
“node_modules/@babel/polyfill/dist/polyfill.min.js”,
“node_modules/bluebird/js/browser/bluebird.core.js”,

1 Like

@LetsZiggy thank you! its works like a charm… :money_mouth_face: