-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
I have a monorepo that contains:
- packageA (depends on sharedC)
- packageB
- sharedC (depends on sharedD)
- sharedD
If I run npm run build --workspace [packageA], this only builds packageA and not sharedC or sharedD
Expected Behavior
I migrated from lerna to npm workspaces - in lerna there was a flag --include-filtered-dependencies which would look at the transitive dependencies of packageA and would run those first. So an npm run build --workspace packageA would run the build first on sharedD and then sharedC before running the build on packageA. I expected to find something like this in npm workspaces.
Right now I have to define the workspaces in the right order in the root package.json but that doesn't solve the problem of npm run since I have many packages and only want to run some command (like a build) on a subtree. In CI it seems I have to specify each of the dependent packages and build them in the right order.
Steps To Reproduce
- In a monorepo environment with a package
packageAthat has dependencies on a shared packagesharedandbuildnpm scripts specified for bothpackageAandshared - With npm 7.17 installed
- Run
npm run build --workspace packageA - Expect to see
sharedpackage build first. Actual:packageAbuilds -sharednever builds.
Environment
- OS: Ubuntu 20.04
- Node: 14.16.0
- npm: 7.17.0