mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Warn if a specific page is not found in build manifest (#4986)
There's an edge case @timothyis is running into, this will show exactly what files are missing. I currently can't reproduce, so this is a first step at providing better error messages
This commit is contained in:
parent
e4a94acd96
commit
a9a3fc1fca
|
@ -43,6 +43,18 @@ export function renderErrorToHTML (err, req, res, pathname, query, opts = {}) {
|
|||
return doRender(req, res, pathname, query, { ...opts, err, page: '/_error' })
|
||||
}
|
||||
|
||||
function getPageFiles (buildManifest, page) {
|
||||
const normalizedPage = normalizePagePath(page)
|
||||
const files = buildManifest.pages[normalizedPage]
|
||||
|
||||
if (!files) {
|
||||
console.warn(`Could not find files for ${normalizedPage} in .next/build-manifest.json`)
|
||||
return []
|
||||
}
|
||||
|
||||
return files
|
||||
}
|
||||
|
||||
async function doRender (req, res, pathname, query, {
|
||||
err,
|
||||
page,
|
||||
|
@ -87,9 +99,9 @@ async function doRender (req, res, pathname, query, {
|
|||
const devFiles = buildManifest.devFiles
|
||||
const files = [
|
||||
...new Set([
|
||||
...buildManifest.pages[normalizePagePath(page)],
|
||||
...buildManifest.pages[normalizePagePath('/_app')],
|
||||
...buildManifest.pages[normalizePagePath('/_error')]
|
||||
...getPageFiles(buildManifest, page),
|
||||
...getPageFiles(buildManifest, '/_app'),
|
||||
...getPageFiles(buildManifest, '/_error')
|
||||
])
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue