rsnext/packages/next/next-server/server/get-page-files.ts
Tim Neutkens 2ba352da39 Move next-server back into next package (#8613)
* Initial move

* Make emitting work

* Update paths

* Remove leftover files

* Add correct externals configuration

* Import correct path

* Update path to work with ts-server test

* Update lib directory

* Compile next-server/lib
2019-09-04 10:00:54 -04:00

30 lines
636 B
TypeScript

import { normalizePagePath } from './normalize-page-path'
export type BuildManifest = {
devFiles: string[]
pages: {
[page: string]: string[]
}
}
export function getPageFiles(
buildManifest: BuildManifest,
page: string
): string[] {
const normalizedPage = normalizePagePath(page)
let files = buildManifest.pages[normalizedPage]
if (!files) {
files = buildManifest.pages[normalizedPage.replace(/\/index$/, '') || '/']
}
if (!files) {
// tslint:disable-next-line
console.warn(
`Could not find files for ${normalizedPage} in .next/build-manifest.json`
)
return []
}
return files
}