Simple monorepos via npm workspaces and TypeScript project references

submited by
Style Pass
2021-07-21 12:00:08

A monorepo is a single repository that is used to manage multiple projects. In this blog post, we’ll explore how to set up a simple monorepo for two npm packages. All we need is already built into npm and TypeScript.

The benefit of (2) is that it’s easier to keep the packages in sync: We can install and build all packages at the same time. And, in Visual Studio Code, we can jump between packages while editing.

“Monorepo” sounds fancy, but my use case for it is actually relatively simple. I am currently working on a minimal static site generator that is called Stoa. It comes in two parts:

In a previous blog post, I explained how to produce ESM modules via TypeScript. That’s also what I have configured for both packages in the monorepo. It has the following file system layout:

The command npm run all is defined via "scripts" and starts generation via the JavaScript version of demo-blog/ts/gen/main.ts. The latter file contains:

Leave a Comment