rsnext/packages/next/server/get-page-files.ts
Tim Neutkens 5b9ad8da90
Move next-server directory files to server directory (#26756)
* Move next-server directory files to server directory

* Update tests

* Update paths in other places
2021-06-30 13:44:40 +02:00

30 lines
745 B
TypeScript

import { normalizePagePath, denormalizePagePath } from './normalize-page-path'
export type BuildManifest = {
devFiles: readonly string[]
ampDevFiles: readonly string[]
polyfillFiles: readonly string[]
lowPriorityFiles: readonly string[]
pages: {
'/_app': readonly string[]
[page: string]: readonly string[]
}
ampFirstPages: readonly string[]
}
export function getPageFiles(
buildManifest: BuildManifest,
page: string
): readonly string[] {
const normalizedPage = denormalizePagePath(normalizePagePath(page))
let files = buildManifest.pages[normalizedPage]
if (!files) {
console.warn(
`Could not find files for ${normalizedPage} in .next/build-manifest.json`
)
return []
}
return files
}