Skip to content

Latest commit

 

History

History
74 lines (46 loc) · 2.59 KB

lerna-and-nx.md

File metadata and controls

74 lines (46 loc) · 2.59 KB
id title type
lerna-and-nx
Lerna and Nx
explainer

Lerna and Nx

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.

Lerna

Features

  1. Bootstrap - Link packages together in the same repo so they can be imported as if they were installed from NPM.
  2. Version - Automatically increment versions of packages
  3. Publish - Automatically create tags and publish packages

Cost

Free and open source

Set up

  • npm install lerna
  • npx lerna init

Nx

Features

  1. Run only tasks affected by a code change
  2. Run prerequisite tasks first
  3. Cache task results locally
  4. Visualize the project graph
  5. Nx Console - Visual Studio Code plugin

Cost

Free and open source

Set up

  • 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. :::


Nx Cloud

Features

  1. Share cached task results across the organization
  2. Distribute task execution efficiently across agent machines

Cost

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.

Set up

  • npx nx connect-to-nx-cloud
  • nx generate @nrwl/workspace:ci-workflow (or set up your CI manually)
  • Continue using Lerna as usual