Skip to content

feat(workspace): add concurrency option and --concurrency CLI flag - #1030

Closed
jpzwarte wants to merge 7 commits into
rolldown:mainfrom
jpzwarte:feat/concurrency-workspace-option
Closed

feat(workspace): add concurrency option and --concurrency CLI flag#1030
jpzwarte wants to merge 7 commits into
rolldown:mainfrom
jpzwarte:feat/concurrency-workspace-option

Conversation

@jpzwarte

Copy link
Copy Markdown
Contributor
  • This PR contains AI-generated code, but I have carefully reviewed it myself. Otherwise, my PR may be closed.

Description

Large workspaces can spawn an excessive number of subprocesses (e.g. TypeScript declaration workers) when all packages build at once, exhausting system resources (#929).

Add workspace.concurrency to limit how many packages build in parallel, with a --concurrency <count> CLI alias. All formats of a package share one concurrency slot, since a package's exports/publint step only resolves once every format of that package has finished. Defaults to unlimited, preserving current behavior.

Linked Issues

Fixes #929

Additional context

Claude generated the Chinese documentation. Please review that yourself as i can't read Chinese :)

Copilot AI review requested due to automatic review settings July 23, 2026 15:36
@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploy Preview for tsdown-main failed.

Name Link
🔨 Latest commit 6b58931
🔍 Latest deploy log https://app.netlify.com/projects/tsdown-main/deploys/6a62534c1bbd1b0008df07e3

@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

tsdown

pnpm add https://pkg.pr.new/tsdown@1030 -D
npm i https://pkg.pr.new/tsdown@1030 -D
yarn add https://pkg.pr.new/tsdown@1030.tgz -D

create-tsdown

pnpm add https://pkg.pr.new/create-tsdown@1030 -D
npm i https://pkg.pr.new/create-tsdown@1030 -D
yarn add https://pkg.pr.new/create-tsdown@1030.tgz -D

@tsdown/css

pnpm add https://pkg.pr.new/@tsdown/css@1030 -D
npm i https://pkg.pr.new/@tsdown/css@1030 -D
yarn add https://pkg.pr.new/@tsdown/css@1030.tgz -D

@tsdown/exe

pnpm add https://pkg.pr.new/@tsdown/exe@1030 -D
npm i https://pkg.pr.new/@tsdown/exe@1030 -D
yarn add https://pkg.pr.new/@tsdown/exe@1030.tgz -D

tsdown-migrate

pnpm add https://pkg.pr.new/tsdown-migrate@1030 -D
npm i https://pkg.pr.new/tsdown-migrate@1030 -D
yarn add https://pkg.pr.new/tsdown-migrate@1030.tgz -D

commit: 6b58931

@jpzwarte

Copy link
Copy Markdown
Contributor Author

@sxzz I've tried to make sure this PR follows your earlier comment in the other PR i just closed. Afaics it's ready for review. Please let me know if there's anything i missed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a workspace-level concurrency limit to reduce resource exhaustion in large monorepos by throttling how many workspace packages are built in parallel, surfaced as both workspace.concurrency and a --concurrency <count> CLI flag.

Changes:

  • Introduces workspace.concurrency (and --concurrency) and threads the resolved concurrency value through config resolution into the build scheduler.
  • Updates the build scheduler to limit parallelism at the package level (all formats for a package share one concurrency slot).
  • Adds a mapConcurrent utility with unit tests, plus an e2e fixture/snapshot covering the new option wiring.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/e2e.test.ts Adds an e2e scenario that uses workspace.concurrency.
tests/snapshots/workspace-concurrency-option.snap.md Snapshot output for the new e2e scenario.
src/utils/general.ts Adds mapConcurrent helper to run async tasks with a concurrency cap.
src/utils/general.test.ts Unit tests for mapConcurrent (order, cap, rejection, unlimited).
src/config/workspace.ts Validates/derives workspace.concurrency and returns it from workspace resolution.
src/config/types.ts Documents Workspace.concurrency and adds InlineConfig.concurrency (CLI alias).
src/config/index.ts Aggregates workspace concurrency and returns it from resolveConfig().
src/cli.ts Adds --concurrency <count> flag.
src/build.ts Applies concurrency when building workspace packages by grouping configs per package.
docs/zh-CN/reference/cli.md Documents --concurrency <count> in Chinese CLI reference.
docs/reference/cli.md Documents --concurrency <count> in English CLI reference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cli.ts
Comment thread src/config/workspace.ts Outdated
Comment thread src/config/types.ts Outdated
Comment thread tests/e2e.test.ts
@jpzwarte

Copy link
Copy Markdown
Contributor Author

@sxzz I'm not sure what is happening with the 2 failing checks (autofix and linting). When i run linting locally i get no errors and the errors on GitHub point to lines that i haven't touched in this PR...

@sxzz
sxzz force-pushed the feat/concurrency-workspace-option branch from b7ca706 to dd9ba7c Compare July 23, 2026 17:43
jpzwarte and others added 3 commits July 24, 2026 02:45
Large workspaces can spawn an excessive number of subprocesses (e.g.
TypeScript declaration workers) when all packages build at once,
exhausting system resources (rolldown#929).

Add `workspace.concurrency` to limit how many packages build in
parallel, with a `--concurrency <count>` CLI alias. All formats of a
package share one concurrency slot, since a package's exports/publint
step only resolves once every format of that package has finished.
Defaults to unlimited, preserving current behavior.

Fixes rolldown#929

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sxzz
sxzz force-pushed the feat/concurrency-workspace-option branch from dd9ba7c to 6b58931 Compare July 23, 2026 17:45
@sxzz sxzz closed this in 8a14c35 Jul 23, 2026
@sxzz

sxzz commented Jul 23, 2026

Copy link
Copy Markdown
Member

Thank you for your contribution and for helping move this forward! I ended up implementing the feature directly on main with a different design: the concurrency limit is CLI-only and applies to each Rolldown build. I added you as a co-author of commit 8a14c35 to acknowledge your work and contribution. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsdown crashes my mbp m4 max

3 participants