|
|
|
## Monorepo
|
|
|
|
### What is Monorepo?
|
|
|
|
Definitions vary, but we define a monorepo as follows:
|
|
|
|
|
|
|
|
The repository contains more than one logical project (e.g. an iOS client and a web-application)
|
|
|
|
These projects are most likely unrelated, loosely connected or can be connected by other means (e.g via dependency management tools)
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
### Benefits
|
|
|
|
* Ease of code reuse
|
|
|
|
* Simplified dependency management
|
|
|
|
* Atomic commits, Faster builds
|
|
|
|
* Large-scale code refactoring
|
|
|
|
* Closer Collaboration across teams
|
|
|
|
|
|
|
|
### Build Tools
|
|
|
|
* [Bazel](https://github.com/bazelbuild/bazel) (Google)
|
|
|
|
* [Buck](https://buck.build/) (Facebook)
|
|
|
|
* [Pants](https://www.pantsbuild.org/) (Twitter)
|
|
|
|
* [Nx](https://nx.dev/)
|
|
|
|
* [Please](https://please.build/)
|
|
|
|
|
|
|
|
## Bazel
|
|
|
|
Bazel is an open-source build and test tool similar to Make, Maven, and Gradle.
|
|
|
|
It uses a human-readable, high-level build language. Bazel supports projects in
|
|
|
|
multiple languages and builds outputs for multiple platforms. Bazel supports
|
|
|
|
large codebases across multiple repositories, and large numbers of users.
|
|
|
|
|
|
|
|
Bazel offers the following advantages:
|
|
|
|
|
|
|
|
* **High-level build language.** Bazel uses an abstract, human-readable
|
|
|
|
language to describe the build properties of your project at a high
|
|
|
|
semantical level. Unlike other tools, Bazel operates on the *concepts*
|
|
|
|
of libraries, binaries, scripts, and data sets, shielding you from the
|
|
|
|
complexity of writing individual calls to tools such as compilers and
|
|
|
|
linkers.
|
|
|
|
|
|
|
|
* **Bazel is fast and reliable.** Bazel caches all previously done work and
|
|
|
|
tracks changes to both file content and build commands. This way, Bazel
|
|
|
|
knows when something needs to be rebuilt, and rebuilds only that. To further
|
|
|
|
speed up your builds, you can set up your project to build in a highly
|
|
|
|
parallel and incremental fashion.
|
|
|
|
|
|
|
|
* **Bazel is multi-platform.** Bazel runs on Linux, macOS, and Windows. Bazel
|
|
|
|
can build binaries and deployable packages for multiple platforms, including
|
|
|
|
desktop, server, and mobile, from the same project.
|
|
|
|
|
|
|
|
* **Bazel scales.** Bazel maintains agility while handling builds with 100k+
|
|
|
|
source files. It works with multiple repositories and user bases in the tens
|
|
|
|
of thousands.
|
|
|
|
|
|
|
|
* **Bazel is extensible.** Many [languages](rules.html) are
|
|
|
|
supported, and you can extend Bazel to support any other language or
|
|
|
|
framework.
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
### Drawbacks
|
|
|
|
One of the major drawback of Monorepo is its size, as all components are in single repo.
|
|
|
|
1. Git sparse-checkout
|
|
|
|
2. Github codespace
|
|
|
|
|
|
|
|
|