Conversation
Add a lightweight parallel rollup runner that processes config arrays concurrently using the rollup JS API. Use it for @sentry/browser's build:bundle which runs 93 rollup builds (31 entrypoints × 3 variants). This reduces the browser bundle build from ~175s to ~65s (~2.6x faster), which was the critical path for the full `yarn build`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| } | ||
|
|
||
| const { default: configs } = await import(pathToFileURL(resolve(configPath)).href); | ||
| const concurrency = cpus().length; |
There was a problem hiding this comment.
Zero concurrency from empty cpus() skips all builds
Medium Severity
os.cpus() can return an empty array in certain container or CI environments (e.g., when /proc is unavailable), making concurrency equal to 0. This causes Array.from({ length: 0 }, worker) to spawn zero workers, so Promise.all([]) resolves immediately and the script exits successfully without building any bundles — a silent, hard-to-debug failure. Using Math.max(1, cpus().length) or os.availableParallelism() (guaranteed ≥ 1) would prevent this.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 790f53f. Configure here.
size-limit report 📦
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b8fd53b. Configure here.
| await bundle.close(); | ||
| done++; | ||
| process.stdout.write(`\r [${done}/${configs.length}] builds completed`); | ||
| } |
There was a problem hiding this comment.
Concurrent builds share mutable rollup plugin instances
Medium Severity
The configs produced by makeBundleConfigVariants share the same rollup plugin instances by reference (e.g., nodeResolvePlugin, sucrasePlugin, licensePlugin, terserPlugin, setSdkSourcePlugin) across their 3 variant configs (.js, .min.js, .debug.min.js). The mergePlugins function in deepMerge concatenates arrays without cloning plugin objects. When two such sibling configs are picked up by different workers simultaneously, concurrent rollup() calls operate on the same plugin instances. Rollup plugins can maintain internal state via closures and hooks like buildStart/closeBundle, and concurrent use of shared instances is an unsupported pattern that could cause subtle, hard-to-reproduce build corruption — especially if any plugin dependency is updated to become stateful.
Reviewed by Cursor Bugbot for commit b8fd53b. Configure here.


Previously, running
yarn build:bundlesfor the browser package is one of the biggest blocker for build time. This is because this builds ~90 bundles in series via rollup. This PR adds a small script to run multiple rollup builds in parallel, hopefully speeding this up significantly. Locally I saw an improvement from ~150s to ~70s.Summary
dev-packages/rollup-utils/rollupParallel.mjs— a ~30 line script that runs rollup config arrays concurrently using the rollup JS API (concurrency = CPU count)@sentry/browser'sbuild:bundle, which builds 93 rollup configs (31 entrypoints × 3 variants:.js,.min.js,.debug.min.js)Rollup processes config arrays sequentially. This was the critical path for
yarn build— the browser bundle step alone took ~175s. With parallel execution it completes in ~65s (~2.6x speedup).The other packages with
build:bundle(replay, feedback, replay-canvas, wasm) only have 3-6 configs each, so the overhead isn't worth it there.Test plan
yarn buildinpackages/browserproduces all 93 bundles + sourcemaps🤖 Generated with Claude Code