2020-06-04 19:32:45 +02:00
|
|
|
import { normalizePagePath, denormalizePagePath } from './normalize-page-path'
|
2018-12-07 13:35:01 +01:00
|
|
|
|
2018-12-18 17:12:49 +01:00
|
|
|
export type BuildManifest = {
|
2019-05-29 13:57:26 +02:00
|
|
|
devFiles: string[]
|
2020-06-07 01:00:03 +02:00
|
|
|
polyfillFiles: string[]
|
2020-02-29 23:09:42 +01:00
|
|
|
lowPriorityFiles: string[]
|
2018-12-07 13:35:01 +01:00
|
|
|
pages: {
|
2020-02-29 23:09:42 +01:00
|
|
|
'/_app': string[]
|
2019-05-29 13:57:26 +02:00
|
|
|
[page: string]: string[]
|
|
|
|
}
|
2018-12-07 13:35:01 +01:00
|
|
|
}
|
|
|
|
|
2019-05-29 13:57:26 +02:00
|
|
|
export function getPageFiles(
|
|
|
|
buildManifest: BuildManifest,
|
|
|
|
page: string
|
|
|
|
): 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) {
|
2018-12-31 14:44:27 +01:00
|
|
|
// tslint:disable-next-line
|
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
|
|
|
|
}
|