mirror of
git://develop.git.wordpress.org/
synced 2025-01-17 12:58:25 +01:00
Build/Test Tools: Add the regenerator-runtime
script as a dependency to wp-polyfill
.
In [51146], the `core-js` package replaced the deprecated `@babel//polyfill` one. The `core-js` package builds `wp-polyfill` from a configuration provided by `@wordpress/babel-preset-default` instead of copying a one size fits all polyfill. That change caused an issue where plugins and themes relying on the `regenerator-runtime` script being included in the `wp-polyfill.js` file encountering fatal JavaScript errors. This adds the `regenerator-runtime` package to Core and registers it as a dependency for `wp-polyfill`. While Core does not require `regenerator-runtime`, it will allow for a smoother transition to using `core-js`. This dependency will be removed in a future version of WordPress, so developers are encouraged to add `regenerator-runtime` as a dependency for any custom script that requires it. Follow up to [51146]. Props gziolo, herregroen, jeherve, hellofromtonya, peterwilsoncc. Fixes #52941. git-svn-id: https://develop.svn.wordpress.org/trunk@51212 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a59cea3c92
commit
1ec56ec5b5
@ -147,6 +147,7 @@
|
||||
"polyfill-library": "3.105.0",
|
||||
"react": "16.13.1",
|
||||
"react-dom": "16.13.1",
|
||||
"regenerator-runtime": "0.13.7",
|
||||
"twemoji": "13.1.0",
|
||||
"underscore": "1.13.1",
|
||||
"whatwg-fetch": "3.0.0"
|
||||
|
@ -80,8 +80,9 @@ function wp_default_packages_vendor( $scripts ) {
|
||||
$suffix = wp_scripts_get_suffix();
|
||||
|
||||
$vendor_scripts = array(
|
||||
'react' => array( 'wp-polyfill' ),
|
||||
'react-dom' => array( 'react' ),
|
||||
'react' => array( 'wp-polyfill' ),
|
||||
'react-dom' => array( 'react' ),
|
||||
'regenerator-runtime',
|
||||
'moment',
|
||||
'lodash',
|
||||
'wp-polyfill-fetch',
|
||||
@ -91,12 +92,13 @@ function wp_default_packages_vendor( $scripts ) {
|
||||
'wp-polyfill-dom-rect',
|
||||
'wp-polyfill-element-closest',
|
||||
'wp-polyfill-object-fit',
|
||||
'wp-polyfill',
|
||||
'wp-polyfill' => array( 'regenerator-runtime' ),
|
||||
);
|
||||
|
||||
$vendor_scripts_versions = array(
|
||||
'react' => '16.13.1',
|
||||
'react-dom' => '16.13.1',
|
||||
'regenerator-runtime' => '0.13.7',
|
||||
'moment' => '2.29.1',
|
||||
'lodash' => '4.17.19',
|
||||
'wp-polyfill-fetch' => '3.0.0',
|
||||
@ -106,7 +108,7 @@ 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' => '3.15.0',
|
||||
);
|
||||
|
||||
foreach ( $vendor_scripts as $handle => $dependencies ) {
|
||||
@ -121,8 +123,6 @@ function wp_default_packages_vendor( $scripts ) {
|
||||
$scripts->add( $handle, $path, $dependencies, $version, 1 );
|
||||
}
|
||||
|
||||
$scripts->add( 'wp-polyfill', null, array( 'wp-polyfill' ) );
|
||||
|
||||
did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );
|
||||
|
||||
did_action( 'init' ) && $scripts->add_inline_script(
|
||||
|
@ -723,7 +723,7 @@ JS;
|
||||
|
||||
$ver = get_bloginfo( 'version' );
|
||||
$suffix = wp_scripts_get_suffix();
|
||||
$expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,wp-polyfill,wp-dom-ready,wp-hooks&ver={$ver}'></script>\n";
|
||||
$expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,regenerator-runtime,wp-polyfill,wp-dom-ready,wp-hooks&ver={$ver}'></script>\n";
|
||||
$expected .= "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
|
||||
$expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
|
||||
$expected .= "<script type='text/javascript' src='/wp-includes/js/dist/i18n{$suffix}.js' id='wp-i18n-js'></script>\n";
|
||||
|
@ -84,6 +84,7 @@ module.exports = function( env = { environment: 'production', watch: false, buil
|
||||
'moment.js': 'moment/moment.js',
|
||||
'react.js': 'react/umd/react.development.js',
|
||||
'react-dom.js': 'react-dom/umd/react-dom.development.js',
|
||||
'regenerator-runtime.js': 'regenerator-runtime/runtime.js',
|
||||
};
|
||||
|
||||
const minifiedVendors = {
|
||||
@ -98,6 +99,7 @@ module.exports = function( env = { environment: 'production', watch: false, buil
|
||||
};
|
||||
|
||||
const minifyVendors = {
|
||||
'regenerator-runtime.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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user