Make WordPress Core


Ignore:
Timestamp:
06/23/2021 12:04:47 AM (4 years ago)
Author:
desrosj
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/dependencies/scripts.php

    r50934 r51212  
    724724        $ver       = get_bloginfo( 'version' );
    725725        $suffix    = wp_scripts_get_suffix();
    726         $expected  = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=jquery-core,jquery-migrate,wp-polyfill,wp-dom-ready,wp-hooks&amp;ver={$ver}'></script>\n";
     726        $expected  = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=jquery-core,jquery-migrate,regenerator-runtime,wp-polyfill,wp-dom-ready,wp-hooks&amp;ver={$ver}'></script>\n";
    727727        $expected .= "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
    728728        $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
Note: See TracChangeset for help on using the changeset viewer.