diff --git a/tools/webpack/packages.js b/tools/webpack/packages.js index 899ee36ec93813..055665c2feb1c8 100644 --- a/tools/webpack/packages.js +++ b/tools/webpack/packages.js @@ -102,6 +102,13 @@ const exportDefaultPackages = [ 'warning', ]; +const copiedVendors = { + 'react.js': 'react/umd/react.development.js', + 'react.min.js': 'react/umd/react.production.min.js', + 'react-dom.js': 'react-dom/umd/react-dom.development.js', + 'react-dom.min.js': 'react-dom/umd/react-dom.production.min.js', +}; + module.exports = { ...baseConfig, name: 'packages', @@ -148,7 +155,13 @@ module.exports = { transform: stylesTransform, noErrorOnMissing: true, } ) ) - .concat( bundledPackagesPhpConfig ), + .concat( bundledPackagesPhpConfig ) + .concat( + Object.entries( copiedVendors ).map( ( [ to, from ] ) => ( { + from: `node_modules/${ from }`, + to: `build/vendors/${ to }`, + } ) ) + ), } ), new MomentTimezoneDataPlugin( { startYear: 2000, diff --git a/tools/webpack/vendors.js b/tools/webpack/vendors.js index d21c029f6c3971..d1b01436f6669b 100644 --- a/tools/webpack/vendors.js +++ b/tools/webpack/vendors.js @@ -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', @@ -35,12 +33,9 @@ module.exports = [ }, }, - externals: - name === 'react' - ? {} - : { - react: 'React', - }, + externals: { + react: 'React', + }, }; } ); } ),