Feat/one hop imports - #14
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.