From 735178072f259ac521bc205ae8b67f3620cc4a0c Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Tue, 16 Jul 2024 14:48:48 +0200 Subject: [PATCH] React: Restore umd builds (#63602) Co-authored-by: youknowriad Co-authored-by: Mamaduka Co-authored-by: tyxla --- tools/webpack/packages.js | 15 ++++++++++++++- tools/webpack/vendors.js | 11 +++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tools/webpack/packages.js b/tools/webpack/packages.js index 899ee36ec9381..055665c2feb1c 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 d21c029f6c397..d1b01436f6669 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', + }, }; } ); } ),