- Install the runtime dependency
npm i --save-dev @babel/plugin-transform-runtime
- Add the plugin to your .babelrc file
{
"plugins": ["@babel/plugin-transform-runtime"]
}
More Info:
https://babeljs.io/docs/en/babel-plugin-transform-runtime
TLDR;
- Async functions are abstraction on top of generators.
- Async functions and generators are now supported in all major browsers and in Node10 and upwards.
- If you are using a transpiler (such as babel) for backwards compatibility, you would need an extra "layer" that transforms generators. This implies transforming ES6 into ES5 at runtime since their syntax isn't backwards compatible. See https://cmichel.io/how-are-generators-transpiled-to-es5