Skip to content

feat(nodejs): infer build edges from pnpm workspace: protocol dependencies - #4

Merged
bruno-archastro merged 1 commit into
mainfrom
bruno/2026-06-24/workspaces
Jun 24, 2026
Merged

feat(nodejs): infer build edges from pnpm workspace: protocol dependencies#4
bruno-archastro merged 1 commit into
mainfrom
bruno/2026-06-24/workspaces

Conversation

@bruno-archastro

Copy link
Copy Markdown
Contributor

This PR enhances the Node.js plugin to correctly infer build dependencies between workspace members when using the pnpm workspace: protocol (as well as yarn-berry/bun). Previously, only file: specifiers and npm workspaces siblings by name were recognized, causing consumers to build before their dependencies and resulting in TypeScript errors (TS2307/TS7016).

Key changes:

  • Parse pnpm-workspace.yaml packages: globs alongside the existing npm workspaces field to discover workspace members.
  • Recognize all forms of the workspace: protocol and resolve them to workspace members:
    • Path forms (workspace:./pkg, workspace:../pkg) resolve by relative path.
    • Alias forms (workspace:@scope/dep@*) resolve by aliased name.
    • Range forms (workspace:*, workspace:^, workspace:~, workspace:1.2.3, etc.) resolve by the dependency key.
  • Apply dependency resolution across both dependencies and devDependencies, deduped by resolved path.
  • The resolved member feeds the same <member>:build edge as file: dependencies, ensuring a dependency's build completes before its dependents.
  • Adds comprehensive tests for all workspace: forms, pnpm workspace discovery, and end-to-end build edge inference.
  • Updates CLI tests to verify that build edges are correctly inferred and exposed in the graph and why commands for pnpm workspaces.

This fixes build ordering issues in pnpm/yarn-berry/bun monorepos and ensures correct dependency resolution for all supported workspace protocols.

aster resolved inter-project edges from `file:` specifiers and from npm
`workspaces` siblings by name, but ignored the `workspace:` protocol and
never read `pnpm-workspace.yaml`. In pnpm/yarn-berry/bun workspaces this
dropped the consumer->dependency build edge, so consumers built before
their dependencies and `tsc` failed with TS2307/TS7016.

- Parse `pnpm-workspace.yaml` `packages:` globs when discovering members,
  alongside the existing npm `workspaces` field.
- Recognize every `workspace:` form and resolve it to a workspace member:
  by relative path for `./`/`../`, by aliased name for `name@range`, and
  by the dependency key for the range forms (`*`, `^`, `~`, semver).
- Apply across `dependencies` and `devDependencies`, deduped by resolved
  path, mirroring how `file:` deps are wired.

The resolved member feeds the same `<member>:build` edge as `file:`, so a
dependency's build completes before its dependents'.
@bruno-archastro bruno-archastro self-assigned this Jun 24, 2026
@archastro

archastro Bot commented Jun 24, 2026

Copy link
Copy Markdown

✅ Clean PR, @bruno-archastro! No blocking findings on 4638dc1 — a few nice things I clocked:

  • Nice consolidation of the dependency loop — file:, workspace: (path/alias/range), and bare-sibling specifiers now resolve through one pass and feed the same <member>:build edge, deduped by resolved path. 🎯
  • Clean extension of workspace discovery — workspace_patterns_at prefers package.json workspaces then falls back to a deliberately minimal, dependency-free pnpm-workspace.yaml parser.
  • Solid red-green discipline — the end-to-end test locks the exact build-ordering failure mode the fix addresses, including CLI graph/why JSON edge coverage. 🙌

Reply @archastro <verb>: review · do <pattern> · don't <pattern> · forget <slug> · list

@bruno-archastro
bruno-archastro merged commit 09d452e into main Jun 24, 2026
2 checks passed
@bruno-archastro
bruno-archastro deleted the bruno/2026-06-24/workspaces branch June 24, 2026 23:09
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.

1 participant