From d4a1326f775c62740a8e6675cca6a47d72c9803b Mon Sep 17 00:00:00 2001 From: William Earnhardt Date: Mon, 29 Oct 2018 14:55:17 -0400 Subject: [PATCH 1/8] Rename wp-polyfill-ecmascript --- docs/reference/scripts.md | 2 +- lib/client-assets.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/reference/scripts.md b/docs/reference/scripts.md index 4fba8a1cbea67f..f24973a757202e 100644 --- a/docs/reference/scripts.md +++ b/docs/reference/scripts.md @@ -66,4 +66,4 @@ It is recommened to use the main `wp-polyfill` script handle which takes care of | [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 | +| [ECMAScript Polyfill](https://babeljs.io/docs/en/babel-polyfill) | wp-babel-polyfill | Emulate a full ES2015+ environment | diff --git a/lib/client-assets.php b/lib/client-assets.php index c34e03edc7d5f1..e6a5a6a08468d2 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -148,7 +148,7 @@ function gutenberg_register_scripts_and_styles() { 'wp-polyfill', null, array( - 'wp-polyfill-ecmascript', + 'wp-babel-polyfill', ) ); wp_script_add_data( @@ -485,7 +485,7 @@ function gutenberg_register_scripts_and_styles() { 'lodash', 'wp-a11y', 'wp-data', - 'wp-polyfill-ecmascript', + 'wp-babel-polyfill', ), filemtime( gutenberg_dir_path() . 'build/notices/index.js' ), true @@ -751,7 +751,7 @@ function gutenberg_register_scripts_and_styles() { 'wp-compose', 'wp-element', 'wp-i18n', - 'wp-polyfill-ecmascript', + 'wp-babel-polyfill', ), filemtime( gutenberg_dir_path() . 'build/list-reusable-blocks/index.js' ), true @@ -979,7 +979,7 @@ function gutenberg_register_vendor_scripts() { 'https://unpkg.com/element-closest@2.0.2/element-closest.js' ); gutenberg_register_vendor_script( - 'wp-polyfill-ecmascript', + 'wp-babel-polyfill', 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill' . $suffix . '.js' ); } From 4fd3335df5d9e795e7068520573943b177127ac9 Mon Sep 17 00:00:00 2001 From: William Earnhardt Date: Tue, 30 Oct 2018 16:07:53 -0400 Subject: [PATCH 2/8] Make babel polyfill be script file for wp-polyfill --- docs/reference/scripts.md | 3 +-- lib/client-assets.php | 13 +++---------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/docs/reference/scripts.md b/docs/reference/scripts.md index f24973a757202e..0bd0cf98927921 100644 --- a/docs/reference/scripts.md +++ b/docs/reference/scripts.md @@ -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-babel-polyfill | Emulate a full ES2015+ environment | diff --git a/lib/client-assets.php b/lib/client-assets.php index e6a5a6a08468d2..3b0236e88778f1 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -146,10 +146,7 @@ function gutenberg_register_scripts_and_styles() { gutenberg_override_script( 'wp-polyfill', - null, - array( - 'wp-babel-polyfill', - ) + 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill' . $suffix . '.js' ); wp_script_add_data( 'wp-polyfill', @@ -485,7 +482,7 @@ function gutenberg_register_scripts_and_styles() { 'lodash', 'wp-a11y', 'wp-data', - 'wp-babel-polyfill', + 'wp-polyfill', ), filemtime( gutenberg_dir_path() . 'build/notices/index.js' ), true @@ -751,7 +748,7 @@ function gutenberg_register_scripts_and_styles() { 'wp-compose', 'wp-element', 'wp-i18n', - 'wp-babel-polyfill', + 'wp-polyfill', ), filemtime( gutenberg_dir_path() . 'build/list-reusable-blocks/index.js' ), true @@ -978,10 +975,6 @@ function gutenberg_register_vendor_scripts() { 'wp-polyfill-element-closest', 'https://unpkg.com/element-closest@2.0.2/element-closest.js' ); - gutenberg_register_vendor_script( - 'wp-babel-polyfill', - 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill' . $suffix . '.js' - ); } /** From 98454ffb8ead98f832432a67f085f5ecd36c517a Mon Sep 17 00:00:00 2001 From: William Earnhardt Date: Tue, 30 Oct 2018 16:15:13 -0400 Subject: [PATCH 3/8] Fix suffix error --- lib/client-assets.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/client-assets.php b/lib/client-assets.php index 3b0236e88778f1..83a537f86b7f00 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -144,6 +144,7 @@ function gutenberg_register_scripts_and_styles() { register_tinymce_scripts(); + $suffix = SCRIPT_DEBUG ? '' : '.min'; gutenberg_override_script( 'wp-polyfill', 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill' . $suffix . '.js' From 13b2a68718b4eff916d308e043659c9402d6c74f Mon Sep 17 00:00:00 2001 From: William Earnhardt Date: Tue, 30 Oct 2018 18:36:50 -0400 Subject: [PATCH 4/8] Stop using CDN directly --- lib/client-assets.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index 83a537f86b7f00..af362f0763fdf4 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -144,16 +144,12 @@ function gutenberg_register_scripts_and_styles() { register_tinymce_scripts(); - $suffix = SCRIPT_DEBUG ? '' : '.min'; - gutenberg_override_script( - 'wp-polyfill', - 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill' . $suffix . '.js' - ); wp_script_add_data( 'wp-polyfill', 'data', gutenberg_get_script_polyfill( array( + 'false' => 'wp-polyfill-ecmascript', '\'fetch\' in window' => 'wp-polyfill-fetch', 'document.contains' => 'wp-polyfill-node-contains', 'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata', @@ -976,6 +972,10 @@ function gutenberg_register_vendor_scripts() { 'wp-polyfill-element-closest', 'https://unpkg.com/element-closest@2.0.2/element-closest.js' ); + gutenberg_register_vendor_script( + 'wp-polyfill', + 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill' . $suffix . '.js' + ); } /** From ed37225f1521851f879e1e2e4cd6a8ee0980b6b7 Mon Sep 17 00:00:00 2001 From: William Earnhardt Date: Wed, 31 Oct 2018 05:55:19 -0400 Subject: [PATCH 5/8] Register wp-polyfill-ecmascript to null for back compat --- lib/client-assets.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/client-assets.php b/lib/client-assets.php index af362f0763fdf4..c51cd21ccc5dd1 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -976,6 +976,14 @@ function gutenberg_register_vendor_scripts() { 'wp-polyfill', 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill' . $suffix . '.js' ); + // Ensure backwards compatibility after renaming to wp-polyfill + gutenberg_override_script( + 'wp-polyfill-ecmascript', + null, + array( + 'wp-polyfill', + ) + ); } /** From d8595660d31b3dc01ca718b90eb4782cf08cdb8c Mon Sep 17 00:00:00 2001 From: William Earnhardt Date: Wed, 31 Oct 2018 06:31:33 -0400 Subject: [PATCH 6/8] Ensure we use some grammar in our comments --- lib/client-assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index c51cd21ccc5dd1..86206e16288dad 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -976,7 +976,7 @@ function gutenberg_register_vendor_scripts() { 'wp-polyfill', 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill' . $suffix . '.js' ); - // Ensure backwards compatibility after renaming to wp-polyfill + // Ensure backwards compatibility after renaming to wp-polyfill. gutenberg_override_script( 'wp-polyfill-ecmascript', null, From fc297b1412b0fa3546aa9863608f7615e3ee18ad Mon Sep 17 00:00:00 2001 From: William Earnhardt Date: Wed, 31 Oct 2018 10:45:53 -0400 Subject: [PATCH 7/8] Remove extraneous wp-polyfill-ecmascript include --- lib/client-assets.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index 86206e16288dad..a3f474c845ad0b 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -149,7 +149,6 @@ function gutenberg_register_scripts_and_styles() { 'data', gutenberg_get_script_polyfill( array( - 'false' => 'wp-polyfill-ecmascript', '\'fetch\' in window' => 'wp-polyfill-fetch', 'document.contains' => 'wp-polyfill-node-contains', 'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata', From 3fc153f65a81eeae5b9dba0c198db098a9b7e982 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 6 Nov 2018 16:49:08 -0500 Subject: [PATCH 8/8] Framework: Log deprecation notice for wp-polyfill-ecmascript --- lib/client-assets.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/client-assets.php b/lib/client-assets.php index a3f474c845ad0b..d109b215c9eac9 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -981,8 +981,14 @@ function gutenberg_register_vendor_scripts() { 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" } );' + ); } /**