Skip to content

Commit 4218fd9

Browse files
committed
refactor: improve vue compiler error reporting
1 parent 797da60 commit 4218fd9

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

packages/plugin-vue/src/utils/error.ts

+10-20
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,16 @@ export function createRollupError(
55
id: string,
66
error: CompilerError | SyntaxError
77
): RollupError {
8-
if ('code' in error) {
9-
return {
10-
id,
11-
plugin: 'vue',
12-
message: error.message,
13-
parserError: error,
14-
loc: error.loc
15-
? {
16-
file: id,
17-
line: error.loc.start.line,
18-
column: error.loc.start.column
19-
}
20-
: undefined
21-
}
22-
} else {
23-
return {
24-
id,
25-
plugin: 'vue',
26-
message: error.message,
27-
parserError: error
8+
;(error as RollupError).id = id
9+
;(error as RollupError).plugin = 'vue'
10+
11+
if ('code' in error && error.loc) {
12+
;(error as any).loc = {
13+
file: id,
14+
line: error.loc.start.line,
15+
column: error.loc.start.column
2816
}
2917
}
18+
19+
return error as RollupError
3020
}

0 commit comments

Comments
 (0)