Managing opensource repositories in a monorepo project

Typescript Oct 08, 2020

The monorepo approach is a source management strategy where all the components of a product (backend, frontend, etc.) are all managed in a unique Git repository. We are working with monorepo at Onna, and as this practice is pretty common nowadays, it was not difficult to find efficient tooling to support it (on the frontend side, we use Nx).

But, our product is also involving opensource libraries we are maintaining. For example, Pastanaga, our UI library, is opensource. We could use it as a regular NPM dependency, but as we are implementing new Pastanaga UI components while developing our product, it is much more convenient to use the sources within our project.

To do so, we could use Git submodules, but it often ends up to be painful, either regarding the developer experience, either regarding the CI chain (either both!).

Our solution is mrs-developer.

mrs-developer is an NPM utility able to check out external Git repositories in our project source tree and declare them to the Typescript compiler as actual packages. we just have to run:

$ missdev

to get the external dependencies properly deployed in our monorepo project.

Its configuration file allows to declare the needed dependencies by targeting either a branch either a tag. It is extremely flexible and fits perfectly with our development flow.

We can work on a feature branch in our monorepo and if implies some changes in our opensource dependencies, they will also be implemented in a feature branch, the mrs-developer configuration just has to reference that branch.

The monorepo production branch at the contrary will reference tags for each external dependency.

The missdev command is executed in our CI tool so any build gets the expected version of each dependency.

Note: mrs-developer is an opensource project which Onna is actively contributing to.

Tags