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
Fix disappearing polyfills when conflicting versions of preset are used #12554
base: main
Are you sure you want to change the base?
Fix disappearing polyfills when conflicting versions of preset are used #12554
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/36836/ |
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 28f6547:
|
import "core-js/modules/es.object.from-entries.js"; | ||
import "core-js/modules/esnext.string.replace-all.js"; | ||
import 'core-js/modules/es.object.from-entries'; | ||
import 'core-js/modules/esnext.string.replace-all'; |
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.
Can you add test cases when input file contains core-js imports ending with .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.
Makes sense 👍 is this single scenario enough or you had more cases in mind?
28f6547
It's possible that this will also be fixed by #12583 |
@ertrzyiks #12583 doesn't fix this bug, but since we are replacing our polyfills injection logic I have copied this PR to babel/babel-polyfills#56 (also, I figured out how to properly add a test). Thanks for the help anyway, and I set you as the author of the commits in the other repo! |
@nicolo-ribaudo makes sense, thanks for letting me know and all the help with my very first PR. It was unexpectedly easy to work with such complex codebase. We can close this PR, right? |
I don't know if #12583 will be merged before the next release, so I think it's better to keep this open for now. |
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 7.13.0 release that replaces this transform is taking way longer than expected, and this PR is a good fix until 7.13.0.
If the preset-env is applied twice and
The core-js polyfills are removed from the bundle.
Example of breaking configuration can be found in the demo project:
https://github.com/ertrzyiks/babel-loader-lost-polyfills-demo
The demo project uses preset-env and preset-react-app. The minimal configuration causing polyfills to disappear is the following:
Updated snapshots
The two updated snapshots are for cases when the input importing specific files like
so judging by the purpose of the original PR introducing the extensions won't be problematic: the original imports are kept untouched. No autogenerated code without .js extension though.