Skip to content

Commit eaebcd0

Browse files
committed
Copy React vendor scripts from Gutenberg, update version number
1 parent 502624f commit eaebcd0

File tree

4 files changed

+12
-32
lines changed

4 files changed

+12
-32
lines changed

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: 6 additions & 6 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-related scripts.
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
*
3934-
* See https://core.trac.wordpress.org/ticket/62422
3934+
* See https://core.trac.wordpress.org/ticket/64958
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
@@ -552,22 +552,17 @@ async function main() {
552552
) {
553553
/*
554554
* Copy special directories with rename (vendors/ → vendor/).
555-
* Only copy react-jsx-runtime from vendors (react and react-dom come from Core's node_modules).
556555
*/
557556
const destName =
558557
scriptsConfig.directoryRenames[ entry.name ];
559558
const dest = path.join( scriptsDest, destName );
560559

561560
if ( entry.name === 'vendors' ) {
562-
// Only copy react-jsx-runtime files, skip react and react-dom.
563561
const vendorFiles = fs.readdirSync( src );
564562
let copiedCount = 0;
565563
fs.mkdirSync( dest, { recursive: true } );
566564
for ( const file of vendorFiles ) {
567-
if (
568-
file.startsWith( 'react-jsx-runtime' ) &&
569-
file.endsWith( '.js' )
570-
) {
565+
if ( file.endsWith( '.js' ) ) {
571566
const srcFile = path.join( src, file );
572567
const destFile = path.join( dest, file );
573568

@@ -576,7 +571,7 @@ async function main() {
576571
}
577572
}
578573
console.log(
579-
` ✅ ${ entry.name }/ → ${ destName }/ (react-jsx-runtime only, ${ copiedCount } files)`
574+
` ✅ ${ entry.name }/ → ${ destName }/ (${ copiedCount } files)`
580575
);
581576
}
582577
} 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)