For JavaScript Projects
A code repository that contains multiple distinct modules or packages that often depend on one another.
We'll talk about monorepos in the context of JavaScript projects. In particular, we'll focus on two tools for managing JS monorepos: Yarn Workspaces and Lerna.
// todo-app/package.json
{
"name": "todo-app",
"version": "1.0.0",
"description": "Track your todo list",
"main": "index.js",
"dependencies": {
"react": "16.10.0",
"todo-checkbox": "1.2.0"
}
}// todo-checkbox/package.json
{
"name": "todo-checkbox",
"version": "1.2.0",
"description": "Checkbox component",
"main": "index.js",
"dependencies": {
"react": "16.10.0"
}
}module.exports = "<Checkbox />";const checkbox = require("todo-checkbox");
console.log("imported local package:", checkbox);
// > imported local package: <Checkbox />cd ~/todo-checkbox
npm link
cd ~/todo-app
npm link todo-checkbox--since
lerna run
$ lerna import ~/repos/todo-checkbox$ lerna someCommand --since master$ lerna run test:unit --since fc419ca