fix(nitro): show all ERR_MODULE_NOT_FOUND errors (#561)

Co-authored-by: Pooya Parsa <pyapar@gmail.com>
This commit is contained in:
Daniel Roe 2021-09-29 15:25:13 +01:00 committed by GitHub
parent 0c14b0a48b
commit f06ee66f1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,10 +15,10 @@ const getSSRApp = cachedImport(() => import('#build/dist/server/server.mjs'))
const getSSRRenderer = cachedResult(async () => { const getSSRRenderer = cachedResult(async () => {
// Load client manifest // Load client manifest
const clientManifest = await getClientManifest() const clientManifest = await getClientManifest()
if (!clientManifest) { throw new Error('client.manifest is missing') } if (!clientManifest) { throw new Error('client.manifest is not available') }
// Load server bundle // Load server bundle
const createSSRApp = await getSSRApp() const createSSRApp = await getSSRApp()
if (!createSSRApp) { throw new Error('Server bundle is missing') } if (!createSSRApp) { throw new Error('Server bundle is not available') }
// Create renderer // Create renderer
const { renderToString } = await import('#nitro-renderer') const { renderToString } = await import('#nitro-renderer')
return createRenderer((createSSRApp), { clientManifest, renderToString, publicPath: clientManifest.publicPath || '/_nuxt' }).renderToString return createRenderer((createSSRApp), { clientManifest, renderToString, publicPath: clientManifest.publicPath || '/_nuxt' }).renderToString
@ -141,10 +141,7 @@ function _interopDefault (e) {
} }
function cachedImport <M> (importer: () => Promise<M>) { function cachedImport <M> (importer: () => Promise<M>) {
return cachedResult(() => importer().then(_interopDefault).catch((err) => { return cachedResult(() => importer().then(_interopDefault))
if (err.code === 'ERR_MODULE_NOT_FOUND') { return null }
throw err
}))
} }
function cachedResult <T> (fn: () => Promise<T>): () => Promise<T> { function cachedResult <T> (fn: () => Promise<T>): () => Promise<T> {