Skip to content

Commit 43b5043

Browse files
committed
feat: use loc.file from rollup errors if available
The loc.file references the file where the error occurred (containing the displayed line and column), rather than e.id which is the module.
1 parent 4f5845a commit 43b5043

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/vite/src/node/build.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,12 @@ async function buildEnvironment(
635635
const stackOnly = extractStack(e)
636636

637637
let msg = colors.red((e.plugin ? `[${e.plugin}] ` : '') + e.message)
638-
if (e.id) {
638+
if (e.loc && e.loc.file && e.loc.file !== id) {
639+
msg += `\nfile: ${colors.cyan(
640+
`${e.loc.file}:${e.loc.line}:${e.loc.column}` +
641+
(e.id ? ` (${e.id})` : ''),
642+
)}`
643+
} else if (e.id) {
639644
msg += `\nfile: ${colors.cyan(
640645
e.id + (e.loc ? `:${e.loc.line}:${e.loc.column}` : ''),
641646
)}`

0 commit comments

Comments
 (0)