Why use a monorepo?

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ม.ค. 2025

ความคิดเห็น • 123

  • @FabianVilersBe
    @FabianVilersBe 2 ปีที่แล้ว +302

    Well, that's more a "How" than a "Why"...

    • @frontendtony
      @frontendtony 2 ปีที่แล้ว +15

      The why is kind of implied

    • @FabianVilersBe
      @FabianVilersBe 2 ปีที่แล้ว +48

      @@frontendtony Yeah, but there's more to say about the pros and cons to adopt a monorepo and the video title is a bit misleading in that regard ;-)

    • @michaellee3502
      @michaellee3502 2 ปีที่แล้ว

      It improves the efficiency of your workflow so you spent more time programming and solving problems rather than administrating your repo

    • @LegitBanananas
      @LegitBanananas 2 ปีที่แล้ว +9

      Mono repo actually adds more administrative work not less in my opinion.

    • @GustavoDiaz93
      @GustavoDiaz93 2 ปีที่แล้ว +1

      Matt just wanted to show off his math package hahaha, I agree the “why” is implicit which means video’s title is clickbait (kinda).

  • @chandragie
    @chandragie 2 ปีที่แล้ว +16

    His way of explaining is on another level!

  • @BritainRitten
    @BritainRitten 2 ปีที่แล้ว +55

    I love Matt's explainers. Very clear

  • @kasraghoreyshi
    @kasraghoreyshi 2 ปีที่แล้ว +2

    I've been very happy with Turborepo and have been using it for almost every solo project that I do. I like it's simplicity and ease of use.

  • @BorisBarroso
    @BorisBarroso 2 ปีที่แล้ว +7

    You can also use *patch-package* which is very simple to use and you can regress the changes you have made once the repo has been updated and you see the problem you fixed is gone.

  • @codewithguillaume
    @codewithguillaume 2 ปีที่แล้ว

    Thanks for that my friend

  • @_vicary
    @_vicary 2 ปีที่แล้ว +13

    Despite not really explaining anything, I love how monorepo is bouncing back from the microservice era.

    • @mikopiko
      @mikopiko 2 ปีที่แล้ว

      Monolith for the win

    • @hojdog
      @hojdog 2 ปีที่แล้ว

      They're completely unrelated
      You can still have both a monorepo and microservices

    • @_vicary
      @_vicary 2 ปีที่แล้ว

      @@hojdog The era represents conventions and the hype within said period, like, living in COVID times doesn't make you COVID itself.
      I know, it's hard to believe.

  • @midlight25
    @midlight25 2 ปีที่แล้ว +24

    In my experience, monorepo if you're working alone and polyrepo if you're working as a team/group. But do be careful because monorepos, after they grow past a certain size, can cause tools like Git and other build tools to slow down/malfunction just because of the sheer amount of data they have to handle.

    • @hojdog
      @hojdog 2 ปีที่แล้ว +9

      I think you have it backwards. I single dev is more easily going to be able to manage polyrepos because they know when dependencies change.
      It’s big teams that get the most benefit from monorepos since dependencies change all the time and need to be kept in sync

  • @alir8zana635
    @alir8zana635 ปีที่แล้ว

    this video was great
    It really demostrates the use of Turborepo very well

  • @TFDusk
    @TFDusk 2 ปีที่แล้ว +13

    I don't really see the benefit on the why. Maybe I'm misunderstanding it but this at least to me seems like it would introduce more problems in the future since now your project would be responsible for maintaining the code that you're using. Sure the example your giving is simple, but depending on the work this can easily be some specific call function that is dependent on a slew of other dependencies in that packages repository that they use on the side. Unless the projects abandoned and you can't find a good alternative, I feel like its better to leave off package maintanence to the maintainers of that project, and just PR fixes to that branch even if it takes hours to push.

    • @sviatoslavnovosiadlyi611
      @sviatoslavnovosiadlyi611 2 ปีที่แล้ว +1

      I think it works well for that specific usecase. But if you have 10 apps using that library, having them all in 1 monorepo would be a mess.. Thanks but no

    • @justinoneill2837
      @justinoneill2837 2 ปีที่แล้ว

      Does a _hybrid_ workflow exist where you have a "maths" package inside a private monorepo but also "maths" in its own public repo on Github so others could contribute?
      I use Turborepo and love it- but I'm in a situation where we're creating packages inside a private monorepo that I also need in my personal monorepo. I need a way to share that same package in both, make updates in both and pull in changes in both.
      Is this possible?

  • @BackInTheDayTunes
    @BackInTheDayTunes 2 ปีที่แล้ว +5

    What if your maths package is being used on 3 separate projects? That would mean bundling the maths package with all 3? This looks like it would be useful but only when theres a 1 to 1 relationship between package and app. Or am I really missing something here?

    • @elvinchu
      @elvinchu 2 ปีที่แล้ว +1

      Yes I am thinking that also

    • @cookie_doki
      @cookie_doki 2 ปีที่แล้ว

      yeah it doesnt make sense really. why even make a package if its only in 1 repo? you can just use two repos in one workspace while you are working on the npm package.

  • @gmabber
    @gmabber ปีที่แล้ว

    I love your teaching style. You rock!

  • @FunctionGermany
    @FunctionGermany 2 ปีที่แล้ว +1

    doesn't this problem already have a "native" solution with npm link or patch-package??

  • @FacePlat3
    @FacePlat3 2 ปีที่แล้ว +5

    Thanks for the tutorial! If only this video was made before my suffering of having to publish and installing over and over again for my package, my life would have been easier 🤣.

  • @aleksd286
    @aleksd286 2 ปีที่แล้ว +10

    Haven't seen anything with nextjs with custom server (check NextJs docs/advanced-features/custom-server)
    That would be cool an example! Just saying. (Having huge troubles myself with it, its impossible to resolve workspace modules)

  • @CoryTheSimmons
    @CoryTheSimmons 2 ปีที่แล้ว +11

    TurboRepo half-heartedly supports Docker. It seems like an afterthought. Vercel doesn't support Docker at all. I'm not trying to be rude, but a monorepo having _something_ Docker is super common, and Render offers this. Does the TurboRepo/Vercel team have any plans for improving Docker support in the upcoming year?
    Specifically, I want to be able to put a docker-compose.yml in every app and/or package in my TurboRepo project, then deploy with something as simple as `$ vercel deploy`. I'd be sold for life.

    • @conor909
      @conor909 2 ปีที่แล้ว

      +1 on this

  • @Loserfr
    @Loserfr 2 ปีที่แล้ว +2

    My company has a monorepo with like 20 apps and I can't even block a PR if the CI doesn't pass (like for test or linter). I'm advocating for smaller multiple repos but they won't do it because "it would take too much time to migrate from one state to another".
    I don't see the point of a monorepo for more than 3-4 apps. I've worked in more than 15 stacks and still can't see any advantage of using a monorepo...

  • @gamertike
    @gamertike 2 ปีที่แล้ว +1

    what is the actual advantages of turborepo over pnpms built-in workspaces?

  • @QiuqiuVG
    @QiuqiuVG 2 ปีที่แล้ว +1

    How is the maths repo configured? Is the example published?

  • @grugbrain
    @grugbrain 5 หลายเดือนก่อน

    Cool! Wish you could make a more indepth video about turborepo monorepo and share more stuff like ts types/react hooks/state stores/api requests among multiple apps or even packages.

  • @RichiAndiProject
    @RichiAndiProject 2 ปีที่แล้ว

    hanks lot Sir.. You helping us..

  • @lsagar
    @lsagar 2 ปีที่แล้ว +1

    Been using nx workspace for mono repo,
    Love it so far

    • @sarunmrzn
      @sarunmrzn 2 ปีที่แล้ว

      horrible experience with nx for me, some guy set it up before i joined the project and now all i get are angular related threads anything related to nx

    • @lsagar
      @lsagar 2 ปีที่แล้ว

      @@sarunmrzn it took me a while to figure out how everything is wired up. Once i got a mental model of what's going on, I love it even more

  • @mikkurogue
    @mikkurogue 2 ปีที่แล้ว +5

    quick question;
    If I were to have my Azure pipeline covering my monorepo, and each successful build would become a release, would turborepo consider a cached build (so out of my 2 apps I have, App1 is cached and App2 has changes to be rebuilt, alongside a ui package for shared react components lets say) a succesful build and thus cause a re-deployment for both apps? this is what my team is currently struggling with. Or is there a way we could emit the cache hit/missed to our pipeline so we can then have that determine wether or not to re-deploy

    • @hassanalthaf8561
      @hassanalthaf8561 2 ปีที่แล้ว +1

      Hey, interesting question.
      This is pretty easy to solve with a mono-repo (there's a technology called Nx Monorepos). Our team picked Nx Monorepos because they ship with a "nx affected:*" command set that lets you to define what steps to follow when deploying on an individual app/library level through a pipeline by using the "nx affected:*" magic and only hitting the "deploy" process for apps/libraries that are TRULY affected by the change in your merge.
      However, you're right, it adds a load of trouble. It was a live and learn process for us, we still continue doing it.
      Would I recommend this? Depends. If you're just trying to bring in 2-3 repos into one mono-repo, then I'd say, not worth the trouble. If you have 5-10 repositories that you want to put together into 1 and each of them have decent changes frequently, then I'd say, yes, the pain of a mono-repo is worth it as you won't have to waste time publishing on one end, and then running your pipelines individually for each app for just bumping a package version.

  • @RicoRioss
    @RicoRioss 2 ปีที่แล้ว +1

    what happen if i have many project and many package, can it make slow on build or start app on development?

  • @seanki
    @seanki 2 ปีที่แล้ว +3

    Inefficient for huge applications that have complex CI pipelines for fixing this type of problem. There are also other aspects to what type of architecture fits best, depends on use case.

  •  2 ปีที่แล้ว +1

    why not use a "link"?

  • @jayshah5695
    @jayshah5695 2 ปีที่แล้ว

    should add a video in versioning strategies and publish workflows of libs and apps in monorepos

  • @kevinzunigacuellar
    @kevinzunigacuellar 2 ปีที่แล้ว +2

    Amazing video Matt!

  • @stunna4498
    @stunna4498 2 ปีที่แล้ว

    whats that vcscode letter theme-?

  • @Narblo
    @Narblo 2 ปีที่แล้ว

    What about a repo with submodules?

  • @ezaezaeza4743
    @ezaezaeza4743 2 ปีที่แล้ว

    Is there a real need to publish the package here ?
    On deployment, won't it be pulled from the monorepo directly ?

  • @sadev0
    @sadev0 2 ปีที่แล้ว

    great explanation

  • @Mitsunee_
    @Mitsunee_ 2 ปีที่แล้ว +1

    Got a bit of a more complicated migration (if I even bother at this point), I have a bigger project in a monolithic repo with multiple scripts (check, prebuild, svgo prepare scripts and such) and utilities shared between backend and those scripts so I'd need some packages to have binaries and couldn't get that to work with yarn 1.x so far and having types accesible outside of packages has already been confusing enough with my current workaround requiring d.ts files in the packages root directory (even tho types get generated into dist... alongside the build). I also already have the next app deployed to vercel, so I'd need to change those settings.

  • @justinoneill2837
    @justinoneill2837 2 ปีที่แล้ว

    Does a _hybrid_ workflow exist where you have a "maths" package inside a private monorepo but also "maths" inside a public monorepo that can be shared?
    I use Turborepo and love it- but I'm in a situation where we're creating packages inside a private monorepo that I also need in my personal monorepo. I need a way to share that same package in both, make updates in both and pull in changes in both.
    Is this possible?

  • @yoshinobuogawa9442
    @yoshinobuogawa9442 2 ปีที่แล้ว

    Hell yeah man good work

  • @mahavirsingh-rh2te
    @mahavirsingh-rh2te 2 ปีที่แล้ว

    yo bro, really thankya. Big respect

  • @shaohaolin517
    @shaohaolin517 2 ปีที่แล้ว

    Matt is hilarious 😊

  • @ishanksharma9051
    @ishanksharma9051 2 ปีที่แล้ว +1

    amazing video

  • @ahmedel-mahrouky5913
    @ahmedel-mahrouky5913 2 ปีที่แล้ว

    Installed, everything works, thanks!

  • @DaniAkash123
    @DaniAkash123 2 ปีที่แล้ว

    I hate the fact that I have to maintain a separate build step for packages inside my monorepo which I'm not going to publish anyway

  • @ultimaweap12
    @ultimaweap12 2 ปีที่แล้ว +2

    Ok, this is cool and all but what happens when another project needs to also use your maths repo?
    You pull it in my-monorepo as well?
    If it's a popular library in your company, I imagine that would get chaotic real quick.
    Also, what happens when there's ANOTHER library you want to use in the way you used maths repo? Let's say... foo repo.
    Foo repo already exists in another location, so by pulling into my-monorepo, you're just basically creating your own fork...
    It sounds like what you did in this video works great if you're making ONE application which requires ONE custom library, then you can tightly couple them together.
    Anything more complicated than that looks... messy.

  • @DanteMishima
    @DanteMishima 2 ปีที่แล้ว +10

    This video is a "how" not a "why"
    I get no reason why I should do this

    • @baka_baca
      @baka_baca 2 ปีที่แล้ว +5

      It's gone over pretty quick, but the reason he essentially gave was this (adding some things he missed to better highlight the overall point):
      Separate packages means that to make even a small change you need to open a new window, make the change, publish the change, then go back to your first project and install the new version once it's ready. If you're working on a team, then there's an entire extra pull request and all the delays that happen there. Your tiny 1 character change could take hours depending on how quick others are to approve the pull request. All the while, you are blocked from other work or need to install the package locally anyway to keep going...
      If you used a monorepo from the start... You'd just make your 1 character change and carry on. You might even find more meaningful changes to make for the next package version than just the 1 character change while developing if you're doing what is shown in the video.
      In other words, breaking everything into separate packages across codebases can take hours to do small changes whereas in a monorepo this happens in mere moments.

  • @ginger-viking
    @ginger-viking 2 ปีที่แล้ว

    great video!

  • @CoooLLer
    @CoooLLer 2 ปีที่แล้ว +2

    Write tests to not have that kind of problems.

  • @mahadevovnl
    @mahadevovnl ปีที่แล้ว

    So basically: you use a monorepo if you want to quickly develop multiple related projects together, of which one or multiple projects (in /packages) might also be published for others to use.
    My employer: "We will now dump everything into one massive monorepo and keep everything closed-source. All projects, related or not, go into one repository."
    Me: "... oh fuck, they're dumb."

  • @mma93067
    @mma93067 2 ปีที่แล้ว +1

    …git submodules exist tho

  • @OfficialProjectSMP
    @OfficialProjectSMP 2 ปีที่แล้ว +9

    ... or just pin versions and test your software.

  • @webcodeuniversity
    @webcodeuniversity 2 ปีที่แล้ว +5

    We can do "yarn link" for instance , Monorepo isn't always the answer, but I'm a big fun of Monorepo though😉, but good marketing 👍

    • @rand0mtv660
      @rand0mtv660 2 ปีที่แล้ว +2

      yarn/npm link is not powerful as this and it's more clunky to work with. Just linking cannot really detect dependencies and rebuild stuff in such a way that a monorepo setup with Turborepo or NX can.

    • @webcodeuniversity
      @webcodeuniversity 2 ปีที่แล้ว

      @@rand0mtv660 I know, but not in all use cases we'll have to use a monorepo, it just doesn't make any sense, it all ends on what you really need and if things need to setup a monorepo, I'm not against it as I'm using it as well in some projects, not all of them 🙃

    • @rand0mtv660
      @rand0mtv660 2 ปีที่แล้ว +2

      @@webcodeuniversity Yeah for sure. I'm just saying that yarn link isn't really an equivalent to a monorepo. But what you are saying is definitely correct. Each tool has its purpose and monorepo isn't always the solution.

    • @webcodeuniversity
      @webcodeuniversity 2 ปีที่แล้ว +1

      ​@@rand0mtv660 sure thing, I agree. I mentioned "yarn link" just to say that monorepo isn't the right thing for everything, because I know some less experienced devs would take it for granted which is misleading. Thanks for your intervention though, it's been nice conversation 🤝

  • @lucavogels
    @lucavogels 2 ปีที่แล้ว +15

    This seems much more work and looks way more complicated than just having two dedicated repos 😅

    • @conor909
      @conor909 2 ปีที่แล้ว +6

      Use a monorepo and then come back and say this

    • @cookie_doki
      @cookie_doki 2 ปีที่แล้ว

      exactly. you dont need a monorepo to use workspaces. you can just add two repos to one workspace.

    • @conor909
      @conor909 2 ปีที่แล้ว

      But then how do you share all the common build tools and configuration with team members?

    • @cookie_doki
      @cookie_doki 2 ปีที่แล้ว

      If you need to share the workspace config you can make that a repo as well. Not 100% sure how turbo will handle that but with yarn workspaces git will not commit every file from the individual repos. It just stores what commit each child repo is on and then you can commit your workspace config. IMO this makes way more sense when a package is being used in a lot of different projects. You can easily add and remove repos to and from your workspace.

    • @conor909
      @conor909 2 ปีที่แล้ว

      @@cookie_doki I don’t see how that’s useful, if your code and packages aren’t all shared amongst each other and you can work in isolation happily, then you don’t need a monorepo

  • @cruelplatypus67
    @cruelplatypus67 2 ปีที่แล้ว +3

    Why use monorepo?
    To confuse yourself in future

  • @arturamorfati
    @arturamorfati ปีที่แล้ว

    nice acting, my man😎

  • @EdwinMartin
    @EdwinMartin ปีที่แล้ว

    I think many go for a monorepo only because they don’t know the npm link command.

    • @zuma206
      @zuma206 8 หลายเดือนก่อน

      but npm link only works in development

    • @EdwinMartin
      @EdwinMartin 8 หลายเดือนก่อน

      @@zuma206 You don’t need npm link in production. In production you just import the packages.

  • @fredericorinco9133
    @fredericorinco9133 2 ปีที่แล้ว

    Superb acting on the + and - part. I truly believed you were capable of cocking up so badly. Have you considered Hollywood? On my way to update it to 0.0.4 to fix my apps.

  • @DuyTran-ss4lu
    @DuyTran-ss4lu 2 ปีที่แล้ว

    Cool

  • @0xpatrakar
    @0xpatrakar 2 ปีที่แล้ว

    Or use submodules

  • @babakfp
    @babakfp 2 ปีที่แล้ว +1

    I don't like examples that doesn't make sense :|

  • @ordinarygg
    @ordinarygg 2 ปีที่แล้ว +1

    Awesome, first create a problem, then rollback to what worked for decades xD. JS devs are not changing)))

  • @arekxv
    @arekxv 2 ปีที่แล้ว

    Why not just use git submodules? There is a thing already made for it. Everything is already there.

  • @Yutaro-Yoshii
    @Yutaro-Yoshii 2 ปีที่แล้ว

    this is actually a solid alternative to using git submodule

  • @nishantshah_
    @nishantshah_ 6 หลายเดือนก่อน

    It is june 2024, is this concept dead?

  • @thekwoka4707
    @thekwoka4707 2 ปีที่แล้ว +1

    The real nightmare here is that you're bundling esm to cjs to use in an ESM project.

  • @Dampfaeus
    @Dampfaeus 2 ปีที่แล้ว

    That was a great explanation. That said, it would have been better to deploy a static .html file.
    Before anyone comments on this being a very small, non-practical example, let me just prelude that static .html files without ads also work on real projects.

  • @orenmizr
    @orenmizr 2 ปีที่แล้ว

    hi, the app now has workspace * . won't it pull the latest all the time ? what about production? no version pinning ?

  • @a89529294
    @a89529294 2 ปีที่แล้ว

    🤴

  • @neil_from_future
    @neil_from_future 2 ปีที่แล้ว +1

    I'm not always watch those video because explanation felt too quick, zoom out zoom in without any word explanation where you at and why use this... But at least I have more knowledge, but not understand. This just like intro video not a "make your monkey brain understand this" type of video.

  • @mbehboodian
    @mbehboodian 2 ปีที่แล้ว

    Jason Statham?!

  • @saichand5752
    @saichand5752 2 ปีที่แล้ว +2

    Explanation felt too quick, need to slow down maybe

  • @StephenRayner
    @StephenRayner 2 ปีที่แล้ว

    Edit video title to how… not why. And you should consider using yarn workspaces and yarn PnP

  • @swyxTV
    @swyxTV 2 ปีที่แล้ว +5

    instructions unclear, in AMERICA we use MATH not MATHS, there is only one MATH and ours is it

    • @mattpocockuk
      @mattpocockuk 2 ปีที่แล้ว +2

      I AM WHO I AM

    • @z-aru
      @z-aru 2 ปีที่แล้ว

      AAUUUGGHHH

    • @baka_baca
      @baka_baca 2 ปีที่แล้ว

      Maths makes just as much sense as mathematics (which is also plural).
      In America, we kind of have a "mathematic" idea to go with our "math". As a fellow American, we might just be the weird ones here :).
      But, same same but different...

    • @Momo-vy4xw
      @Momo-vy4xw 2 ปีที่แล้ว

      My guy here must be using python_communism on a daily basis

  • @45g4rerf45f45
    @45g4rerf45f45 2 ปีที่แล้ว

    JavaScript nightmare

  • @isakthehackervlogs
    @isakthehackervlogs 2 ปีที่แล้ว

    This looks like a really bad and inefficient way to do thing if I am being honest

  • @DevinRhode2
    @DevinRhode2 2 ปีที่แล้ว

    Sorry, I really hate these 1+1 !== 2 examples. I immediately start checking out. Then, I hear about npm publish is too painful, my immediate response is, no, it's not too painful. The basis of 1 + 1 not being 2 is just not sound. Yes, give us a fictionalish example, but, I definitely don't like the 1+1 !== 2. Just one opinion tho, maybe I'm the outlier!!

    • @exactzero
      @exactzero 2 ปีที่แล้ว +1

      Hmm.. how about 2+2 !== 3?

    • @Dxpress_
      @Dxpress_ 2 ปีที่แล้ว +1

      Well, fixing the obvious "1 + 1" bug isn't the point. The point is about different ways to manage dependency versions across a repository. I.E: Multiple repositories VS. one mono-repo.
      The "1 + 1" bug is only there to serve the purpose of needing to release a new version of a project. Migrating to that new version is the actual example.
      Granted, I do feel like this video missed the point it was trying to make also. Like other comments say, it's just showing you "how" to utilize a mono-repo, not "why" you should.