Skip to content

Re-export barrels unresolved after #130: default re-exports (export { default as X } from './x.svelte'), bare './' index imports, and package-subpath barrels - callers/callees/impact miss the edge (false 0 callers) #629

@nakisen

Description

@nakisen

Builds on #130 (re-export chain following). On v0.9.8 several common barrel forms are still not resolved, so the symbol-level edge between a consumer and the re-exported definition is never created. This affects both directions:

  • codegraph_callees leaves the barrel as a raw, unresolved import node (no edge to the real symbol).
  • codegraph_callers / codegraph_impact of the underlying definition return 0 — a false "orphan". This is risky because 0 callers is the canonical dead-code signal, so it can lead to deleting live code.

Still-missed forms (after #130)

#130 covered export { a, b as c } from '...', export * from '...', and export * as ns from '...'. The following are still missed:

  1. Default re-exportexport { default as Foo } from './Foo.svelte'. Re-exporting the default binding (ubiquitous for Svelte / React component barrels). A .svelte file's component (its default export) is not matched as default.
  2. Bare directory importimport { Foo } from './' (or from '.'), which should resolve to ./index.ts. The specifier is not mapped to the directory's index.ts.
  3. Workspace package-subpath barrelsimport { X } from '@scope/pkg/sub'packages/pkg/.../sub/index.tsx.svelte.

Minimal repro

// lib/foo/Foo.svelte                 — a Svelte component (default export)
// lib/foo/index.ts
export { default as Foo } from './Foo.svelte';
// lib/Bar.svelte
import { Foo } from './foo';          // uses <Foo /> in markup
codegraph callees Bar
  -> lists "./foo (import)" as a raw unresolved node; no edge to Foo / Foo.svelte

codegraph callers Foo
  -> No callers found            (expected: Bar)
  • Querying the alias name (callers Foo, where Foo is the re-exported name) returns at most the import line of some consumers and misses others; it is never unified with the underlying component node.
  • The package-subpath form behaves the same: import { X } from '@scope/pkg/sub'callees shows @scope/pkg/sub (import) raw; callers X = 0 despite many importers.

Expected

Resolve these re-export forms so the consumer↔definition edge exists in both callees and callers / impact:

  • export { default as X } from './X.svelte' (map a .svelte default export to its component node),
  • bare './' / '.'index.ts,
  • workspace package-subpath barrels (@scope/pkg/sub → its index.ts).

Why it matters

Barrels (index.ts aggregators) are universal in TS / Svelte / React component libraries. A false 0 callers defeats the primary use case of callers / impact (safe refactor / dead-code detection). Observed in a Svelte 5 + SvelteKit 2 bun-workspace monorepo (~600 files indexed): multiple live components reported 0 callers and minimal impact purely because they are consumed through these barrel forms — only an external grep revealed they were live. The forward callees check confirms the barrel import is left unresolved, so this is an edge-creation gap, not only a query-side issue.

Environment

  • codegraph v0.9.8 (node:sqlite backend)
  • Windows 11
  • TypeScript + Svelte (SvelteKit 2 / Svelte 5), bun workspace monorepo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions