Improve parallelism limits in build-workspace yarn pack

Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
Eric Peterson
2025-01-29 10:50:41 +01:00
parent cec92027c7
commit 86c72c1fa7
4 changed files with 11 additions and 10 deletions
-1
View File
@@ -130,7 +130,6 @@
"node-libs-browser": "^2.2.1",
"npm-packlist": "^5.0.0",
"ora": "^5.3.0",
"p-limit": "^3.1.0",
"p-queue": "^6.6.2",
"pirates": "^4.0.6",
"postcss": "^8.1.0",
@@ -21,7 +21,6 @@ import {
resolve as resolvePath,
relative as relativePath,
} from 'path';
import pLimit from 'p-limit';
import { tmpdir } from 'os';
import tar, { CreateOptions, FileOptions } from 'tar';
import partition from 'lodash/partition';
@@ -369,11 +368,10 @@ async function moveToDistWorkspace(
}
// Repacking in parallel is much faster and safe for all packages outside of the Backstage repo
// Limit concurrency to 10 to avoid resource exhaustion on larger monorepos.
const limit = pLimit(10);
await Promise.all(
safePackages.map((target, index) =>
limit(() => pack(target, `temp-package-${index}.tgz`)),
),
);
await runParallelWorkers({
items: safePackages.map((target, index) => ({ target, index })),
worker: async ({ target, index }) => {
await pack(target, `temp-package-${index}.tgz`);
},
});
}