Should I share packages on Turborepo?

I have 2 clients on my app, and I notice they literally have almost all the same dependencies. What I havent understood well about monorepo is about sharing dependencies, I have a package.json at Root of the project and each one for each project. Yesterday I had to import one package that I didnt had on a specific project but had in other and it work without install and I was WTF I see the right way of working is: - Dependencies which are in more than one project set on the package.json root and the specific ones on the project itself but what about deploying? will vercel for example find these dependencies or should I extend the package.json root somehow somwhere is that the right way to handle dependencies in a monorepo?
5 Replies
Rafael Corrêa
Monorepos share their packages instantiating them on the root node_modules, there are many tools that allow you to sync dependencies on a monorepo too. Also, avoid putting project level packages in package.json root, in the root its usually indicated to put global scope packages (such as linting).
kevinka
kevinka2y ago
Thank you! So you saying that doesnt matter if multiple projects has the same dependencies on it, Turborepo will handle them for me? what tools to sync you meant?
Rafael Corrêa
Yes, not actually turbo, I think that is a package manager level of organization (yarn, npm, dont use pnpm with monorepos). Thats why you also need to be careful with versioning, because if there is different versions, it will start to create a mess. tools: syncpack, taze (there are many others, but I use those)
kevinka
kevinka2y ago
hmmmm! make sense. any article or something talking better about package managers do you recommend? for me they are just for installing/removing packages and cache it lol
Rafael Corrêa
I usually go with yarn, they are really good at resolving dependencies in monorepo. Also allowing you to self reference packages inside its context, so you don't actually have to transpile/move/publish code.
Want results from more Discord servers?
Add your server