-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Polyfills: exclude web.immediate #49234
Conversation
Size Change: +620 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
Flaky tests detected in 70c7d74. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4480504475
|
Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
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.
Thank you so much for this improvement.
Thank you for the review, @gziolo! 👍 |
@sgomes, @gziolo, should we override For the context: The behavior to use |
@sgomes, as you note in the PR description, I'm not sure why the plugin is not doing that already, since it overrides 99% of scripts used by the editor(s). See https://github.com/WordPress/gutenberg/blob/trunk/lib/client-assets.php#L185-L239. |
@Mamaduka Oh, I see, thank you! 👍 So if I understand you correctly, you're suggesting that we override |
Correct! We can also ship similar fixes faster to folks who use the plugin. |
Good idea 👍 |
What?
Remove
setImmediate
/clearImmediate
from the list of features that we polyfill.Why?
While investigating some performance issues in Safari, I noticed that
setImmediate
/clearImmediate
are being polyfilled bycore-js
. These are IE-only features which we don't use, and therefore don't need polyfills for. That alone is probably reason enough to exclude them.But beyond that, it's worth pointing out that
react
does look for them in some circumstances, when deciding how to schedule work. It prefers the nativesetImmediate
implementation when available vs other functionality (such as message channels), due to some inherent characteristics of how it's implemented. So when we polyfillsetImmediate
, we trick React into opting for this approach, even though the inherent characteristics it prefers are not there (since it's just a polyfill that's implemented on top of other functionality).It's therefore best to simply have
react
pick one of the other approaches, instead of havingcore-js
spend the effort to poorly reimplementreact
's preferred approach.How?
It excludes the aforementioned features by changing the
babel-preset-default
configuration.Testing Instructions
It's not entirely clear to me how to force the testing environment to load a newly-generated set of polyfills, given that it seems to be controlled via
load-scripts.php
(which, in my testing, didn't pick up the modified polyfills).(I had to resort to local overrides in my browser to manually modify the concatenated script)
Assuming you can get the new polyfills to load, however, it's simple: just load the editor and smoke-test any functionality, as any problems would make themselves evident immediately. If possible, test using Safari, which does follow the
react
scheduling codepath in question.Testing Instructions for Keyboard
N/A
Screenshots or screencast
N/A