Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 6384

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 60k
Author
Asked: November 27, 20242024-11-27T06:02:08+00:00 2024-11-27T06:02:08+00:00

Lerna is no longer maintained. Now what? – Part 1

  • 60k

In this article join me as I migrate my Pedalboard monorepo from Lerna to NX.

So I've recently seen that the Lerna project announced (in it’s main README) that it will no longer be maintained –

Image description

Just like that with no second warning, a project that was the groundbreaking pioneer in monorepo’s management called it quits,
Indeed a shame but no surprise there, right? I mean, seriously, this project had “not for long, mates” written all over it, and yet I still decide that it will power a small portion of my Pedalboard monorepo.

Why?

Have a look in my “No BS monorepo – Part 1” article where I explain why, at the time, Lerna appealed more to me. As a matter of a fact, if it wasn’t going “deprecated” I probably would still use it, since I kept it very focused on the tasks it does best.
Oh well, this is how our industry rolls sometimes… ¯\_(ツ)_/¯


First of all let’s check what I used Lerna for in my monorepo.

  • Be able to launch npm/yarn scripts from the root project which will run on all the packages on my monorepo
  • Be able to bump a package version, along with generating a CHANGELOG.md file and git tagging it
  • Be able to publish the changed packages to NPM

Great. So I know what I require from the alternative, but what alternatives are out there?
This wonderful monorepo.tools resource compares the leading solutions for monorepos today, check it out if you haven't already.

Scrolling down to the bottom you can see a very detailed comparison and it looks like NX is the clear winner with most “checks”. Adding that to the fact that I hear more and more how NX improved monorepo workflows in the industry, and I think it is time to have a go with it –

NX it is.

So let’s start with our first goal:

Launch npm/yarn scripts from the root project which will run on all the packages on my monorepo

Going to NX docs I found a resource talking about how to add NX to an already Lerna powered monorepo.
As suggested I run this command on the project’s root:

npx add-nx-to-monorepo

I’m prompted with a question of whether I would like to use Nx Cloud or not. Nx Cloud is a feature which allows a project to persist its script running computations (such as tests results, etc.) in the cloud, thus making following calls to those scripts run much faster, given that nothing was altered to bust the cache.
This is something I don’t feel I need at the moment, but if I regret it I can add it later on.

I read that there is a cool feature of seeing the monorepo dependencies graph, and being a FED at heart I cannot resist. Let’s check it out by running yarn nx graph

Image description

Oh nice 🙂 I feel like a proud parent looking at a picture of my kids. Here is my little components package and look there – it depends on the hooks package. How adorable
ok, ok, we’re moving on.

On the root project’s package.json I have the scripts which run on the entire packages, such as testing or linting. Here is how it looks now using lerna:

"scripts": {    "test": "lerna run test --",    "coverage": "yarn test --coverage",    "lint": "lerna run lint",    "build": "lerna run build",    "publish:lerna": "lerna publish --yes --no-verify-access",    "coverage:combined": "pedalboard-scripts aggregatePackagesCoverage && nyc report --reporter lcov"  }, 
Enter fullscreen mode Exit fullscreen mode

If I run yarn test for example, it runs the test script for each package and I get this output:

Image description

Now let’s try and make it with NX.
The NX command is a bit different. I need to use the “run-many” command and state the target script I want to run.

So the test command will now look something like this:

"test": "nx run-many --target=test --all", 
Enter fullscreen mode Exit fullscreen mode

This works well, let's change the lint and build commands as well:

"scripts": {        "test": "nx run-many --target=test --all",        "coverage": "yarn test --coverage",        "lint": "nx run-many --target=lint --all",        "build": "nx run-many --target=build --all",        "publish:lerna": "lerna publish --yes --no-verify-access",        "coverage:combined": "pedalboard-scripts aggregatePackagesCoverage && nyc report --reporter lcov"    }, 
Enter fullscreen mode Exit fullscreen mode

Notice that the “coverage” command is using the “yarn test” command in turn, and this seems to work as expected, passing the “–coverage” param and producing the coverage directory in all relevant packages. One thing I’ve noticed though is that it does not output the coverage results in the terminal as Lerna did.

The coverage:combined does not involve Lerna and still works as before. You can read more about it here

Ok, this completes our first goal of having the ability to run scripts for all packages. Cool and pretty straightforward.

In the next episode we will dive into how to detect changes and bump package versions accordingly, along with generating a CHANGELOG.md file and git tagging it. Stay tuned.

As always, if you know of other means of achieving what's written above, please make sure to share them with the rest of us 🙂

Hey! If you liked what you've just read check out @mattibarzeev on Twitter 🍻

Art by Cornelis Cort, Achenbach Foundation for Graphic Arts

npmtutorialwebdevyarn
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 1k
  • Popular
  • Answers
  • Author

    How to ensure that all the routes on my Symfony ...

    • 0 Answers
  • Author

    Insights into Forms in Flask

    • 0 Answers
  • Author

    Kick Start Your Next Project With Holo Theme

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.