Skip to content

Commit af59f88

Browse files
committed
chore: docs improvements
1 parent 536676f commit af59f88

File tree

9 files changed

+126
-89
lines changed

9 files changed

+126
-89
lines changed

core/lerna/commands/add-caching/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ $ lerna add-caching
1414

1515
Each question the wizard asks will inform how the `nx.json` file is updated.
1616

17-
### Which of the following scripts need to be run in deterministic/topological order?
17+
### Which scripts need to be run in order?
1818

1919
Each script selected will be marked to run dependency scripts of the same name before running the script itself.
2020

@@ -32,7 +32,7 @@ If you mark `build` as needing topological order, the `nx.json` file will look l
3232
}
3333
```
3434

35-
### Which of the following scripts are cacheable?
35+
### Which scripts are cacheable?
3636

3737
Each script selected will be cached by Lerna. Only select scripts that do not depend on any external inputs (like network calls). `build` and `test` are usually cacheable. `start` and `serve` are usually not cacheable. Sometimes `e2e` is cacheable.
3838

website/docs/concepts/alternate-bootstrapping-methods.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
---
22
id: alternate-bootstrapping-methods
3-
title: Alternate Bootstrapping Methods
3+
title: "Legacy: Alternate Bootstrapping Methods"
44
type: explainer
55
---
66

7-
# Alternate Bootstrapping Methods
7+
# Legacy: Alternate Bootstrapping Methods
88

9-
If you can't [use your package manager's built in bootstrapping support](../features/bootstrap) for some reason, Lerna can handle the bootstrapping for you. There are several ways Lerna can set up your monorepo such that an app (`remixapp`) can find libraries in the same repo (`header` and `footer`), and one of them is to make it such that the `header` and `footer` end up in the `node_modules` folder of `remixapp` (or a different folder at the root)--that's what `lerna bootstrap` (without `--use-workspaces`) does.
9+
:::info
10+
11+
NOTE: Lerna's legacy package management capabilities are being deprecated in Lerna v7, [please see here for full background](../features/legacy-package-management)
12+
13+
:::
14+
15+
There are several ways Lerna can set up your monorepo such that an app (`remixapp`) can find libraries in the same repo (`header` and `footer`), and one of them is to make it such that the `header` and `footer` end up in the `node_modules` folder of `remixapp` (or a different folder at the root)--that's what `lerna bootstrap` (without `--use-workspaces`) does.
1016

1117
Running `lerna bootstrap` will invoke `npm install` in each of the packages, and will link local package such that the resulting structure will look like this.
1218

website/docs/concepts/hoisting.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
---
22
id: hoisting
3-
title: Hoisting
3+
title: "Legacy: Hoisting"
44
type: explainer
55
---
66

7-
# Hoisting
7+
# Legacy: Hoisting
8+
9+
:::info
10+
11+
NOTE: Lerna's legacy package management capabilities are being deprecated in Lerna v7, [please see here for full background](../features/legacy-package-management)
12+
13+
:::
14+
815

916
```bash
1017
lerna bootstrap --hoist

