Unverified Commit 4b8bf686 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

[dev-overlay] deprecate `devIndicators.buildActivityPosition` and rename to `position` (#76069)

### Why?

Since the `buildActivity` is deprecated at #76067, `buildActivityPosition` may also be deprecated. However, we are planning to preserve the option to position the dev indicator. Therefore, this PR adds a new option `position` and deprecates and aliases the `buildActivityPosition` to `position`.

### Success Criteria

Deprecation:

- [x] Does using `buildActivityPosition` show a deprecation warning?
- [x] Does `buildActivityPosition` have a deprecation in JSDoc?

Alias:

> Is it backward compatible with the old overlay?

- [x] Does setting `buildActivityPosition` correctly set the build activity indicator position?
- [x] Does it warn if `buildActivityPosition` is set instead of `position`?
- [x] Does `buildActivityPosition` supersede `position` value to prevent breaking change?
- [x] Does setting the `position` correctly set the build activity indicator position?

### Follow Up

In the following PRs, we will add the behavior for `position` to adjust the dev indicator's position. After removing the old overlay's sources, we can remove any logic that `buildActivityPosition` was holding for the old overlay and make it fully an alias for backwards compatibility.

Closes NDX-837
parent 2c3cb02d
...@@ -202,6 +202,7 @@ pub enum BuildActivityPositions { ...@@ -202,6 +202,7 @@ pub enum BuildActivityPositions {
pub struct DevIndicatorsConfig { pub struct DevIndicatorsConfig {
pub build_activity: Option<bool>, pub build_activity: Option<bool>,
pub build_activity_position: Option<BuildActivityPositions>, pub build_activity_position: Option<BuildActivityPositions>,
pub position: Option<BuildActivityPositions>,
} }
#[derive( #[derive(
......
...@@ -640,5 +640,6 @@ ...@@ -640,5 +640,6 @@
"639": "unstable_rootParams() can only be used within App Router.", "639": "unstable_rootParams() can only be used within App Router.",
"640": "Route %s used \"unstable_rootParams\" inside \\`\"use cache\"\\` or \\`unstable_cache\\`. Support for this API inside cache scopes is planned for a future version of Next.js.", "640": "Route %s used \"unstable_rootParams\" inside \\`\"use cache\"\\` or \\`unstable_cache\\`. Support for this API inside cache scopes is planned for a future version of Next.js.",
"641": "Route %s used \\`unstable_rootParams()\\` in Pages Router. This API is only available within App Router.", "641": "Route %s used \\`unstable_rootParams()\\` in Pages Router. This API is only available within App Router.",
"642": "Route %s used \\`unstable_rootParams()\\` inside \\`\"use cache\"\\` or \\`unstable_cache\\`. Support for this API inside cache scopes is planned for a future version of Next.js." "642": "Route %s used \\`unstable_rootParams()\\` inside \\`\"use cache\"\\` or \\`unstable_cache\\`. Support for this API inside cache scopes is planned for a future version of Next.js.",
"643": "Invalid \"devIndicator.position\" provided, expected one of %s, received %s"
} }
...@@ -2131,7 +2131,7 @@ export default async function getBaseWebpackConfig( ...@@ -2131,7 +2131,7 @@ export default async function getBaseWebpackConfig(
pageExtensions: pageExtensions, pageExtensions: pageExtensions,
trailingSlash: config.trailingSlash, trailingSlash: config.trailingSlash,
buildActivity: config.devIndicators.buildActivity, buildActivity: config.devIndicators.buildActivity,
buildActivityPosition: config.devIndicators.buildActivityPosition, buildActivityPosition: config.devIndicators.position,
productionBrowserSourceMaps: !!config.productionBrowserSourceMaps, productionBrowserSourceMaps: !!config.productionBrowserSourceMaps,
reactStrictMode: config.reactStrictMode, reactStrictMode: config.reactStrictMode,
optimizeCss: config.experimental.optimizeCss, optimizeCss: config.experimental.optimizeCss,
......
...@@ -240,7 +240,7 @@ export function getDefineEnv({ ...@@ -240,7 +240,7 @@ export function getDefineEnv({
'process.env.__NEXT_BUILD_INDICATOR': 'process.env.__NEXT_BUILD_INDICATOR':
config.devIndicators.buildActivity ?? true, config.devIndicators.buildActivity ?? true,
'process.env.__NEXT_BUILD_INDICATOR_POSITION': 'process.env.__NEXT_BUILD_INDICATOR_POSITION':
config.devIndicators.buildActivityPosition ?? 'bottom-right', config.devIndicators.position ?? 'bottom-right',
'process.env.__NEXT_STRICT_MODE': 'process.env.__NEXT_STRICT_MODE':
config.reactStrictMode === null ? false : config.reactStrictMode, config.reactStrictMode === null ? false : config.reactStrictMode,
'process.env.__NEXT_STRICT_MODE_APP': 'process.env.__NEXT_STRICT_MODE_APP':
......
...@@ -239,6 +239,14 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() => ...@@ -239,6 +239,14 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
z.literal('top-right'), z.literal('top-right'),
]) ])
.optional(), .optional(),
position: z
.union([
z.literal('bottom-left'),
z.literal('bottom-right'),
z.literal('top-left'),
z.literal('top-right'),
])
.optional(),
}) })
.optional(), .optional(),
distDir: z.string().min(1).optional(), distDir: z.string().min(1).optional(),
......
...@@ -838,11 +838,21 @@ export interface NextConfig extends Record<string, any> { ...@@ -838,11 +838,21 @@ export interface NextConfig extends Record<string, any> {
/** Configure indicators in development environment */ /** Configure indicators in development environment */
devIndicators?: { devIndicators?: {
/** /**
* Show "building..."" indicator in development * @deprecated The dev tools indicator has it enabled by default.
* */
appIsrStatus?: boolean
/**
* Show "building..." indicator in development
* @deprecated The dev tools indicator has it enabled by default. * @deprecated The dev tools indicator has it enabled by default.
*/ */
buildActivity?: boolean buildActivity?: boolean
/** Position of "building..." indicator in browser */
/**
* Position of "building..." indicator in browser
* @default "bottom-right"
* @deprecated Renamed as `position`.
*/
buildActivityPosition?: buildActivityPosition?:
| 'bottom-right' | 'bottom-right'
| 'bottom-left' | 'bottom-left'
...@@ -850,9 +860,10 @@ export interface NextConfig extends Record<string, any> { ...@@ -850,9 +860,10 @@ export interface NextConfig extends Record<string, any> {
| 'top-left' | 'top-left'
/** /**
* @deprecated The dev tools indicator has it enabled by default. * Position of "building..." indicator in browser
* @default "bottom-right"
* */ * */
appIsrStatus?: boolean position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'
} }
/** /**
...@@ -1098,7 +1109,7 @@ export const defaultConfig: NextConfig = { ...@@ -1098,7 +1109,7 @@ export const defaultConfig: NextConfig = {
compress: true, compress: true,
images: imageConfigDefault, images: imageConfigDefault,
devIndicators: { devIndicators: {
buildActivityPosition: 'bottom-right', position: 'bottom-right',
}, },
onDemandEntries: { onDemandEntries: {
maxInactiveAge: 60 * 1000, maxInactiveAge: 60 * 1000,
......
...@@ -55,7 +55,8 @@ export function warnOptionHasBeenDeprecated( ...@@ -55,7 +55,8 @@ export function warnOptionHasBeenDeprecated(
nestedPropertyKey: string, nestedPropertyKey: string,
reason: string, reason: string,
silent: boolean silent: boolean
) { ): boolean {
let hasWarned = false
if (!silent) { if (!silent) {
let current = config let current = config
let found = true let found = true
...@@ -69,9 +70,11 @@ export function warnOptionHasBeenDeprecated( ...@@ -69,9 +70,11 @@ export function warnOptionHasBeenDeprecated(
} }
} }
if (found) { if (found) {
Log.warn(reason) Log.warnOnce(reason)
hasWarned = true
} }
} }
return hasWarned
} }
export function warnOptionHasBeenMovedOutOfExperimental( export function warnOptionHasBeenMovedOutOfExperimental(
...@@ -477,6 +480,23 @@ function assignDefaults( ...@@ -477,6 +480,23 @@ function assignDefaults(
silent silent
) )
const hasWarnedBuildActivityPosition = warnOptionHasBeenDeprecated(
result,
'devIndicators.buildActivityPosition',
`\`devIndicators.buildActivityPosition\` has been renamed to \`devIndicators.position\`. Please update your ${configFileName} file accordingly.`,
silent
)
if (
hasWarnedBuildActivityPosition &&
result.devIndicators?.buildActivityPosition &&
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.`
)
result.devIndicators.position = result.devIndicators.buildActivityPosition
}
warnOptionHasBeenMovedOutOfExperimental( warnOptionHasBeenMovedOutOfExperimental(
result, result,
'bundlePagesExternals', 'bundlePagesExternals',
...@@ -815,8 +835,8 @@ function assignDefaults( ...@@ -815,8 +835,8 @@ function assignDefaults(
} }
} }
if (result.devIndicators?.buildActivityPosition) { if (result.devIndicators?.position) {
const { buildActivityPosition } = result.devIndicators const { position } = result.devIndicators
const allowedValues = [ const allowedValues = [
'top-left', 'top-left',
'top-right', 'top-right',
...@@ -824,11 +844,11 @@ function assignDefaults( ...@@ -824,11 +844,11 @@ function assignDefaults(
'bottom-right', 'bottom-right',
] ]
if (!allowedValues.includes(buildActivityPosition)) { if (!allowedValues.includes(position)) {
throw new Error( throw new Error(
`Invalid "devIndicator.buildActivityPosition" provided, expected one of ${allowedValues.join( `Invalid "devIndicator.position" provided, expected one of ${allowedValues.join(
', ' ', '
)}, received ${buildActivityPosition}` )}, received ${position}`
) )
} }
} }
......
...@@ -67,7 +67,7 @@ describe('Build Activity Indicator', () => { ...@@ -67,7 +67,7 @@ describe('Build Activity Indicator', () => {
await check( await check(
() => stripAnsi(stderr), () => stripAnsi(stderr),
new RegExp( new RegExp(
`Invalid "devIndicator.buildActivityPosition" provided, expected one of top-left, top-right, bottom-left, bottom-right, received ttop-leff` `Invalid "devIndicator.position" provided, expected one of top-left, top-right, bottom-left, bottom-right, received ttop-leff`
) )
) )
......
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