File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
packages/vite/src/node/optimizer Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { promisify } from 'node:util'
55import { performance } from 'node:perf_hooks'
66import colors from 'picocolors'
77import type { BuildContext , BuildOptions as EsbuildBuildOptions } from 'esbuild'
8- import esbuild , { build } from 'esbuild'
8+ import esbuild , { build , formatMessages } from 'esbuild'
99import { init , parse } from 'es-module-lexer'
1010import { isDynamicPattern } from 'tinyglobby'
1111import type { ResolvedConfig } from '../config'
@@ -724,12 +724,24 @@ export function runOptimizeDeps(
724724 return successfulResult
725725 } )
726726
727- . catch ( ( e ) => {
727+ . catch ( async ( e ) => {
728728 if ( e . errors && e . message . includes ( 'The build was canceled' ) ) {
729729 // esbuild logs an error when cancelling, but this is expected so
730730 // return an empty result instead
731731 return cancelledResult
732732 }
733+ const prependMessage = colors . red (
734+ 'Error during dependency optimization:\n\n' ,
735+ )
736+ if ( e . errors ) {
737+ const msgs = await formatMessages ( e . errors , {
738+ kind : 'error' ,
739+ color : true ,
740+ } )
741+ e . message = prependMessage + msgs . join ( '\n' )
742+ } else {
743+ e . message = prependMessage + e . message
744+ }
733745 throw e
734746 } )
735747 . finally ( ( ) => {
You can’t perform that action at this time.
0 commit comments