Skip to content

fix(ingestion): extract TS/JS re-exports, multi-line imports, and computed dynamic imports#194

Merged
theagenticguy merged 2 commits into
mainfrom
roadmap/ts-import-edges
Jun 6, 2026
Merged

fix(ingestion): extract TS/JS re-exports, multi-line imports, and computed dynamic imports#194
theagenticguy merged 2 commits into
mainfrom
roadmap/ts-import-edges

Conversation

@theagenticguy
Copy link
Copy Markdown
Owner

What

Fixes three correctness gaps in the shared TS/JS import extractor (packages/ingestion/src/providers/ts-shared.ts) that silently dropped real dependency edges. TS/JS is the dominant indexed language, and OpenCodeHub indexes itself with hundreds of re-export barrels and multi-line imports, so this directly improves impact / context / blast-radius accuracy.

1. Re-export barrels were dropped

A !line.startsWith("import") guard meant export { x } from "m" and export * from "m" never produced an IMPORTS edge. Added:

  • REEXPORT_NAMEDexport { x, y as z } from "m"named record with importedNames.
  • REEXPORT_STARexport * from "m" and export * as ns from "m"package-wildcard record with isWildcard (+ localAlias for the as ns form).

2. Multi-line named imports were dropped

The single-physical-line from-clause regex failed on formatter-wrapped imports. Added joinLogicalLines(), mirroring the Python extractor's paren-scoped joiner but brace-scoped. It only begins accumulating when a line OPENS an import/export named clause (CLAUSE_OPEN), so function/class bodies and object literals are left untouched.

3. Template-literal dynamic imports were dropped

DYNAMIC_IMPORT only matched import("..."). Added DYNAMIC_IMPORT_TEMPLATE + staticTemplatePrefix(): pure import(`./x`) and static-prefixed import(`./locales/${l}.json`)./locales/; fully-interpolated templates dropped (no bogus edge).

Why no schema change

ExtractedImport / ImportKind already carry the needed shapes. Every record flows through the existing IMPORTS edge materialization in pipeline/phases/parse.ts keyed on source. Output stays source-order deterministic.

Scope

Shared by .ts, .tsx, and .js/.mjs/.cjs/.jsx — all route extractImports → extractTsImports, verified.

Verified

  • pnpm -F @opencodehub/ingestion build + full pnpm --filter '!@opencodehub/docs' -r build — clean
  • pnpm -F @opencodehub/ingestion test — 567 pass / 0 fail (up from 562; +5 new cases, no regressions)
  • Biome clean; banned-strings PASS

🤖 Surfaced by an automated roadmap-survey workflow; implemented + verified in an isolated worktree.

…puted dynamic imports

The shared TS/JS import extractor dropped three dependency-edge cases:

- `export ... from "m"` re-export barrels were skipped by an
  `import`-prefix guard, so barrel files produced no IMPORTS edge.
- Multi-line named-import clauses (clause wrapped across physical lines
  by a formatter) failed the single-line `from` regex and were dropped.
- Dynamic `import(`tpl`)` template-literal specifiers were ignored;
  only string-literal `import("...")` matched.

Adds a brace-scoped `joinLogicalLines` (mirrors the Python extractor's
paren-scoped join) that only accumulates lines opening an import/export
named clause, so function/class bodies are never swallowed. Adds
re-export regexes (named -> `named`, `export *` -> `package-wildcard`)
and a static-prefix resolver for template-literal dynamic imports. All
records still flow through the existing IMPORTS edge path keyed on
`source`; no schema change. Shared by .ts/.tsx/.js/.jsx.

Tests: new cases for multi-line imports, named/star re-exports, and
string + template dynamic imports in typescript.test.ts, plus a .js
re-export/dynamic case in javascript.test.ts.
@theagenticguy theagenticguy merged commit f1f2844 into main Jun 6, 2026
42 checks passed
@theagenticguy theagenticguy deleted the roadmap/ts-import-edges branch June 6, 2026 04:06
@github-actions github-actions Bot mentioned this pull request Jun 6, 2026
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