Workspaces and Monorepos in Package Managers
18 days ago
- #workspaces
- #package-managers
- #monorepos
- Workspaces in package managers solve the problem of coordinating local dependencies without manual symlinking or publishing.
- Common use cases for workspaces include developing libraries with plugins, apps with local utilities, and debugging dependencies locally.
- Different package managers implement workspaces differently: npm and Yarn use symlinks and hoist dependencies, pnpm avoids hoisting and uses a workspace protocol, and Cargo shares a lockfile and build directory.
- Go uses go.work files for local development without affecting published modules, while Bundler and Composer rely on path dependencies as workarounds.
- Common problems with workspaces include phantom dependencies, version mismatches, tooling assumptions, CI divergence, build orchestration, and publishing coordination.
- Workspaces make monorepos practical by handling dependency wiring, but they don't solve all coordination issues, leading to tools like Turborepo and Changesets.