Skip to content

Commit 74382b9

Browse files
authored
fix(build): build error message output twice (vitejs#15664)
1 parent b7c6629 commit 74382b9

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

packages/vite/src/node/build.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ export async function build(
544544
},
545545
}
546546

547-
const outputBuildError = (e: RollupError) => {
547+
const mergeRollupError = (e: RollupError) => {
548548
let msg = colors.red((e.plugin ? `[${e.plugin}] ` : '') + e.message)
549549
if (e.id) {
550550
msg += `\nfile: ${colors.cyan(
@@ -554,6 +554,11 @@ export async function build(
554554
if (e.frame) {
555555
msg += `\n` + colors.yellow(e.frame)
556556
}
557+
return msg
558+
}
559+
560+
const outputBuildError = (e: RollupError) => {
561+
const msg = mergeRollupError(e)
557562
clearLine()
558563
config.logger.error(msg, { error: e })
559564
}
@@ -704,7 +709,8 @@ export async function build(
704709
}
705710
return Array.isArray(outputs) ? res : res[0]
706711
} catch (e) {
707-
outputBuildError(e)
712+
e.message = mergeRollupError(e)
713+
clearLine()
708714
throw e
709715
} finally {
710716
if (bundle) await bundle.close()

playground/tsconfig-json-load-error/__tests__/tsconfig-json-load-error.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '~utils'
1212

1313
const unexpectedTokenSyntaxErrorRE =
14-
/^parsing .* failed: SyntaxError: Unexpected token.*\}.*/
14+
/(\[vite:esbuild\] )*parsing .* failed: SyntaxError: Unexpected token.*\}.*/
1515

1616
describe.runIf(isBuild)('build', () => {
1717
test('should throw an error on build', () => {

0 commit comments

Comments
 (0)