1
0
Fork 0
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:
Tim Neutkens 2018-08-20 13:01:21 +02:00 committed by GitHub
parent e4a94acd96
commit a9a3fc1fca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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')
])
]