1. Separate repository and monorepo tool
2 min read
Last updated
2 min read
Last updated
This page is part of list - 1/7
Following up on our deep dive into exile.watch's use of Lerna, this page tackles the first crucial steps: setting up a separate repository and introducing Lerna as our monorepo tool.
It was fairly straightforward—I created an empty repository through GitHub's UI
Starting with an empty repository, the best approach was to follow the "starting from scratch" instructions from the Lerna setup guide, utilizing the npx lerna init
CLI command.
Running lerna init
got everything prepped for a true Lerna workspace.
Although I don’t remember the exact output, I initially ended up with the following lerna.json
:
As of March 2024, let’s break down the options and definitions in the above JSON:
This refers to JSON schemas, which help to describe your JSON data structure.
When using the fixed mode, all the affected packages will be published using the same version. The last published version is recorded in lerna.json
If you decide to use independent
, then every package has it's own version.
I went with independent
option.
I opted for this approach because some packages will change more often than others.
Also it wasn’t necessary to version the repository's package.json
, and doing so is generally not recommended:
This is an array of globs indicating where packages can be found. By default, it’s set to ["packages/*"]
, which is how configurations for splinters, nucleus and writ are structured.
package.json
to leverage NPM WorkspacesThe last change involved updating package.json
to make the most of npm workspaces:
With our repository and Lerna setup ready, let's now focus on the second key piece: the module bundler, crucial for efficiently packaging our code.