Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tracking of client reference manifest #52505

Merged
merged 2 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 () => {
shuding marked this conversation as resolved.
Show resolved Hide resolved
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'
)
})
}
}
)