diff --git a/packages/next/src/build/webpack/plugins/app-build-manifest-plugin.ts b/packages/next/src/build/webpack/plugins/app-build-manifest-plugin.ts index fb143a5dbd54f..d6d26d44dc718 100644 --- a/packages/next/src/build/webpack/plugins/app-build-manifest-plugin.ts +++ b/packages/next/src/build/webpack/plugins/app-build-manifest-plugin.ts @@ -1,7 +1,6 @@ import { webpack, sources } from 'next/dist/compiled/webpack/webpack' import { APP_BUILD_MANIFEST, - CLIENT_REFERENCE_MANIFEST, CLIENT_STATIC_FILES_RUNTIME_MAIN_APP, SYSTEM_ENTRYPOINTS, } from '../../../shared/lib/constants' @@ -77,22 +76,7 @@ export class AppBuildManifestPlugin { } const filesForPage = getEntrypointFiles(entrypoint) - const manifestsForPage = - 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]), - ] + manifest.pages[pagePath] = [...new Set([...mainFiles, ...filesForPage])] } const json = JSON.stringify(manifest, null, 2) diff --git a/packages/next/src/build/webpack/plugins/next-trace-entrypoints-plugin.ts b/packages/next/src/build/webpack/plugins/next-trace-entrypoints-plugin.ts index a95e94f7e3d73..8627ee17f00bd 100644 --- a/packages/next/src/build/webpack/plugins/next-trace-entrypoints-plugin.ts +++ b/packages/next/src/build/webpack/plugins/next-trace-entrypoints-plugin.ts @@ -6,7 +6,10 @@ import { nodeFileTrace, NodeFileTraceReasons, } 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 { NODE_ESM_RESOLVE_OPTIONS, @@ -285,6 +288,27 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance { // don't include the entry itself in the trace 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[] = [] for (const file of new Set([ diff --git a/packages/next/src/server/base-server.ts b/packages/next/src/server/base-server.ts index 1232ebf7f48d4..3479cf20b0a8e 100644 --- a/packages/next/src/server/base-server.ts +++ b/packages/next/src/server/base-server.ts @@ -293,7 +293,6 @@ export default abstract class Server { }): Promise protected abstract getFontManifest(): FontManifest | undefined protected abstract getPrerenderManifest(): PrerenderManifest - // protected abstract getServerComponentManifest(): any protected abstract getNextFontManifest(): NextFontManifest | undefined protected abstract attachRequestMeta( req: BaseNextRequest, diff --git a/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts b/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts index eec55667091e7..3e71e1d12d8f7 100644 --- a/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts +++ b/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts @@ -564,16 +564,6 @@ createNextDescribe( }) 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' - ) - }) } } )