Monorepo — A Concept Summary
Bringing scattered repositories under one roof — definition, differences from multi-repo, and key tradeoffs of the monorepo approach.
Restored from a 2020-05 archive. Lerna was the default choice then; today pnpm workspaces and Turborepo are more common.
I recently started a module project built on the monorepo concept, so I'm revisiting monorepo fundamentals in this post.
Until now I only had a basic conceptual understanding — I hadn't had much chance to try it in a real project. I'd been developing NPM modules with the classic multi-repo approach: one repository per module.
Then a new project came up that adopted Lerna as a version management tool, which gave me a reason to organize my thinking about monorepos again.
In one sentence: a monorepo puts what was managed as multiple repositories into a single repository. The opposite is a multi-repo.
Monorepo vs Multi-Repo
| Type | Definition |
|---|---|
| Monorepo | Manage multiple logical repositories inside one physical repository |
| Multi-Repo | Each package lives in its own repository |
Monorepo Advantages
- Easier management from a single repo
- Simpler code reuse
- Lower overhead for dependency management
- Easier dev environment setup, build, and test
- Cross-project integration tests and code search become straightforward
- A single commit can refactor an API and all its callers
- Makes large-scale refactoring feasible
- Smoother collaboration across teams
Monorepo Disadvantages
- Need mechanisms for tracking up-to-date dependencies
- Version information can be lost
- Weaker per-project isolation boundaries
- Requires more storage
Guestbook
Leave a short note about this post
Loading...