Skip to content

Instantly share code, notes, and snippets.

@prabh-62
Created March 21, 2021 14:40
Show Gist options
  • Save prabh-62/6caf975f84b0ac81e9d92cd9e0c51169 to your computer and use it in GitHub Desktop.
Save prabh-62/6caf975f84b0ac81e9d92cd9e0c51169 to your computer and use it in GitHub Desktop.
Benefits of a monorepo

How monorepo eventually save $$?

What is monorepo?

When we store all(or most) of our source code in a single git repository, we term the git repository as mono-repository. Mono-repository usually contains multiple applications, and several reusable libraries.

Updating/Debugging library

Typically, when a developer needs to debug a library source code, they have to first clone the library source code and then somehow link the library and application source code together.

Also, if a developer has to update a library, they have to again clone the library source code, make updates and then verify the resulting package. Upon verification, dev publishes newer version of the library.

Assuming, a developer is paid $100 per hour. If the developer has to follow this pattern of updating libraries, it will usually take them at-least an hour resulting in $100 loss to business.

Compare this approach to a monorepo, where actual application and library code are in the same git repository and developer doesn't have to do much to update/debug the library source code saving company's overall time

Keeping packages up-to-date

In the case of multiple repositories, when some developer updates the library, they will usually update the library only in their application. This means that other applications using the same library will be out of date soon. Also, it will be harder for a developer to make a breaking change since all of the consuming applications will be impacted.

Interestingly in the case of monorepo, developer can scan for usages of the library code in all applications and modify it within few minutes. Furthermore, all the applications will always be using latest version of library.

Easier Onboarding

When a new developer joins your team, he/she will have to clone multiple git repos and understand the hierarchy whereas in monorepo approach, he/she will just have to git clone one repo.

No Impact on build times

We get to hear this argument from others having opposite opinion that in a monorepo, build times are higher since all libraries will need to be built all the time. However, with latest tools and advancements, build tools can cache previous builds and only build projects that actually need to be built using some heuristics.

Atomic Commits

When we create a release, we can tag the repo at that time, which means even after a year, if we git clone with the same tag name, we can recreate the same release packages. This would be difficult with multiple repositories since each repository would need to be tagged and who knows one might forget to tag one or the other repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment