Skip to content

Commit 7d5cc40

Browse files
ijjknatew
authored andcommitted
Ensure conditional resolve alias does not affect server (vercel#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: vercel#25538 (comment)
1 parent c9c6c21 commit 7d5cc40

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

packages/next/build/webpack-config.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,15 @@ export default async function getBaseWebpackConfig(
491491
[DOT_NEXT_ALIAS]: distDir,
492492
...getOptimizedAliases(isServer),
493493
...getReactProfilingInProduction(),
494-
[clientResolveRewrites]: hasRewrites
495-
? clientResolveRewrites
496-
: // With webpack 5 an alias can be pointed to false to noop
497-
false,
494+
495+
...(!isServer
496+
? {
497+
[clientResolveRewrites]: hasRewrites
498+
? clientResolveRewrites
499+
: // With webpack 5 an alias can be pointed to false to noop
500+
false,
501+
}
502+
: {}),
498503
},
499504
...(!isServer
500505
? {

test/integration/production/test/index.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ describe('Production Usage', () => {
9393
/node_modules\/react\/index\.js/,
9494
/node_modules\/react\/package\.json/,
9595
/node_modules\/react\/cjs\/react\.production\.min\.js/,
96+
/next\/link\.js/,
97+
/next\/dist\/client\/link\.js/,
98+
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
9699
],
97100
notTests: [/node_modules\/react\/cjs\/react\.development\.js/],
98101
},
@@ -106,6 +109,7 @@ describe('Production Usage', () => {
106109
/node_modules\/react\/cjs\/react\.production\.min\.js/,
107110
/next\/link\.js/,
108111
/next\/dist\/client\/link\.js/,
112+
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
109113
],
110114
notTests: [/node_modules\/react\/cjs\/react\.development\.js/],
111115
},
@@ -119,6 +123,7 @@ describe('Production Usage', () => {
119123
/node_modules\/react\/cjs\/react\.production\.min\.js/,
120124
/next\/router\.js/,
121125
/next\/dist\/client\/router\.js/,
126+
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
122127
],
123128
notTests: [/node_modules\/react\/cjs\/react\.development\.js/],
124129
},
@@ -130,6 +135,9 @@ describe('Production Usage', () => {
130135
/node_modules\/react\/index\.js/,
131136
/node_modules\/react\/package\.json/,
132137
/node_modules\/react\/cjs\/react\.production\.min\.js/,
138+
/next\/link\.js/,
139+
/next\/dist\/client\/link\.js/,
140+
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
133141
],
134142
notTests: [/next\/dist\/server\/next\.js/, /next\/dist\/bin/],
135143
},

0 commit comments

Comments
 (0)