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

Use builtins #319

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Use builtins #319

wants to merge 3 commits into from

Conversation

sfarthin
Copy link

@sfarthin sfarthin commented Mar 4, 2020

See #317 first. Will be a much smaller changeset if that PR is merged.


Previously this library depended on a global polyfills (@babel/polyfill) to be compatible with older platforms (e.g. older browsers and node). Babel deprecated this strategy and encourages importing from core-js directly. With babel-preset-env preset, we can automatically import the required polyfills with the useBuiltins options.

For example previously we would get this as a babel output...

$ echo "Promise.resolve().finally();" > myTest.js
$ babel myTest.js
"use strict";

Promise.resolve()["finally"]();

Now with the useBuiltins option, our output looks like this:

$ echo "Promise.resolve().finally();" > myTest.js
$ babel myTest.js
"use strict";

require("core-js/modules/es6.promise");

require("core-js/modules/es6.object.to-string");

require("core-js/modules/es7.promise.finally");

Promise.resolve()["finally"]();

Including the polyfills in the library will increase the size, but solves issues with versions of @babel/polyfill and other globals effecting this library. Another option would be to use babel/runtime, but that would require changes to the consumers. See more details on the tradeoffs.

Steven Farthing added 3 commits March 4, 2020 12:01
Update to babel 7's scoped packages and remove unneeded transform-object-rest-spread plugin
Remove compatibly issues with babel-polyfill, stop side-effects related to polluting global scope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant