diff --git a/.changeset/cli-melancholy-in-advance.md b/.changeset/cli-melancholy-in-advance.md new file mode 100644 index 0000000000..7a2c6f8658 --- /dev/null +++ b/.changeset/cli-melancholy-in-advance.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +The packing process when running `build-workspace` with the `--alwaysYarnPack` flag now respects the `BACKSTAGE_CLI_BUILD_PARALLEL` environment variable, defaulting parallel work limits based on CPU availability. diff --git a/packages/cli/package.json b/packages/cli/package.json index a7f3898fd1..04197985e5 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -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", diff --git a/packages/cli/src/lib/packager/createDistWorkspace.ts b/packages/cli/src/lib/packager/createDistWorkspace.ts index ea1682bc4f..9ca3f7af70 100644 --- a/packages/cli/src/lib/packager/createDistWorkspace.ts +++ b/packages/cli/src/lib/packager/createDistWorkspace.ts @@ -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`); + }, + }); } diff --git a/yarn.lock b/yarn.lock index d082e97c2b..1914267894 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4020,7 +4020,6 @@ __metadata: nodemon: ^3.0.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