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

Add support for --workspaces to run on all npm workspaces #60

Open
voxpelli opened this issue Sep 29, 2021 · 15 comments
Open

Add support for --workspaces to run on all npm workspaces #60

voxpelli opened this issue Sep 29, 2021 · 15 comments

Comments

@voxpelli
Copy link
Collaborator

voxpelli commented Sep 29, 2021

I'm thinking it would be neat to be able to do:

run-p --workspaces check:*

Related issues:

Interesting modules:

@bcomnes
Copy link
Owner

bcomnes commented Sep 29, 2021

Makes sense now that npm supports workspaces.

@voxpelli
Copy link
Collaborator Author

When --max-parallel is set, should it try to spread out the executions across the workspaces or just assemble a long list of all tasks to be run and execute them from top to bottom?

The latter would be more a 1:1 between run-s --workspaces and run-p --workspaces but I kind of like the idea of balancing it across the different workspaces. Probably overengineering to do though, right?

@bcomnes
Copy link
Owner

bcomnes commented May 18, 2023

Probably do what ever is simplest to implement and maintain.

@voxpelli voxpelli self-assigned this May 18, 2023
@voxpelli
Copy link
Collaborator Author

I'm going to give it a stab now

@bcomnes
Copy link
Owner

bcomnes commented May 18, 2023

If you do take a stab at this, feel free to refactor ancient promise callbacks to async await etc. Whatever cleans it up.

@voxpelli
Copy link
Collaborator Author

Created a helper for reading all packages from a workspace, with similar filtering as npm itself has: https://github.com/voxpelli/read-workspaces

Started using it in list-installed and as such also in installed-check / installed-check-core now

@voxpelli
Copy link
Collaborator Author

RFC for providing npm-run-all style functionality within npm itself, with workspace support being one of the highlights: npm/rfcs#190

Maybe we could try crowdfunding the development of this addition? Through eg. https://polar.sh/ or Open Collective?

@bcomnes
Copy link
Owner

bcomnes commented Feb 21, 2025

Would love for run-s and run-p to be upstreamed. Is npm accepting PRs these days?

@justinfagnani
Copy link

I've been advocating for incorporating Wireit's script runner into npm - since I don't think that running scripts sequentially or in parallel is nearly sufficient.

I did hear from an npm team member after filing that issue that while they loved the idea, they didn't have the bandwidth to maintain such an addition, even if it were community contributed. I'm not sure if that situation still stands. A development since then is that Deno is adding a Wireit-inspired script runner as Deno Tasks. Maybe that moves forward the recognition that we need a more robust script running solution.

@bcomnes
Copy link
Owner

bcomnes commented Feb 25, 2025

I haven't used wireit yet, but it looks cool, especially for more sophisticated builds. Will give it a read through soon. run-s and run-p definitely have their limits, but also so does nearly every other tool in the npm ecosystem. Small modules almost never needed anything beyond what these two offered, but I also realize the trend these days is to try and operate entire companies out of workspaces, and so these simpler solutions fall over at that scale.

Personally I like working within limits, I think they help avoid large problems/messes but I understand this is completely the minority position these days.

@voxpelli
Copy link
Collaborator Author

With more elaborate approaches the design choices also increase and it’s harder to align everyone on the same approach

It’s the classic small core vs big core argument – should it be solved within the core or does it belong in a pluralistic ecosystem

I think run-p and run-s style functionality could maybe belong in core but more than that: Probably not

@justinfagnani
Copy link

I don't think you need much scale before run-p and run-s fall over - you only need 4 scripts to create a diamond dependency where the deepest script should only run once.

A common setup might be a test script that depends on test:unit and test:integration, which both depend on build.

@voxpelli
Copy link
Collaborator Author

run-s build test:*

@justinfagnani
Copy link

@voxpelli the goal is to be able to not have to know how the script graph is structured in order to correctly run the scripts.

If something like this were included in npm, I would expect that npm test would just do the right thing and that the config for test wouldn't have to list out its transitive dependencies.

@voxpelli
Copy link
Collaborator Author

@justinfagnani If you only have the 4 scripts then it works perfectly fine to do:

"test": "run-s build test:*"

There is some point where it may be better for tasks to describe their own dependencies, but what percentage of npm projects are at such a complexity?

Many even find it enough to do so something like eslint && mocha or similar and use a single script for everything

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

No branches or pull requests

3 participants