Skip to content

Commit 2bca1fd

Browse files
ztannereps1lon
andauthored
[Deprecation Warnings]: add amp deprecation warning (#82551)
We are dropping amp support in an upcoming major. This adds a warning for using these configuration options and updates the docs with the warning. --------- Co-authored-by: Sebastian "Sebbie" Silbermann <[email protected]>
1 parent 7f20cbd commit 2bca1fd

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

docs/02-pages/02-guides/amp.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ description: With minimal config, and without leaving React, you can start addin
1111

1212
</details>
1313

14+
> **Warning**: Built-in amp support will be removed in Next.js 16.
15+
1416
With Next.js you can turn any React page into an AMP page, with minimal config, and without leaving React.
1517

1618
You can read more about AMP in the official [amp.dev](https://amp.dev/) site.

packages/next/src/server/config-shared.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ export interface ExperimentalConfig {
500500
nextScriptWorkers?: boolean
501501
scrollRestoration?: boolean
502502
externalDir?: boolean
503+
/** @deprecated built-in amp support will be removed in Next 16 */
503504
amp?: {
504505
optimizer?: any
505506
validator?: string
@@ -1146,7 +1147,10 @@ export interface NextConfig extends Record<string, any> {
11461147
pagesBufferLength?: number
11471148
}
11481149

1149-
/** @see [`next/amp`](https://nextjs.org/docs/api-reference/next/amp) */
1150+
/**
1151+
* @deprecated built-in amp support will be removed in Next 16
1152+
* @see [`next/amp`](https://nextjs.org/docs/api-reference/next/amp)
1153+
*/
11501154
amp?: {
11511155
canonicalBase?: string
11521156
}

packages/next/src/server/config.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,26 @@ function assignDefaults(
503503
}
504504
}
505505

506+
// There are a good amount of test fixtures that have amp enabled
507+
// that also assert on stderr output being empty, so we're gating the
508+
// warning to be skipped when running in Next.js tests until we fully
509+
// remove the feature.
510+
if (!process.env.__NEXT_TEST_MODE) {
511+
warnOptionHasBeenDeprecated(
512+
result,
513+
'amp',
514+
`Built-in amp support is deprecated and the \`amp\` configuration option will be removed in Next.js 16.`,
515+
silent
516+
)
517+
518+
warnOptionHasBeenDeprecated(
519+
result,
520+
'experimental.amp',
521+
`Built-in amp support is deprecated and the \`experimental.amp\` configuration option will be removed in Next.js 16.`,
522+
silent
523+
)
524+
}
525+
506526
warnCustomizedOption(
507527
result,
508528
'experimental.esmExternals',

0 commit comments

Comments
 (0)