From fef57f5b523107ee48c1195a729f5f4e5598f4ef Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Mon, 21 Nov 2022 21:43:15 +0100 Subject: [PATCH] add react aliases --- packages/next/build/webpack-config.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 2e7bebaaf90df..f0beab26227b1 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -863,6 +863,9 @@ export default async function getBaseWebpackConfig( [COMPILER_NAMES.edgeServer]: ['browser', 'module', 'main'], } + const reactDir = path.dirname(require.resolve('react/package.json')) + const reactDomDir = path.dirname(require.resolve('react-dom/package.json')) + const resolveConfig = { // Disable .mjs for node_modules bundling extensions: isNodeServer @@ -928,7 +931,13 @@ export default async function getBaseWebpackConfig( 'next/dist/compiled/react/jsx-dev-runtime', 'react/jsx-runtime$': 'next/dist/compiled/react/jsx-runtime', } - : undefined), + : { + react: reactDir, + 'react-dom$': reactDomDir, + 'react-dom/server$': `${reactDomDir}/server`, + 'react-dom/server.browser$': `${reactDomDir}/server.browser`, + 'react-dom/client$': `${reactDomDir}/client`, + }), 'styled-jsx/style$': require.resolve(`styled-jsx/style`), 'styled-jsx$': require.resolve(`styled-jsx`),