Sources: Robinhood's LinkedIn post; The Bazel Bet Behind Robinhood Legend: Infrastructure from First Principles by David Aghassi and Max Rabiciuc, Robinhood Tech Blog, 2026-11-10.
In one paragraph
Robinhood's legacy web trading app lived in a Bazel monorepo but was built with Webpack as one Bazel target, and its tests ran as one Jest suite. Any change invalidated the whole cache, a one-line edit meant a roughly 40-minute rebuild, and CI was slow and flaky. Years of Webpack tuning didn't help, because the bottleneck was the shape of the build: one target meant one unit of cache invalidation. For the new desktop product, Legend, the team rebuilt the JavaScript build on pnpm and the rules_js family of Bazel rulesets. They used one BUILD.bazel file per folder, generated by Gazelle, with RSPack doing only the final bundling. Reported results: P95 CI about 50% faster (about 25 minutes), P50 about 80% faster (about 10 minutes), installs about 75% faster, and an isolatedDeclarations rollout that cut type-check time by about 80% and monorepo-wide build time by about 25%.
Goals they set first
Local developer experience couldn't get worse: IDE autocomplete and inline types had to keep working.
CI and local builds had to stay identical, to avoid a new class of failures that can't be reproduced.
The existing web monorepo couldn't break, so the migration had to be gradual, with old and new tooling side by side.
Options weighed
Keep tuning rules_nodejs and Webpack. Rejected because its maintainers were winding it down, so this meant a future fork of an abandoned project.
Turborepo. Real caching wins, but it would step outside Bazel's company-wide graph and its shared remote caching and remote build workers, leaving JavaScript as an island.
Restructure folders only. Tried and reverted: friction for developers with no caching payoff, because nothing used the new structure.
Replace the JS tooling under Bazel (chosen). pnpm, whose symlinked global store suits Bazel's resolution, plus rules_js with rules_ts, rules_swc and rules_jest, and a Gazelle plugin for BUILD generation like other languages already had.
How the build works
One target per folder. Each source folder gets a BUILD.bazel mirroring the tree. Third-party packages and first-party folders are both just edges in the graph.
Macros plus Gazelle. A single macros file at the app root wraps the standard rules, pinning the app root and injecting Jest's ambient type dependency into every test target. Gazelle directives map the default rule kinds to those macros and enforce import validation and visibility. Developers write TypeScript and never hand-edit build files.
Tests depend on their source target by name, inheriting its dependencies rather than repeating them.
Bundling is last and narrow. Bazel typechecks and transpiles per target, and RSPack only bundles.
Remote caching on CI. A change to one widget leaves everything upstream as cache hits.
isolatedDeclarations. When P95 type-checking climbed to 16 minutes, they turned on TypeScript's isolatedDeclarations, which needs explicit types at module boundaries so each file checks independently and in parallel. It was rolled out folder by folder with ts-fix, with leftovers marked by @ts-expect-error for later cleanup.
Staged rollout. Libraries were migrated first, then applications, with the largest customer-facing apps last. Legend, built fresh, used the proven pattern from day one.
Tradeoffs and failure modes
Explicit types tax. isolatedDeclarations moves work onto developers and leaves @ts-expect-error debt that needs an owner.
Generated build files are only as good as import analysis. Ambient globals such as Jest's must be injected by hand, and dynamic imports or side-effect imports can hide edges.
Very fine targets raise Bazel analysis overhead and remote-cache traffic. The post doesn't report those costs.
The headline numbers are mostly from a greenfield app. The legacy app's gains depend on how far its migration has gone, which the post doesn't quantify.
Vendor-free but self-reported. There's no breakdown of the CI improvement between caching, test sharding and the type-check change.
Review checklist for a monorepo build
Is the unit of cache invalidation small enough that a one-line change rebuilds only its dependents?
Do tests run as cacheable per-target units, rather than one suite?
Are build files generated from source, with import validation set to fail on undeclared dependencies?
Are local and CI builds the same graph?
Are module boundaries typed explicitly enough for independent, parallel type-checks?
Is the migration staged smallest-first, with a way to run old and new tooling side by side?
Do you measure P50 and P95 CI time separately?
Related
R001 (Scaling Git at OpenAI): monorepo infrastructure redesigned when the shape of the work changed.
R046 (Hardwood scheduler): the same lesson in a different layer, where structure, not micro-tuning, sets the performance ceiling.