Skip to content

Commit

Permalink
Use vendored React version in Middleware and Instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Sep 3, 2024
1 parent 6fa17e0 commit 0159ceb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
17 changes: 5 additions & 12 deletions packages/next/src/build/create-compiler-aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,6 @@ export function createAppRouterApiAliases(isServerOnlyLayer: boolean) {
return aliasMap
}

export function createRSCRendererAliases(bundledReactChannel: string) {
return {
// react-server-dom-webpack alias
'react-server-dom-webpack/client$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/client`,
'react-server-dom-webpack/client.edge$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/client.edge`,
'react-server-dom-webpack/server.edge$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/server.edge`,
'react-server-dom-webpack/server.node$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/server.node`,
'react-server-dom-webpack/static.edge$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/static.edge`,
}
}

export function createRSCAliases(
bundledReactChannel: string,
{
Expand Down Expand Up @@ -274,7 +263,11 @@ export function createRSCAliases(
// optimizations to ignore the legacy build of react-dom/server in `server.edge` build
'react-dom/server.edge$': `next/dist/build/webpack/alias/react-dom-server-edge${bundledReactChannel}.js`,
// react-server-dom-webpack alias
...createRSCRendererAliases(bundledReactChannel),
'react-server-dom-webpack/client$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/client`,
'react-server-dom-webpack/client.edge$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/client.edge`,
'react-server-dom-webpack/server.edge$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/server.edge`,
'react-server-dom-webpack/server.node$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/server.node`,
'react-server-dom-webpack/static.edge$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/static.edge`,
}

if (!isEdgeServer) {
Expand Down
15 changes: 10 additions & 5 deletions packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ import {
createRSCAliases,
createNextApiEsmAliases,
createAppRouterApiAliases,
createRSCRendererAliases,
} from './create-compiler-aliases'
import { hasCustomExportOutput } from '../export/utils'
import { CssChunkingPlugin } from './webpack/plugins/css-chunking-plugin'
Expand Down Expand Up @@ -1475,8 +1474,11 @@ export default async function getBaseWebpackConfig(
resolve: {
mainFields: getMainField(compilerType, true),
conditionNames: reactServerCondition,
// Always use default channels when use installed react
alias: createRSCRendererAliases(''),
alias: createRSCAliases(bundledReactChannel, {
reactProductionProfiling,
layer: WEBPACK_LAYERS.middleware,
isEdgeServer,
}),
},
},
{
Expand All @@ -1486,8 +1488,11 @@ export default async function getBaseWebpackConfig(
resolve: {
mainFields: getMainField(compilerType, true),
conditionNames: reactServerCondition,
// Always use default channels when use installed react
alias: createRSCRendererAliases(''),
alias: createRSCAliases(bundledReactChannel, {
reactProductionProfiling,
layer: WEBPACK_LAYERS.instrument,
isEdgeServer,
}),
},
},
...(hasAppDir
Expand Down

0 comments on commit 0159ceb

Please sign in to comment.