1. Separate repository and monorepo tool

2 min read

exile.watch logo

This page is part of The toolkit I needed to make it all happen 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.


Separate repository

It was fairly straightforward—I created an empty repository through GitHub's UI

Monorepo tool (Lerna)

Starting with an empty repository, the best approach was to follow the "starting from scratcharrow-up-right" instructions from the Lerna setup guide, utilizing the npx lerna init CLIarrow-up-right 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:

$schema

This refers to JSON schemasarrow-up-right, which help to describe your JSON data structure.

version ("fixed" mode)

circle-info

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

version ("independent" mode)

circle-info

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:arrow-up-right

packages

This is an array of globsarrow-up-right indicating where packages can be found. By default, it’s set to ["packages/*"], which is how configurations for splintersarrow-up-right, nucleusarrow-up-right and writarrow-up-right are structured.

Updating package.json to leverage NPM Workspaces

The last change involved updating package.json to make the most of npm workspacesarrow-up-right:


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.

Last updated