Dependency management
Karr is built on Node with pnpm. Pnpm offers a feature called catalogs. This feature enables dependency consistency within the monorepo, and lets us categorise our dependencies.
Catalogs
Section titled “Catalogs”At the root of the monorepo, there is a pnpm-workspace.yaml
file.
Among other things, this file contains all catalogs.
The current list of catalogs is made to sort the dependencies neatly by use.
Tooling
Section titled “Tooling”Since the catalogs feature in pnpm is still relatively recent, tooling support isn’t great yet, even inside pnpm itself. To bridge that gap, there are a couple of neat little tools to make life easier.
Nip enables us to install dependencies directly inside a catalog.
Instead of finding a dependency version and adding it ourslves in the appropriate catalog,
or installing it directly inside a package then moving it manually to a catalog,
we can simply pass it to nip
and it will do the work for us.
Instead of running pnpm install package-name
, run:
pnpm nip package-name
Follow the promps to choose the appropriate catalog, and your dependency will be added neatly!
You probably won’t need to use this one yourself.
Taze is a tool that makes updating all dependencies in a workspace much easier.
This is run periodically via Github Actions to automate the upgrade process.
Simply run pnpm taze
to update everything inside pnpm-workspace.yaml
.