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

preset-env: Offer automated locus of control to consumers for `targets` choices (and whether to include builtin deps.) #10087

brettz9 opened this issue Jun 12, 2019 · 1 comment


None yet
2 participants
Copy link

commented Jun 12, 2019

Feature Request

Is your feature request related to a problem? Please describe.

While @babel/preset-env has useBuiltIns (and exclude: ["@babel/plugin-transform-regenerator"]) to reduce what is consumed out of core-js (or regenerator-runtime), libraries are still forced to determine targets and consumers are all still forced to use core-js or regenerator-runtime (and have no choice as to their own wishes for targets). OTOH, when useBuiltins is not used, libraries or applications are unaware of what dependencies ought to be added or having an automated way to get at this, at least without going through another Babelification routine.

Describe the solution you'd like

I am thinking Babel (as with @babel/preset-env) could optionally save a config file indicating the polyfills for builtins in use within a package (though bundling it separately from the distribution file, say as JSON).

A build tool employed optionally by an application could look for this config file in each of its dependencies and add core-js or regenerator-runtime imports to the application's entry file (eliminating duplicate import statements if different projects required the same).

Describe alternatives you've considered

(Explained above.)

Teachability, Documentation, Adoption, Migration Strategy

Libraries using @babel/preset-env could set a new option buildBuiltinsJSON to true and probably avoid setting useBuiltIns.

Consuming applications would ideally have access to a command line or programmatic tool from Babel to add (or replace existing) imports within a specified entry file for their application, based on the .babel-builtins.json files across all of their dependencies.


This comment has been minimized.

Copy link

commented Jun 12, 2019

Hey @brettz9! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
that typically always has someone willing to help. You can sign-up here
for an invite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.