Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Monorepos in the Wild

Monorepos in the Wild

Managing multi-package Node.js projects using a Monorepo approach and Lerna

Avatar for Markus Oberlehner

Markus Oberlehner

May 11, 2017

Other Decks in Programming

Transcript

  1. About me • (Frontend) Web Developer @ karriere.at • Web

    Tinkerer @ github.com/maoberlehner (node-sass-magic-importer, avalanche,…) • Blogger @ markus.oberlehner.net 13.01.18 2
  2. Multiple projects in a single repository • A single repository

    containing the code of multiple projects • Projects may or may not be related • Projects can be dependents of each other (e.g. React and react-dom) 13.01.18 4
  3. Examples for Monorepos • The code of a website, apps

    and an API in a single repository • All the code and assets of a (tech) company in a single repository • The core functionality and related components in a single repository 13.01.18 5
  4. Modular code & monolithic source control • Modular open source

    projects are using Monorepos • Micro services based infrastructures are built using Monorepos 13.01.18 9
  5. The best of two worlds • Modular code is easier

    to share and reuse • Code in a single repository is easier to maintain and refactor • Monolithic source control != tightly coupled code • Code in a Monorepo can be modular and maintainable 13.01.18 10
  6. Cons • Increased codebase complexity • Potential scaling problems •

    Harder to implement access control • Potential build and test bloat 13.01.18 12
  7. Pros • One source of truth • Extensive code sharing

    and reusing • Large scale refactoring made easy • Easier collaboration across teams 13.01.18 13
  8. Monstrous Monorepos • All the code of a (tech) company

    is stored in a single repository • Twitter: Git fork, several GB • Facebook: Mercurial, over 50GB • Google: Piper, Clients in the Cloud, over 90TB 13.01.18 15
  9. Project Monorepos • The core functionality and optional components in

    a single repository • Components may depend on each other • Examples: React, Babel, Ember, Symfony,… 13.01.18 16
  10. Babel • 100+ components managed in one Monorepo • Uses

    Lerna to manage the multi-package repository • Fixed versions, all packages have the same version number • Packaging via NPM 13.01.18 17
  11. Symfony • 30+ components managed in one Monorepo • Combination

    of Monorepo and Manyrepo approach • Automatic generation of read-only Manyrepos with splitsh • Packaging via Composer 13.01.18 19
  12. Modular SASS framework avalanche • 40+ NPM packages / 40+

    GitHub repositories • Major refactoring would have been very hard to do • Tooling (linting, testing,…) repeated in every repository 13.01.18 21
  13. Basic Lerna workflow 13.01.18 27 • Install (cross) dependencies •

    Publish new releases of (modified) packages
  14. Summary • Monolithic source control != monolithic software • Two

    types of Monorepos • Tools: splitsh, Lerna 13.01.18 29