ADR-001: pnpm Workspaces
Date: 2024-01-01 Status: Accepted
Context
For a monorepo, we need to choose a package manager that:
- Efficiently handles multiple packages
- Prevents dependency duplication
- Provides clear workspace management
- Has good tooling support
- Maintains fast installation times
Three main candidates were considered:
- npm with workspaces
- Yarn with workspaces
- pnpm with workspaces
Decision
We chose pnpm with workspaces as the primary package manager for this monorepo.
Rationale
- Disk Efficiency: pnpm uses a content-addressable filesystem, reducing disk space by 50-70% compared to npm/yarn
- Installation Speed: 2-3x faster than npm, faster than yarn in most cases
- Strict Dependency Resolution: pnpm enforces stricter dependency management, preventing "phantom dependencies"
- Workspace Protocol:
workspace:*allows explicit workspace dependencies - Lock File Quality: Deterministic lock files that are easy to review in diffs
- Community Adoption: Growing adoption in monorepo projects
- Performance: Better caching and concurrent operations
Consequences
Positive
- Fast, efficient monorepo management
- Smaller CI/CD caches
- Reduced node_modules size (saves ~60% space)
- Better package isolation
- Clear dependency relationships
Negative
- Requires pnpm installation (not pre-installed like npm)
- Some legacy tools may have compatibility issues
- Steeper learning curve for npm-only developers
Alternatives Considered
- npm workspaces: Simpler, included with Node, but slower and less efficient
- Yarn: Good performance but added complexity; pnpm offers same benefits with better disk efficiency
Migration Path
To switch to npm/yarn in future:
- Convert
pnpm-workspace.yamlto npm workspaces format - Generate new
package-lock.jsonoryarn.lock - Update CI/CD pipelines
- Update documentation