File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -80,14 +80,34 @@ const createBundler = (esBuildUserOptions = {}) => {
8080 const customBuildPlugin = {
8181 name : 'cypress-esbuild-watch-plugin' ,
8282 setup ( build ) {
83- build . onEnd ( result => {
83+ build . onEnd ( ( result ) => {
84+ if ( result . errors . length > 0 ) {
85+ debug (
86+ 'watch on %s build failed, errors %o' ,
87+ filePath ,
88+ result . errors ,
89+ )
90+
91+ bundled [ filePath ] = new Promise ( ( resolve , reject ) => {
92+ esbuild
93+ . formatMessages ( result . errors , {
94+ kind : 'error' ,
95+ color : false ,
96+ } )
97+ . then ( ( messages ) => reject ( new Error ( messages . join ( '\n\n' ) ) ) )
98+ } )
99+
100+ file . emit ( 'rerun' )
101+ return
102+ }
103+
84104 debug (
85105 'watch on %s build succeeded, warnings %o' ,
86106 filePath ,
87107 result . warnings ,
88108 )
89109 file . emit ( 'rerun' )
90- } ) ;
110+ } )
91111 } ,
92112 }
93113 const plugins = esBuildOptions . plugins ? [ ...esBuildOptions . plugins , customBuildPlugin ] : [ customBuildPlugin ] ;
You can’t perform that action at this time.
0 commit comments