Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add experimental support to run tasks via Nx #3139

Merged
merged 1 commit into from May 25, 2022

Conversation

vsavkin
Copy link
Contributor

@vsavkin vsavkin commented May 24, 2022

Nx is the third option in addition to p-map and p-queue

Description

Currently running lerna run will result in Lerna either delegating to p-map or p-queue to schedule tasks/processes. Lerna has direct dependencies on both p-map and p-queue.

The industry has advanced since the time of p-map and p-queue. Tools like Nx and Lage are much more powerful and efficient task orchestrators. They support computation caching and, in case of Nx, config-free task distribution. A lot of teams are moving away from Lerna for this reason.

This PR adds Nx (which is a MIT-licenced extensible build system) as a third option (in addition to p-map and p-queue). If you have the nx package installed, and you have nx.json in your workspace, Lerna can now delegate its lerna run commands to Nx. This is optional: you have to opt into it. And it's done in a backwards-compatible way: every lerna run command will work but will be significantly faster and can be distributed across multiple machines without any config.

How Has This Been Tested?

We have tested on several small Lerna repos. For instance, this repo contains a benchmark measuring cache restoration of different monorepo-based tools: https://github.com/vsavkin/large-monorepo

With this change enabled, Lerna is on par with Nx, and is significantly faster than other tools.

Once the beta with this change is out, we are going to add it on several large enterprise Lerna repos to measure the perf and make sure the change handles all edge cases well.

@vsavkin vsavkin force-pushed the add-experimental-nx-task-runner branch 2 times, most recently from d9b7962 to 25ace94 Compare May 24, 2022 16:02
Copy link
Contributor

@juristr juristr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just couple of observations

commands/run/README.md Show resolved Hide resolved
commands/run/README.md Show resolved Hide resolved
Nx is the third option in addition to p-map and p-queue
@vsavkin vsavkin force-pushed the add-experimental-nx-task-runner branch from 25ace94 to 7aacd2e Compare May 25, 2022 11:35
@vsavkin vsavkin merged commit 1c35828 into lerna:main May 25, 2022
ghiscoding added a commit to lerna-lite/lerna-lite that referenced this pull request May 26, 2022
- follows same implementation as Lerna's [PR #3139](lerna/lerna#3139), follow the link to get full description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants