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

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

1 change: 1 addition & 0 deletions crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ pub enum BuildActivityPositions {
pub struct DevIndicatorsConfig {
pub build_activity: Option<bool>,
pub build_activity_position: Option<BuildActivityPositions>,
pub position: Option<BuildActivityPositions>,
}

#[derive(
Expand Down
3 changes: 2 additions & 1 deletion packages/next/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -640,5 +640,6 @@
"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.",
"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"
}
2 changes: 1 addition & 1 deletion packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ export default async function getBaseWebpackConfig(
pageExtensions: pageExtensions,
trailingSlash: config.trailingSlash,
buildActivity: config.devIndicators.buildActivity,
buildActivityPosition: config.devIndicators.buildActivityPosition,
buildActivityPosition: config.devIndicators.position,
productionBrowserSourceMaps: !!config.productionBrowserSourceMaps,
reactStrictMode: config.reactStrictMode,
optimizeCss: config.experimental.optimizeCss,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export function getDefineEnv({
'process.env.__NEXT_BUILD_INDICATOR':
config.devIndicators.buildActivity ?? true,
'process.env.__NEXT_BUILD_INDICATOR_POSITION':
config.devIndicators.buildActivityPosition ?? 'bottom-right',
config.devIndicators.position ?? 'bottom-right',
'process.env.__NEXT_STRICT_MODE':
config.reactStrictMode === null ? false : config.reactStrictMode,
'process.env.__NEXT_STRICT_MODE_APP':
Expand Down
8 changes: 8 additions & 0 deletions packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
z.literal('top-right'),
])
.optional(),
position: z
.union([
z.literal('bottom-left'),
z.literal('bottom-right'),
z.literal('top-left'),
z.literal('top-right'),
])
.optional(),
})
.optional(),
distDir: z.string().min(1).optional(),
Expand Down
21 changes: 16 additions & 5 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,21 +838,32 @@ export interface NextConfig extends Record<string, any> {
/** Configure indicators in development environment */
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.
*/
buildActivity?: boolean
/** Position of "building..." indicator in browser */

/**
* Position of "building..." indicator in browser
* @default "bottom-right"
* @deprecated Renamed as `position`.
*/
buildActivityPosition?:
| 'bottom-right'
| 'bottom-left'
| 'top-right'
| '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'
}

/**
Expand Down Expand Up @@ -1098,7 +1109,7 @@ export const defaultConfig: NextConfig = {
compress: true,
images: imageConfigDefault,
devIndicators: {
buildActivityPosition: 'bottom-right',
position: 'bottom-right',
},
onDemandEntries: {
maxInactiveAge: 60 * 1000,
Expand Down
34 changes: 27 additions & 7 deletions packages/next/src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export function warnOptionHasBeenDeprecated(
nestedPropertyKey: string,
reason: string,
silent: boolean
) {
): boolean {
let hasWarned = false
if (!silent) {
let current = config
let found = true
Expand All @@ -69,9 +70,11 @@ export function warnOptionHasBeenDeprecated(
}
}
if (found) {
Log.warn(reason)
Log.warnOnce(reason)
hasWarned = true
}
}
return hasWarned
}

export function warnOptionHasBeenMovedOutOfExperimental(
Expand Down Expand Up @@ -477,6 +480,23 @@ function assignDefaults(
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.`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For those who're curious how it'd look like:

CleanShot 2025-02-15 at 21 25 54

)
result.devIndicators.position = result.devIndicators.buildActivityPosition
}

warnOptionHasBeenMovedOutOfExperimental(
result,
'bundlePagesExternals',
Expand Down Expand Up @@ -815,20 +835,20 @@ function assignDefaults(
}
}

if (result.devIndicators?.buildActivityPosition) {
const { buildActivityPosition } = result.devIndicators
if (result.devIndicators?.position) {
const { position } = result.devIndicators
const allowedValues = [
'top-left',
'top-right',
'bottom-left',
'bottom-right',
]

if (!allowedValues.includes(buildActivityPosition)) {
if (!allowedValues.includes(position)) {
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}`
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/build-indicator/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Build Activity Indicator', () => {
await check(
() => stripAnsi(stderr),
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`
)
)

Expand Down
Loading