Skip to content

Commit 2aee2eb

Browse files
authored
fix: formatError() outside rollup context (#11156)
1 parent 401647f commit 2aee2eb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/vite/src/node/server/pluginContainer.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,21 @@ export async function createPluginContainer(
445445
}
446446
}
447447
}
448+
} else if (err.loc) {
449+
if (!err.frame) {
450+
let code = err.pluginCode
451+
if (err.loc.file) {
452+
err.id = normalizePath(err.loc.file)
453+
if (!code) {
454+
try {
455+
code = fs.readFileSync(err.loc.file, 'utf-8')
456+
} catch {}
457+
}
458+
}
459+
if (code) {
460+
err.frame = generateCodeFrame(code, err.loc)
461+
}
462+
}
448463
}
449464
return err
450465
}

0 commit comments

Comments
 (0)