Unverified Commit a9a3fc1f authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

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
parent e4a94acd
...@@ -43,6 +43,18 @@ export function renderErrorToHTML (err, req, res, pathname, query, opts = {}) { ...@@ -43,6 +43,18 @@ export function renderErrorToHTML (err, req, res, pathname, query, opts = {}) {
return doRender(req, res, pathname, query, { ...opts, err, page: '/_error' }) 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, { async function doRender (req, res, pathname, query, {
err, err,
page, page,
...@@ -87,9 +99,9 @@ async function doRender (req, res, pathname, query, { ...@@ -87,9 +99,9 @@ async function doRender (req, res, pathname, query, {
const devFiles = buildManifest.devFiles const devFiles = buildManifest.devFiles
const files = [ const files = [
...new Set([ ...new Set([
...buildManifest.pages[normalizePagePath(page)], ...getPageFiles(buildManifest, page),
...buildManifest.pages[normalizePagePath('/_app')], ...getPageFiles(buildManifest, '/_app'),
...buildManifest.pages[normalizePagePath('/_error')] ...getPageFiles(buildManifest, '/_error')
]) ])
] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment