Skip to content

npm/yarn workspaces not detected for import resolution (only pnpm-workspace.yaml) #1334

Closed

Description

@vivekv77

Following up on #1317 (thanks again for the fast v0.8.40 turnaround).

Observation. graphify resolves workspace-package imports well: entry via exports/main/module/src/index, subpaths, and tsconfig path aliases. That resolution only happens once a repo is recognized as a workspace, and _find_workspace_root (extract.py) detects a workspace only via pnpm-workspace.yaml. npm and yarn monorepos instead declare members in the package.json "workspaces" field (a string array, or the { "packages": [...] } object form). For those repos the workspace-resolution path never fires, so sibling-package imports like import x from '@acme/common' stay unresolved/external.

Repro. An npm-workspaces monorepo (root package.json with "workspaces": ["packages/*"], no pnpm-workspace.yaml); a cross-package @scope/pkg import does not resolve to the member's entry file.

Proposed fix (small, additive). Recognize npm/yarn "workspaces" as a workspace marker: have _find_workspace_root also treat a package.json containing "workspaces" as a root, and _workspace_globs read member globs from it (array form plus the {packages:[]} form). Everything downstream (_resolve_workspace_import, entry resolution) is reused unchanged; this just lets the existing machinery fire for npm/yarn. Deterministic, 0-token, and it only resolves previously-dangling imports.

Happy to open a PR with tests (npm array form, yarn object form, pnpm regression) if you are open to it.

Activity

  1. added a commit that references this issue on Jun 17, 2026
    9a7dbfb
  2. added a commit that references this issue on Aug 13, 2026
    9cb8b39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions