Skip to content

[BUG] run transitive dependencies with --workspace flag? #3413

@adiun

Description

@adiun

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

  1. In a monorepo environment with a package packageA that has dependencies on a shared package shared and build npm scripts specified for both packageA and shared
  2. With npm 7.17 installed
  3. Run npm run build --workspace packageA
  4. Expect to see shared package build first. Actual: packageA builds - shared never builds.

Environment

  • OS: Ubuntu 20.04
  • Node: 14.16.0
  • npm: 7.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions