File tree 1 file changed +22
-9
lines changed
packages/vite/src/node/ssr
1 file changed +22
-9
lines changed Original file line number Diff line number Diff line change 1
1
import path from 'node:path'
2
2
import { pathToFileURL } from 'node:url'
3
+ import colors from 'picocolors'
3
4
import type { ViteDevServer } from '../server'
4
5
import {
5
6
dynamicImport ,
@@ -203,17 +204,24 @@ async function instantiateModule(
203
204
)
204
205
} catch ( e ) {
205
206
mod . ssrError = e
207
+
206
208
if ( e . stack && fixStacktrace ) {
207
209
ssrFixStacktrace ( e , moduleGraph )
208
- server . config . logger . error (
209
- `Error when evaluating SSR module ${ url } :\n${ e . stack } ` ,
210
- {
211
- timestamp : true ,
212
- clear : server . config . clearScreen ,
213
- error : e ,
214
- } ,
215
- )
216
210
}
211
+
212
+ server . config . logger . error (
213
+ colors . red (
214
+ `Error when evaluating SSR module ${ url } :` +
215
+ ( e . importee ? ` failed to import "${ e . importee } "\n` : '\n' ) ,
216
+ ) ,
217
+ {
218
+ timestamp : true ,
219
+ clear : server . config . clearScreen ,
220
+ error : e ,
221
+ } ,
222
+ )
223
+
224
+ delete e . importee
217
225
throw e
218
226
}
219
227
@@ -257,7 +265,12 @@ async function nodeImport(
257
265
try {
258
266
const mod = await dynamicImport ( url )
259
267
return proxyESM ( mod )
260
- } catch { }
268
+ } catch ( err ) {
269
+ // tell external error handler which mod was imported with error
270
+ err . importee = id
271
+
272
+ throw err
273
+ }
261
274
}
262
275
263
276
// rollup-style default import interop for cjs
You can’t perform that action at this time.
0 commit comments