Unverified Commit 9e65c6a9 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Strongly type PageLoader (#16132)

Fixes #16131
parent e72ac764
...@@ -1064,6 +1064,8 @@ export default async function build( ...@@ -1064,6 +1064,8 @@ export default async function build(
await telemetry.flush() await telemetry.flush()
} }
export type ClientSsgManifest = Set<string>
function generateClientSsgManifest( function generateClientSsgManifest(
prerenderManifest: PrerenderManifest, prerenderManifest: PrerenderManifest,
{ {
...@@ -1072,7 +1074,7 @@ function generateClientSsgManifest( ...@@ -1072,7 +1074,7 @@ function generateClientSsgManifest(
isModern, isModern,
}: { buildId: string; distDir: string; isModern: boolean } }: { buildId: string; distDir: string; isModern: boolean }
) { ) {
const ssgPages: Set<string> = new Set<string>([ const ssgPages: ClientSsgManifest = new Set<string>([
...Object.entries(prerenderManifest.routes) ...Object.entries(prerenderManifest.routes)
// Filter out dynamic routes // Filter out dynamic routes
.filter(([, { srcRoute }]) => srcRoute == null) .filter(([, { srcRoute }]) => srcRoute == null)
......
...@@ -15,13 +15,15 @@ import { ampFirstEntryNamesMap } from './next-drop-client-page-plugin' ...@@ -15,13 +15,15 @@ import { ampFirstEntryNamesMap } from './next-drop-client-page-plugin'
const isWebpack5 = parseInt(webpack.version!) === 5 const isWebpack5 = parseInt(webpack.version!) === 5
export type ClientBuildManifest = Record<string, string[]>
// This function takes the asset map generated in BuildManifestPlugin and creates a // This function takes the asset map generated in BuildManifestPlugin and creates a
// reduced version to send to the client. // reduced version to send to the client.
function generateClientManifest( function generateClientManifest(
assetMap: BuildManifest, assetMap: BuildManifest,
isModern: boolean isModern: boolean
): string { ): string {
const clientManifest: { [s: string]: string[] } = {} const clientManifest: ClientBuildManifest = {}
const appDependencies = new Set(assetMap.pages['/_app']) const appDependencies = new Set(assetMap.pages['/_app'])
Object.entries(assetMap.pages).forEach(([page, dependencies]) => { Object.entries(assetMap.pages).forEach(([page, dependencies]) => {
......
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