diff --git a/package-lock.json b/package-lock.json index 549aada3..6fd16c9b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6183,9 +6183,9 @@ "dev": true }, "husky": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/husky/-/husky-2.2.0.tgz", - "integrity": "sha512-lG33E7zq6v//H/DQIojPEi1ZL9ebPFt3MxUMD8MR0lrS2ljEPiuUUxlziKIs/o9EafF0chL7bAtLQkcPvXmdnA==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/husky/-/husky-2.3.0.tgz", + "integrity": "sha512-A/ZQSEILoq+mQM3yC3RIBSaw1bYXdkKnyyKVSUiJl+iBjVZc5LQEXdGY1ZjrDxC4IzfRPiJ0IqzEQGCN5TQa/A==", "dev": true, "requires": { "cosmiconfig": "^5.2.0", @@ -6195,9 +6195,9 @@ "is-ci": "^2.0.0", "pkg-dir": "^4.1.0", "please-upgrade-node": "^3.1.1", - "read-pkg": "^5.0.0", + "read-pkg": "^5.1.1", "run-node": "^1.0.0", - "slash": "^2.0.0" + "slash": "^3.0.0" }, "dependencies": { "pkg-dir": { @@ -6220,6 +6220,12 @@ "parse-json": "^4.0.0", "type-fest": "^0.4.1" } + }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true } } }, @@ -6701,8 +6707,7 @@ "is-wsl": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", - "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=", - "dev": true + "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=" }, "isarray": { "version": "1.0.0", diff --git a/package.json b/package.json index ef4bc006..ee0be3d0 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "dependencies": { "cacache": "^11.3.2", "find-cache-dir": "^2.0.0", + "is-wsl": "^1.1.0", "schema-utils": "^1.0.0", "serialize-javascript": "^1.7.0", "source-map": "^0.6.1", diff --git a/src/TaskRunner.js b/src/TaskRunner.js index 2c625b6b..87b4c580 100644 --- a/src/TaskRunner.js +++ b/src/TaskRunner.js @@ -4,6 +4,7 @@ import cacache from 'cacache'; import findCacheDir from 'find-cache-dir'; import workerFarm from 'worker-farm'; import serialize from 'serialize-javascript'; +import isWsl from 'is-wsl'; import minify from './minify'; @@ -19,10 +20,13 @@ export default class TaskRunner { // In some cases cpus() returns undefined // https://github.com/nodejs/node/issues/19022 const cpus = os.cpus() || { length: 1 }; - this.maxConcurrentWorkers = - parallel === true - ? cpus.length - 1 - : Math.min(Number(parallel) || 0, cpus.length - 1); + // WSL sometimes freezes, error seems to be on the WSL side + // https://github.com/webpack-contrib/terser-webpack-plugin/issues/21 + this.maxConcurrentWorkers = isWsl + ? 1 + : parallel === true + ? cpus.length - 1 + : Math.min(Number(parallel) || 0, cpus.length - 1); } run(tasks, callback) {