Skip to content

Commit

Permalink
External Libraries: Append .1 to react/react-dom versions.
Browse files Browse the repository at this point in the history
Replaces the `-umd` appendage for the `react` and `react-dom` script versions with `.1`. This it to prevent issues with third party code expecting the version number in the form `/^[\d\.]+$/`.

Updates the version to tests in `Tests_Dependencies_Scripts::test_vendor_script_versions_registered_manually` to include the modified version used for cache busting.

Follow up to [59536], [58775].

Props azaozz, desrosj, peterwilsoncc.
Fixes #62422.




git-svn-id: https://develop.svn.wordpress.org/trunk@59540 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
peterwilsoncc committed Dec 19, 2024
1 parent a2107c2 commit 9e4b268
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ function wp_default_packages_vendor( $scripts ) {
);

$vendor_scripts_versions = array(
'react' => '18.3.1-umd',
'react-dom' => '18.3.1-umd',
'react' => '18.3.1.1', // Final .1 due to switch to UMD build, can be removed in the next update.
'react-dom' => '18.3.1.1', // Final .1 due to switch to UMD build, can be removed in the next update.
'react-jsx-runtime' => '18.3.1',
'regenerator-runtime' => '0.14.1',
'moment' => '2.30.1',
Expand Down
15 changes: 15 additions & 0 deletions tests/phpunit/tests/dependencies/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -3413,6 +3413,21 @@ public function test_vendor_script_versions_registered_manually( $script, $handl
$handle = $script;
}

/*
* Append '.1' to the version number for React and ReactDOM.
*
* This is due to a change in the build to use the UMD version of the
* scripts, requiring a different version number in order to break the
* caches of some CDNs.
*
* This can be removed in the next update to the packages.
*
* See https://core.trac.wordpress.org/ticket/62422
*/
if ( in_array( $handle, array( 'react', 'react-dom' ), true ) ) {
$package_json[ $script ] .= '.1';
}

$script_query = $wp_scripts->query( $handle, 'registered' );

$this->assertNotFalse( $script_query, "The script '{$handle}' should be registered." );
Expand Down

0 comments on commit 9e4b268

Please sign in to comment.