Lerna - the hidden powerhouse of exile.watch
15 min read (including sub-pages)
Last updated
15 min read (including sub-pages)
Last updated
I briefly touched on why I picked Lerna and what it's all about in an exile.watch architecture post before.
However, exile.watch's approach to Lerna deserves its own post with a total deep dive.
This isn't exactly a step-by-step guide on using Lerna.
Instead, think of it as a behind-the-scenes look at how exile.watch harnesses Lerna to our advantage.
Lerna is a fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.
Monorepos let you develop multiple packages in the same repository, which is fantastic for productivity. You can share code, establish clear ownership, and have fast unified CI.
To use monorepos well, you need a good monorepo tool, and Lerna is exactly that. Lerna is fast, widely used, and battle tested.
There was one real problem, and one imaginary problem:
The real deal: a dependency mess, which I've already mentioned about in exile.watch architecturepost.
The not-so-real deal: just my own itch to dive into Lerna, especially since I left myself a nice, messy sandbox to play in with that dependency chaos.
I brushed over that idea before, but now, let's dive deeper into how that worked out.
Because each component plays a crucial role in the grand scheme, I've detailed them on their own subpages. Feel free to click through for a deep dive into each part of my setup. Here’s a quick rundown of what I needed:
To pull this off, I needed a few key things in my arsenal:
(2 min read) 1. Separate repository and monorepo tool
(1 min read) 2. A module bundler - the fun begins
(1 min read) 3. Module registry (a place where packages get to chill)
(2 min read) 4. Versioning, Publishing, and Configuring lerna.json for Commit Conventions
(2 min read) 5. Some automation magic using the (Lerna) CLI
(5 min read) 6. How does one test lerna packages at exile.watch: locally and in the real world
Regardless of how deep you've dived into the sections above, it's worth highlighting the significant impact Lerna has had on exile.watch.
Spinning up a new package or project now takes mere seconds.
And yes, while one might argue "But doesn't setting up a repository template do the same?", there's a catch—over time, disparate dependency versions inevitably lead to incompatibility nightmares.
So back to square one.
Thanks to Lerna and the "boilerplate" strategy I've detailed earlier, we dodge such dilemmas, scaling effortlessly.
That’s the real beauty of it. Admittedly, this approach demands some upkeep of our internal ecosystem, but it's a small price for coherent progress.
To wrap up, I'll leave you with a question that might stir some thought:
If you were in charge of steering your company's tech direction, which path would you choose?
a) Accepting rapidly accumulating tech debt and inconsistent dependencies across projects, leading to: - headaches and reduced engineering productivity, which ultimately costs more money
— or —
b) Keeping projects up-to-date with a person or a small team dedicated to this task, ensuring: - smooth transitions between teams - straightforward onboarding for new hires and immediate productivity from day one
Consider this: The smaller the team, the more pronounced the diminishing returns from implementing Lerna might seem.
If the focus is solely on short-term gains, aiming to quickly deliver features to meet specific goals, then option a) might seem more appealing, and it's not inherently wrong to think that way.
Focusing just on the short-term is like building a house of cards: it might stand up for a while, but eventually, it’s going to come tumbling down.
Author: Sebastian Krzyżanowski About exile.watch: https://docs.exile.watch/ Github: https://github.com/exile-watch Visit https://exile.watch/ to experience it first hand