id | title | type |
---|---|---|
lerna-and-nx |
Lerna and Nx |
explainer |
Nrwl (the company behind the open source build system Nx) has taken over stewardship of Lerna. Nx 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.
The following is a high level overview of what each tool provides. Note that all of the existing Lerna commands will continue to function as they have. Adding Nx or Nx Cloud simply improves what you're already doing.
- Bootstrap - Link packages together in the same repo so they can be imported as if they were installed from NPM.
- Version - Automatically increment versions of packages
- Publish - Automatically create tags and publish packages
Free and open source
npm install lerna
npx lerna init
- Run only tasks affected by a code change
- Run prerequisite tasks first
- Cache task results locally
- Visualize the project graph
- Nx Console - Visual Studio Code plugin
Free and open source
npx lerna add-caching
- Continue using Lerna as usual
:::note
When Lerna is set to use Nx and detects nx.json
with targetDefaults
in the workspace, it will defer to Nx to detect task dependencies. Some options for lerna run
will behave differently than older versions of Lerna. See Using Lerna (Powered by Nx) to Run Tasks for more details.
:::
- Share cached task results across the organization
- Distribute task execution efficiently across agent machines
Free for open source projects
For closed source repositories, the first 500 computation hours per month are free. Most repositories do not exceed this limit. $1 per computation hour after that.
npx nx connect-to-nx-cloud
nx generate @nrwl/workspace:ci-workflow
(or set up your CI manually)- Continue using Lerna as usual