Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Lerna needed anymore with NPM 7.0.0's workspaces?

Is Lerna needed anymore with NPM 7.0.0 workspaces?

I dont really have experience with this new npm feature.

Npm/rfcs writes regarding this:

First and foremost there’s the alternative of leaving the problem set for userland to solve, there’s already the very popular project Lerna that provides some of these features.

Also available is the alternative of supporting only the install (or bootstrap as Lerna names it) aspect of this proposal, following a less feature-rich approach but one that would still enable the basic goal of improving the user experience of managing multiple child packages but from all the feedback collected during the research phase of this RFC, this alternative is much less desirable to the community of maintainers involved.

Glad for every answer and explanation :)

like image 932
Markus Guder Avatar asked Nov 19 '20 10:11

Markus Guder


People also ask

Is lerna needed?

Why Should Developers Use Lerna? Lerna makes things easier for developers by managing tasks like versioning, deployment of code, dependency management between projects, and much more. It is mostly used in bigger projects, where it becomes hard to maintain all these tasks manually over time.

Is lerna still supported?

Its goal was to enhance and make it scalable helping build, orchestrate, and publish your packages. Lerna has been officially killed recently.

Does lerna work with npm?

Lerna is a popular and widely used tool written in JavaScript for setting and managing multi-package repositories for Node. js projects with npm and Git.

What is npm lerna?

Lerna is a fast modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.


1 Answers

NPM 7 is out and it supports workspaces. they will also continue to develop this domain in the upcoming releases,

With that said, lerna comes with many more high level features than npm7 or yarn workspaces, furthermore, yarn declared that they will never try to replace tools like lerna, rather they intend to implement the core logic of handling workspaces like installing children packages dependencies and packages symlink. I expect npm to do the same.

One great example is the command: lerna changed which gives you the list of packages that have changed since the last tagged release, this could be extremely helpful for CI/CD. you are welcome to explore the extra commands provided by lerna.

The only command as of today supported by npm7 related to workspaces is actually npm i / npm ci which is not new, but it does take care of nested packages and symlink.

I've written an article that goes deeper into the configuration in case you want to move to a monorepo with npm7, so working without lerna is definitely an option, you will probably need to do more work on the CI/CD side compared to lerna and add some dev scripts by your self that will affect the nested packages. Also IMO lerna fits more to develop libs rather than apps.

like image 148
jony89 Avatar answered Sep 20 '22 01:09

jony89