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.
Related: 94a3887#commitcomment-22078032
This pull request seeks to introduce
babel-polyfill
to ensure that ES2015+ base type instance methods are available in every supported environment (e.g.Array#find
,String#startsWith
). We already use thetransform-runtime
plugin which converts ES2015 static property methods likeObject.assign
into ES5 equivalents.This is intended as a developer experience improvement. We don't need the polyfill, and in fact it incurs a non-trivial weight cost. But in my experience the lack of a polyfill is very frequently overlooked, and developers will expect all ES2015+ features to work out of the box. These are subtle bugs because evergreen browsers implement these functions natively, but older yet supported browsers do not (IE11).
But alas, I grow weary of being the polyfill naysayer and enforcer. Should anyone else volunteer to assume this role, we could consider forgoing it.
By specifying the
useBuiltIns
option in ourbabel-preset-env
configuration, we can ensure that polyfills included are only those which are necessary for the browsers we target.Implementation notes:
Because of how our Webpack configuration is set up, the polyfill is wrapped by a
wp.polyfill
global. This isn't great, but still works as intended. Since we'll need to reconsider our bundling setup during core reconciliation, I'm fine to punt this to a future date.Testing instructions:
This is difficult to test because the editor is quite broken in IE11. Instead, I merely changed the
wp_register_script
call forwp-esnext-polyfill
towp_enqueue_script
so that the script is loaded on every screen, then proceeded to try ES2015 methods in IE11's developer tools console.