Inject core-js@3 imports in Program:exit instead of on post()#10146
Inject core-js@3 imports in Program:exit instead of on post()#10146nicolo-ribaudo merged 4 commits intobabel:masterfrom
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11016/ |
|
I wonder how this works with the combination of builtins-usage and the commonjs transform. The commonjs transform uses |
|
In that case, after modules have been transformed, useBuiltIns will inject a plain require call to the polyfill. |
packages/babel-preset-env/src/polyfills/corejs3/entry-plugin.js
Outdated
Show resolved
Hide resolved
| @@ -1,2 +1,2 @@ | |||
| import "core-js/modules/es.object.from-entries"; | |||
| import "core-js/modules/esnext.string.replace-all"; | |||
| import 'core-js/modules/es.object.from-entries'; | |||
There was a problem hiding this comment.
These quote changes seem unintended/unnecessary?
There was a problem hiding this comment.
It's because Babel, when possible, reuses the original quotes.
The old implementation removed this import statements and replaced with a new copy of them, while this implementation avoids replacing an import which is already ok.
This allows them to be requeued and transformed by other plugins.
2245b06 to
05792c3
Compare
…s [skip ci] Co-Authored-By: Brian Ng <bng412@gmail.com>
Nodes injected during
post()can't be visited again, so it should be avoided.When reviewing this PR, disable whitespaces in the diff.