-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
core-js: only polyfill stable features #57674
Conversation
Size Change: 0 B Total Size: 1.69 MB ℹ️ View Unchanged
|
I would have to double check but I have the impression that we have always discussed supporting only stage 4 proposals in WordPress core. If that’s true then we should definitely get rid of stage 3 and lower from the bundle. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This config is confusing.
modules: [ 'es', 'web' ],
- it does not exclude anything sinceesnext
also starts fromes
. That means that even stage 0 proposals are included - it's too dangerous. Usees.
or a regex. It's too common issue and similar patterns will be disallowed in the next major release in favor of regexes or full module names.- I strongly don't recommend excluding
'es.promise'
pattern:- That also excludes other modules that start from
es.promise
- like in the case above - for example, polyfills for modern features likePromise.any
,Promise.withResolvers
,Promise#finally
, etc. excluded from the bundle. - Only tenths of a percent of actually used browser
Promise
implementations (Chrome < 67, FF < 69, Safari < 11) fails thecore-js
Promise
feature detection and currentcore-js
Promise
implementation with proper usage should not cause any problems. Could you explain why this exclusion is required?
- That also excludes other modules that start from
I don't think it works that way. Here |
@swissspidy I know how it works since I wrote it, see this line -) And yes, as I wrote - it's confusing and in v4 it will be replaced with more obvious logic. |
Haha whoops, never mind then :D |
I played with the build config for a while and this is what I arrived at:
The result of
My main assumption here is that |
Neat, thanks for the detailed analysis!
That sounds interesting! I just added this, but how can I see this output when I do a |
For me it just worked. I added |
After moving proposals to stable ES, |
Note that in |
In your output some moments confuse me - here missed polyfill for some modern features - like |
Flaky tests detected in 12b8001. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7640799857
|
That's true, after update of
That's nice, even |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good to go now 👍
Thanks, now the lockfile looks much better. Only upgrades existing packages and doesn't add any duplicates. |
If you wanna polyfill "brand new methods" it's better take a look at stage 3 proposals. Stage 4 (stable ES) can be accepted only if a feature is implemented in 2 from 3 actual browser JS engines. Stage 3 is a flag that feature could be implemented in engines and almost all actual stage 3 proposals has at least one browser implementation. New However, if your policy strictly define "stable JS only" - it's your choice -) |
Yes, we indeed have a conservative policy to use only stable ES featues 🙂 |
What?
Fixes #57247 by ensuring only stable features are polyfilled.
Updates browserslist and core-js to the latest versions.
Polyfill size decreases from 380kB to just 125KB 🎉 🚀
The following polyfills are now included:
Why?
Addresses a performance concern for heavy usage of JSON for cloning data.
How?
Exclude the polyfill that's causing this
Testing Instructions
TODO