Skip to content

Commit

Permalink
revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Oct 22, 2022
1 parent 2176d32 commit 070da10
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 11 deletions.
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -181,6 +181,8 @@
"react-17": "npm:react@17.0.2",
"react-dom": "18.2.0",
"react-dom-17": "npm:react-dom@17.0.2",
"react-exp": "npm:react@0.0.0-experimental-9cdf8a99e-20221018",
"react-dom-exp": "npm:react-dom@0.0.0-experimental-9cdf8a99e-20221018",
"react-server-dom-webpack": "0.0.0-experimental-9cdf8a99e-20221018",
"react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3",
Expand Down
40 changes: 29 additions & 11 deletions packages/next/build/webpack-config.ts
Expand Up @@ -832,6 +832,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
Expand Down Expand Up @@ -884,6 +887,11 @@ export default async function getBaseWebpackConfig(
// '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`),
Expand Down Expand Up @@ -1565,7 +1573,7 @@ export default async function getBaseWebpackConfig(
},
]
: []),
...(hasAppDir && !isClient
...(hasAppDir && !isClient && !isEdgeServer
? [
{
issuerLayer: WEBPACK_LAYERS.server,
Expand All @@ -1581,16 +1589,24 @@ export default async function getBaseWebpackConfig(

return true
},
resolve: {
conditionNames: ['react-server', 'node', 'require'],
alias: {
// If missing the alias override here, the default alias will be used which aliases
// react to the direct file path, not the package name. In that case the condition
// will be ignored completely.
react: 'react',
'react-dom': 'react-dom',
},
},
resolve: process.env.__NEXT_REACT_CHANNEL
? {
conditionNames: ['react-server', 'node', 'require'],
alias: {
react: `react-${process.env.__NEXT_REACT_CHANNEL}`,
'react-dom': `react-dom-${process.env.__NEXT_REACT_CHANNEL}`,
},
}
: {
conditionNames: ['react-server', 'node', 'require'],
alias: {
// If missing the alias override here, the default alias will be used which aliases
// react to the direct file path, not the package name. In that case the condition
// will be ignored completely.
react: 'react',
'react-dom': 'react-dom',
},
},
},
]
: []),
Expand Down Expand Up @@ -1630,6 +1646,7 @@ export default async function getBaseWebpackConfig(
// Alias react-dom for ReactDOM.preload usage.
// Alias react for switching between default set and share subset.
oneOf: [
/*
{
// test: codeCondition.test,
issuerLayer: WEBPACK_LAYERS.server,
Expand Down Expand Up @@ -1661,6 +1678,7 @@ export default async function getBaseWebpackConfig(
},
},
},
*/
// Disable before prebundling is landed
// {
// test: codeCondition.test,
Expand Down
36 changes: 36 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions test/lib/react-channel-require-hook.js
Expand Up @@ -3,6 +3,8 @@ const mod = require('module')
// The value will be '17' or 'exp' to alias the actual react channel
const reactVersion = process.env.__NEXT_REACT_CHANNEL

console.log('reactVersion', reactVersion)

const reactDir = `react-${reactVersion}`
const reactDomDir = `react-dom-${reactVersion}`

Expand Down

0 comments on commit 070da10

Please sign in to comment.