Skip to content

Commit ed263d0

Browse files
committed
some refactoring/improvement
1 parent af437b0 commit ed263d0

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

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

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export class DataSchemaCompiler {
109109
const transpile = async () => {
110110
let cubeNames;
111111
let cubeSymbols;
112+
let transpilerNames;
112113

113114
if (getEnv('transpilationWorkerThreads')) {
114115
cubeNames = Object.keys(this.cubeDictionary.byId);
@@ -126,25 +127,26 @@ export class DataSchemaCompiler {
126127
)],
127128
),
128129
);
130+
131+
// Transpilers are the same for all files within phase.
132+
transpilerNames = this.transpilers.map(t => t.constructor.name);
133+
134+
// Warming up swc compiler cache
135+
const dummyFile = {
136+
fileName: 'dummy.js',
137+
content: ';',
138+
};
139+
const warmups = Array.from(
140+
{ length: workersCount },
141+
(_, _i) => this.transpileJsFile(
142+
dummyFile,
143+
errorsReport,
144+
{ cubeNames, cubeSymbols, transpilerNames, contextSymbols: CONTEXT_SYMBOLS }
145+
),
146+
);
147+
await Promise.all(warmups);
129148
}
130149

131-
// Transpilers are the same for all files within phase.
132-
const transpilerNames = this.transpilers.map(t => t.constructor.name);
133-
134-
// Warming up swc compiler cache
135-
const dummyFile = {
136-
fileName: 'dummy.js',
137-
content: ';',
138-
};
139-
const warmups = Array.from(
140-
{ length: workersCount },
141-
(_, _i) => this.transpileJsFile(
142-
dummyFile,
143-
errorsReport,
144-
{ cubeNames, cubeSymbols, transpilerNames, contextSymbols: CONTEXT_SYMBOLS }
145-
),
146-
);
147-
await Promise.all(warmups);
148150
const results = await Promise.all(toCompile.map(f => this.transpileFile(f, errorsReport, { transpilerNames })));
149151
return results.filter(f => !!f);
150152
};

0 commit comments

Comments
 (0)