What
A single repository holding the code of multiple projects .
What
A tool that helps you manage multi-package Monorepos with Git and npm
Created by Babel contributors to help them manage 100+ babel packages.
Why
Teams collaborate more efficiently.
Why
React Web app A - website
React Web app B - chrome extension
React native Mobile app
Shared view components
Style guide app
Graphical assets library
Utilities ( validators / parsers / middleware… )
Microservices
Why
Who
How
npm install -g lerna
git init my-mono-repo && cd my-mono-repo
lerna init
How
How
How
lerna init -i
How
{
"packages": [
"packages/*"
],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true
}
{
"name": "root",
"private": true,
"devDependencies": {
"lerna": "^3.13.4"
},
"workspaces": ["packages/*"]
}
How
lerna bootstrap
How
lerna publish
How
lerna import <path-to-external-repository>
How
lerna run <npm script> -- [...args]
lerna run build
lerna run start --scope "foo-*"
lerna run watch --parallel --stream
How
lerna exec -- <shell command>
lerna exec -- ls
lerna exec -- rm rf ./node_modules
How
lerna clean [--yes] [--scope] [--ignore]
# Equivalent to:
$ lerna exec -- rm -rf ./node_modules