-
Notifications
You must be signed in to change notification settings - Fork 30k
fix: should not warn depredated config if next config file does not exist #82593
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
Changes from all commits
3abd1e9
e8a27f0
8167bd4
1c92717
e3341c2
23424cc
b68f0bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,7 +81,8 @@ export function warnOptionHasBeenDeprecated( | |
| break | ||
| } | ||
| } | ||
| if (found) { | ||
|
|
||
| if (found && config.configFile) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we're adding a new property to I'm not crazy about adding new properties to the config object. I feel like the correct fix is to call these warning functions only when we have a user config, not some merged/default config.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're not adding a new prop, this is always present in loaded config, the filename is from
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: since now we pass userConfig, no need to check if the config file exists? |
||
| Log.warnOnce(reason) | ||
| hasWarned = true | ||
| } | ||
|
|
@@ -524,7 +525,7 @@ function assignDefaults( | |
| } | ||
|
|
||
| warnCustomizedOption( | ||
| result, | ||
| userConfig, | ||
| 'experimental.esmExternals', | ||
| true, | ||
| 'experimental.esmExternals is not recommended to be modified as it may disrupt module resolution', | ||
|
|
@@ -533,44 +534,49 @@ function assignDefaults( | |
| ) | ||
|
|
||
| warnOptionHasBeenDeprecated( | ||
| result, | ||
| userConfig, | ||
| 'experimental.instrumentationHook', | ||
| `\`experimental.instrumentationHook\` is no longer needed, because \`instrumentation.js\` is available by default. You can remove it from ${configFileName}.`, | ||
| silent | ||
| ) | ||
|
|
||
| warnOptionHasBeenDeprecated( | ||
| result, | ||
| userConfig, | ||
| 'experimental.after', | ||
| `\`experimental.after\` is no longer needed, because \`after\` is available by default. You can remove it from ${configFileName}.`, | ||
| silent | ||
| ) | ||
|
|
||
| warnOptionHasBeenDeprecated( | ||
| result, | ||
| userConfig, | ||
| 'devIndicators.appIsrStatus', | ||
| `\`devIndicators.appIsrStatus\` is deprecated and no longer configurable. Please remove it from ${configFileName}.`, | ||
| silent | ||
| ) | ||
|
|
||
| warnOptionHasBeenDeprecated( | ||
| result, | ||
| userConfig, | ||
| 'devIndicators.buildActivity', | ||
| `\`devIndicators.buildActivity\` is deprecated and no longer configurable. Please remove it from ${configFileName}.`, | ||
| silent | ||
| ) | ||
|
|
||
| const hasWarnedBuildActivityPosition = warnOptionHasBeenDeprecated( | ||
| result, | ||
| userConfig, | ||
| 'devIndicators.buildActivityPosition', | ||
| `\`devIndicators.buildActivityPosition\` has been renamed to \`devIndicators.position\`. Please update your ${configFileName} file accordingly.`, | ||
| silent | ||
| ) | ||
| if ( | ||
| hasWarnedBuildActivityPosition && | ||
| result.devIndicators !== false && | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The buildActivityPosition deprecation logic has inconsistent references between View Details📝 Patch Detailsdiff --git a/packages/next/src/server/config.ts b/packages/next/src/server/config.ts
index 3c4ff78cb7..6a74d5e503 100644
--- a/packages/next/src/server/config.ts
+++ b/packages/next/src/server/config.ts
@@ -569,14 +569,12 @@ function assignDefaults(
)
if (
hasWarnedBuildActivityPosition &&
- userConfig.devIndicators !== false &&
- userConfig.devIndicators &&
- 'buildActivityPosition' in userConfig.devIndicators &&
- userConfig.devIndicators.position &&
- userConfig.devIndicators.buildActivityPosition !==
- userConfig.devIndicators.position &&
+ result.devIndicators !== false &&
result.devIndicators &&
- 'buildActivityPosition' in result.devIndicators
+ 'buildActivityPosition' in result.devIndicators &&
+ result.devIndicators.position &&
+ result.devIndicators.buildActivityPosition !==
+ result.devIndicators.position
) {
Log.warnOnce(
`The \`devIndicators\` option \`buildActivityPosition\` ("${result.devIndicators.buildActivityPosition}") conflicts with \`position\` ("${result.devIndicators.position}"). Using \`buildActivityPosition\` ("${result.devIndicators.buildActivityPosition}") for backward compatibility.`
AnalysisIn the buildActivityPosition logic, the code checks for properties on
This could lead to the warning logic not triggering when it should, or potentially accessing undefined properties if the object structures differ between RecommendationMake the property references consistent. Since the warning message and final assignment use if (
hasWarnedBuildActivityPosition &&
result.devIndicators !== false &&
result.devIndicators &&
'buildActivityPosition' in result.devIndicators &&
result.devIndicators.position &&
result.devIndicators.buildActivityPosition !== result.devIndicators.position
) {Alternatively, if the intent is to check the user's original config, then use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved lower, we should check against userConfig. Still keeping cond is only to make ts happy |
||
| 'buildActivityPosition' in result.devIndicators && | ||
| result.devIndicators.buildActivityPosition !== result.devIndicators.position | ||
| userConfig.devIndicators !== false && | ||
| userConfig.devIndicators && | ||
| 'buildActivityPosition' in userConfig.devIndicators && | ||
| userConfig.devIndicators.position && | ||
| userConfig.devIndicators.buildActivityPosition !== | ||
| userConfig.devIndicators.position && | ||
| result.devIndicators && | ||
| 'buildActivityPosition' in result.devIndicators | ||
| ) { | ||
| Log.warnOnce( | ||
| `The \`devIndicators\` option \`buildActivityPosition\` ("${result.devIndicators.buildActivityPosition}") conflicts with \`position\` ("${result.devIndicators.position}"). Using \`buildActivityPosition\` ("${result.devIndicators.buildActivityPosition}") for backward compatibility.` | ||
|
|
@@ -579,28 +585,28 @@ function assignDefaults( | |
| } | ||
|
|
||
| warnOptionHasBeenMovedOutOfExperimental( | ||
| result, | ||
| userConfig, | ||
| 'bundlePagesExternals', | ||
| 'bundlePagesRouterDependencies', | ||
| configFileName, | ||
| silent | ||
| ) | ||
| warnOptionHasBeenMovedOutOfExperimental( | ||
| result, | ||
| userConfig, | ||
| 'serverComponentsExternalPackages', | ||
| 'serverExternalPackages', | ||
| configFileName, | ||
| silent | ||
| ) | ||
| warnOptionHasBeenMovedOutOfExperimental( | ||
| result, | ||
| userConfig, | ||
| 'relay', | ||
| 'compiler.relay', | ||
| configFileName, | ||
| silent | ||
| ) | ||
| warnOptionHasBeenMovedOutOfExperimental( | ||
| result, | ||
| userConfig, | ||
| 'styledComponents', | ||
| 'compiler.styledComponents', | ||
| configFileName, | ||
|
|
@@ -614,42 +620,42 @@ function assignDefaults( | |
| silent | ||
| ) | ||
| warnOptionHasBeenMovedOutOfExperimental( | ||
| result, | ||
| userConfig, | ||
| 'reactRemoveProperties', | ||
| 'compiler.reactRemoveProperties', | ||
| configFileName, | ||
| silent | ||
| ) | ||
| warnOptionHasBeenMovedOutOfExperimental( | ||
| result, | ||
| userConfig, | ||
| 'removeConsole', | ||
| 'compiler.removeConsole', | ||
| configFileName, | ||
| silent | ||
| ) | ||
| warnOptionHasBeenMovedOutOfExperimental( | ||
| result, | ||
| userConfig, | ||
| 'swrDelta', | ||
| 'expireTime', | ||
| configFileName, | ||
| silent | ||
| ) | ||
| warnOptionHasBeenMovedOutOfExperimental( | ||
| result, | ||
| userConfig, | ||
| 'outputFileTracingRoot', | ||
| 'outputFileTracingRoot', | ||
| configFileName, | ||
| silent | ||
| ) | ||
| warnOptionHasBeenMovedOutOfExperimental( | ||
| result, | ||
| userConfig, | ||
| 'outputFileTracingIncludes', | ||
| 'outputFileTracingIncludes', | ||
| configFileName, | ||
| silent | ||
| ) | ||
| warnOptionHasBeenMovedOutOfExperimental( | ||
| result, | ||
| userConfig, | ||
| 'outputFileTracingExcludes', | ||
| 'outputFileTracingExcludes', | ||
| configFileName, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |||||||||||||||||||||||||||||||||||
| import fs from 'fs-extra' | ||||||||||||||||||||||||||||||||||||
| import { join } from 'path' | ||||||||||||||||||||||||||||||||||||
| import webdriver from 'next-webdriver' | ||||||||||||||||||||||||||||||||||||
| import { findPort, launchApp, killApp, waitFor, check } from 'next-test-utils' | ||||||||||||||||||||||||||||||||||||
| import { findPort, launchApp, killApp, waitFor, retry } from 'next-test-utils' | ||||||||||||||||||||||||||||||||||||
| import stripAnsi from 'strip-ansi' | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| const appDir = join(__dirname, '..') | ||||||||||||||||||||||||||||||||||||
|
|
@@ -33,7 +33,7 @@ describe('Build Activity Indicator', () => { | |||||||||||||||||||||||||||||||||||
| ` | ||||||||||||||||||||||||||||||||||||
| module.exports = { | ||||||||||||||||||||||||||||||||||||
| devIndicators: { | ||||||||||||||||||||||||||||||||||||
| buildActivityPosition: 'ttop-leff' | ||||||||||||||||||||||||||||||||||||
| buildActivityPosition: 'top-leff' | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| ` | ||||||||||||||||||||||||||||||||||||
|
|
@@ -47,12 +47,13 @@ describe('Build Activity Indicator', () => { | |||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||
| await fs.remove(configPath) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| await check( | ||||||||||||||||||||||||||||||||||||
| () => stripAnsi(stderr), | ||||||||||||||||||||||||||||||||||||
| new RegExp( | ||||||||||||||||||||||||||||||||||||
| `Invalid "devIndicator.position" provided, expected one of top-left, top-right, bottom-left, bottom-right, received ttop-leff` | ||||||||||||||||||||||||||||||||||||
| await retry(() => { | ||||||||||||||||||||||||||||||||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test was wrong before, there's no
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's next.js/packages/next/src/server/config-shared.ts Lines 1121 to 1137 in ea5b03b
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on the user input we should warn
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see what you mean 👍 |
||||||||||||||||||||||||||||||||||||
| const cleanStderr = stripAnsi(stderr) | ||||||||||||||||||||||||||||||||||||
| // buildActivityPosition is deprecated, but we should warn it's not a valid option | ||||||||||||||||||||||||||||||||||||
| expect(cleanStderr).toContain( | ||||||||||||||||||||||||||||||||||||
| `Invalid input at "devIndicators.buildActivityPosition"` | ||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if (app) { | ||||||||||||||||||||||||||||||||||||
| await killApp(app) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.