Skip to content
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

[babel 8] Remove core-js 2 and regenerator from preset-env #15838

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Aug 3, 2023

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link babel/website#2839
Any Dependency Changes?
License MIT

This PR removes support for babel-plugin-polyfill-corejs2 and babel-plugin-polyfill-regenerator from @babel/preset-env:

  • core-js 2 is not maintained anymore (core-js 3 was released years ago), and users shuold not use it
  • Babel now injects regenerator-runtime as a normal helper, so there is no need for the polyfill provider

If users still need those two plugins (for example, because they are manually writing references to regeneratorRuntime in their code, or because they cannot migrate to core-js 3), they can still use them directly rather than through preset-env.

The deleted corejs2 tests already have equivalent corejs2-babel7 folders, so the deleted files are only for Babel 8.

I will open a similar PR for transform-runtime.

@@ -0,0 +1,9 @@
// TODO(Babel 8): Remove this file
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 rewrote the files in this folder to CJS so that they can easily be conditionally required.

@babel-bot
Copy link
Collaborator

babel-bot commented Aug 3, 2023

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

@nicolo-ribaudo nicolo-ribaudo force-pushed the babel-8-env-corejs2 branch 2 times, most recently from b41b429 to 4624ff2 Compare August 7, 2023 17:26
@JLHwung JLHwung removed the babel 8 label Aug 8, 2023
@JLHwung JLHwung added this to the Babel 8.0 milestone Aug 8, 2023
@JLHwung JLHwung added the PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release label Aug 8, 2023
@JLHwung
Copy link
Contributor

JLHwung commented Aug 8, 2023

I mark this PR as breaking change because the preset-env options corejs, include and exclude will be affected by this change.

@@ -90,10 +90,9 @@
"@babel/plugin-transform-unicode-regex": "workspace:^",
"@babel/plugin-transform-unicode-sets-regex": "workspace:^",
"@babel/preset-modules": "0.1.6-no-external-plugins",
"@babel/types": "workspace:^",
"babel-plugin-polyfill-corejs2": "^0.4.5",
"babel-plugin-polyfill-corejs2": "condition:BABEL_8_BREAKING ? : ^0.4.5 (peer:@babel/core)",
Copy link
Member Author

Choose a reason for hiding this comment

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

(peer:@babel/core) is to correctly propagate the @babel/core dep provided by @babel/preset-env to babel-plugin-polyfill-corejs2-BABEL_8_BREAKING-false.

* Remove getPolyfillPlugins from the public API
* Only load babel 7 polyfill plugins when used
* Support `@babel/core` cjs proxy in local dev
@nicolo-ribaudo
Copy link
Member Author

It's bee two months since I touched this code -- I self-reviewed it and it seems good. It only changed Babel 8 behavior, and in Babel 7 everything behaves the same (including "accidentally exposed" function from @babel/preset-env).

I'm merging this, because this PR touches a lot of files and rebasing it is difficult every time.

@nicolo-ribaudo nicolo-ribaudo changed the title [babel 8] Remove corejs2 and regenerator from preset-env [babel 8] Remove core-js 2 and regenerator from preset-env Oct 13, 2023
@nicolo-ribaudo nicolo-ribaudo merged commit 0ba00c4 into babel:main Oct 13, 2023
47 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the babel-8-env-corejs2 branch October 13, 2023 06:19
@@ -0,0 +1,4 @@
/* eslint-disable */
module.exports = require("$repo-utils").USE_ESM
Copy link
Member

Choose a reason for hiding this comment

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

Won't this file be preserved on release? We should not depend on $repo-utils.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's in .npmignore

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.

@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 Jan 30, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 30, 2024
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 pkg: preset-env PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants