diff --git a/packages/next/src/build/analysis/get-page-static-info.ts b/packages/next/src/build/analysis/get-page-static-info.ts index 9951b583b1f04..6d6cc421f895f 100644 --- a/packages/next/src/build/analysis/get-page-static-info.ts +++ b/packages/next/src/build/analysis/get-page-static-info.ts @@ -527,7 +527,22 @@ export async function getPageStaticInfo(params: { if (pageType === 'app') { if (config) { - const message = `\`export const config\` in ${pageFilePath} is deprecated. Please change \`runtime\` property to segment export config. See https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config` + let message = `Page config in ${pageFilePath} is deprecated. Replace \`export const config=…\` with the following:` + + if (config.runtime) { + message += `\n - \`export const runtime = ${JSON.stringify( + config.runtime + )}\`` + } + + if (config.regions) { + message += `\n - \`export const preferredRegion = ${JSON.stringify( + config.regions + )}\`` + } + + message += `\nVisit https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config for more information.` + if (isDev) { Log.warnOnce(message) } else { diff --git a/test/e2e/app-dir-legacy-edge-runtime-config/app/legacy-runtime-config/page.js b/test/e2e/app-dir-legacy-edge-runtime-config/app/legacy-runtime-config/page.js index 5d8f880535531..d1387c9d24020 100644 --- a/test/e2e/app-dir-legacy-edge-runtime-config/app/legacy-runtime-config/page.js +++ b/test/e2e/app-dir-legacy-edge-runtime-config/app/legacy-runtime-config/page.js @@ -9,4 +9,5 @@ export default function Page() { export const config = { runtime: 'edge', + regions: ['us-east-1'], } diff --git a/test/e2e/app-dir-legacy-edge-runtime-config/index.test.ts b/test/e2e/app-dir-legacy-edge-runtime-config/index.test.ts index 23a1f111c4dc3..628692f9f56ad 100644 --- a/test/e2e/app-dir-legacy-edge-runtime-config/index.test.ts +++ b/test/e2e/app-dir-legacy-edge-runtime-config/index.test.ts @@ -19,9 +19,15 @@ createNextDescribe( } else { expect(error).toBeDefined() } - expect(next.cliOutput).toContain('`export const config`') + + expect(next.cliOutput).toContain('Page config in ') + expect(next.cliOutput).toContain( + // the full path is more complex, we only care about this part + 'app/legacy-runtime-config/page.js is deprecated. Replace `export const config=…` with the following:' + ) + expect(next.cliOutput).toContain('- `export const runtime = "edge"`') expect(next.cliOutput).toContain( - 'app/legacy-runtime-config/page.js is deprecated. Please change `runtime` property to segment export config. See https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config' + '- `export const preferredRegion = ["us-east-1"]`' ) }) }