@@ -172,20 +172,24 @@ export class DataSchemaCompiler {
172172 . map ( f => this . transpileFile ( f , errorsReport , { transpilerNames, compilerId } ) ) ;
173173
174174 const jsFiles = toCompile . filter ( file => file . fileName . endsWith ( '.js' ) ) ;
175- let jsChunks ;
176- if ( jsFiles . length < transpilationNativeThreadsCount * transpilationNativeThreadsCount ) {
177- jsChunks = [ jsFiles ] ;
178- } else {
179- const baseSize = Math . floor ( jsFiles . length / transpilationNativeThreadsCount ) ;
180- jsChunks = [ ] ;
181- for ( let i = 0 ; i < transpilationNativeThreadsCount ; i ++ ) {
182- // For the last part, we take the remaining files so we don't lose the extra ones.
183- const start = i * baseSize ;
184- const end = ( i === transpilationNativeThreadsCount - 1 ) ? jsFiles . length : start + baseSize ;
185- jsChunks . push ( jsFiles . slice ( start , end ) ) ;
175+ let JsFilesTasks = [ ] ;
176+
177+ if ( jsFiles . length > 0 ) {
178+ let jsChunks ;
179+ if ( jsFiles . length < transpilationNativeThreadsCount * transpilationNativeThreadsCount ) {
180+ jsChunks = [ jsFiles ] ;
181+ } else {
182+ const baseSize = Math . floor ( jsFiles . length / transpilationNativeThreadsCount ) ;
183+ jsChunks = [ ] ;
184+ for ( let i = 0 ; i < transpilationNativeThreadsCount ; i ++ ) {
185+ // For the last part, we take the remaining files so we don't lose the extra ones.
186+ const start = i * baseSize ;
187+ const end = ( i === transpilationNativeThreadsCount - 1 ) ? jsFiles . length : start + baseSize ;
188+ jsChunks . push ( jsFiles . slice ( start , end ) ) ;
189+ }
186190 }
191+ JsFilesTasks = jsChunks . map ( chunk => this . transpileJsFilesBulk ( chunk , errorsReport , { transpilerNames, compilerId } ) ) ;
187192 }
188- const JsFilesTasks = jsChunks . map ( chunk => this . transpileJsFilesBulk ( chunk , errorsReport , { transpilerNames, compilerId } ) ) ;
189193
190194 results = ( await Promise . all ( [ ...nonJsFilesTasks , ...JsFilesTasks ] ) ) . flat ( ) ;
191195 } else if ( transpilationWorkerThreads ) {
0 commit comments