EasyMonorepo📖 Theory Question

What is a monorepo and what are its advantages over a polyrepo setup?

💡

Hint

All packages in one repo — atomic commits, easier refactors, shared tooling; trade-off is CI scale and access control

Full Answer

A monorepo stores multiple projects/packages in a single Git repository. A polyrepo gives each project its own repo.

Monorepo advantages:

  • Atomic cross-package commits — one PR can change a shared library and all consumers simultaneously, keeping them in sync.
  • Easier large-scale refactors — rename a function across 20 packages in one commit; no cross-repo PR coordination.
  • Shared tooling — one ESLint config, one TypeScript config, one CI setup for all packages.
  • Dependency visibility — you can see exactly which packages depend on what; circular deps are detectable at the repo level.
  • Simpler DX — pnpm install at root installs everything; no npm linking hacks needed.

Trade-offs:

  • CI must be smart (only build/test affected packages) — tools like Turborepo and Nx handle this.
  • Access control is coarser — everyone can see all packages. CODEOWNERS files mitigate this.
  • Repo size grows — Git history includes all packages; shallow clones help.

More Monorepo Questions

EasyHow does Turborepo's caching work and what makes it fast?→EasyHow does Nx differ from Turborepo?→EasyWhat are pnpm workspaces and why are they preferred in monorepos?→EasyWhat are module boundary rules in Nx and why do they matter?→

Practice this in a timed sprint →

5 free questions, no signup required

⚡ Start Sprint