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

Restore core-js and useBuiltIns = usage #26576

Closed
wants to merge 1 commit into from
Closed

Restore core-js and useBuiltIns = usage #26576

wants to merge 1 commit into from

Conversation

WraithKenny
Copy link

@WraithKenny WraithKenny commented Oct 29, 2020

No description provided.

Currently, the preset doesn't actually pollyfill anything, which seems weird and unintended.

An attempt was made to add these options before (but was strangely only under `isTestEnv`) but was promptly removed in the next patch (because it didn't really belong in `isTestEnv`)
@gziolo
Copy link
Member

gziolo commented Oct 30, 2020

See #9643 where useBuiltIns was disabled for production code.

This pull request seeks to disable our use of the @babel/runtime useBuiltIns option, replaced instead by @babel/polyfill as a dependency of every script registered by Gutenberg. This could be further enhanced to conditionally load the script only for browsers where expected features are not supported, but at this time it is not evident how such a condition would be formed.

While this technically adds a new script to be loaded, there is a net decrease in bundle size, from 2011.96kb total to 1803.72kb (+89.6kb polyfill) (minified, pre-gzip), for an overall savings of 118.64kb. Full build comparison below:

We include the following note for all packages that need polyfills (it will need to be updated when Babel 8 is shipped):

This package assumes that your code will run in an ES2015+ environment. If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using core-js or @babel/polyfill will add support for these methods. Learn more about it in Babel docs.

What would be the reason to change it back to enable useBuiltIns?

@gziolo gziolo added [Tool] Babel preset /packages/babel-preset-default [Status] Needs More Info Follow-up required in order to be actionable. labels Oct 30, 2020
@gziolo
Copy link
Member

gziolo commented Nov 7, 2020

I'm closing this PR. Feel free to reopen if there is a compelling reason yo change the current approach.

@gziolo gziolo closed this Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Needs More Info Follow-up required in order to be actionable. [Tool] Babel preset /packages/babel-preset-default
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants