-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add back "moduleName" option to @babel/plugin-transform-runtime
#15426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53911/ |
| const { | ||
| moduleName = corejsVersion === 3 | ||
| ? "@babel/runtime-corejs3" | ||
| : corejsVersion === 2 | ||
| ? "@babel/runtime-corejs2" | ||
| : "@babel/runtime", | ||
| } = options; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I slightly prefer to have it at the top so that we have (roughly, because there is the logic to compute the corejsVersion variable):
- get the various options, with their default values
- validate all the options
- throw about old options
- the rest of the plugin logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using
babel-plugin-polyfill-corejs3and@babel/runtimeseparately, which is technically the recommended config since it clearly splits handling of helpers and polyfills (which are two separate concepts, and we just happened to handle them together for historical reasons),@babel/plugin-transform-runtimeinjects helpers imports to the version of@babel/runtimewhich internally doesn't use core-js polyfills (i.e. not@babel/runtime-corejs3).This option was already supported in Babel 6, but it had been removed in #8266.
This fixes babel/babel-polyfills#128 (comment) (@emmyakin, sorry for being one year late 😬)
The new config would be
{ "plugins": [ ["@babel/plugin-transform-runtime", { "moduleName": "@babel/runtime-corejs3" }], ["babel-plugin-polyfill-corejs3", { "method": "usage-pure" }] ] }Additionally, this option would potentially allow users to use different forks of
@babel/runtimewith their own different sets of polyfills.