Skip to content

Commit

Permalink
fix: use loc.file from rollup errors if available (#19222)
Browse files Browse the repository at this point in the history
  • Loading branch information
karlvr authored Jan 23, 2025
1 parent ba03da2 commit ce3fe23
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,12 @@ async function buildEnvironment(
const stackOnly = extractStack(e)

let msg = colors.red((e.plugin ? `[${e.plugin}] ` : '') + e.message)
if (e.id) {
if (e.loc && e.loc.file && e.loc.file !== e.id) {
msg += `\nfile: ${colors.cyan(
`${e.loc.file}:${e.loc.line}:${e.loc.column}` +
(e.id ? ` (${e.id})` : ''),
)}`
} else if (e.id) {
msg += `\nfile: ${colors.cyan(
e.id + (e.loc ? `:${e.loc.line}:${e.loc.column}` : ''),
)}`
Expand Down

0 comments on commit ce3fe23

Please sign in to comment.