Skip to content

Commit a8dfbc1

Browse files
committed
Copy React vendor scripts from Gutenberg, update version number
1 parent 4d3b0b9 commit a8dfbc1

4 files changed

Lines changed: 11 additions & 31 deletions

File tree

src/wp-includes/script-loader.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ function wp_default_packages_vendor( $scripts ) {
106106
);
107107

108108
$vendor_scripts_versions = array(
109-
'react' => '18.3.1.1', // Final .1 due to switch to UMD build, can be removed in the next update.
110-
'react-dom' => '18.3.1.1', // Final .1 due to switch to UMD build, can be removed in the next update.
111-
'react-jsx-runtime' => '18.3.1',
109+
// Add `-wp` suffix to React package versions to differentiate from the UMD builds. We build our own bundles now.
110+
'react' => '18.3.1-wp',
111+
'react-dom' => '18.3.1-wp',
112+
'react-jsx-runtime' => '18.3.1-wp',
112113
'regenerator-runtime' => '0.14.1',
113114
'moment' => '2.30.1',
114115
'lodash' => '4.17.23',

tests/phpunit/tests/dependencies/scripts.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3923,18 +3923,18 @@ public function test_vendor_script_versions_registered_manually( $script, $handl
39233923
}
39243924

39253925
/*
3926-
* Append '.1' to the version number for React and ReactDOM.
3926+
* Append '-wp' to the version number for React and ReactDOM.
39273927
*
3928-
* This is due to a change in the build to use the UMD version of the
3928+
* This is due to a change in the build to stop using the UMD version of the
39293929
* scripts, requiring a different version number in order to break the
39303930
* caches of some CDNs.
39313931
*
3932-
* This can be removed in the next update to the packages.
3932+
* This can be removed in the next update to the packages (to React 19).
39333933
*
39343934
* See https://core.trac.wordpress.org/ticket/62422
39353935
*/
3936-
if ( in_array( $handle, array( 'react', 'react-dom' ), true ) ) {
3937-
$package_json[ $script ] .= '.1';
3936+
if ( in_array( $handle, array( 'react', 'react-dom', 'react-jsx-runtime' ), true ) ) {
3937+
$package_json[ $script ] .= '-wp';
39383938
}
39393939

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

tools/gutenberg/copy.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -574,22 +574,17 @@ async function main() {
574574
) {
575575
/*
576576
* Copy special directories with rename (vendors/ → vendor/).
577-
* Only copy react-jsx-runtime from vendors (react and react-dom come from Core's node_modules).
578577
*/
579578
const destName =
580579
scriptsConfig.directoryRenames[ entry.name ];
581580
const dest = path.join( scriptsDest, destName );
582581

583582
if ( entry.name === 'vendors' ) {
584-
// Only copy react-jsx-runtime files, skip react and react-dom.
585583
const vendorFiles = fs.readdirSync( src );
586584
let copiedCount = 0;
587585
fs.mkdirSync( dest, { recursive: true } );
588586
for ( const file of vendorFiles ) {
589-
if (
590-
file.startsWith( 'react-jsx-runtime' ) &&
591-
file.endsWith( '.js' )
592-
) {
587+
if ( file.endsWith( '.js' ) ) {
593588
const srcFile = path.join( src, file );
594589
const destFile = path.join( dest, file );
595590

@@ -598,7 +593,7 @@ async function main() {
598593
}
599594
}
600595
console.log(
601-
` ✅ ${ entry.name }/ → ${ destName }/ (react-jsx-runtime only, ${ copiedCount } files)`
596+
` ✅ ${ entry.name }/ → ${ destName }/ (${ copiedCount } files)`
602597
);
603598
}
604599
} else {

tools/vendors/copy-vendors.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,6 @@ const VENDOR_FILES = {
5454
],
5555
},
5656

57-
// React (UMD builds from node_modules)
58-
'react': {
59-
files: [
60-
{ from: 'react/umd/react.development.js', to: 'react.js' },
61-
{ from: 'react/umd/react.production.min.js', to: 'react.min.js' },
62-
],
63-
},
64-
65-
// React DOM (UMD builds from node_modules)
66-
'react-dom': {
67-
files: [
68-
{ from: 'react-dom/umd/react-dom.development.js', to: 'react-dom.js' },
69-
{ from: 'react-dom/umd/react-dom.production.min.js', to: 'react-dom.min.js' },
70-
],
71-
},
72-
7357
// Main Polyfill bundle
7458
'wp-polyfill': {
7559
files: [

0 commit comments

Comments
 (0)