Skip to content
Open
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
7 changes: 4 additions & 3 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ function wp_default_packages_vendor( $scripts ) {
);

$vendor_scripts_versions = array(
'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',
// Add `-wp` suffix to React package versions to differentiate from the UMD builds. We build our own bundles now.
'react' => '18.3.1-wp',
'react-dom' => '18.3.1-wp',
'react-jsx-runtime' => '18.3.1-wp',
'regenerator-runtime' => '0.14.1',
'moment' => '2.30.1',
'lodash' => '4.17.23',
Expand Down
10 changes: 5 additions & 5 deletions tests/phpunit/tests/dependencies/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -3923,18 +3923,18 @@ public function test_vendor_script_versions_registered_manually( $script, $handl
}

/*
* Append '.1' to the version number for React and ReactDOM.
* Append '-wp' to the version number for React and ReactDOM.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And react-jsx-runtime?

*
* This is due to a change in the build to use the UMD version of the
* This is due to a change in the build to stop using 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.
* This can be removed in the next update to the packages (to React 19).
*
* See https://core.trac.wordpress.org/ticket/62422
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Worth also adding https://core.trac.wordpress.org/ticket/64958 for context?

If I'm reading it correctly, the previous ticket refers to switching to UMD builds, and this PR is switching away.

*/
if ( in_array( $handle, array( 'react', 'react-dom' ), true ) ) {
$package_json[ $script ] .= '.1';
if ( in_array( $handle, array( 'react', 'react-dom', 'react-jsx-runtime' ), true ) ) {
$package_json[ $script ] .= '-wp';
}

$script_query = $wp_scripts->query( $handle, 'registered' );
Expand Down
9 changes: 2 additions & 7 deletions tools/gutenberg/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,22 +574,17 @@ async function main() {
) {
/*
* Copy special directories with rename (vendors/ → vendor/).
* Only copy react-jsx-runtime from vendors (react and react-dom come from Core's node_modules).
*/
const destName =
scriptsConfig.directoryRenames[ entry.name ];
const dest = path.join( scriptsDest, destName );

if ( entry.name === 'vendors' ) {
// Only copy react-jsx-runtime files, skip react and react-dom.
const vendorFiles = fs.readdirSync( src );
let copiedCount = 0;
fs.mkdirSync( dest, { recursive: true } );
for ( const file of vendorFiles ) {
if (
file.startsWith( 'react-jsx-runtime' ) &&
file.endsWith( '.js' )
) {
if ( file.endsWith( '.js' ) ) {
const srcFile = path.join( src, file );
const destFile = path.join( dest, file );

Expand All @@ -598,7 +593,7 @@ async function main() {
}
}
console.log(
` ✅ ${ entry.name }/ → ${ destName }/ (react-jsx-runtime only, ${ copiedCount } files)`
` ✅ ${ entry.name }/ → ${ destName }/ (${ copiedCount } files)`
);
}
} else {
Expand Down
16 changes: 0 additions & 16 deletions tools/vendors/copy-vendors.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,6 @@ const VENDOR_FILES = {
],
},

// React (UMD builds from node_modules)
'react': {
files: [
{ from: 'react/umd/react.development.js', to: 'react.js' },
{ from: 'react/umd/react.production.min.js', to: 'react.min.js' },
],
},

// React DOM (UMD builds from node_modules)
'react-dom': {
files: [
{ from: 'react-dom/umd/react-dom.development.js', to: 'react-dom.js' },
{ from: 'react-dom/umd/react-dom.production.min.js', to: 'react-dom.min.js' },
],
},

// Main Polyfill bundle
'wp-polyfill': {
files: [
Expand Down
Loading