@@ -295,11 +295,9 @@ export class DataSchemaCompiler {
295
295
}
296
296
297
297
if ( transpilationNative ) {
298
- const nonJsFilesTasks = [ ...jinjaTemplatedFiles , ...yamlFiles ]
299
- . map ( f => this . transpileFile ( f , errorsReport , { cubeNames, cubeSymbols, transpilerNames, compilerId } ) ) ;
300
-
301
298
const jsFiles = originalJsFiles ;
302
299
let jsFilesTasks : Promise < ( FileContent | undefined ) [ ] > [ ] = [ ] ;
300
+ let yamlFilesTasks : Promise < ( FileContent | undefined ) [ ] > [ ] = [ ] ;
303
301
304
302
if ( jsFiles . length > 0 ) {
305
303
// Warming up swc compiler cache
@@ -311,10 +309,18 @@ export class DataSchemaCompiler {
311
309
await this . transpileJsFile ( dummyFile , errorsReport , { cubeNames, cubeSymbols, transpilerNames, contextSymbols : CONTEXT_SYMBOLS , compilerId, stage } ) ;
312
310
313
311
const jsChunks = splitFilesToChunks ( jsFiles , transpilationNativeThreadsCount ) ;
314
- jsFilesTasks = jsChunks . map ( chunk => this . transpileJsFilesBulk ( chunk , errorsReport , { transpilerNames, compilerId } ) ) ;
312
+ jsFilesTasks = jsChunks . map ( chunk => this . transpileJsFilesNativeBulk ( chunk , errorsReport , { transpilerNames, compilerId } ) ) ;
313
+ }
314
+
315
+ if ( yamlFiles . length > 0 ) {
316
+ const yamlChunks = splitFilesToChunks ( yamlFiles , transpilationNativeThreadsCount ) ;
317
+ yamlFilesTasks = yamlChunks . map ( chunk => this . transpileYamlFilesNativeBulk ( chunk , errorsReport , { transpilerNames, compilerId } ) ) ;
315
318
}
316
319
317
- results = ( await Promise . all ( [ ...nonJsFilesTasks , ...jsFilesTasks ] ) ) . flat ( ) ;
320
+ const jinjaFilesTasks = jinjaTemplatedFiles
321
+ . map ( f => this . transpileJinjaFile ( f , errorsReport , { cubeNames, cubeSymbols, transpilerNames } ) ) ;
322
+
323
+ results = ( await Promise . all ( [ ...jsFilesTasks , ...yamlFilesTasks , ...jinjaFilesTasks ] ) ) . flat ( ) ;
318
324
} else if ( transpilationWorkerThreads ) {
319
325
results = await Promise . all ( toCompile . map ( f => this . transpileFile ( f , errorsReport , { cubeNames, cubeSymbols, transpilerNames } ) ) ) ;
320
326
} else {
@@ -350,7 +356,7 @@ export class DataSchemaCompiler {
350
356
await this . transpileJsFile ( dummyFile , errorsReport , { cubeNames, cubeSymbols, transpilerNames, contextSymbols : CONTEXT_SYMBOLS , compilerId, stage } ) ;
351
357
352
358
const jsChunks = splitFilesToChunks ( toCompile , transpilationNativeThreadsCount ) ;
353
- const jsFilesTasks = jsChunks . map ( chunk => this . transpileJsFilesBulk ( chunk , errorsReport , { transpilerNames, compilerId } ) ) ;
359
+ const jsFilesTasks = jsChunks . map ( chunk => this . transpileJsFilesNativeBulk ( chunk , errorsReport , { transpilerNames, compilerId } ) ) ;
354
360
355
361
results = ( await Promise . all ( jsFilesTasks ) ) . flat ( ) ;
356
362
} else if ( transpilationWorkerThreads ) {
@@ -591,11 +597,7 @@ export class DataSchemaCompiler {
591
597
}
592
598
}
593
599
594
- /**
595
- * Right now it is used only for transpilation in native,
596
- * so no checks for transpilation type inside this method
597
- */
598
- private async transpileJsFilesBulk (
600
+ private async transpileJsFilesNativeBulk (
599
601
files : FileContent [ ] ,
600
602
errorsReport : ErrorReporter ,
601
603
{ cubeNames, cubeSymbols, contextSymbols, transpilerNames, compilerId, stage } : TranspileOptions
@@ -633,6 +635,33 @@ export class DataSchemaCompiler {
633
635
} ) ;
634
636
}
635
637
638
+ private async transpileYamlFilesNativeBulk (
639
+ files : FileContent [ ] ,
640
+ errorsReport : ErrorReporter ,
641
+ { compilerId } : TranspileOptions
642
+ ) : Promise < ( FileContent | undefined ) [ ] > {
643
+ const reqDataArr = files . map ( file => ( {
644
+ fileName : file . fileName ,
645
+ fileContent : file . content ,
646
+ transpilers : [ ] ,
647
+ compilerId : compilerId || '' ,
648
+ } ) ) ;
649
+ const res = await transpileYaml ( reqDataArr ) ;
650
+
651
+ return files . map ( ( file , index ) => {
652
+ errorsReport . inFile ( file ) ;
653
+ if ( ! res [ index ] ) { // This should not happen in theory but just to be safe
654
+ errorsReport . error ( `No transpilation result received for the file ${ file . fileName } .` ) ;
655
+ return undefined ;
656
+ }
657
+ errorsReport . addErrors ( res [ index ] . errors ) ;
658
+ errorsReport . addWarnings ( res [ index ] . warnings as unknown as SyntaxErrorInterface [ ] ) ;
659
+ errorsReport . exitFile ( ) ;
660
+
661
+ return { ...file , content : res [ index ] . code } ;
662
+ } ) ;
663
+ }
664
+
636
665
private async transpileJsFile (
637
666
file : FileContent ,
638
667
errorsReport : ErrorReporter ,
0 commit comments