Unverified Commit 0fe6e850 authored by Shu Ding's avatar Shu Ding Committed by GitHub

Fix tracking of client reference manifest (#52505)

The problem was introduced in #52450, that the client reference manifest isn't being tracked and included in the function.

Verified that this fixes the issue.
parent 4ddb6fc7
import { webpack, sources } from 'next/dist/compiled/webpack/webpack' import { webpack, sources } from 'next/dist/compiled/webpack/webpack'
import { import {
APP_BUILD_MANIFEST, APP_BUILD_MANIFEST,
CLIENT_REFERENCE_MANIFEST,
CLIENT_STATIC_FILES_RUNTIME_MAIN_APP, CLIENT_STATIC_FILES_RUNTIME_MAIN_APP,
SYSTEM_ENTRYPOINTS, SYSTEM_ENTRYPOINTS,
} from '../../../shared/lib/constants' } from '../../../shared/lib/constants'
...@@ -77,22 +76,7 @@ export class AppBuildManifestPlugin { ...@@ -77,22 +76,7 @@ export class AppBuildManifestPlugin {
} }
const filesForPage = getEntrypointFiles(entrypoint) const filesForPage = getEntrypointFiles(entrypoint)
const manifestsForPage = manifest.pages[pagePath] = [...new Set([...mainFiles, ...filesForPage])]
pagePath.endsWith('/page') ||
pagePath === '/not-found' ||
pagePath === '/_not-found'
? [
'server/app' +
pagePath.replace(/%5F/g, '_') +
'_' +
CLIENT_REFERENCE_MANIFEST +
'.js',
]
: []
manifest.pages[pagePath] = [
...new Set([...mainFiles, ...manifestsForPage, ...filesForPage]),
]
} }
const json = JSON.stringify(manifest, null, 2) const json = JSON.stringify(manifest, null, 2)
......
...@@ -6,7 +6,10 @@ import { ...@@ -6,7 +6,10 @@ import {
nodeFileTrace, nodeFileTrace,
NodeFileTraceReasons, NodeFileTraceReasons,
} from 'next/dist/compiled/@vercel/nft' } from 'next/dist/compiled/@vercel/nft'
import { TRACE_OUTPUT_VERSION } from '../../../shared/lib/constants' import {
CLIENT_REFERENCE_MANIFEST,
TRACE_OUTPUT_VERSION,
} from '../../../shared/lib/constants'
import { webpack, sources } from 'next/dist/compiled/webpack/webpack' import { webpack, sources } from 'next/dist/compiled/webpack/webpack'
import { import {
NODE_ESM_RESOLVE_OPTIONS, NODE_ESM_RESOLVE_OPTIONS,
...@@ -285,6 +288,27 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance { ...@@ -285,6 +288,27 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
// don't include the entry itself in the trace // don't include the entry itself in the trace
entryFiles.delete(nodePath.join(outputPath, `../${entrypoint.name}.js`)) entryFiles.delete(nodePath.join(outputPath, `../${entrypoint.name}.js`))
if (entrypoint.name.startsWith('app/')) {
// include the client reference manifest
const clientManifestsForPage =
entrypoint.name.endsWith('/page') ||
entrypoint.name === '/not-found' ||
entrypoint.name === '/_not-found'
? nodePath.join(
outputPath,
'..',
entrypoint.name.replace(/%5F/g, '_') +
'_' +
CLIENT_REFERENCE_MANIFEST +
'.js'
)
: null
if (clientManifestsForPage !== null) {
entryFiles.add(clientManifestsForPage)
}
}
const finalFiles: string[] = [] const finalFiles: string[] = []
for (const file of new Set([ for (const file of new Set([
......
...@@ -293,7 +293,6 @@ export default abstract class Server<ServerOptions extends Options = Options> { ...@@ -293,7 +293,6 @@ export default abstract class Server<ServerOptions extends Options = Options> {
}): Promise<FindComponentsResult | null> }): Promise<FindComponentsResult | null>
protected abstract getFontManifest(): FontManifest | undefined protected abstract getFontManifest(): FontManifest | undefined
protected abstract getPrerenderManifest(): PrerenderManifest protected abstract getPrerenderManifest(): PrerenderManifest
// protected abstract getServerComponentManifest(): any
protected abstract getNextFontManifest(): NextFontManifest | undefined protected abstract getNextFontManifest(): NextFontManifest | undefined
protected abstract attachRequestMeta( protected abstract attachRequestMeta(
req: BaseNextRequest, req: BaseNextRequest,
......
...@@ -564,16 +564,6 @@ createNextDescribe( ...@@ -564,16 +564,6 @@ createNextDescribe(
}) })
await Promise.all(promises) await Promise.all(promises)
}) })
it('should generate client reference manifest for edge SSR pages', async () => {
const buildManifest = JSON.parse(
await next.readFile('.next/app-build-manifest.json')
)
expect(buildManifest.pages['/edge/dynamic/page']).toInclude(
'server/app/edge/dynamic/page_client-reference-manifest.js'
)
})
} }
} }
) )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment