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

Managing monorepos with Lerna

Managing monorepos with Lerna

Monorepos are useful but they are difficult to manage. Lerna is a tool to simplify your daily work with JS monorepos.

I gave this talk in the SevillaJS meetup. You can watch it in spanish in https://youtu.be/y8MGSdaPlS8.

Ángel M

April 26, 2018
Tweet

More Decks by Ángel M

Other Decks in Programming

Transcript

  1. What's a monorepo? A monorepo is a single repository that

    hosts more than one individual project
  2. Who uses monorepos? "Facebook’s main source repository is enormous—many times

    larger than even the Linux kernel, which checked in at 17 million lines of code and 44,000 files in 2013." Facebook team
  3. Why monorepos? • Single source of truth • Simplify the

    management of dependencies • Minify the issues with cross-project changes • Improve integration testing
  4. Where's the poop? • Need specific tooling to work with

    it • High operation times • Tagging could be a mess • Large files • …
  5. So, should I migrate all my code to a monorepo?

    Nope. Just use a monorepo when it makes sense for you. You can have several monorepos
  6. HEx challenges • Keep all the code in the same

    repo • Support several "compilation" pipelines • Manage cross-dependencies • Generate separate assets and packages • Versioning • Be able to add more packages in the future
  7. HEx packages Project Dependencies Pipeline npm hex-core - gulp* yes

    hex hex-core gulp* yes hex-js - webpack yes hex-docs hex, hex-core gulp** nope
  8. Every package inside the packages folder is an independent project.

    All of them have their own package.json file lerna init
  9. Check the changes you are going to deploy in the

    new version lerna diff && lerna updated
  10. lerna publish 1. Run ~lerna updated to get updated packages

    2. Increment versions 3. Update dependencies 4. Create a commit and a tag 5. Publish the packages to npm