lerna is [not] deprecated!

Lakshmaji
3 min readJul 3, 2022

lerna | migrating from 3.x to 5.x | faster builds in monorepo

On April 20, 2022, a pull request was raised, which stated that lerna is going to be deprecated.

But something else has happened!

Lerna made a comeback on 6th May, 2022 with a maintainernce status update along with brand new documentation with architectural improvements, concepts, and integrations.

Now we can upgrade lerna to the latest version and continue adding features to projects that we are working on.

But that's not the end of the story, nrwl has taken the ownership of maintaining the project. nrwl are the creators of another monorepo build and package management tool nx, which is popularly used with frontend and backend javascript based applications or projects.

The new maintainers have added new features and improvements to the existing Lerna, resulting in an artifact-based build system. In simple terms now Lerna has implemented similar features that are available with turborepo. Turborepo has been open-sourced on December 9 2021 after its acquisition by vercel.

Distribution cache feature is available with both Lerna, Turborepo as a proprietary (cloud) and managed (self-hosted) solutions.

Lerna new features (with nx)

  • Faster builds
  • Concurrency
  • Local cache
  • Distribution cache
  • Target dependencies (one package or application depending on another)
  • Powerful Graph visualizer, yes visually better than turborepo as of today (i.e. 3rd July 2022)

As Lerna is a newcomer in the build system model, it needs some time and developer/contributor hands for stability. This will be resolved in the near future.

illustration from lerna.js.org

Migrating from lerna@3.22.1 to lerna@5.1.0

  • Replace lerna version in package.json from 3.22.1 to 5.1.0
  • [Optional steps], if you want to enable task builds using nx (faster)
    – Add useNx: true to lerna.json
    – Install nx@14.2.0
  • When we try to build the project, the build system will run build based on the application or package order in the directory listing.
npx lerna run build
  • To enable caching and change the default behavior in build order (dependants or targets), first generate the nx.json.
npx nx init
  • Configure the build task runner option in nx.json using cacheableOperations

--

--