Monorepo, through a Newbie’s perspective

Soyokaze
4 min readNov 1, 2022

--

Photo by Michael Dziedzic on Unsplash

The first thing that rings about monorepo is that, it might be something related to repo being single 🥺 — Why does it sounds like a programmer’s life already? anyways — Well that’s half the truth about monorepos.

In this blog we’ll have a look on what a monorepo is? What are the tools used for it? pros & cons and summarizing all that with where you might need it.

What is a monorepo?

For starters it’s a repo 🤷, and by mono we know it’s a singular entity. To get an idea of what a monorepo is, have a look at the diagram below. I’ll take it as a reference to explain it further.

fig: monorepo analogy

The big circle that encapsulates the smaller ones is our monorepo, and then we have the smaller ones which represents different apps and libraries — ikik, I haven’t explained what monorepo is and started blabbering about it’s contents but bare with me —.

So, from the figure we got an idea that monorepo is a repo where multiple apps or libs exists. But that’s not what a monorepo is, sharing a folder doesn’t make the folder a monorepo, in-short “colocation” isn’t the only factor which makes a repo monorepo.

Having inter-dependency over each other while sharing common dependencies, which can be stored at a single place and from there it can be accessed by other apps and libs for development and stuff that are housed inside can be called as a monorepo.

So, to summarize the points that defines a monorepo:

  • Colocation.
  • Sharing of dependencies
  • Inter-dependency

A common repo that houses different apps and libraries an organization has to offer, which are interdependent in some way and some might only share common dependencies.

What are some tools for it’s management?

I have referenced all these from here: https://monorepo.tools/ , it’s a great site to learn about monorepos for starters.

So Why do we need a monorepo? What are the benefits?

  • Code re-usability across different applications. We can import functions and components directly from other apps and libs that are housed inside the monorepo without having to setup something like an npm registry and then installing the app or lib as dependency for using it’s functionality.
  • We can have atomic commits. Which means we are now free to commit even a small change without worrying about publishing the code if it needs to be published and be consumed in other apps, we can make changes in one go with a single commit/PR.
  • Sharing of dependencies. We can install dependencies which are common at the root of monorepo and from there all the apps and libs have access to them.
  • No need to checkout gazillions of repos, just to run a single app that have a dependency on others.

Not everything is a need…

While building different apps and libs which have some inter-dependency and some common deps, monorepo might seem a good take, reducing repos, less headache setting up all those and managing them all together.

But monorepo has it’s cons as well.

  • Bigger is not always better. Checking out the repo that houses all the apps and libs you have in your arsenal will definitely take its time to spin up.
  • Managing apps independently will be a distant dream. Once they are inter twined, we have to treat all the apps as one.
  • As we are treating them as one version different apps differently is not a good idea and versioning without a change is also not a good idea.

Now we know what a monorepo is, maybe a little, as beginner this is my take on what monorepo is. But hold on, this is not it. Now we know what it is but what about what is not a monorepo? 👀.

What doesn’t count as a monorepo?

Well as discussed in the starting, only having everything under same hood doesn’t make it a monorepo, we call them as “monolithic repo”, as they house different apps and libs but these are not interdependent and even if they are, there is no connection that is being made between them to use each other as dependencies.

So this was all I think a monorepo is and isn’t. Let me know what you think, clap if you like it, comment if you not or do and subscribe to get to know more. Till then, see you in the next…, 👋

Signing off Soyokaze ❤

--

--

Soyokaze
Soyokaze

No responses yet