@@ -10,29 +10,44 @@ type TransferContent = {
1010 contextSymbols : Record < string , string > ;
1111} ;
1212
13+ type CubeMetaData = {
14+ cubeNames : string [ ] ;
15+ cubeSymbols : Record < string , Record < string , boolean > > ;
16+ contextSymbols : Record < string , string > ;
17+ } ;
18+
1319type TranspilerPlugin = [ string , Record < string , any > ] ;
1420
21+ let cache : CubeMetaData ;
1522
1623const transpilers = {
1724 ValidationTranspiler :
18- ( _data : TransferContent ) : TranspilerPlugin => [ '@cubejs-backend/validation-transpiler-swc-plugin' , { } ] ,
25+ ( _data : CubeMetaData ) : TranspilerPlugin => [ '@cubejs-backend/validation-transpiler-swc-plugin' , { } ] ,
1926 ImportExportTranspiler :
20- ( _data : TransferContent ) : TranspilerPlugin => [ '@cubejs-backend/import-export-transpiler-swc-plugin' , { } ] ,
27+ ( _data : CubeMetaData ) : TranspilerPlugin => [ '@cubejs-backend/import-export-transpiler-swc-plugin' , { } ] ,
2128 CubeCheckDuplicatePropTranspiler :
22- ( _data : TransferContent ) : TranspilerPlugin => [ '@cubejs-backend/check-dup-prop-transpiler-swc-plugin' , { } ] ,
29+ ( _data : CubeMetaData ) : TranspilerPlugin => [ '@cubejs-backend/check-dup-prop-transpiler-swc-plugin' , { } ] ,
2330 CubePropContextTranspiler :
24- ( data : TransferContent ) : TranspilerPlugin => [ '@cubejs-backend/cube-prop-ctx-transpiler-swc-plugin' , {
31+ ( data : CubeMetaData ) : TranspilerPlugin => [ '@cubejs-backend/cube-prop-ctx-transpiler-swc-plugin' , {
2532 cubeNames : data . cubeNames ,
2633 cubeSymbols : data . cubeSymbols ,
2734 contextSymbols : data . contextSymbols ,
2835 } ] ,
2936} ;
3037
3138const transpile = ( data : TransferContent ) => {
39+ if ( data . cubeNames ) {
40+ cache = {
41+ cubeNames : data . cubeNames ,
42+ cubeSymbols : data . cubeSymbols ,
43+ contextSymbols : data . contextSymbols ,
44+ } ;
45+ }
46+
3247 const transpilersConfigs = data . transpilers . map ( transpilerName => {
3348 const ts = transpilers [ transpilerName ] ;
3449 if ( ts ) {
35- return ts ( data ) ;
50+ return ts ( cache ) ;
3651 } else {
3752 throw new Error ( `Transpiler ${ ts } not supported` ) ;
3853 }
0 commit comments