diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 3feb83a48b348c..2a2cd8d1b08454 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -337,7 +337,7 @@ export default async function build(dir: string, conf = null): Promise { const staticCheckWorkers = new Worker(staticCheckWorker, { numWorkers: config.experimental.cpus, - enableWorkerThreads: true, + enableWorkerThreads: config.experimental.cpus > 1, }) const analysisBegin = process.hrtime() diff --git a/packages/next/build/webpack/plugins/terser-webpack-plugin/src/TaskRunner.js b/packages/next/build/webpack/plugins/terser-webpack-plugin/src/TaskRunner.js index b306966292ede4..cb905786e3ea2f 100644 --- a/packages/next/build/webpack/plugins/terser-webpack-plugin/src/TaskRunner.js +++ b/packages/next/build/webpack/plugins/terser-webpack-plugin/src/TaskRunner.js @@ -28,8 +28,8 @@ export default class TaskRunner { if (this.maxConcurrentWorkers > 1) { this.workers = new Worker(worker, { - enableWorkerThreads: true, numWorkers: this.maxConcurrentWorkers, + enableWorkerThreads: this.maxConcurrentWorkers > 1, }) this.boundWorkers = options => this.workers.default(options) } else { diff --git a/packages/next/export/index.ts b/packages/next/export/index.ts index dba1116a3f3d1c..0792904475bf4e 100644 --- a/packages/next/export/index.ts +++ b/packages/next/export/index.ts @@ -267,7 +267,7 @@ export default async function( { maxRetries: 0, numWorkers: threads, - enableWorkerThreads: true, + enableWorkerThreads: threads > 1, exposedMethods: ['default'], } ) as any