@@ -13,7 +13,7 @@ import workerpool from 'workerpool';
1313import { LRUCache } from 'lru-cache' ;
1414
1515import { FileContent , getEnv , isNativeSupported , SchemaFileRepository } from '@cubejs-backend/shared' ;
16- import { NativeInstance , PythonCtx , transpileJs } from '@cubejs-backend/native' ;
16+ import { NativeInstance , PythonCtx , transpileJs , transpileYaml } from '@cubejs-backend/native' ;
1717import { UserError } from './UserError' ;
1818import { ErrorReporter , ErrorReporterOptions , SyntaxErrorInterface } from './ErrorReporter' ;
1919import { CONTEXT_SYMBOLS , CubeDefinition , CubeSymbols } from './CubeSymbols' ;
@@ -623,14 +623,33 @@ export class DataSchemaCompiler {
623623 return undefined ;
624624 }
625625
626+ // We update the yaml file content to the transpiled js content
627+ // and raise related flag so it will go JS transpilation flow afterward
628+ // avoiding costly YAML/Python parsing again.
626629 private async transpileYamlFile (
627630 file : FileContent ,
628631 errorsReport : ErrorReporter ,
629- { cubeNames, cubeSymbols, contextSymbols , transpilerNames , compilerId, stage } : TranspileOptions
632+ { cubeNames, cubeSymbols, compilerId } : TranspileOptions
630633 ) : Promise < ( FileContent | undefined ) > {
631- /* if (getEnv('transpilationNative')) {
634+ if ( getEnv ( 'transpilationNative' ) ) {
635+ const reqData = {
636+ fileName : file . fileName ,
637+ fileContent : file . content ,
638+ transpilers : [ ] ,
639+ compilerId : compilerId || '' ,
640+ } ;
641+
642+ errorsReport . inFile ( file ) ;
643+ const res = await transpileYaml ( [ reqData ] ) ;
644+ errorsReport . addErrors ( res [ 0 ] . errors ) ;
645+ errorsReport . addWarnings ( res [ 0 ] . warnings as unknown as SyntaxErrorInterface [ ] ) ;
646+ errorsReport . exitFile ( ) ;
647+
648+ file . content = res [ 0 ] . code ;
649+ file . convertedToJs = true ;
632650
633- } else */ if ( getEnv ( 'transpilationWorkerThreads' ) ) {
651+ return { ...file , content : res [ 0 ] . code } ;
652+ } else if ( getEnv ( 'transpilationWorkerThreads' ) ) {
634653 const data = {
635654 fileName : file . fileName ,
636655 content : file . content ,
@@ -651,9 +670,6 @@ export class DataSchemaCompiler {
651670 const transpiledFile = this . yamlCompiler . transpileYamlFile ( file , errorsReport ) ;
652671
653672 if ( transpiledFile ) {
654- // We update the yaml file content to the transpiled js content
655- // and raise related flag so it will go JS transpilation flow afterward
656- // avoiding costly YAML/Python parsing again.
657673 file . content = transpiledFile . content ;
658674 file . convertedToJs = true ;
659675 }
0 commit comments