Skip to content

Commit 2715474

Browse files
committed
reuse yaml transpilation flow for jinja files
1 parent f842355 commit 2715474

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
@@ -736,33 +736,25 @@ export class DataSchemaCompiler {
736736
private async transpileJinjaFile(
737737
file: FileContent,
738738
errorsReport: ErrorReporter,
739-
{ cubeNames, cubeSymbols, contextSymbols, transpilerNames, compilerId, stage }: TranspileOptions
739+
options: TranspileOptions
740740
): Promise<(FileContent | undefined)> {
741-
// if (getEnv('transpilationNative')) {
742-
//
743-
// } else if (getEnv('transpilationWorkerThreads')) {
744-
//
745-
// } else {
746741
const transpileJinjaFileTimer = perfTracker.start('transpileJinjaFile (common)');
747742

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

762755
transpileJinjaFileTimer.end();
763756

764-
return transpiledFile;
765-
// }
757+
return this.transpileYamlFile(file, errorsReport, options);
766758
}
767759

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