Unverified Commit d5de1c53 authored by Pepijn Senders's avatar Pepijn Senders Committed by GitHub

Don't swallow MODULE_NOT_FOUND error (#24577)

## Bug

- [x] Related issues linked using [`fixes #24328`](https://github.com/vercel/next.js/pull/24328#issuecomment-828847472)
- [ ] Integration tests added

The change in #24328 will swallow any `MODULE_NOT_FOUND` errors triggered in the page. If you for example have a page with a broken import, it will tell you `Error: Failed to load /whatever`. This of course doesn't really tell people what is going on internally (a broken import). I added a check to see if the error actually happened in the page.
parent e783b0a2
...@@ -74,20 +74,9 @@ export async function loadComponents( ...@@ -74,20 +74,9 @@ export async function loadComponents(
} as LoadComponentsReturnType } as LoadComponentsReturnType
} }
let DocumentMod const DocumentMod = await requirePage('/_document', distDir, serverless)
let AppMod const AppMod = await requirePage('/_app', distDir, serverless)
let ComponentMod const ComponentMod = await requirePage(pathname, distDir, serverless)
try {
DocumentMod = await requirePage('/_document', distDir, serverless)
AppMod = await requirePage('/_app', distDir, serverless)
ComponentMod = await requirePage(pathname, distDir, serverless)
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
throw new Error(`Failed to load ${pathname}`)
}
throw err
}
const [ const [
buildManifest, buildManifest,
......
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