Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Don't swallow MODULE_NOT_FOUND error (vercel#24577)
Browse files Browse the repository at this point in the history
## Bug

- [x] Related issues linked using [`fixes vercel#24328`](vercel#24328 (comment))
- [ ] Integration tests added

The change in vercel#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.
  • Loading branch information
PepijnSenders authored Apr 30, 2021
1 parent 4139c1d commit 3ef8a67
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions packages/next/next-server/server/load-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,9 @@ export async function loadComponents(
} as LoadComponentsReturnType
}

let DocumentMod
let AppMod
let ComponentMod

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 DocumentMod = await requirePage('/_document', distDir, serverless)
const AppMod = await requirePage('/_app', distDir, serverless)
const ComponentMod = await requirePage(pathname, distDir, serverless)

const [
buildManifest,
Expand Down

0 comments on commit 3ef8a67

Please sign in to comment.