Exclude core-js polyfills from ESM-capable browser bundles#6068
Merged
Conversation
**Why**: So that the majority of users don't have to pay the performance penalty for polyfills supporting legacy browsers, avoid loading those polyfills except in the legacy browsers.
…r modern browsers
aduth
commented
Mar 15, 2022
| @@ -1,8 +1,7 @@ | |||
| import 'promise-polyfill/src/polyfill'; | |||
Contributor
Author
There was a problem hiding this comment.
core-js includes a Promise and URL polyfill, so we don't need the other one. Which is nice because it lets us use fewer dependencies.
Contributor
Author
|
Based on failing build, looks like I need to fix something with how the regenerator runtime is included for modern browser builds. |
aduth
added a commit
that referenced
this pull request
Mar 16, 2022
aduth
added a commit
that referenced
this pull request
Mar 17, 2022
…#6075) * Revert "Revert "Exclude core-js polyfills from ESM-capable browser bundles (#6068)" (#6074)" This reverts commit 376bc2c. * Drop jsbundling_rails in favor of custom rake task **Why**: So that we can have CI install dependencies in the same way as is expected in production, since jsbundling_rails will always install devDependencies with no option to opt-out. * Revert "Drop jsbundling_rails in favor of custom rake task" This reverts commit c4b97b5. * Use NODE_ENV production to exclude devDependencies in CI * Move babel-plugin-polyfill-corejs3 to dependencies **Why**: So that it's available in production build environments. changelog: Improvements, Optimization, Skip polyfill load behavior for modern browsers
aduth
added a commit
that referenced
this pull request
Apr 12, 2022
**Why**: - Because polyfills are intended to be confined to the polyfill package (#6060) - So that it's not included in modern browsers (#6068, -0.9kb gzipped) - To reduce surface area of dependencies shared with USWDS (related to 18F/identity-design-system#312 (comment)) changelog: Internal, Optimization, Reduce size of JavaScript for modern browsers
aduth
added a commit
that referenced
this pull request
Apr 13, 2022
**Why**: - Because polyfills are intended to be confined to the polyfill package (#6060) - So that it's not included in modern browsers (#6068, -0.9kb gzipped) - To reduce surface area of dependencies shared with USWDS (related to 18F/identity-design-system#312 (comment)) changelog: Internal, Optimization, Reduce size of JavaScript for modern browsers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: So that the majority of users don't have to pay the performance penalty for polyfills supporting legacy browsers, avoid loading those polyfills except in the legacy browsers.
This builds on #6060 (#6060 (comment)). While #6060 excluded polyfills implemented through our
@18f/identity-polyfillpackage, it did not cover polyfills injected through Babel's@babel/preset-envpreset. With these changes,@babel/preset-envis configured to only include polyfills for browsers which are capable of ESM, and includes a full set of polyfills for non-ESM-capable browsers in@18f/identity-polyfill, to be loaded only for those browsers. JavaScript syntax is still downgraded to all supported browsers including IE11, which is also tested for usingyarn es5-safe.Local measurements (via
NODE_ENV=production make run) show a reduction of JavaScript on the home page of ~34% (80.3kb to 53.2kb).