bef9b56109
Updates the way filenames are generated for browser compilation. Notably: - All entry bundles now have hashes in production, this includes pages (previously pages used a buildId in the path) - The AmpFiles no longer depends on hardcoded bundle names, it uses the buildManifest instead (internals) - All cases where we match the page name from the chunk/entrypoint name now use the same function `getRouteFromEntrypoint` (internals) - In development we no longer include the "faked" `buildId` set to `development` for page files, instead we just use the `/_next/static/pages` path (was `/_next/static/development/pages`). This was changed as it caused unneeded complexity and makes generating the bundles easier (internals) - Updated tons of tests to be more resilient to these changes by relying on the buildManifest instead of hardcoded paths (internals) Follow up of these PRs: https://github.com/vercel/next.js/pull/13759 https://github.com/vercel/next.js/pull/13870 https://github.com/vercel/next.js/pull/13937 https://github.com/vercel/next.js/pull/14130 https://github.com/vercel/next.js/pull/14176 https://github.com/vercel/next.js/pull/14268 Fixes #6303 Fixes #12087 Fixes #1948 Fixes #4368 Fixes #4255 Fixes #2548
31 lines
705 B
TypeScript
31 lines
705 B
TypeScript
import { normalizePagePath, denormalizePagePath } from './normalize-page-path'
|
|
|
|
export type BuildManifest = {
|
|
devFiles: string[]
|
|
ampDevFiles: string[]
|
|
polyfillFiles: string[]
|
|
lowPriorityFiles: string[]
|
|
pages: {
|
|
'/_app': string[]
|
|
[page: string]: string[]
|
|
}
|
|
ampFirstPages: string[]
|
|
}
|
|
|
|
export function getPageFiles(
|
|
buildManifest: BuildManifest,
|
|
page: string
|
|
): string[] {
|
|
const normalizedPage = denormalizePagePath(normalizePagePath(page))
|
|
let files = buildManifest.pages[normalizedPage]
|
|
|
|
if (!files) {
|
|
// tslint:disable-next-line
|
|
console.warn(
|
|
`Could not find files for ${normalizedPage} in .next/build-manifest.json`
|
|
)
|
|
return []
|
|
}
|
|
|
|
return files
|
|
}
|