Skip to content

fix: detect dependencies from monorepo workspace packages#1868

Open
lucamorettibuilds wants to merge 1 commit intoupstash:masterfrom
lucamorettibuilds:fix/monorepo-deps-detection
Open

fix: detect dependencies from monorepo workspace packages#1868
lucamorettibuilds wants to merge 1 commit intoupstash:masterfrom
lucamorettibuilds:fix/monorepo-deps-detection

Conversation

@lucamorettibuilds
Copy link

Fixes #1860

detectProjectDependencies only scans package.json in the given cwd directory. In monorepos using pnpm/npm/yarn workspaces, dependencies declared in sub-packages are completely missed.

This adds workspace detection:

  • getWorkspaceDirs(cwd) checks pnpm-workspace.yaml and package.json workspaces field
  • resolveWorkspaceGlobs(cwd, patterns) resolves packages/* style patterns into directories
  • Each workspace package is scanned for its own package.json dependencies
  • Results are deduplicated with the root dependencies

No new dependencies added. Backwards compatible — non-monorepo projects work exactly as before.

Supports pnpm workspaces, npm workspaces, and yarn workspaces.

detectProjectDependencies only scanned package.json in the given cwd
directory, missing dependencies declared in workspace packages. For
monorepos using pnpm workspaces or npm/yarn workspaces, only the root
package.json was parsed — sub-packages under patterns like 'packages/*'
were ignored entirely.

Add getWorkspaceDirs() to detect workspace packages by reading
pnpm-workspace.yaml (with lightweight YAML parsing) or the 'workspaces'
field in package.json. Each discovered workspace package directory is
scanned for its own package.json dependencies, which are merged into the
final dependency list.

Supports:
- pnpm workspaces (pnpm-workspace.yaml)
- npm/yarn workspaces (package.json 'workspaces' field)
- Single-star glob patterns (packages/*, apps/*)
- Exact path patterns (tools/foo)

Closes upstash#1860
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.

ctx7 skills suggest does not discover dependencies in pnpm monorepo subpackages

1 participant

Comments