DEV Community

Tea Reggi
Tea Reggi

Posted on • Updated on

Finding an Ideal Monorepo / Semantic Release setup.

I've had a dream for a couple of years now. The main idea of the dream is that I want a simple way to create node code, document it, test it, and share it. I have a strong desire to compartmentalize and organize code I've written and work on personal projects I have in the backlog.

This isn't a guide, tutorial, or demo. This is just a way for me to document my journey for setting up a monorepo. It's not yet complete, and is still a work in progress.

My Journey for Module Domination

I've been trying for over 5 years to have some sort of unified repository where I could store npm projects. Here's a list of the failed experiments:

Github Template as Monorepo Alternative

Most recently I've stumbled upon using a GitHub Template Repository I created called node-generate which is a template for a repo / npm module using TypeScript, Mocha, and a couple of other configure tools. The idea being that using GitHub generators allows you to easily create a new repo for a project and you're off to the races, however it's the opposite from a monorepo approach. Each of the projects I've created with that generator have been CLI tools, and they haven't been referring to one another.

I find myself again at a crossroads. I need a monorepo again. I don't want to have to maintain versioning sibling dependencies manually, it's a giant pain. If I continue with the single-npm-package-per-repo approach I will be stuck updating dependencies manually when a change cascades. However I've come to love GitHub actions, mainly semantic-release. I am finding it hard to get examples of monorepos working with semantic-release.

lerna v.s rush

I've been diving deep into rush as an alternative to lerna. I have only been diving it to rush recently and so I haven't fully flushed out if it's the right tool for me. If I had to place my bet on one of these tools sticking around I'd say the microsoft backed rush project is going to take the cake. lerna has seemed to stagnate over the past couple of years, while yarn has been incorporating workspaces. That being said all of these tools, and all of the work from the developers being these tools have been vital to where we are today.

Apparently back in May 2020 npm issued that they will be including "workspaces" into the new version of npm. A standard format for how monorepos are setup could really benefit the entire community. This may open up the scene for wider adoption of tooling.

My Recent Discovery of semantic-release

With my excessive use of Github Actions it's been easier than ever to set up CI pipelines in my GitHub projects. One thing I've heard about for many years but never implemented is semantic-release.

semantic-release allows you to publish npm modules through git commits, messages included with a specific prefix, and through the severity of that prefix can determine what version increment to publish the module at (ie. major for breaking changes, minor for feature changes, and patches for bug fixes). This means I never have to manually publish a npm module again!

My open question is how easy is it to set up a monorepo to use semantic-release?

Stay tuned for part 2! I will be continue this series to find an ultimate monorepo setup!

Top comments (2)

Collapse
 
spunkie profile image
Spunkie

Really looking forward to the follow up on this. πŸ‘

Collapse
 
xamgore profile image
Igor Strebezhev • Edited

From now on Lerna uses npm workspaces.