Skip to content

Commit 3625cfa

Browse files
committed
reuse yaml transpilation flow for jinja files
1 parent 5680972 commit 3625cfa

File tree

2 files changed

+9
-31
lines changed

2 files changed

+9
-31
lines changed

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -710,33 +710,25 @@ export class DataSchemaCompiler {
710710
private async transpileJinjaFile(
711711
file: FileContent,
712712
errorsReport: ErrorReporter,
713-
{ cubeNames, cubeSymbols, contextSymbols, transpilerNames, compilerId, stage }: TranspileOptions
713+
options: TranspileOptions
714714
): Promise<(FileContent | undefined)> {
715-
// if (getEnv('transpilationNative')) {
716-
//
717-
// } else if (getEnv('transpilationWorkerThreads')) {
718-
//
719-
// } else {
720715
const transpileJinjaFileTimer = perfTracker.start('transpileJinjaFile (common)');
721716

722-
const transpiledFile = await this.yamlCompiler.compileYamlWithJinjaFile(
717+
const renderedFile = await this.yamlCompiler.renderTemplate(
723718
file,
724-
errorsReport,
725719
this.standalone ? {} : this.cloneCompileContextWithGetterAlias(this.compileContext),
726720
this.pythonContext!
727721
);
728-
if (transpiledFile) {
729-
// We update the jinja/yaml file content to the transpiled js content
730-
// and raise related flag so it will go JS transpilation flow afterward
731-
// avoiding costly YAML/Python parsing again.
732-
file.content = transpiledFile.content;
733-
file.convertedToJs = true;
734-
}
722+
723+
// We update the jinja/yaml file content to the rendered content
724+
// to reuse the same transpileYamlFile() flow afterward which
725+
// will update the content to the transpiled js content
726+
// avoiding costly YAML/Python parsing again.
727+
file.content = renderedFile.content;
735728

736729
transpileJinjaFileTimer.end();
737730

738-
return transpiledFile;
739-
// }
731+
return this.transpileYamlFile(file, errorsReport, options);
740732
}
741733

742734
public withQuery(query, fn) {

packages/cubejs-schema-compiler/src/compiler/YamlCompiler.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,6 @@ export class YamlCompiler {
6565
};
6666
}
6767

68-
public async compileYamlWithJinjaFile(
69-
file: FileContent,
70-
errorsReport: ErrorReporter,
71-
compileContext: CompileContext,
72-
pythonContext: PythonCtx
73-
): Promise<FileContent | undefined> {
74-
const renderedFile = await this.renderTemplate(file, compileContext, pythonContext);
75-
76-
const transpileJinjaFileTimer2 = perfTracker.start('compile Jinja - transpileYamlFile');
77-
const res = this.transpileYamlFile(renderedFile, errorsReport);
78-
transpileJinjaFileTimer2.end();
79-
return res;
80-
}
81-
8268
public transpileYamlFile(
8369
file: FileContent,
8470
errorsReport: ErrorReporter,

0 commit comments

Comments
 (0)