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'
5
5
import { performance } from 'node:perf_hooks'
6
6
import colors from 'picocolors'
7
7
import type { BuildContext , BuildOptions as EsbuildBuildOptions } from 'esbuild'
8
- import esbuild , { build } from 'esbuild'
8
+ import esbuild , { build , formatMessages } from 'esbuild'
9
9
import { init , parse } from 'es-module-lexer'
10
10
import { isDynamicPattern } from 'tinyglobby'
11
11
import type { ResolvedConfig } from '../config'
@@ -724,12 +724,24 @@ export function runOptimizeDeps(
724
724
return successfulResult
725
725
} )
726
726
727
- . catch ( ( e ) => {
727
+ . catch ( async ( e ) => {
728
728
if ( e . errors && e . message . includes ( 'The build was canceled' ) ) {
729
729
// esbuild logs an error when cancelling, but this is expected so
730
730
// return an empty result instead
731
731
return cancelledResult
732
732
}
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
+ }
733
745
throw e
734
746
} )
735
747
. finally ( ( ) => {
You can’t perform that action at this time.
0 commit comments