Skip to content

Conversation

@nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Feb 15, 2023

Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature? Yes
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

When using babel-plugin-polyfill-corejs3 and @babel/runtime separately, 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-runtime injects helpers imports to the version of @babel/runtime which 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/runtime with their own different sets of polyfills.

@nicolo-ribaudo nicolo-ribaudo added the PR: New Feature 🚀 A type of pull request used for our changelog categories label Feb 15, 2023
@babel-bot
Copy link
Collaborator

babel-bot commented Feb 15, 2023

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53911/

Comment on lines 94 to 101
const {
moduleName = corejsVersion === 3
? "@babel/runtime-corejs3"
: corejsVersion === 2
? "@babel/runtime-corejs2"
: "@babel/runtime",
} = options;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Aug 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: New Feature 🚀 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ownKeys, _objectSpread not imported from @babel/runtime helpers

4 participants