Allow TLA for legacy build and remove static Intl polyfills #19207
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.
Proposed change
Webpack's issue with TLA having ES5 support, webpack/webpack#11874, is likely never to get fixed, so I wrote a fairly simple plugin to do the job using Babel: https://github.com/steverep/transform-async-modules-webpack-plugin.
So this change gets rid of the static imports for the
Intl
polyfills, and now technically allows any TLA use. However, that comes with a big hiccup for now. Note that even though the change removes ~2MB of locale and time zone data from the bundle, the bundle size actually goes significantly up.this is because the plugin does not make use of
@babel/runtime
and instead includes the helpers and regenerator inline. Because of duplicates from code splitting and the fact that every module that imports the polyfill is affected, that results in a lot of bytes. (Recall the drastic reductions from #16466.)I think I can make the plugin use
@babel/runtime
, but it makes it much more complex. I could probably also mess with Webpack settings to reduce that duplication in a follow up. I think it's probably still worth merging now for browsers at the top of the legacy spectrum though since there would still be deferral benefits and some polyfill chunks would never get loaded.Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: