Skip to content

Commit

Permalink
Fix tracking of client reference manifest (#52505)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shuding committed Jul 10, 2023
1 parent 4ddb6fc commit 0fe6e85
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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([
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ export default abstract class Server<ServerOptions extends Options = Options> {
}): Promise<FindComponentsResult | null>
protected abstract getFontManifest(): FontManifest | undefined
protected abstract getPrerenderManifest(): PrerenderManifest
// protected abstract getServerComponentManifest(): any
protected abstract getNextFontManifest(): NextFontManifest | undefined
protected abstract attachRequestMeta(
req: BaseNextRequest,
Expand Down
10 changes: 0 additions & 10 deletions test/e2e/app-dir/rsc-basic/rsc-basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
})
}
}
)

0 comments on commit 0fe6e85

Please sign in to comment.