intermediate
Workspaces
Manage multi-package repositories with shared installs, local package linking, script orchestration, and publish boundaries.
Workspaces let one repository host multiple packages with shared installation and local linking. Packages declare dependencies on sibling names (`"ui": "workspace:*"`) instead of publishing tarballs during development.
{
"name": "root",
"private": true,
"workspaces": ["apps/*", "packages/*"]
}
Root scripts often orchestrate builds (`npm run build --workspaces`, `pnpm -r build`, `yarn workspaces foreach`). Boundaries matter: each package should own its public API, version policy, and dependency list.
On interviews: workspace discovery, filtered commands, local protocol links, root versus package-level dependencies, and when to add Turborepo/Nx on top.
Common pitfalls: importing across packages without declaring dependencies; leaking app code into shared packages; root `devDependencies` hiding missing package deps.
The trade-off is developer velocity in multi-package repos versus boundary discipline and release complexity.
Checklist:
- Define package ownership and public APIs.
- Declare sibling deps explicitly.
- Use filtered scripts for targeted CI.
- Add task orchestration only when scripts sprawl.