Skip to content

Commit

Permalink
refactor: improve vue compiler error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 29, 2020
1 parent 797da60 commit 4218fd9
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions packages/plugin-vue/src/utils/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,16 @@ export function createRollupError(
id: string,
error: CompilerError | SyntaxError
): RollupError {
if ('code' in error) {
return {
id,
plugin: 'vue',
message: error.message,
parserError: error,
loc: error.loc
? {
file: id,
line: error.loc.start.line,
column: error.loc.start.column
}
: undefined
}
} else {
return {
id,
plugin: 'vue',
message: error.message,
parserError: error
;(error as RollupError).id = id
;(error as RollupError).plugin = 'vue'

if ('code' in error && error.loc) {
;(error as any).loc = {
file: id,
line: error.loc.start.line,
column: error.loc.start.column
}
}

return error as RollupError
}

0 comments on commit 4218fd9

Please sign in to comment.