Skip to content

Feat/one hop imports - #14

Merged
ggange merged 2 commits into
mainfrom
feat/one-hop-imports
Jul 5, 2026
Merged

Feat/one hop imports#14
ggange merged 2 commits into
mainfrom
feat/one-hop-imports

Conversation

@ggange

@ggange ggange commented Jul 5, 2026

Copy link
Copy Markdown
Owner

No description provided.

ggange and others added 2 commits July 5, 2026 11:59
For every component a route renders, resolve the import and extract that
file's content into the page's .md — the fix for the component-shell
empty-page case (return <Pricing/>), the top real-world gap.

- resolver (src/resolve.ts): relative specifiers, tsconfig/jsconfig
  paths aliases via get-tsconfig (JSONC-safe, extends-chains free),
  barrel re-exports followed to the declaring file (named, default,
  export *; depth-capped, cycle-guarded via visited set); node_modules
  and out-of-project files excluded
- visitor: collects import bindings and capitalized JSX component usage
  (first-use order, nav/skip regions excluded)
- cli: one extraction per component file for the whole run (memo Map =
  cycle guard); best-effort — unresolvable imports never fail a route;
  child isDynamic propagates to the page
- tests: relative, default-import, JSONC alias, barrel, export *,
  re-export cycle, missing-file/node_modules, nav/skip exclusion,
  dynamic propagation (9 new, 134 total)
- real-repo matrix re-run: zero crashes; subscription-payments 1/3 →
  2/3 routes with content; demo pricing page now extracts PricingTable
- publish.yml: prerelease versions publish under the rc dist-tag so an
  rc can never move latest
- docs: README limitation rewritten as the one-hop boundary; annotation
  guide preamble updated; demo output regenerated

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Review of feat/one-hop-imports surfaced 8 findings; all fixed:

- createResolver: getTsconfig() call moved inside the try/catch (only
  createPathsMatcher was guarded before). A broken or circular tsconfig
  'extends' chain — common in real monorepos — made get-tsconfig throw
  and crashed the whole run; it now degrades to 'no aliases', matching
  the 'never a failure source' contract.
- resolve(): default imports now follow barrels like named imports do
  (previously returned the barrel file itself before ever calling
  followBarrel, so 'export { default } from ./Hero' dropped Hero's
  content silently).
- resolveToFile: a NodeNext/ESM '.js' specifier (real file is .tsx) is
  now tried against the source extensions instead of failing outright.
- visitor: componentsUsed is gone in favor of a 'component' placeholder
  ContentBlock inserted at the JSX position, restricted to plain
  JSXIdentifier names — <Ctx.Provider>/<motion.div> (member expressions)
  no longer resolve to their object's import and leak unrelated file
  content into the page.
- cli.ts expandOneHop: splices each placeholder's resolved blocks in
  place instead of appending all component content after the page's
  own text, so document order is preserved. Also drives the coverage
  summary correctly now: an unresolved component leaves 0 blocks
  ('mostly empty'), a resolved one contributes real blocks.
- annotation guide: files successfully one-hop-extracted are now
  excluded from ai-annotation-guide.md (derived from componentMemo,
  already-awaited) — previously the same content was both written to
  the page .md and listed as 'can't extract', a direct contradiction
  proven by the committed demo output.
- followBarrel now returns string | null (null = not traced) instead of
  overloading the file path as both 'found' and 'gave up'; deletes the
  redundant declaresNameInFile second parse of the same file.
- resolve.ts imports PAGE_EXTENSIONS from router.ts instead of
  redeclaring an identical list.
- bonus: added a resolveCache/parseCache in the resolver so a shared
  barrel is read/parsed once per run, not once per importing route.

8 new regression tests (ordering, default-barrel, member-expression
exclusion, .js resolution, broken/circular tsconfig, guide exclusion,
bucketing with an unresolved component) — 142 total, tsc clean.
Real-repo matrix and demo re-verified: zero crashes, guide/output
contradiction gone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ggange
ggange merged commit 8825cfe into main Jul 5, 2026
2 checks passed
@ggange
ggange deleted the feat/one-hop-imports branch July 6, 2026 07:50
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