From 4218fd9b7adf773876edef8ef8e7ceb45c1d1616 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 29 Dec 2020 18:21:25 -0500 Subject: [PATCH] refactor: improve vue compiler error reporting --- packages/plugin-vue/src/utils/error.ts | 30 +++++++++----------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/packages/plugin-vue/src/utils/error.ts b/packages/plugin-vue/src/utils/error.ts index 1ff2fd3e..a2916cc6 100644 --- a/packages/plugin-vue/src/utils/error.ts +++ b/packages/plugin-vue/src/utils/error.ts @@ -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 }