Skip to content

Commit 0caed3d

Browse files
committed
reuse yaml transpilation flow for jinja files
1 parent 1fb23aa commit 0caed3d

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

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

758751
transpileJinjaFileTimer.end();
759752

760-
return transpiledFile;
761-
// }
753+
return this.transpileYamlFile(file, errorsReport, options);
762754
}
763755

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