Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,24 @@
.map(f => this.transpileFile(f, errorsReport, { transpilerNames, compilerId }));

const jsFiles = toCompile.filter(file => file.fileName.endsWith('.js'));
let jsChunks;
if (jsFiles.length < transpilationNativeThreadsCount * transpilationNativeThreadsCount) {
jsChunks = [jsFiles];
} else {
const baseSize = Math.floor(jsFiles.length / transpilationNativeThreadsCount);
jsChunks = [];
for (let i = 0; i < transpilationNativeThreadsCount; i++) {
// For the last part, we take the remaining files so we don't lose the extra ones.
const start = i * baseSize;
const end = (i === transpilationNativeThreadsCount - 1) ? jsFiles.length : start + baseSize;
jsChunks.push(jsFiles.slice(start, end));
let JsFilesTasks = [];

Check warning on line 175 in packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.js

View check run for this annotation

Codecov / codecov/patch

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

Added line #L175 was not covered by tests

if (jsFiles.length > 0) {
let jsChunks;
if (jsFiles.length < transpilationNativeThreadsCount * transpilationNativeThreadsCount) {
jsChunks = [jsFiles];

Check warning on line 180 in packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.js

View check run for this annotation

Codecov / codecov/patch

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

Added line #L180 was not covered by tests
} else {
const baseSize = Math.floor(jsFiles.length / transpilationNativeThreadsCount);
jsChunks = [];
for (let i = 0; i < transpilationNativeThreadsCount; i++) {

Check warning on line 184 in packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.js

View check run for this annotation

Codecov / codecov/patch

packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.js#L182-L184

Added lines #L182 - L184 were not covered by tests
// For the last part, we take the remaining files so we don't lose the extra ones.
const start = i * baseSize;

Check warning on line 186 in packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.js

View check run for this annotation

Codecov / codecov/patch

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

Added line #L186 was not covered by tests
const end = (i === transpilationNativeThreadsCount - 1) ? jsFiles.length : start + baseSize;
jsChunks.push(jsFiles.slice(start, end));

Check warning on line 188 in packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.js

View check run for this annotation

Codecov / codecov/patch

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

Added line #L188 was not covered by tests
}
}
JsFilesTasks = jsChunks.map(chunk => this.transpileJsFilesBulk(chunk, errorsReport, { transpilerNames, compilerId }));

Check warning on line 191 in packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.js

View check run for this annotation

Codecov / codecov/patch

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

Added line #L191 was not covered by tests
}
const JsFilesTasks = jsChunks.map(chunk => this.transpileJsFilesBulk(chunk, errorsReport, { transpilerNames, compilerId }));

results = (await Promise.all([...nonJsFilesTasks, ...JsFilesTasks])).flat();
} else if (transpilationWorkerThreads) {
Expand Down
Loading