Skip to content

Import graph (TS/JS): a package's imports of itself by name (from "zod/v4") resolve nowhere, costing ~130 call links on zod #3789

Closed

Description

@squid-protocol

What

Inside a package, code often imports the package itself by its published name, resolved through package.json exports and self-reference. In a monorepo it's resolved through workspace packages:

import * as z from "zod/v4";   // in packages/zod/src/v4/classic/tests/*.test.ts
z.string().min(3);

The import graph treats zod/v4 as a bare npm specifier outside the repo (docs/graph_accuracy.md: "bare npm specifiers and tsconfig aliases" aren't resolved). So z.x() never reaches the repo's own v4/classic exports, and every such call is unresolved.

Evidence

callgraph_triage.py typescript (#3774) on zod: 133 reference edges in the resolved_outside bucket are z.x() calls. That's the largest single cause in the bucket, and 5% of all reference edges.

Likely fix

Resolve a bare specifier to repo files when it names a package in this repo:

  • read each package.json's name and exports map, including conditions such as customConditions;
  • read workspace declarations (pnpm-workspace.yaml, workspaces in the root package.json).

Then zod/v4 maps to the file that packages/zod/package.json's exports["./v4"] points at. After that, measure the import-graph accuracy gate (import_graph_accuracy.py) as well as the call-graph gate.

Activity

  1. added
    bug
    core-engine
    on Sep 26, 2026
  2. added
    scope:infra
    on Oct 16, 2026
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

    bugcore-enginescope:infra

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions