diff --git a/packages/next/client/app-index.tsx b/packages/next/client/app-index.tsx
index 70cdea5f76348e..b486c1f80f8a53 100644
--- a/packages/next/client/app-index.tsx
+++ b/packages/next/client/app-index.tsx
@@ -7,7 +7,7 @@ import { createFromReadableStream } from 'next/dist/compiled/react-server-dom-we
import { HeadManagerContext } from '../shared/lib/head-manager-context'
import { GlobalLayoutRouterContext } from '../shared/lib/app-router-context'
-import { NEXT_DYNAMIC_NO_SSR_CODE } from '../shared/lib/dynamic'
+import { NEXT_DYNAMIC_NO_SSR_CODE } from '../shared/lib/no-ssr-error'
///
diff --git a/packages/next/client/index.tsx b/packages/next/client/index.tsx
index 6610370d0a861b..e365963a13477e 100644
--- a/packages/next/client/index.tsx
+++ b/packages/next/client/index.tsx
@@ -43,7 +43,7 @@ import {
PathnameContextProviderAdapter,
} from '../shared/lib/router/adapters'
import { SearchParamsContext } from '../shared/lib/hooks-client-context'
-import { NEXT_DYNAMIC_NO_SSR_CODE } from '../shared/lib/dynamic'
+import { NEXT_DYNAMIC_NO_SSR_CODE } from '../shared/lib/no-ssr-error'
///
diff --git a/packages/next/export/worker.ts b/packages/next/export/worker.ts
index 64b4684f9d4972..98cfab1b32c462 100644
--- a/packages/next/export/worker.ts
+++ b/packages/next/export/worker.ts
@@ -32,7 +32,7 @@ import { normalizeAppPath } from '../shared/lib/router/utils/app-paths'
import { REDIRECT_ERROR_CODE } from '../client/components/redirect'
import { DYNAMIC_ERROR_CODE } from '../client/components/hooks-server-context'
import { NOT_FOUND_ERROR_CODE } from '../client/components/not-found'
-import { NEXT_DYNAMIC_NO_SSR_CODE } from '../shared/lib/dynamic'
+import { NEXT_DYNAMIC_NO_SSR_CODE } from '../shared/lib/no-ssr-error'
loadRequireHook()
@@ -451,15 +451,22 @@ export default async function exportPage({
try {
await promises.access(ampHtmlFilepath)
} catch (_) {
+ let ampRenderResult
// make sure it doesn't exist from manual mapping
- let ampRenderResult = await renderMethod(
- req,
- res,
- page,
- // @ts-ignore
- { ...query, amp: '1' },
- curRenderOpts as any
- )
+ try {
+ ampRenderResult = await renderMethod(
+ req,
+ res,
+ page,
+ // @ts-ignore
+ { ...query, amp: '1' },
+ curRenderOpts as any
+ )
+ } catch (err: any) {
+ if (err.digest !== NEXT_DYNAMIC_NO_SSR_CODE) {
+ throw err
+ }
+ }
const ampHtml = ampRenderResult
? ampRenderResult.toUnchunkedString()
diff --git a/packages/next/server/app-render.tsx b/packages/next/server/app-render.tsx
index ec1be285075871..3f084381a02fce 100644
--- a/packages/next/server/app-render.tsx
+++ b/packages/next/server/app-render.tsx
@@ -35,7 +35,7 @@ import { REDIRECT_ERROR_CODE } from '../client/components/redirect'
import { RequestCookies } from './web/spec-extension/cookies'
import { DYNAMIC_ERROR_CODE } from '../client/components/hooks-server-context'
import { NOT_FOUND_ERROR_CODE } from '../client/components/not-found'
-import { NEXT_DYNAMIC_NO_SSR_CODE } from '../shared/lib/dynamic'
+import { NEXT_DYNAMIC_NO_SSR_CODE } from '../shared/lib/no-ssr-error'
import { HeadManagerContext } from '../shared/lib/head-manager-context'
import { Writable } from 'stream'
import stringHash from 'next/dist/compiled/string-hash'
diff --git a/packages/next/server/render.tsx b/packages/next/server/render.tsx
index 224aff62f5f7ce..7ab0e3205aeca4 100644
--- a/packages/next/server/render.tsx
+++ b/packages/next/server/render.tsx
@@ -89,7 +89,7 @@ import {
} from '../shared/lib/router/adapters'
import { AppRouterContext } from '../shared/lib/app-router-context'
import { SearchParamsContext } from '../shared/lib/hooks-client-context'
-import { NEXT_DYNAMIC_NO_SSR_CODE } from '../shared/lib/dynamic'
+import { NEXT_DYNAMIC_NO_SSR_CODE } from '../shared/lib/no-ssr-error'
let tryGetPreviewData: typeof import('./api-utils/node').tryGetPreviewData
let warn: typeof import('../build/output/log').warn
diff --git a/packages/next/shared/lib/dynamic.tsx b/packages/next/shared/lib/dynamic.tsx
index f0fdf19c478790..e70e293eb28530 100644
--- a/packages/next/shared/lib/dynamic.tsx
+++ b/packages/next/shared/lib/dynamic.tsx
@@ -74,9 +74,9 @@ export function noSSR
(
return () => (
-
-
-
+
+ {/*
+ */}
)
}
diff --git a/packages/next/shared/lib/loadable-context.ts b/packages/next/shared/lib/loadable-context.ts
index c449b61d3ee962..914b64939d3867 100644
--- a/packages/next/shared/lib/loadable-context.ts
+++ b/packages/next/shared/lib/loadable-context.ts
@@ -1,5 +1,3 @@
-'use client'
-
import React from 'react'
type CaptureFn = (moduleName: string) => void
diff --git a/test/.stats-app/stats-config.js b/test/.stats-app/stats-config.js
index 924441c7ad1315..3ae253132424fe 100644
--- a/test/.stats-app/stats-config.js
+++ b/test/.stats-app/stats-config.js
@@ -81,8 +81,6 @@ module.exports = {
module.exports = {
experimental: {
appDir: true,
- // remove after next stable release (current v12.3.1)
- serverComponents: true,
},
generateBuildId: () => 'BUILD_ID',
webpack(config) {
@@ -103,8 +101,6 @@ module.exports = {
module.exports = {
experimental: {
appDir: true,
- // remove after next stable relase (current v12.3.1)
- serverComponents: true,
},
generateBuildId: () => 'BUILD_ID'
}