Skip to content

Commit 8f1f038

Browse files
committed
reuse yaml transpilation flow for jinja files
1 parent 5e4943c commit 8f1f038

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
@@ -733,33 +733,25 @@ export class DataSchemaCompiler {
733733
private async transpileJinjaFile(
734734
file: FileContent,
735735
errorsReport: ErrorReporter,
736-
{ cubeNames, cubeSymbols, contextSymbols, transpilerNames, compilerId, stage }: TranspileOptions
736+
options: TranspileOptions
737737
): Promise<(FileContent | undefined)> {
738-
// if (getEnv('transpilationNative')) {
739-
//
740-
// } else if (getEnv('transpilationWorkerThreads')) {
741-
//
742-
// } else {
743738
const transpileJinjaFileTimer = perfTracker.start('transpileJinjaFile (common)');
744739

745-
const transpiledFile = await this.yamlCompiler.compileYamlWithJinjaFile(
740+
const renderedFile = await this.yamlCompiler.renderTemplate(
746741
file,
747-
errorsReport,
748742
this.standalone ? {} : this.cloneCompileContextWithGetterAlias(this.compileContext),
749743
this.pythonContext!
750744
);
751-
if (transpiledFile) {
752-
// We update the jinja/yaml file content to the transpiled js content
753-
// and raise related flag so it will go JS transpilation flow afterward
754-
// avoiding costly YAML/Python parsing again.
755-
file.content = transpiledFile.content;
756-
file.convertedToJs = true;
757-
}
745+
746+
// We update the jinja/yaml file content to the rendered content
747+
// to reuse the same transpileYamlFile() flow afterward which
748+
// will update the content to the transpiled js content
749+
// avoiding costly YAML/Python parsing again.
750+
file.content = renderedFile.content;
758751

759752
transpileJinjaFileTimer.end();
760753

761-
return transpiledFile;
762-
// }
754+
return this.transpileYamlFile(file, errorsReport, options);
763755
}
764756

765757
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)