Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix thread-load JOBS handling/documentation #1191

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
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
21 changes: 15 additions & 6 deletions packages/webpack/src/ember-webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,12 +557,21 @@ const threadLoaderOptions = {
poolTimeout: Infinity,
};

function canUseThreadLoader(extraOptions: object | false | undefined) {
// If the environment sets JOBS to 0, or if our extraOptions are set to false,
// we have been explicitly configured not to use thread-loader
if (process.env.JOBS === '0' || extraOptions === false) {
return false;
} else {
return true;
}
}

function warmUp(extraOptions: object | false | undefined) {
// We don't know if we'll be parallel-safe or not, but if the environment sets
// JOBS to 0, or our extraOptions are set to false, we know we won't use
// thread-loader, so no need to consume extra resources warming the worker
// pool
if (process.env.JOBS === '1' || extraOptions === false) {
// We don't know if we'll be parallel-safe or not, but if we've been
// configured to not use thread-loader, then there is no need to consume extra
// resources warming the worker pool
if (!canUseThreadLoader(extraOptions)) {
return null;
}

Expand All @@ -573,7 +582,7 @@ function warmUp(extraOptions: object | false | undefined) {
}

function maybeThreadLoader(isParallelSafe: boolean, extraOptions: object | false | undefined) {
if (process.env.JOBS === '0' || extraOptions === false || !isParallelSafe) {
if (!canUseThreadLoader(extraOptions) || !isParallelSafe) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/webpack/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface Options {
// will be used to configure `thread-loader`. If not specified,
// `thread-loader` will be used with a default configuration.
//
// Note that setting `JOBS=1` in the environment will also disable
// Note that setting `JOBS=0` in the environment will also disable
// `thread-loader`.
threadLoaderOptions?: object | false;

Expand Down