diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index 23f64a0b56227..93c5e6592d193 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -1051,14 +1051,14 @@ type GenerateParams = Array<{ isLayout?: boolean }> -export const collectGenerateParams = ( +export const collectGenerateParams = async ( segment: any, parentSegments: string[] = [], generateParams: GenerateParams = [] -): GenerateParams => { +): Promise => { if (!Array.isArray(segment)) return generateParams const isLayout = !!segment[2]?.layout - const mod = isLayout ? segment[2]?.layout?.() : segment[2]?.page?.() + const mod = await (isLayout ? segment[2]?.layout?.() : segment[2]?.page?.()) const result = { isLayout, @@ -1264,7 +1264,7 @@ export async function isPageStatic({ if (pageType === 'app') { const tree = componentsResult.ComponentMod.tree - const generateParams = collectGenerateParams(tree) + const generateParams = await collectGenerateParams(tree) appConfig = generateParams.reduce( (builtConfig: AppConfig, curGenParams): AppConfig => { diff --git a/packages/next/server/base-server.ts b/packages/next/server/base-server.ts index 13e3b6770a5bf..b2b07f66ca006 100644 --- a/packages/next/server/base-server.ts +++ b/packages/next/server/base-server.ts @@ -483,6 +483,16 @@ export default abstract class Server { if (typeof parsedUrl.query === 'string') { parsedUrl.query = parseQs(parsedUrl.query) } + // in minimal mode we detect RSC revalidate if the .rsc path is requested + if ( + this.minimalMode && + (req.url.endsWith('.rsc') || + (typeof req.headers['x-matched-path'] === 'string' && + req.headers['x-matched-path'].endsWith('.rsc'))) + ) { + parsedUrl.query.__nextDataReq = '1' + } + req.url = normalizeRscPath(req.url, this.hasAppDir) parsedUrl.pathname = normalizeRscPath( parsedUrl.pathname || '', @@ -1042,7 +1052,9 @@ export default abstract class Server { ) if (isSSG && req.headers['__rsc__']) { - isDataReq = true + if (!this.minimalMode) { + isDataReq = true + } // strip header so we generate HTML still if ( opts.runtime !== 'experimental-edge' || diff --git a/packages/next/server/dev/static-paths-worker.ts b/packages/next/server/dev/static-paths-worker.ts index 720f47c612ced..4779ac7eb02d0 100644 --- a/packages/next/server/dev/static-paths-worker.ts +++ b/packages/next/server/dev/static-paths-worker.ts @@ -80,7 +80,9 @@ export async function loadStaticPaths({ workerWasUsed = true if (isAppPath) { - const generateParams = collectGenerateParams(components.ComponentMod.tree) + const generateParams = await collectGenerateParams( + components.ComponentMod.tree + ) return buildAppStaticPaths({ page: pathname, generateParams, diff --git a/test/e2e/app-dir/app-static.test.ts b/test/e2e/app-dir/app-static.test.ts index e6f96d683c921..6ace29735bca2 100644 --- a/test/e2e/app-dir/app-static.test.ts +++ b/test/e2e/app-dir/app-static.test.ts @@ -41,6 +41,7 @@ describe('app-dir static/dynamic handling', () => { ).filter((file) => file.match(/.*\.(js|html|rsc)$/)) expect(files).toEqual([ + '(new)/custom/page.js', 'blog/[author]/[slug]/page.js', 'blog/[author]/page.js', 'blog/seb.html', diff --git a/test/e2e/app-dir/app-static/app/(new)/custom/page.js b/test/e2e/app-dir/app-static/app/(new)/custom/page.js new file mode 100644 index 0000000000000..ddc2d8b0fd754 --- /dev/null +++ b/test/e2e/app-dir/app-static/app/(new)/custom/page.js @@ -0,0 +1,7 @@ +export const config = { + revalidate: 0, +} + +export default function Page() { + return

new root ssr

+} diff --git a/test/e2e/app-dir/app-static/app/(new)/layout.js b/test/e2e/app-dir/app-static/app/(new)/layout.js new file mode 100644 index 0000000000000..f37ea744b8e09 --- /dev/null +++ b/test/e2e/app-dir/app-static/app/(new)/layout.js @@ -0,0 +1,10 @@ +export default function Layout({ children }) { + return ( + + + my static blog + + {children} + + ) +}