Your organisation has 30 front-end teams, 12 deployable web apps, about 150 internal packages (design system, data clients, utilities, feature libraries) and 400 engineers contributing. Code lives in a mix of about 60 repositories; shared packages are published to a private registry and every upgrade is a cross-repo chore. Many apps are two or three majors behind on the shared libraries.
Leadership has decided to consolidate into a front-end monorepo. You are asked to design the repository, build, test and CI/CD platform:
Compare tooling options (Nx, Turborepo, Bazel, Rush, plain pnpm workspaces) and justify your choices.
A monorepo is a trade: you give up the isolation of separate repositories in exchange for atomic changes across packages, one version of each dependency, and one place to enforce standards. The trade only pays off if the tooling makes the repository feel small to each engineer. Without affected-only builds, caching and clear ownership, a 400-person monorepo becomes a 60-minute CI pipeline that everybody blames on everybody else.
So the design has three pillars:
install under 2 minutes cold; dev server for one app starts in under 10 seconds.apps/
storefront/ # Next.js
admin/ # Vite SPA
packages/
design-system/ # @acme/design-system
data/orders-client/ # generated API client
features/checkout/ # domain feature library
utils/dates/
tooling/
eslint-config/ tsconfig/ jest-preset/ generators/
Every project has a manifest (package.json plus project.json or turbo.json task config) with tags describing
its type and domain: type:app, type:feature, type:ui, type:util, domain:checkout. Tags drive boundary rules.
node_modules layout prevents phantom dependencies (importing a package
you did not declare), which is critical for accurate graphs. workspace:* protocol for internal deps.The graph is derived from package.json dependencies plus static import analysis. Rules expressed as data:
{
"depConstraints": [
{ "sourceTag": "type:app", "onlyDependOnLibsWithTags": ["type:feature", "type:ui", "type:util", "type:data"] },
{ "sourceTag": "type:feature", "onlyDependOnLibsWithTags": ["type:ui", "type:util", "type:data"] },
{ "sourceTag": "type:ui", "onlyDependOnLibsWithTags": ["type:ui", "type:util"] },
{ "sourceTag": "type:util", "onlyDependOnLibsWithTags": ["type:util"] },
{ "sourceTag": "domain:checkout", "onlyDependOnLibsWithTags": ["domain:checkout", "domain:shared"] }
]
}
This mirrors Nx's enforce-module-boundaries lint rule; with Turborepo you implement the same thing with
eslint-plugin-boundaries, dependency-cruiser or Turborepo's boundaries feature.
{
"tasks": {
"build": { "dependsOn": ["^build"], "inputs": ["src/**", "package.json", "tsconfig.json"], "outputs": ["dist/**"] },
"typecheck": { "dependsOn": ["^build"], "outputs": [] },
"test": { "dependsOn": [], "inputs": ["src/**", "test/**", "$TEST_CONFIG"], "outputs": ["coverage/**"] },
"lint": { "outputs": [] },
"e2e": { "dependsOn": ["build"], "cache": false }
}
}
Cache key = hash of task inputs (source files, dependency outputs, lockfile slice, declared env vars, tool versions). Declaring inputs accurately is everything: an undeclared env var means a stale cache hit, which destroys trust in the cache faster than any slowness.
# CODEOWNERS
/apps/storefront/ @acme/storefront-team
/packages/features/checkout/ @acme/checkout-team
/packages/design-system/ @acme/design-system
/tooling/ @acme/dx-platform
/pnpm-lock.yaml @acme/dx-platform
Combined with each project's metadata (owner, slack, oncall), this powers review routing and the service catalogue.
pnpm dev storefront # starts one app and only what it needs
pnpm affected test --base=origin/main
pnpm gen package --name dates --type util --domain shared # generator with tags, tsconfig, lint, owners
pnpm graph # interactive project graph
pnpm doctor # checks Node version, pnpm version, cache config, git hooks
A thin wrapper (acme CLI or package scripts) hides whether the underlying tool is Nx or Turborepo, so the platform
team can change internals without retraining 400 people.
lint, typecheck, test, build in parallel across agents, pulling from remote cache.| Tool | Strengths | Weaknesses | Fit |
|---|---|---|---|
| Nx | Rich project graph, affected commands, module boundary lint rule, generators, plugins for many frameworks, distributed task execution and remote cache (Nx Cloud, or self-hosted cache options) | More concepts to learn; plugins can be opinionated; some features tied to the paid cloud | Large JS/TS monorepo needing governance features out of the box |
| Turborepo | Simple config, fast, excellent caching, low ceremony; remote cache via Vercel or self-hosted implementations | Fewer built-in governance features; no first-party distributed execution; graph is package-level only | Medium monorepos; teams that want minimal tooling |
| Bazel (with rules_js) | Hermetic, correct caching and remote execution at huge scale; polyglot | Steep learning curve, heavy maintenance, friction with JS ecosystem conventions | Very large polyglot orgs with a build team |
| Rush (with pnpm) | Strict policies, version policies, good for publishing many packages | Smaller community, less dev-loop tooling | Library-heavy monorepos |
| pnpm workspaces alone | Zero extra tooling | No caching or affected detection | Under about 20 packages |
Recommendation for this brief: pnpm + Nx, primarily for affected detection, boundary enforcement, generators and distributed execution at 150–300 projects. Turborepo would be a legitimate choice if the org values simplicity and is willing to assemble boundaries and distribution separately. Bazel is not justified for a front-end only repo of this size: its correctness is excellent, but the cost of owning it is a dedicated build team.
features/checkout only builds checkout and the apps
that depend on it.@swc/jest), tsc --build with
incremental project references for typechecking, Vite or Rspack for app builds..nvmrc / engines and Corepack or a
version manager.At 300 merges a day, a 1% flaky test is a daily blocker. Detect flakiness by re-running failures automatically and recording pass-on-retry, quarantine flaky tests automatically (still run, not blocking) with an auto-created ticket for the owning team, and report flaky rate per team. End-to-end tests are kept to critical journeys per app; the rest is component and integration tests.
onlyBuiltDependencies style allow-lists for install scripts, lockfile review by code owners,
minimumReleaseAge-type delays on brand-new versions, and audit tooling in CI.tsconfig keep the language
server responsive.pnpm dev <app> must start only that app and its watched dependencies.git subtree or tools that rewrite paths), one domain at a time, starting with the
most-shared packages so consumers benefit immediately.Plan for 2–3 quarters. The bottleneck is dependency convergence, not git.
Why not keep polyrepos with better automation? You can, with Renovate and a shared CI template. But cross-package changes remain multi-PR, multi-release sequences, and version drift returns. If teams rarely change shared code, polyrepos are fine; here, drift is the stated problem.
How do you handle an app that must stay on an older React for a quarter? Temporary exception in the version policy with an owner and expiry; pnpm can install a different version for that one workspace. Track it on the dashboard; exceptions without deadlines become permanent.
How do you stop one team's change from breaking another team's app? The affected graph runs the other app's tests in the same PR, and code owners of the shared package review public API changes. That is the main safety benefit of the monorepo.
What about very large tests like visual regression? Run them only for affected UI projects, use a service such as Chromatic with TurboSnap-like change detection, and accept them as non-blocking for unrelated changes.
Who owns main when it breaks? The merge queue should prevent most breaks. When one happens, an automatic revert bot reverts the culprit PR after bisecting within the queue batch, and the author is notified. Humans fix forward only when the revert is unsafe.
Spotted a mistake or a rights concern? Report an issue