Victor Ndaba

Managing monorepos using pnpm

By Victor Ndaba, 10/27/2022
Tags: #pnpm#monorepos#workspaces

NOTE: This blog post is incomplete. I will be adding more content to it soon.

If you are unfamiliar with what a monorepo is, it is simply a single repository containing different but related projects. Projects like babel have adopted a monorepo structure since it is much easier to manage when dealing with closely related packages. In the javascript ecosystem, there are various ways of managing a monorepo. There are tools like lerna, turborepo, Nx, Rush but I have found that using pnpm mostly eliminates the need for using a third party tool.

All package managers support the concept of workspaces which is what allows us to have multiple JS/TS projects in a single repository. For our purposes, we will only be using pnpm-workspaces which are a bit different from yarn/npm workspaces. There are usually two kind of monorepos. The first kind can be consisted of apps and packages in the sense that apps are the projects that can be executed (i.e A react app, or remix app) while packages are libraries that can only be imported into other projects. The other kind of monorepo is one that is purely comprised of libraries which is what most open source tools use.

See an error on this page? Edit on github
Managing monorepos using pnpm