website/docs/features/bootstrap.md

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
id: legacy-package-management
3+
title: Legacy Package Management
4+
type: recipe
5+
---
6+
7+
# Legacy Package Management
8+
9+
## Background
10+
11+
Lerna is the original monorepo/workspace tool in the JavaScript ecosystem. When it was created in 2015/2016 the ecosystem looked totally different, and there were no built in capabilities to handle working with multiple packages in a single repository (a "workspace"). Commands like lerna bootstrap, lerna add and lerna link were all a critical part of the lerna project, because there were no other options.
12+
13+
However, now that we find ourselves in late 2022, the fact is that - for many years now - the package managers we know and love (`npm`, `yarn` and `pnpm`) all fully support that concept of workspaces as a first-class use-case.
14+
15+
They have battle tested implementations covering adding, removing and linking local packages, and combining them with third party dependencies in a natural way.
16+
17+
This is the reason why, for the past several years of his tenure as lead maintainer of Lerna, Daniel, has been encouraging folks to strongly reconsider their use of the legacy package management commands in lerna, and instead leverage their package manager of choice to do what it does best.
18+
19+
We knew about this context from afar, but as new stewards of the project we did not want to jump straight in and start removing capabilities without first taking the time to get familiar with the reality up close. Now that we have been actively maintaining the project for half a year, we are in full agreement with Daniel and others that the legacy package management commands in lerna need to be retired.
20+
21+
By removing these legacy pieces which have better alternatives natively in package managers, we and the rest of the lerna community will be freed up to concentrate our efforts on things which are uniquely valuable about lerna (such as, but not limited to, versioning and publishing), and making them the best they can be!
22+
23+
From version 7, therefore, we will no longer ship the legacy package management commands (such as lerna bootstrap, lerna add and lerna link) by default with lerna, and instead make them available as an add-on via a separate package (name TBD).
24+
25+
This new package can be thought of as being in maintenance mode only - no new features will be considered for legacy package management concerns (such as lerna bootstrap, lerna add and lerna link), and we will only look to merge critical patches and security updates.
26+
27+
:::info
28+
29+
This same context is covered on the [Lerna v7 discussion](https://github.com/lerna/lerna/discussions/3410), if you have any specific concerns, please join us there and provide as much information as possible!
30+
31+
:::
32+
33+
## Legacy Bootstrap Command
34+
35+
Lerna's legacy bootstrap command links different projects within the repo so they can import each other without having to publish anything to NPM. To show how Lerna does it, we will take [this repository](https://github.com/lerna/getting-started-example) as an example.
36+
37+
The repo contains three packages or projects:
38+
39+
- `header` (a library of React components)
40+
- `footer` (a library of React components)
41+
- `remixapp` (an app written using the Remix framework which depends on both `header` and `footer`)
42+
43+
The Remix app imports the `header` and `footer` libraries as follows:
44+
45+
```typescript jsx title="packages/remixapp/app/routes/index.tsx"
46+
import { Header } from "header";
47+
import { Footer } from "footer";
48+
49+
export default function Index() {
50+
return (
51+
<>
52+
<Header />
53+
<div>Content!</div>
54+
<Footer />
55+
</>
56+
);
57+
}
58+
```
59+
60+
And it depends on them in its `package.json` as follows:
61+
62+
```json title="packages/remixapp/package.json"
63+
{
64+
"dependencies": {
65+
"@remix-run/node": "^1.5.1",
66+
"@remix-run/react": "^1.5.1",
67+
"@remix-run/serve": "^1.5.1",
68+
"react": "^17.0.2",
69+
"react-dom": "^17.0.2",
70+
"header": "*",
71+
"footer": "*"
72+
}
73+
}
74+
```
75+
76+
To make the `header` and `footer` available inside the `remixapp`, run:
77+
78+
```bash
79+
lerna bootstrap --use-workspaces
80+
```
81+
82+
This installs all the dependencies needed for the 3 projects and links the `header` and `footer` projects so that `remixapp` can reference them like npm packages. `--use-workspaces` tells Lerna to delegate package linking process to your package manager. (This feature is supported by npm, yarn and pnpm.)
83+
84+
You can also set `useWorkspaces` as the default behavior in the `lerna.json` file:
85+
86+
```json title="lerna.json"
87+
{
88+
...
89+
"useWorkspaces": true
90+
}
91+
```
92+
93+
## Other Bootstrapping Methods
94+
95+
Bootstrapping this way should work for most people, but you can use [Alternate Legacy Bootstrapping Methods](../concepts/alternate-bootstrapping-methods) if needed.

website/docs/getting-started.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ When running `lerna init`, Lerna configures the workspace to use NPM/YARN/PNPM w
9191

9292
:::info
9393

94-
Lerna has its own dependency management solution: `lerna bootstrap`. This was required because at the times when Lerna got first released, there were no solutions available. Nowadays the modern package managers come with a built-in "workspaces" solution, so it is highly recommended to go with that instead.
94+
Lerna has historically its own dependency management solution: `lerna bootstrap`. This was required because at the time when Lerna was first released, there were no native solutions available. Nowadays the modern package managers come with a built-in "workspaces" solution, so it is highly recommended to go with that instead. `lerna bootstrap` and other related commands will be officially deprecated in Lerna v7. See https://github.com/lerna/lerna/discussions/3410
9595
:::
9696

9797
You can see this configured in the root-level `package.json` `workspaces` property as well as by having `useWorkspaces` set to `true` in `lerna.json`
@@ -128,7 +128,7 @@ npm install
128128

129129
Now all the projects in the workspace can properly reference each other via local package linking.
130130

131-
## Visualizing Workspace
131+
## Visualizing the Workspace
132132

133133
Since Lerna is powered by Nx, you can use its capabilities to open an interactive visualization of the workspace project graph.
134134

@@ -200,7 +200,7 @@ npx lerna add-caching
200200
A series of questions will be asked to properly configure the workspace:
201201

202202
```bash
203-
? Which of the following scripts need to be run in deterministic/topoglogical order?
203+
? Which scripts need to be run in order? (e.g. before building a project, dependent projects must be built.)
204204
(Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed)
205205
❯◉ build
206206
test
@@ -209,8 +209,7 @@ A series of questions will be asked to properly configure the workspace:
209209
```
210210

211211
```bash
212-
? Which of the following scripts are cacheable? (Produce the same output given the same input, e.g. build, test and lint usually are, serve and
213-
start are not)
212+
? Which scripts are cacheable? (Produce the same output given the same input, e.g. build, test and lint usually are, serve and start are not.)
214213
(Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed)
215214
◉ build
216215
❯◉ test

website/docs/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ It solves three of the biggest problems of JavaScript monorepos:
1414
- Lerna runs a command against any number of projects, and it does it in the most efficient way, in the right order, and with the possibility to distribute that on multiple machines.
1515
- Lerna manages your publishing process, from version management to publishing to NPM, and it provides a variety of options to make sure any workflow can be accommodated.
1616

17-
Nrwl (the company behind the open source build system Nx) has taken over [stewardship of Lerna](https://dev.to/nrwl/lerna-is-dead-long-live-lerna-3jal). [Nx](https://nx.dev) is a build system developed by ex-Googlers and utilizes many of the techniques used by internal Google tools. Lerna v5 is the first release under this new stewardship, updating outdated packages and starting to do some cleanup on the repository itself. Starting with v5.1+, Lerna comes with the new possibility to integrate Nx and defer a lot of the task scheduling work to it.
17+
Nrwl (the company behind the open source build system Nx) has taken over [stewardship of Lerna](https://dev.to/nrwl/lerna-is-dead-long-live-lerna-3jal). [Nx](https://nx.dev) is a build system developed by ex-Googlers and utilizes many of the techniques used by internal Google tools. Lerna v5 is the first release under this new stewardship, updating outdated packages and starting to do some cleanup on the repository itself. Starting with v6+, Lerna delegates task scheduling work to Nx's battle tested, industry-leading task runner, meaning `lerna run` gets the benefits of caching and command distribution for free!
1818

1919
## Why Lerna?
2020

21-
- **Super Fast!** Lerna v5+ is fast, even faster than most comparable solutions out there ([see this benchmark](https://github.com/vsavkin/large-monorepo) to learn more). How? Under the hood, [Lerna v5+ has the ability to use Nx to run tasks](https://twitter.com/i/status/1529493314621145090). Learn more about [running tasks here](./features/run-tasks.md).
21+
- **Super Fast!** Lerna is fast, even faster than most comparable solutions out there ([see this benchmark](https://github.com/vsavkin/large-monorepo) to learn more). How? Under the hood, [Lerna v6+ uses Nx to run tasks](https://twitter.com/i/status/1529493314621145090). Learn more about [running tasks here](./features/run-tasks.md).
2222
- **Computation Caching** - Lerna knows when the task you are about to run has been executed in the past. Instead of running it, Lerna will restore the files and replay the terminal output instantly. Plus, this cache can be shared with your co-workers and CI. When using Lerna, your whole organization will never have to build or test the same thing twice. [Read more &raquo;](./features/cache-tasks.md)
2323
- **Configuration-Free Distributed Task Execution** Lerna can distribute any command across multiple machines without any configuration, while preserving the dev ergonomics of running it on a single machine. In other words, scaling your monorepo with Lerna is as simple as enabling a boolean flag. See the examples of how enabling DTE can make you CI 20 times faster. [Read more &raquo;](./features/distribute-tasks.md)
2424
- **Beautiful Terminal Output** Monorepos can have hundreds or thousands of projects. Printing everything on every command makes it hard to see what fails and why. Thankfully, Lerna does a much better job.

website/docs/lerna-and-nx.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ The following is a high level overview of what each tool provides. Note that all
1414

1515
### Features
1616

17-
1. [Bootstrap](./features/bootstrap) - Link packages together in the same repo so they can be imported as if they were installed from NPM.
18-
2. [Version](./features/version-and-publish) - Automatically increment versions of packages
19-
3. [Publish](./features/version-and-publish) - Automatically create tags and publish packages
17+
1. [Version](./features/version-and-publish) - Automatically increment versions of packages, generate changelog information, create Github releases etc.
18+
2. [Publish](./features/version-and-publish) - Automatically create tags and publish packages to package registries, such as npm
2019

2120
### Cost
2221

website/sidebars.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ const sidebars = {
2525
type: "category",
2626
label: "Features",
2727
items: [
28-
"features/bootstrap",
2928
"features/run-tasks",
3029
"features/cache-tasks",
3130
"features/share-your-cache",
3231
"features/project-graph",
3332
"features/distribute-tasks",
3433
"features/version-and-publish",
3534
"features/editor-integrations",
35+
"features/legacy-package-management",
3636
],
3737
link: {
3838
type: "generated-index",
@@ -45,11 +45,11 @@ const sidebars = {
4545
type: "category",
4646
label: "Concepts",
4747
items: [
48-
"concepts/alternate-bootstrapping-methods",
49-
"concepts/hoisting",
5048
"concepts/task-pipeline-configuration",
5149
"concepts/how-caching-works",
5250
"concepts/dte-guide",
51+
"concepts/alternate-bootstrapping-methods",
52+
"concepts/hoisting",
5353
],
5454
link: {
5555
type: "generated-index",

0 commit comments

Comments
 (0)