guid 利弊_利弊monorepos解释

guid 利弊

什么是Monorepo?(What Is Monorepo?)

As the name suggests, Monorepo (mono repository) is an architectural pattern where a single repository will contain all the code for a given project.

顾名思义,Monorepo(单一存储库)是一种架构模式,其中单个存储库将包含给定项目的所有代码。

In other words, you can have several apps in one repo. You can either have a website code base, mobile app code base, etc. in a single repo. Or you can also have a single repo that contains several different modules of a complex application, where each module is an isolated app.

换句话说,您可以在一个存储库中包含多个应用程序。 您可以在单个存储库中拥有网站代码库,移动应用程序代码库等。 或者,您也可以拥有一个包含一个复杂应用程序的几个不同模块的单个存储库,其中每个模块都是一个独立的应用程序。

Monorepo vs.Multirepo (Monorepo vs. Multirepo)

As I said before, Monorepo keeps everything in a single repo. Multirepo (aka Polyrepo), on the other hand, has one repository per project. If there are four projects, there will be four repositories.

就像我之前说的,Monoropo将所有内容保存在一个回购中。 另一方面,Multirepo(又名Polyrepo)在每个项目中都有一个存储库。 如果有四个项目,那么将有四个存储库。

使用Monorepo的优势 (Advantages of Using a Monorepo)

Using a Monorepo architecture pattern has several advantages. Let’s look into them:

使用Monorepo架构模式具有多个优点。 让我们看看它们:

  • One source of truth — Instead of having a lot of repositories with their own configs, we can have a single configuration to manage all the projects, making it easier to manage.

    真理的来源-与其拥有大量具有自己配置的存储库,不如让我们拥有一个配置来管理所有项目,从而更易于管理。

  • Code reuse — If there is a common code or a dependency that has to be used in different projects, we can actually share them easily.

    代码重用-如果必须在不同项目中使用通用代码或依赖项,我们实际上可以轻松地共享它们。

  • Transparency — It gives us visibility of code used in every project. We will be able to check all the code in a single place.

    透明度-它使我们可以看到每个项目中使用的代码。 我们将能够在一个地方检查所有代码。

  • Atomic changes — We can make a single change and reflect the changes in all the packages, thus making development much quicker.

    原子更改-我们可以进行单个更改并在所有程序包中反映更改,从而使开发更快。

使用Monorepo的缺点 (Disadvantages of Using a Monorepo)

When there are advantages, there should also be some disadvantages. Let’s have a look at a few disadvantages:

当有优点时,也应该有一些缺点。 让我们看一下一些缺点:

  • Unable to restrict access — Every member who has access to the repo will have access to view all the code. There’s no way to restrict some parts of the app, which is irrelevant to the user.

    无法限制访问-每个有权访问该存储库的成员都将有权查看所有代码。 无法限制应用程序的某些部分,这与用户无关。

  • Long build times — Since there is a lot of code in one place, the build time is much longer compared to building separate projects independently.

    较长的构建时间-由于在一个地方有很多代码,因此与独立构建单独的项目相比,构建时间要长得多。

  • Git performance — Since the whole code is in one place, and since a lot of developers commit and work together over the same repo, there are a lot of commits that are tracked by Git. Since the number of commits is huge, Git’s performance becomes slow as the history deepens.

    Git性能-由于整个代码位于一个地方,并且由于许多开发人员在同一个存储库中进行提交和协同工作,因此Git会跟踪许多提交。 由于提交的数量巨大,因此随着历史的加深,Git的性能会变慢。

使用Monorepo的公司 (Companies That Use Monorepo)

A lot of top companies use Monorepo. Some of them include:

许多顶级公司都使用Monorepo。 其中一些包括:

  • Google

    谷歌
  • Facebook

    脸书
  • Microsoft

    微软
  • Uber

    优步
  • Airbnb

    爱彼迎
  • Twitter

    推特

Monorepo工具(Monorepo Tools)

Monorepo tools provide several functionalities, such as bootstrapping and linking the local packages among themselves, building the code, validating them, publishing them to a package registry, etc. Some of the most popular tools are:

Monorepo工具提供了几种功能,例如引导程序和相互链接本地软件包,构建代码,对其进行验证,将它们发布到软件包注册表等。一些最受欢迎的工具是:

  • LernaLerna is a tool used to manage JS projects with multiple packages. It is built on Yarn.

    LernaLerna是用于管理具有多个软件包的JS项目的工具。 它基于纱线。

  • BazelBazel is a monorepo build system built by Google.

    BazelBazel是由Google构建的monorepo构建系统。

  • Yarn — Yarn is a JS dependency management tool that also supports monorepos through workspaces.

    Yarn -Yarn是JS依赖项管理工具,它还支持通过工作区的monorepos。

  • NXNX is a set of extensible dev tools for monorepos.

    NXNX是用于monorepos的一组可扩展开发工具。

  • RushJSRushJS is another tool that should support the full lifecycle of monorepos. It’s developed by Microsoft.

    RushJSRushJS是另一个工具,应支持monorepos的整个生命周期。 它是由Microsoft开发的。

我应该选择这种方法吗? (Should I Choose This Approach?)

Monorepos are just a tool that has its own advantages as well as disadvantages. In fact, this approach has definitely made the life of developers easy when compared to Multirepo. However, it has still issues that I hope will be resolved in the future.

Monorepos只是具有自己的优点和缺点的工具。 实际上,与Multirepo相比,这种方法绝对简化了开发人员的工作。 但是,它仍然存在一些问题,我希望将来能够解决。

I believe I’ve explained a bit about Monorepo, and by now, you have a good understanding of how it works. According to me, whether you should use it depends on the application that you are building. If there are a lot of dependencies in common and if you need to share code, this would be a good approach. Anyways, I’ll leave this answer to you, as it completely depends on your application’s needs.

我相信我已经对Monorepo进行了一些解释,到目前为止,您已经对Monorepo的工作原理有了很好的了解。 据我说,是否应该使用它取决于您正在构建的应用程序。 如果有很多共同的依赖项,并且需要共享代码,那么这将是一个好方法。 无论如何,我将把这个答案留给您,因为它完全取决于您应用程序的需求。

I hope this article was helpful. Thanks for reading!

希望本文对您有所帮助。 谢谢阅读!

翻译自: https://medium.com/better-programming/the-pros-and-cons-monorepos-explained-f86c998392e1

guid 利弊

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值