-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Use the babel-plugin-polyfill-*
packages in preset-env
#12583
Conversation
526ed65
to
275ec2d
Compare
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/41469/ |
"opera": "48", | ||
"safari": "10.1", | ||
"samsung": "8.2" | ||
} |
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.
The targets are now printed multiple times: once by preset-env (for the transform) and one by the polyfill plugin. I could inject a secret parameter used only by preset-env
to avoid printing them in the polyfill provider, but I don't think that it's worth the complexity.
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.
FWIW, I do think it's worth the complexity :)
import "core-js/modules/es7.object.values.js"; | ||
import "core-js/modules/es6.array.map.js"; |
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'm not sure why the old code included these polyfills, but the new one seems correct to me.
7782a8b
to
2dac5c2
Compare
@@ -27,7 +27,7 @@ | |||
"devDependencies": { | |||
"@babel/core": "workspace:*", | |||
"@babel/helper-plugin-test-runner": "workspace:*", | |||
"babel-plugin-polyfill-corejs3": "0.0.10", | |||
"babel-plugin-polyfill-corejs3": "0.0.11", |
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.
@merceyz If I don't update this to 0.0.11
, I get this error:
➤ YN0001: │ Error: Assertion failed: /home/nicolo/Documenti/dev/babel/babel/packages/babel-plugin-proposal-async-generator-functions/node_modules/@babel/types cannot merge nodes with different link types
Is it a Yarn bug?
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.
@nicolo-ribaudo Yes, looks like a Yarn bug, I will take a look and report back
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.
Thanks for the ping, I forwarded it to @larixer as he has a better grip on this part of the codebase
Apparently I didn't send this comment earlier
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.
@nicolo-ribaudo Is this line really needed:
https://github.com/nicolo-ribaudo/babel/blob/polyfill-providers/package.json#L82
I'm afraid with this line you have atypical dependency graph, when there are workspace nodes not only at the beginning of the graph, but deep inside graph and that might make the graph unrepresentable in node_modules layout. I'm still investigating and I'm not fully understand what is happening yet, but the graph you have seems very difficult with this line.
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 think it's needed because:
@babel/parser
doesn't have a dependency on@babel/types
, which is used for TS typings (before adding it we need to add/fix different TS types across the monorepo)- To avoid failures, yarn uses
packageExtensions
to add a@babel/types
dependency - It pulls in
@babel/types
from npm, causing problems due to nominal types
If the problem is that line, we will fix it at some point and for now we'll make sure to have the same babel-plugin-polyfill-corejs3
in all the packages to help yarn deduping (it's working with this exact setup).
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.
@nicolo-ribaudo Thanks, for now I think its a Yarn bug which should be fixed, I'll let you know when I have more information.
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.
@nicolo-ribaudo Looks like the bug happens due to hoisting result is not terminal, if another pass of hoisting is done for this repo the conflict on @babel/types
version is gone. I have implemented multi-pass hoisting which finishes when the result is the same on two consecutive hoisting passes here:
yarnpkg/berry#2394
For this repo 3 passes are needed, on the 1st and 2nd pass the hoisting layout changes and on 3rd pass nothing is changed, but it is still needed for algorithm to understand that we have a terminal result.
The downside of this approach is that it is obviously slower, in master
hoisting takes 380ms for me, and multi-pass hoisting takes 1.28s
. I'm still looking into ways to optimise multi-pass hoisting speed.
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 735bb3d:
|
32686ff
to
08d77ec
Compare
08d77ec
to
ac7553f
Compare
packages/babel-preset-env/test/fixtures/corejs2/usage-shippedProposals/output.js
Outdated
Show resolved
Hide resolved
packages/babel-preset-env/test/fixtures/corejs2/usage-symbol-iterator-in/output.mjs
Show resolved
Hide resolved
a3d3a8d
to
cdf30ac
Compare
This PR is marked as |
20ae842
to
17712d3
Compare
This PR is now targeting
main
without any feature flags because now the polyfill packages are transpiled to be compatible with Node.js 6, so they don't introduce breaking changes.We will still need to update
transform-runtime
, but that is harder because thebabel-plugin-polyfill-*
packages don't inject imports to@babel/runtime
.This PR depends on babel/babel-polyfills#50, babel/babel-polyfills#51 and babel/babel-polyfills#52,
so I expect CI to fail for now. (EDIT: These PRs have been merged and published)