From e9415fc7855b51ec945e6025da90ad7206b26744 Mon Sep 17 00:00:00 2001 From: Jiwon Choi Date: Tue, 17 Dec 2024 04:45:44 +0900 Subject: [PATCH] Add feature flag for new dev overlay (#73977) This PR enabled feature flag for the new dev overlay, no behavioral change. - Added `experimental.newDevOverlay` Next.js option, which handles `__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY` env value. - Added `__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY` env to be resolved at build time so that it can be used to render the overlay conditionally --- .../next/src/build/webpack/plugins/define-env-plugin.ts | 2 ++ packages/next/src/server/config-schema.ts | 1 + packages/next/src/server/config-shared.ts | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/packages/next/src/build/webpack/plugins/define-env-plugin.ts b/packages/next/src/build/webpack/plugins/define-env-plugin.ts index b4f5a3e230dab..1a3cdf834291f 100644 --- a/packages/next/src/build/webpack/plugins/define-env-plugin.ts +++ b/packages/next/src/build/webpack/plugins/define-env-plugin.ts @@ -288,6 +288,8 @@ export function getDefineEnv({ needsExperimentalReact(config), } : undefined), + 'process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY': + config.experimental.newDevOverlay ?? false, } const userDefines = config.compiler?.define ?? {} diff --git a/packages/next/src/server/config-schema.ts b/packages/next/src/server/config-schema.ts index d1f20739ecc7a..5a4c5c39915bd 100644 --- a/packages/next/src/server/config-schema.ts +++ b/packages/next/src/server/config-schema.ts @@ -439,6 +439,7 @@ export const configSchema: zod.ZodType = z.lazy(() => typedEnv: z.boolean().optional(), serverComponentsHmrCache: z.boolean().optional(), authInterrupts: z.boolean().optional(), + newDevOverlay: z.boolean().optional(), }) .optional(), exportPathMap: z diff --git a/packages/next/src/server/config-shared.ts b/packages/next/src/server/config-shared.ts index 8adfefc99dda7..026f9c93fee64 100644 --- a/packages/next/src/server/config-shared.ts +++ b/packages/next/src/server/config-shared.ts @@ -562,6 +562,11 @@ export interface ExperimentalConfig { * This config allows you to enable the experimental navigation API `forbidden` and `unauthorized`. */ authInterrupts?: boolean + + /** + * Enables the new dev overlay. + */ + newDevOverlay?: boolean } export type ExportPathMap = { @@ -1163,6 +1168,7 @@ export const defaultConfig: NextConfig = { staticGenerationMinPagesPerWorker: 25, dynamicIO: false, inlineCss: false, + newDevOverlay: false, }, bundlePagesRouterDependencies: false, }