-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[BUG] workspace scripts should be run in topological order by default #4139
Comments
Just leaving a comment to link this to #3413 which is a related issue I think. |
Hi @justinfagnani thanks for taking the time to bring this up to our attention. Given that this would be an entire new feature for npm workspaces to support I would recommend you to propose this as either a issue or discussion over at our RFC repo where it can pick up the attention from the community and the rest of the npm cli team. |
Sorry, I don't really have time to do that. This is how other monorepo tools work though, so if you want to just copy, say Lerna, that would probably be great for your users. |
Sounds good, no worries at all @justinfagnani 😊 eventually someone in the team (maybe even myself) will take the time to open an RFC for discussion and we'll move on from there. I appreciate your help and keep an eye for updates! Thanks 😄 |
I went ahead and opened an RFC issue here We are hoping for this feature to land in |
A workaround here is to order your packages in the Example
|
Is this still true? Using 10.8.1 I'm finding that "npm install" (locally) runs the "prepare" script for each workspace first, meaning that if you require one workspace package for the "prepare" script of another workspace (e.g. if you want to run |
npm workspaces doesn't detect dependency topology when building multiple workspaces. I don't know when, and I don't care to debug it. - npm/cli#4139 - npm/cli#3034
* unversion the build artifacts * build the app before: installing, publishing, and running the app * don't use prepare since it does not work well with npm workspaces See npm/cli#4139 (comment)
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
when running a script across workspaces like
npm run build --workspaces
you'll most likely end up with errors if your workspaces depend on each other as npm doesn't execute the script in topological order. Other monorepo tools like Lerna do this automatically.The only workaround is to not use
"workspaces": ["packages/*"]
in package.json, but manually enter and maintain the list of packages by hand.Expected Behavior
Scripts should run in topological order.
Steps To Reproduce
"workspaces": ["packages/*"]
, and one package that depends on another, and say both use TypeScript...npm run build --workspaces
Environment
legacy-peer-deps = true
The text was updated successfully, but these errors were encountered: