So you can still have a monorepo and you can still have microservices, for example, inside of the monorepo. The only difference from a monorepo to a multirepo approach is actually that you have all your apps or packages, libraries inside of the same repository.
But then you might ask yourself, why do I need to have a monorepo? Why do I need to put all my code together in the same repository instead of having them separately in individual repositories? There must be a good reason for other companies doing that, right? Like why monorepos are so hot in those companies, for example, Google, Netflix, Facebook, and Twitter, they all use monorepos in some shape or form. And there must be very good reasons for them not to go with the multi-repo approach, right? And let's talk about them.
The first one is actually code reuse. If you have everything under the same repository, then it's much easier for you to share code with your teammates. Like think about it, you could have a modules package where you have all your database modules, and you can also have a package there with your UI components. And then everybody else in your team can just reuse them without having to reinvent anything or to re-import anything or to install any extra package.
The other reason you might want to consider a monorepo is to have shared standards. In a monorepo, you can actually have true shared standards across your code base. Because think about it, you could have a yeslin config where it's completely share across all the packages, and then you can update in one single place. And then every other package can benefit from it immediately. So if you're using TypeScript, for example, you can have one single TypeScript configuration shared across all of your projects. So it was also very easy to adopt and share stuff among the packages inside of the monorepo.
Another thing that works really well in the monorepo setup is team collaboration. So if you have everything under the same repository, you can easily share a pull request with other engineers and get feedback because they have already all the context around the code base. They don't have to set up anything. They don't have to install a different node version. They don't have to set up any SDK in the machine or anything like this because they have been working in the same code base. They have every tool installed already. So they don't have to figure out anything. If you need to do a pair programming session, for example, it's just much easier to do it. You can just share a screen, fire up the dev server, and then everything is in there. You don't need to clone anything. You don't need to do any setup. It's just much easier and much faster for a big team.
Another big selling point for monorepo is atomic changes. If you have a single repository, you can actually change several different apps and packages at the same time, in the same pull requests. This way, you can actually guarantee that everything is going to work together.
Comments