Hey 吕立青, Great question. We need to use @babel/preset-env which transforms syntax. We need to use @babel/transform-runtime to avoid duplicate code, and config core-js: 3 to polyfill.
babel-plugin-transform-runtime automatically injects Regenerator where generators or async/await are used.
So, installing babel/runtime and @babel/plugin-transform-runtime will solve your problem.
So, what you can do is,
yarn add @babel/plugin-transform-runtime
yarn add @babel/runtime
and in .babelrc, you can add this plugin.
"plugins": [
["@babel/plugin-transform-runtime",
{
"regenerator": true
}
]
]
By default regenerator is true
JimmyLv_吕立青
想做产品,却误入程序世界爱上设计的摄影师。
Do we still need @babel/runtime and @babel/plugin-transform-runtime if we need to use (Iterator、Generator、Set、Maps、Proxy、Reflect、Symbol、Promise、Object.assign) the new JavaScript Syntax after applying @babel/preset-env?