Skip to content

Commit 1d72259

Browse files
committed
add stage for transpile native
1 parent 452633c commit 1d72259

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

packages/cubejs-backend-native/js/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export interface TransformConfig {
128128
cubeNames: string[];
129129
cubeSymbols: Record<string, Record<string, boolean>>;
130130
contextSymbols: Record<string, string>;
131+
stage: 0 | 1 | 2 | 3;
131132
}
132133
}
133134

packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ export class DataSchemaCompiler {
108108
);
109109
}
110110

111-
const transpile = async () => {
111+
/**
112+
* @param stage Number
113+
* @returns {Promise<*>}
114+
*/
115+
const transpile = async (stage) => {
112116
let cubeNames;
113117
let cubeSymbols;
114118
let transpilerNames;
@@ -143,7 +147,7 @@ export class DataSchemaCompiler {
143147
content: ';',
144148
};
145149

146-
await this.transpileJsFile(dummyFile, errorsReport, { cubeNames, cubeSymbols, transpilerNames, contextSymbols: CONTEXT_SYMBOLS, compilerId });
150+
await this.transpileJsFile(dummyFile, errorsReport, { cubeNames, cubeSymbols, transpilerNames, contextSymbols: CONTEXT_SYMBOLS, compilerId, stage });
147151

148152
results = await Promise.all(toCompile.map(f => this.transpileFile(f, errorsReport, { transpilerNames, compilerId })));
149153
} else if (transpilationWorkerThreads) {
@@ -155,17 +159,17 @@ export class DataSchemaCompiler {
155159
return results.filter(f => !!f);
156160
};
157161

158-
const compilePhase = async (compilers) => this.compileCubeFiles(compilers, await transpile(), errorsReport);
162+
const compilePhase = async (compilers, stage) => this.compileCubeFiles(compilers, await transpile(stage), errorsReport);
159163

160-
return compilePhase({ cubeCompilers: this.cubeNameCompilers })
161-
.then(() => compilePhase({ cubeCompilers: this.preTranspileCubeCompilers.concat([this.viewCompilationGate]) }))
164+
return compilePhase({ cubeCompilers: this.cubeNameCompilers }, 0)
165+
.then(() => compilePhase({ cubeCompilers: this.preTranspileCubeCompilers.concat([this.viewCompilationGate]) }, 1))
162166
.then(() => (this.viewCompilationGate.shouldCompileViews() ?
163-
compilePhase({ cubeCompilers: this.viewCompilers })
167+
compilePhase({ cubeCompilers: this.viewCompilers }, 2)
164168
: Promise.resolve()))
165169
.then(() => compilePhase({
166170
cubeCompilers: this.cubeCompilers,
167171
contextCompilers: this.contextCompilers,
168-
}))
172+
}, 3))
169173
.then(() => {
170174
if (transpilationNative) {
171175
// Clean up cache
@@ -177,7 +181,7 @@ export class DataSchemaCompiler {
177181
return this.transpileJsFile(
178182
dummyFile,
179183
errorsReport,
180-
{ cubeNames: [], cubeSymbols: {}, transpilerNames: [], contextSymbols: {}, compilerId: this.compilerId }
184+
{ cubeNames: [], cubeSymbols: {}, transpilerNames: [], contextSymbols: {}, compilerId: this.compilerId, stage: 0 }
181185
);
182186
} else if (transpilationWorkerThreads && this.workerPool) {
183187
this.workerPool.terminate();
@@ -225,7 +229,7 @@ export class DataSchemaCompiler {
225229
}
226230
}
227231

228-
async transpileJsFile(file, errorsReport, { cubeNames, cubeSymbols, contextSymbols, transpilerNames, compilerId }) {
232+
async transpileJsFile(file, errorsReport, { cubeNames, cubeSymbols, contextSymbols, transpilerNames, compilerId, stage }) {
229233
try {
230234
if (getEnv('transpilationNative')) {
231235
const reqData = {
@@ -237,6 +241,7 @@ export class DataSchemaCompiler {
237241
cubeNames,
238242
cubeSymbols,
239243
contextSymbols,
244+
stage
240245
},
241246
}),
242247
};

0 commit comments

Comments
 (0)