Make WordPress Core

Opened 6 weeks ago

Last modified 2 weeks ago

#52941 new task (blessed)

Remove `@babel/polyfill` in favor of `core-js/stable`.

Reported by: desrosj Owned by:
Milestone: 5.8 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:


The @babel/polyfill is deprecated and should be replaced with core-js/stable:

A related issue in Gutenberg with more details: https://github.com/WordPress/gutenberg/issues/22417.

Copied over from #52854 after it was brought up by @gziolo.

Change History (8)

#1 @desrosj
6 weeks ago

  • Milestone changed from Awaiting Review to 5.8

#2 @ocean90
6 weeks ago

#52946 was marked as a duplicate.

#3 @gziolo
6 weeks ago

It looks like we need to create a webpack entry point that imports core-js and regenerator-runtime.

import 'core-js/stable';
import 'regenerator-runtime/runtime';

They aren't defined as dependencies in package.json at the moment.

Thinking a bit more about other polyfill integrations we might also use the copy technique for individual scripts. Similar to how other polyfills in #52854 are handled.

This ticket was mentioned in PR #1191 on WordPress/wordpress-develop by gziolo.

4 weeks ago

  • Keywords has-patch added

#5 @sergiomdgomes
2 weeks ago

The regenerator-runtime/runtime import shouldn't be necessary, but it shouldn't harm us either, provided that the Babel configuration is correctly set up to remove unnecessary polyfills.

Do note that core-js is extremely conservative in which polyfills to include, however, with tiny browser implementation bugs that anyone rarely cares about leading to an inclusion of the full polyfill for that feature.

As a reference, with last 2 chrome versions this setup produces a 9.7KB bundle (not gzipped), whereas with last 2 safari versions that bumps up to 54KB (not gzipped), which is the same value as for the current set of supported browsers minus IE 11 (i.e., Safari becomes the new bottleneck following the dropping of IE 11).

It may be worth diving a bit deeper and configuring the level of aggressiveness to something saner: https://github.com/zloirock/core-js#configurable-level-of-aggressiveness

Last edited 2 weeks ago by sergiomdgomes (previous) (diff)

#6 @prbot
2 weeks ago

gziolo commented on PR #1191:

@sgomes, thanks for the pointer. I arrived at the same documentation before reading your comment when looking at how to reword notes in WordPress packages after dropping support for IE11.

#7 @gziolo
2 weeks ago

I see there is https://www.npmjs.com/package/core-js-builder that we could use to generate our own customized polyfill. I plan to test it in the Gutenberg repository first.

#8 @prbot
2 weeks ago

gziolo commented on PR #1191:

I'm exploring a completely revised approach in https://github.com/WordPress/gutenberg/pull/31279.

Note: See TracTickets for help on using tickets.