Skip to content

Commit

Permalink
fix(plugin-vue): misleading error thrown after refresh or hmr (#5870)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
y1d7ng and antfu committed Nov 28, 2021
1 parent e1e19cd commit 8bc76eb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/plugin-vue/src/utils/error.ts
Expand Up @@ -5,16 +5,22 @@ export function createRollupError(
id: string,
error: CompilerError | SyntaxError
): RollupError {
;(error as RollupError).id = id
;(error as RollupError).plugin = 'vue'
const { message, name, stack } = error
const rollupError: RollupError = {
id,
plugin: 'vue',
message,
name,
stack
}

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

return error as RollupError
return rollupError
}

0 comments on commit 8bc76eb

Please sign in to comment.