Skip to content

Commit

Permalink
alias react-dom to rendering stub
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Oct 24, 2022
1 parent f28559e commit 8717740
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/next/build/webpack-config.ts
Expand Up @@ -127,6 +127,7 @@ function isResourceInPackages(resource: string, packageNames?: string[]) {

const bundledReactImports = [
'react',
'react-dom',
'react/jsx-runtime',
'react/jsx-dev-runtime',
'next/dist/compiled/react-server-dom-webpack/server.browser',
Expand Down Expand Up @@ -1069,6 +1070,10 @@ export default async function getBaseWebpackConfig(
return `commonjs ${request}`
}
if (/^(react(?:$|\/)|react-dom(?:$|\/))/.test(request)) {
// override react-dom to server-rendering-stub for server
if (request === 'react-dom' && hasAppDir) {
request = 'react-dom/server-rendering-stub'
}
return `commonjs ${hasAppDir ? 'next/dist/compiled/' : ''}${request}`
}

Expand Down

0 comments on commit 8717740

Please sign in to comment.