fix(vite): normalize vite-node error data from server (#7589)

This commit is contained in:
pooya parsa 2022-09-16 19:43:35 +02:00 committed by GitHub
parent 2b57bfe36c
commit cfaca9c5c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -113,7 +113,13 @@ function createViteNodeMiddleware (ctx: ViteBuildContext, invalidates: Set<strin
throw createError({ statusCode: 400 })
}
const module = await node.fetchModule(moduleId).catch((err) => {
throw createError({ data: err })
const errorData = {
code: 'VITE_ERROR',
id: moduleId,
stack: '',
...err
}
throw createError({ data: errorData })
})
return module
}