DEV Community

Erik Guzman
Erik Guzman

Posted on

Zeal 11/1/2019 - Learning Lerna with Matti

Checkout the stream @ https://www.twitch.tv/codingzeal

What the VOD of the whole stream to follow along:
https://www.twitch.tv/videos/502681554

Today Objectives

  • [x] Learn about Lerna
  • [x] Learn about mono-repos

Notes

  • Mono-repos: Some reason why you might one to use them.
    • One place to test and manage packages
    • One place to file and manage issues
  • If you want to customize your create-react-app webpack con
  • esm - YOU DONT HAVE TO USE BABEL WITH THIS!!! https://www.npmjs.com/package/esm The brilliantly simple, babel-less, bundle-less ECMAScript module loader.
  • Level up your command line with more information: https://starship.rs
  • Lerna
    • Help manage multiple package in your mono-repo
    • If you use Yarn workspaces with lerna it will host all dependencies to top level for you. Reduces a lot of node_modules to install
      • Just have to tweak lerna.json and package.json to make the dream happen
    • create-react-app for yarn workspaces, if doesnt work out of the box
    • Something to look over about using lerna with Rails and React front-end, maybe good idea?
    • Commands: https://github.com/lerna/lerna/tree/master/commands
      • npx lerna init - to generate you project
      • lerna create common - scaffolds out package, like npm init
      • lerna import - Import existing packages into lerna for you
      • lerna exec — command_to_run - Runs a shell command in all packages
      • lerna add package_name —scope={other_packge_name} - Add a package dependency and link to other packages in lerna
      • lerna bootstrap - like yarn/npm install
        • lerna bootstrap —hosit - "Hoists" up common dependencies to top level node_modules
      • lerna diff - Like git diff between release version
      • lerna ls - Show public packages for your repos
      • lerna add package_name - Installs a package to all projects
        • lerna add —scope={packages_to_instal_to, another_package}
      • lerna clean - Automatically delete node_modules in all packages
      • lerna run command_name - Runs a package command in all your packages

Shoutouts and Thanks

  • Matti for walking us through lerna and monorepos AND having some great examples to work through

Future action items

  • [ ] Try out lerna on my own projects!!!!

Top comments (0)