People think monorepos are hard to understand and don't know much about them. That's why you don't hear about them much, but it's all wrong. One of the biggest companies in the world, Facebook, is a great example of a monorepo codebase.
Before I go any further, I want to clear up some confusion about monorepos, multirepos, and monolithic codebases. Monorepos can handle any number of microservices in a single codebase, which is amazing. You can easily convert a multirepo into a monorepo by just merging the repos into a single one. Easy peasy!
Now, let's talk about monolithic codebases. Monorepos make it easier to share code and refactor projects across multiple codebases. They also lower the cost of creating libraries, microservices, and microfrontends.
So, there you have it! Monorepos are not as hard to understand as people think. They're actually quite useful and can save you a lot of time and money.
misconceptions:
Another team can break my app or change the codebase without knowing: The developers knew this could happen hence there are various check related to this and various tools allows us to configure ownership of the folder.
Hard to manage the codebase of multiple repos in one.
It is hard to scale and even harder to implement the development phase.
I know I covered the misconceptions part before as you might have heard it part which doesn't excite you and puts you in a dilemma about whether you should learn or not. But let's dive deep into the actual meaning of it and the beauty of monorepo.
Monorepo is an architectural concept that keeps your code organized in one place. It's the opposite of a monolithic app, which is a single app that contains all of your code. With monorepo, you can have multiple apps in one repository, like a website and its iOS app. This can be helpful for keeping your code organized and making it easier to work on multiple projects at once.
WHY THE BUZZ
Dependency Management: All the modules of the repository are hosted in the package itself. Hence need for a package manager is important.
Conflicting Versions: All the packages required for the project are of one version as there is no need to have different modules in a monorepo.
Atomic Commits: It allows for a larger scale refactoring. Hence allowing updates of several packages or projects in a single commit.
Unified CI/CD, Build process
For Further Read Click on me
Multiple open-source projects use monorepo for development and package distribution.
A company like NixOS: For publishing packages.
Projects like React, Ember and Babel all use monorepo.
Let's discuss a crucial part of monorepo and how to effectively utilize it.
Bazel: Developed by Google, it supports many languages and is capable of building and testing at scale.
Lerna: Integrates with popular framework.
Projects like React, Angular and Babel.
I have discussed all the good parts of monorepo, Now let's discuss the disadvantages of it.
Monorepos are tough on DevOps toolchains because:
Long waits cause the queues to back up.
Any errors will make the problem worse.
A monorepo can be so big that it takes up more than one disk drive.
Many tools create super large files.
In other words, monorepos can be a pain in the neck.
TurboRepo is a build system that integrates the monorepo structure and accelerates development by 10x. It was created by Vercel, the team behind Next.js. This implies that they are experts in web technologies, modules, and the resources required to run apps.
So, should you use a monorepo?
The answer depends on a lot of factors, like your company's needs, work culture, and how you want your team to communicate.
Monorepos are great for open and collaborative cultures, where teams are working on multiple projects that share code. They can also be helpful for enforcing code style and rules across the entire company.
But monorepos can also be complex and difficult to manage, especially if you have a lot of code. And they can be less efficient for teams that need to work on independent projects.
If you're not sure if a monorepo is right for you, it's worth talking to your team and doing some research. There are pros and cons to both monorepos and multirepos, so the best solution will vary depending on your specific needs.
Here are a few things to consider when making your decision:
The size of your codebase
The number of projects you're working on
The level of collaboration you need
Your team's comfort level with complexity
Your budget
Once you've considered all of these factors, you can make a decision that's right for your team.
References for you to read more.
Toptal | monolithic != monorepo | monorepo? | Comparisons
Feel free to hit me up on Twitter or connect with me on LinkedIn if you like this.
Top comments (0)