nrwl / monorepo.tools

Your defacto guide on monorepos, and in depth feature comparisons of tooling solutions.
https://monorepo.tools
MIT License
290 stars 31 forks source link

Integrate Yarn 3 #40

Closed adrienharnay closed 2 years ago

adrienharnay commented 2 years ago

Hello,

I just found your website after integrating a monorepo with Yarn 3, and I feel it could compare against other solutions. I would understand why Yarn 1 or 2 are not present, but is there a specific reason Yarn 3 has been omitted?

Thank you for your great website and have a nice day, Adrien

bcabanes commented 2 years ago

Hi @adrienharnay Thank you for your comment and need of clarification on this domain, I actually think we should have a section on the website explaining the sentiment about using only Yarn/PnPm workspaces for a monorepo setup.

Even if they can work for some projects and folks, answering their need at the time, we wouldn't really qualify these as "monorepo solution" since they lack all the features for managing and scaling a monorepo. They are, though, an intrinsic element of monorepos by handling all the Nodejs dependencies (aka node_modules), whatever the tool being used.

Let me explain a little deeper

First let see what these tools are, Yarn and Pnpm are Nodejs dependency manager tools. They are alternatives to the default Npm command delivered with Node by default. With the latest versions, these tools are better and give you more features in the management of your dependencies. Specifically Yarn 3 (Berry) that now allows you to have a thing called "Zerro Install" and "Plug'n'Play" to make everything even faster since your dependencies are basically now Gitted.

They also introduced the concept of workspaces. These workspaces are basically a way to have multiple folders containing your source code for apps & libs with each one a package.json. The main goals behind this concept is to deduplicate the number of packages downloaded for each projects you have in the repository and to link your projects together to have a coherent way to think about them.

Example, if you have 2 projects (folders) that use the same dependencies with the same versions, like reactjs, Yarn will download only the reactjs package once then will reference these 2 projects dependencies to the root node_modules. It will make the installation of packages faster since you only need to download one and only one package. They also allows you to link project references which can help you using your own code as if it was a published package (but this is limited).

More information on Yarn workspaces here: https://yarnpkg.com/features/workspaces#what-does-it-mean-to-be-a-workspace

This is great and this is something that can be used in a monorepo by folks for small project or if they only want to have project linking setup in their repository. Though, as soon as you want to do more with your monorepo, you will lack many features for scaling your monorepo and have the best possible outcome.

Yarn/Pnpm have to be complemented by other tools to add the CI/CD and Developer Experience layers & capabilities for a monorepo to be usable and scalable. You can add these manually, one by one, even creating them from scratch or trying to find other packages that help you achieve them. There are also dedicated monorepo tooling which exists specially for that and the main goal of monorepo.tools is to make these tools more visible.

Using monorepo tools on top of Yarn and Pnpm will allow you to have:

For this reason, we can not put Yarn or Pnpm in the comparison table since they would lake all the features we need to manage at scale a monorepo.

Though, we will probably be adding a new section to website to talk about this.