Skip to content

Commit

Permalink
Build Tools: Use umd builds provided by React instead of bundling our…
Browse files Browse the repository at this point in the history
… own builds.

We tried moving away from the deprecated React UMD builds previously,
the problem we faced is that there's a warning that is triggered on the console because we're not using a separate impact for `createRoot`.

This warning has been removed in React 19 along with the removal of the UMD builds, so we should be able to revert this commit when we upgrade to React 19 but for now, we need to restore the usage of the umd builds.

Props mamaduka.
See #61324.

git-svn-id: https://develop.svn.wordpress.org/trunk@58775 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
youknowriad committed Jul 22, 2024
1 parent 308271c commit f003fd0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 4 additions & 0 deletions tools/webpack/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ module.exports = function (
'wp-polyfill-importmap.js': 'es-module-shims/dist/es-module-shims.wasm.js',
'moment.js': 'moment/moment.js',
'regenerator-runtime.js': 'regenerator-runtime/runtime.js',
'react.js': 'react/umd/react.development.js',
'react-dom.js': 'react-dom/umd/react-dom.development.js',
};

const minifiedVendors = {
Expand All @@ -109,6 +111,8 @@ module.exports = function (
'objectFitPolyfill/dist/objectFitPolyfill.min.js',
'wp-polyfill-inert.min.js': 'wicg-inert/dist/inert.min.js',
'moment.min.js': 'moment/min/moment.min.js',
'react.min.js': 'react/umd/react.production.min.js',
'react-dom.min.js': 'react-dom/umd/react-dom.production.min.js',
};

const minifyVendors = {
Expand Down
13 changes: 4 additions & 9 deletions tools/webpack/vendors.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
const { join } = require( 'path' );

const importedVendors = {
react: { import: 'react', global: 'React' },
'react-dom': { import: 'react-dom', global: 'ReactDOM' },
'react-jsx-runtime': {
import: 'react/jsx-runtime',
global: 'ReactJSXRuntime',
Expand All @@ -21,7 +19,7 @@ module.exports = function (
: mode === 'production'
? 'build'
: 'src';
buildTarget = buildTarget + '/wp-includes/js/dist/vendor/';
buildTarget = buildTarget + '/wp-includes/js/dist/vendor/';
return [
...Object.entries( importedVendors ).flatMap( ( [ name, config ] ) => {
return [ 'production', 'development' ].map( ( currentMode ) => {
Expand All @@ -45,12 +43,9 @@ module.exports = function (
},
},

externals:
name === 'react'
? {}
: {
react: 'React',
},
externals: {
react: 'React',
},
};
} );
} ),
Expand Down

0 comments on commit f003fd0

Please sign in to comment.