Skip to content
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

Rename wp-polyfill-ecmascript #11216

Merged
merged 8 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/reference/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ It is recommened to use the main `wp-polyfill` script handle which takes care of

| Script Name | Handle | Description |
|-------------|--------|-------------|
| polyfill | wp-polyfill | Main script to load all the below mentioned polyfills |
| [Babel Polyfill](https://babeljs.io/docs/en/babel-polyfill) | wp-polyfill | Emulate a full ES2015+ environment. Main script to load all the below mentioned additional polyfills |
| [Fetch Polyfill](https://www.npmjs.com/package/whatwg-fetch) | wp-polyfill-fetch | Polyfill that implements a subset of the standard Fetch specification |
| [Promise Polyfill](https://www.npmjs.com/package/promise-polyfill) | wp-polyfill-promise| Lightweight ES6 Promise polyfill for the browser and node |
| [Formdata Polyfill](https://www.npmjs.com/package/formdata-polyfill) | wp-polyfill-formdata| Polyfill conditionally replaces the native implementation |
| [Node Contains Polyfill](https://polyfill.io) | wp-polyfill-node-contains |Polyfill for Node.contains |
| [Element Closest Polyfill](https://www.npmjs.com/package/element-closest) | wp-polyfill-element-closest| Return the closest element matching a selector up the DOM tree |
| [ECMAScript Polyfill](https://babeljs.io/docs/en/babel-polyfill) | wp-polyfill-ecmascript | Emulate a full ES2015+ environment |
27 changes: 17 additions & 10 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,6 @@ function gutenberg_register_scripts_and_styles() {

register_tinymce_scripts();

gutenberg_override_script(
'wp-polyfill',
null,
array(
'wp-polyfill-ecmascript',
)
);
wp_script_add_data(
'wp-polyfill',
'data',
Expand Down Expand Up @@ -485,7 +478,7 @@ function gutenberg_register_scripts_and_styles() {
'lodash',
'wp-a11y',
'wp-data',
'wp-polyfill-ecmascript',
'wp-polyfill',
),
filemtime( gutenberg_dir_path() . 'build/notices/index.js' ),
true
Expand Down Expand Up @@ -751,7 +744,7 @@ function gutenberg_register_scripts_and_styles() {
'wp-compose',
'wp-element',
'wp-i18n',
'wp-polyfill-ecmascript',
'wp-polyfill',
),
filemtime( gutenberg_dir_path() . 'build/list-reusable-blocks/index.js' ),
true
Expand Down Expand Up @@ -979,9 +972,23 @@ function gutenberg_register_vendor_scripts() {
'https://unpkg.com/[email protected]/element-closest.js'
);
gutenberg_register_vendor_script(
'wp-polyfill-ecmascript',
'wp-polyfill',
'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill' . $suffix . '.js'
);
// Ensure backwards compatibility after renaming to wp-polyfill.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something we want to do away with eventually? Should we make that clearer in the comment? How can we plan to follow-up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm honestly not sure best course of action here. Realistically, what is the likelihood that plugins are counting on this script handle? If we plan to eventually remove it, how long should we wait?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could follow the standard deprecation workflow:

https://wordpress.org/gutenberg/handbook/reference/deprecated/

We've done similar before for server-side features in either (a) enqueuing an inline script to run wp.deprecated( '...' ) messaging or (b) _doing_it_wrong. The former seems easiest, since the second would be difficult in determining whether there are scripts which define a dependency on the script.

Examples:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wp-polyfill-promise looks like a good example of prior art. What version should we set for removal?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two versions out, 4.5, which may or may not actually happen.

gutenberg_override_script(
'wp-polyfill-ecmascript',
null,
array(
'wp-polyfill',
'wp-deprecated',
)
);
wp_script_add_data(
'wp-polyfill-ecmascript',
'data',
'wp.deprecated( "wp-polyfill-ecmascript script handle", { plugin: "Gutenberg", version: "4.5" } );'
);
}

/**
Expand Down