Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix alias paths for bundling #40800

Merged
merged 1 commit into from Sep 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 14 additions & 14 deletions packages/next/build/webpack-config.ts
Expand Up @@ -826,14 +826,6 @@ export default async function getBaseWebpackConfig(
[COMPILER_NAMES.edgeServer]: ['browser', 'module', 'main'],
}

const reactAliases = {
react: reactDir,
'react-dom$': reactDomDir,
'react-dom/server$': `${reactDomDir}/server`,
'react-dom/server.browser$': `${reactDomDir}/server.browser`,
'react-dom/client$': `${reactDomDir}/client`,
}

const resolveConfig = {
// Disable .mjs for node_modules bundling
extensions: isNodeServer
Expand All @@ -846,7 +838,11 @@ export default async function getBaseWebpackConfig(
alias: {
next: NEXT_PROJECT_ROOT,

...reactAliases,
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 @@ -1009,11 +1005,15 @@ export default async function getBaseWebpackConfig(
// we need to provide that alias to webpack's resolver.
alias: process.env.__NEXT_REACT_CHANNEL
? {
...reactAliases,
'react/package.json': `${reactDir}/package.json`,
'react/jsx-runtime': `${reactDir}/jsx-runtime`,
'react/jsx-dev-runtime': `${reactDir}/jsx-dev-runtime`,
'react-dom/package.json': `${reactDomDir}/package.json`,
react: `react-${process.env.__NEXT_REACT_CHANNEL}`,
'react/package.json': `react-${process.env.__NEXT_REACT_CHANNEL}/package.json`,
'react/jsx-runtime': `react-${process.env.__NEXT_REACT_CHANNEL}/jsx-runtime`,
'react/jsx-dev-runtime': `react-${process.env.__NEXT_REACT_CHANNEL}/jsx-dev-runtime`,
'react-dom': `react-dom-${process.env.__NEXT_REACT_CHANNEL}`,
'react-dom/package.json': `react-dom-${process.env.__NEXT_REACT_CHANNEL}/package.json`,
'react-dom/server': `react-dom-${process.env.__NEXT_REACT_CHANNEL}/server`,
'react-dom/server.browser': `react-dom-${process.env.__NEXT_REACT_CHANNEL}/server.browser`,
'react-dom/client': `react-dom-${process.env.__NEXT_REACT_CHANNEL}/client`,
}
: false,
conditionNames: ['react-server'],
Expand Down