Unverified Commit a20b0d59 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Ensure conditional resolve alias does not affect server (#29673)

This ensures we don't add the no-op resolve alias when rewrites aren't used for the server resolving since it is still needed while tracing server files. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`

Fixes: https://github.com/vercel/next.js/pull/25538#issuecomment-936101951
parent aa8a8855
...@@ -491,10 +491,15 @@ export default async function getBaseWebpackConfig( ...@@ -491,10 +491,15 @@ export default async function getBaseWebpackConfig(
[DOT_NEXT_ALIAS]: distDir, [DOT_NEXT_ALIAS]: distDir,
...getOptimizedAliases(isServer), ...getOptimizedAliases(isServer),
...getReactProfilingInProduction(), ...getReactProfilingInProduction(),
[clientResolveRewrites]: hasRewrites
? clientResolveRewrites ...(!isServer
: // With webpack 5 an alias can be pointed to false to noop ? {
false, [clientResolveRewrites]: hasRewrites
? clientResolveRewrites
: // With webpack 5 an alias can be pointed to false to noop
false,
}
: {}),
}, },
...(!isServer ...(!isServer
? { ? {
......
...@@ -93,6 +93,9 @@ describe('Production Usage', () => { ...@@ -93,6 +93,9 @@ describe('Production Usage', () => {
/node_modules\/react\/index\.js/, /node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/, /node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/, /node_modules\/react\/cjs\/react\.production\.min\.js/,
/next\/link\.js/,
/next\/dist\/client\/link\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
], ],
notTests: [/node_modules\/react\/cjs\/react\.development\.js/], notTests: [/node_modules\/react\/cjs\/react\.development\.js/],
}, },
...@@ -106,6 +109,7 @@ describe('Production Usage', () => { ...@@ -106,6 +109,7 @@ describe('Production Usage', () => {
/node_modules\/react\/cjs\/react\.production\.min\.js/, /node_modules\/react\/cjs\/react\.production\.min\.js/,
/next\/link\.js/, /next\/link\.js/,
/next\/dist\/client\/link\.js/, /next\/dist\/client\/link\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
], ],
notTests: [/node_modules\/react\/cjs\/react\.development\.js/], notTests: [/node_modules\/react\/cjs\/react\.development\.js/],
}, },
...@@ -119,6 +123,7 @@ describe('Production Usage', () => { ...@@ -119,6 +123,7 @@ describe('Production Usage', () => {
/node_modules\/react\/cjs\/react\.production\.min\.js/, /node_modules\/react\/cjs\/react\.production\.min\.js/,
/next\/router\.js/, /next\/router\.js/,
/next\/dist\/client\/router\.js/, /next\/dist\/client\/router\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
], ],
notTests: [/node_modules\/react\/cjs\/react\.development\.js/], notTests: [/node_modules\/react\/cjs\/react\.development\.js/],
}, },
...@@ -130,6 +135,9 @@ describe('Production Usage', () => { ...@@ -130,6 +135,9 @@ describe('Production Usage', () => {
/node_modules\/react\/index\.js/, /node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/, /node_modules\/react\/package\.json/,
/node_modules\/react\/cjs\/react\.production\.min\.js/, /node_modules\/react\/cjs\/react\.production\.min\.js/,
/next\/link\.js/,
/next\/dist\/client\/link\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
], ],
notTests: [/next\/dist\/server\/next\.js/, /next\/dist\/bin/], notTests: [/next\/dist\/server\/next\.js/, /next\/dist\/bin/],
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment