@@ -86,17 +86,25 @@ export async function compileSwc(
86
86
rmSync ( normalizedOptions . outputPath , { recursive : true , force : true } ) ;
87
87
}
88
88
89
- const swcCmdLog = execSync ( getSwcCmd ( normalizedOptions ) , {
90
- encoding : 'utf8' ,
91
- cwd : normalizedOptions . swcCliOptions . swcCwd ,
92
- windowsHide : false ,
93
- } ) ;
94
- logger . log ( swcCmdLog . replace ( / \n / , '' ) ) ;
95
- const isCompileSuccess = swcCmdLog . includes ( 'Successfully compiled' ) ;
89
+ try {
90
+ const swcCmdLog = execSync ( getSwcCmd ( normalizedOptions ) , {
91
+ encoding : 'utf8' ,
92
+ cwd : normalizedOptions . swcCliOptions . swcCwd ,
93
+ windowsHide : false ,
94
+ stdio : 'pipe' ,
95
+ } ) ;
96
+ logger . log ( swcCmdLog . replace ( / \n / , '' ) ) ;
97
+ } catch ( error ) {
98
+ logger . error ( 'SWC compilation failed' ) ;
99
+ if ( error . stderr ) {
100
+ logger . error ( error . stderr . toString ( ) ) ;
101
+ }
102
+ return { success : false } ;
103
+ }
96
104
97
105
if ( normalizedOptions . skipTypeCheck && ! normalizedOptions . isTsSolutionSetup ) {
98
106
await postCompilationCallback ( ) ;
99
- return { success : isCompileSuccess } ;
107
+ return { success : true } ;
100
108
}
101
109
102
110
const { errors, warnings } = await runTypeCheck (
@@ -111,7 +119,7 @@ export async function compileSwc(
111
119
112
120
await postCompilationCallback ( ) ;
113
121
return {
114
- success : ! hasErrors && isCompileSuccess ,
122
+ success : ! hasErrors ,
115
123
outfile : normalizedOptions . mainOutputPath ,
116
124
} ;
117
125
}
0 commit comments