-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
What do we need to make usage-global
injection work with @babel/runtime
?
#16391
Labels
Comments
I don't remember how internally works
It looks slower than the predefined list of dependencies but simpler for maintenance. |
As I'm a naive user, I like what @zloirock proposed as it has the following two advantages:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
馃捇
What problem are you trying to solve?
@nyngwang has been going around a bit checking how our polyfill injection works (thank you very much!), and after going through their comments I realized that our injection story for
usage-global
is pretty bad when it comes to helpers.If you have this config:
Babel will inject imports for helpers like
import _typeof from "@babel/runtime/helpers/typeof"
.Then you decide that you want to inject global polyfills through
core-js
, so you update your config to this:now Babel will inject imports like
import "core-js/modules/es.array.flat.js";
, but suddently your imports for helpers will becomeimport "@babel/runtime-corejs3/helpers/typeof"
(which depends oncore-js-pure
). This is to make sure that the helpers are also polyfilled, but:core-js
andcore-js-pure
If you still want to use
@babel/runtime
(because@babel/runtime-corejs3
includes polyfills down to ES5), you have to instead use this config:Describe the solution you'd like
What if for each helper we maintained the list of built-ins that it relies on, and when injecting a
import "@babel/runtime/typeof/helpers"
we called the polyfill provider saying "hey, we included a helper that usesSymbol
andArray.prototype.flat
: if needed for the configured target, consider injecting imports to these polyfills".Then, when compiling
typeof foo
and using["babel-plugin-polyfill-corejs3", { "method": "usage-global" }]
, we would generate some code likerather than
This list would probably need to be manually-maintained by us for each helper, and:
@babel/runtime
versionsDescribe alternatives you've considered
Do nothing
Documentation, Adoption, Migration Strategy
No response
The text was updated successfully, but these errors were encountered: