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

Build: Remove @babel/polyfill in favor of core-js/stable #1191

Closed
wants to merge 1 commit into from
Closed
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
23 changes: 11 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"webpack-livereload-plugin": "2.3.0"
},
"dependencies": {
"@babel/polyfill": "7.10.1",
"@wordpress/a11y": "2.14.3",
"@wordpress/annotations": "1.24.8",
"@wordpress/api-fetch": "3.21.5",
Expand Down Expand Up @@ -129,6 +128,7 @@
"@wordpress/wordcount": "2.14.1",
"backbone": "1.4.0",
"clipboard": "2.0.8",
"core-js": "3.10.1",
"core-js-url-browser": "3.6.4",
"element-closest": "^2.0.2",
"formdata-polyfill": "3.0.20",
Expand All @@ -145,6 +145,7 @@
"polyfill-library": "3.104.0",
"react": "16.13.1",
"react-dom": "16.13.1",
"regenerator-runtime": "0.13.7",
"twemoji": "13.0.2",
"underscore": "1.12.1",
"whatwg-fetch": "3.0.0"
Expand Down
8 changes: 5 additions & 3 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ function wp_default_packages_vendor( $scripts ) {
'wp-polyfill-dom-rect',
'wp-polyfill-element-closest',
'wp-polyfill-object-fit',
'wp-polyfill',
'wp-polyfill-regenerator',
'wp-polyfill-core-js',
);

$vendor_scripts_versions = array(
Expand All @@ -106,7 +107,8 @@ function wp_default_packages_vendor( $scripts ) {
'wp-polyfill-dom-rect' => '3.104.0',
'wp-polyfill-element-closest' => '2.0.2',
'wp-polyfill-object-fit' => '2.3.5',
'wp-polyfill' => '7.4.4',
'wp-polyfill-regenerator' => '0.13.7',
'wp-polyfill-core-js' => '3.10.1',
);

foreach ( $vendor_scripts as $handle => $dependencies ) {
Expand All @@ -121,7 +123,7 @@ function wp_default_packages_vendor( $scripts ) {
$scripts->add( $handle, $path, $dependencies, $version, 1 );
}

$scripts->add( 'wp-polyfill', null, array( 'wp-polyfill' ) );
$scripts->add( 'wp-polyfill', null, array( 'wp-polyfill-core-js', 'wp-polyfill-regenerator' ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good. We need to be careful to not change the script handle. I don't think the other changes above will have any affect on that. But we should just double check.

did_action( 'init' ) && $scripts->add_inline_script(
'wp-polyfill',
wp_get_script_polyfill(
Expand Down
6 changes: 4 additions & 2 deletions tools/webpack/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ module.exports = function( env = { environment: 'production', watch: false, buil

const vendors = {
'lodash.js': 'lodash/lodash.js',
'wp-polyfill.js': '@babel/polyfill/dist/polyfill.js',
'wp-polyfill-core-js.js': 'core-js/stable/index.js',
Copy link
Member Author

Choose a reason for hiding this comment

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

@desrosj, I need to do some research because it doesn't look like core-js has a distribution version but rather a long list of require calls ...

'wp-polyfill-regenerator.js': 'regenerator-runtime/runtime.js',
'wp-polyfill-fetch.js': 'whatwg-fetch/dist/fetch.umd.js',
'wp-polyfill-element-closest.js': 'element-closest/element-closest.js',
'wp-polyfill-node-contains.js': 'polyfill-library/polyfills/__dist/Node.prototype.contains/raw.js',
Expand All @@ -88,7 +89,6 @@ module.exports = function( env = { environment: 'production', watch: false, buil

const minifiedVendors = {
'lodash.min.js': 'lodash/lodash.min.js',
'wp-polyfill.min.js': '@babel/polyfill/dist/polyfill.min.js',
'wp-polyfill-formdata.min.js': 'formdata-polyfill/formdata.min.js',
'wp-polyfill-url.min.js': 'core-js-url-browser/url.min.js',
'wp-polyfill-object-fit.min.js': 'objectFitPolyfill/dist/objectFitPolyfill.min.js',
Expand All @@ -98,6 +98,8 @@ module.exports = function( env = { environment: 'production', watch: false, buil
};

const minifyVendors = {
'wp-polyfill-core-js.min.js': 'core-js/stable/index.js',
'wp-polyfill-regenerator.min.js': 'regenerator-runtime/runtime.js',
'wp-polyfill-fetch.min.js': 'whatwg-fetch/dist/fetch.umd.js',
'wp-polyfill-element-closest.min.js': 'element-closest/element-closest.js',
'wp-polyfill-node-contains.min.js': 'polyfill-library/polyfills/__dist/Node.prototype.contains/raw.js',
Expand Down