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

Ensure conditional resolve alias does not affect server #29673

Merged
merged 3 commits into from Oct 6, 2021
Merged
Show file tree
Hide file tree
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
13 changes: 9 additions & 4 deletions packages/next/build/webpack-config.ts
Expand Up @@ -491,10 +491,15 @@ export default async function getBaseWebpackConfig(
[DOT_NEXT_ALIAS]: distDir,
...getOptimizedAliases(isServer),
...getReactProfilingInProduction(),
[clientResolveRewrites]: hasRewrites
? clientResolveRewrites
: // With webpack 5 an alias can be pointed to false to noop
false,

...(!isServer
? {
[clientResolveRewrites]: hasRewrites
? clientResolveRewrites
: // With webpack 5 an alias can be pointed to false to noop
false,
}
: {}),
},
...(!isServer
? {
Expand Down
8 changes: 8 additions & 0 deletions test/integration/production/test/index.test.js
Expand Up @@ -93,6 +93,9 @@ describe('Production Usage', () => {
/node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/,
/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/],
},
Expand All @@ -106,6 +109,7 @@ describe('Production Usage', () => {
/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/],
},
Expand All @@ -119,6 +123,7 @@ describe('Production Usage', () => {
/node_modules\/react\/cjs\/react\.production\.min\.js/,
/next\/router\.js/,
/next\/dist\/client\/router\.js/,
/next\/dist\/shared\/lib\/router\/utils\/resolve-rewrites\.js/,
],
notTests: [/node_modules\/react\/cjs\/react\.development\.js/],
},
Expand All @@ -130,6 +135,9 @@ describe('Production Usage', () => {
/node_modules\/react\/index\.js/,
/node_modules\/react\/package\.json/,
/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/],
},
Expand Down