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