2022-04-30 13:19:27 +02:00
|
|
|
import { denormalizePagePath } from '../shared/lib/page-path/denormalize-page-path'
|
|
|
|
import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path'
|
2018-12-07 13:35:01 +01:00
|
|
|
|
2018-12-18 17:12:49 +01:00
|
|
|
export type BuildManifest = {
|
2020-08-14 06:30:25 +02:00
|
|
|
devFiles: readonly string[]
|
|
|
|
ampDevFiles: readonly string[]
|
|
|
|
polyfillFiles: readonly string[]
|
|
|
|
lowPriorityFiles: readonly string[]
|
2022-05-03 12:37:23 +02:00
|
|
|
rootMainFiles: readonly string[]
|
2018-12-07 13:35:01 +01:00
|
|
|
pages: {
|
2020-08-14 06:30:25 +02:00
|
|
|
'/_app': readonly string[]
|
|
|
|
[page: string]: readonly string[]
|
2019-05-29 13:57:26 +02:00
|
|
|
}
|
2020-08-14 06:30:25 +02:00
|
|
|
ampFirstPages: readonly string[]
|
2018-12-07 13:35:01 +01:00
|
|
|
}
|
|
|
|
|
2019-05-29 13:57:26 +02:00
|
|
|
export function getPageFiles(
|
|
|
|
buildManifest: BuildManifest,
|
|
|
|
page: string
|
2020-08-14 06:30:25 +02:00
|
|
|
): readonly string[] {
|
2020-06-08 16:17:03 +02:00
|
|
|
const normalizedPage = denormalizePagePath(normalizePagePath(page))
|
2019-04-18 05:15:56 +02:00
|
|
|
let files = buildManifest.pages[normalizedPage]
|
|
|
|
|
2018-12-07 13:35:01 +01:00
|
|
|
if (!files) {
|
2019-05-29 13:57:26 +02:00
|
|
|
console.warn(
|
|
|
|
`Could not find files for ${normalizedPage} in .next/build-manifest.json`
|
|
|
|
)
|
2018-12-07 13:35:01 +01:00
|
|
|
return []
|
|
|
|
}
|
|
|
|
|
|
|
|
return files
|
|
|
|
}
|