Repository navigation
Vue: Follow a re-export to the component that declares it - #35821
Conversation
A story that imports its component from a barrel gets no docgen at all, while
a story importing the same component directly gets a full props table:
import Badge from './Badge.vue' -> argTypes: text, tone
import { Badge } from './index' -> error: No docgen found
`vue-component-meta` looks for the declaration inside the file it is handed.
Given the index file it finds an export specifier, throws, and the throw is
swallowed into a generic message naming a file the user never wrote a
component in.
The server path now resolves the alias to the declaring module before asking
for meta, which is what the Angular analyzer already does for the same shape.
Resolving before rather than after also means the event-description pass reads
the SFC instead of the index file.
Importing from a public entry point is the normal shape for a design system,
so this is not an edge case.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (8)
Included review availability: 2 reviews are currently available. Based on recent review activity, included reviews refill at 3 per hour. WalkthroughChangesVue docgen re-export resolution
Sequence Diagram(s)sequenceDiagram
participant buildDocgen
participant TypeScriptChecker
participant MetadataManager
buildDocgen->>TypeScriptChecker: Resolve the component re-export
TypeScriptChecker-->>buildDocgen: Return declaring file and export
buildDocgen->>MetadataManager: Collect Vue metadata
MetadataManager-->>buildDocgen: Return component metadata
Merge Risk: ⚪ Minimal · up to This localized change makes Vue component documentation work through barrel-file re-exports while preserving direct imports, with focused regression coverage; no actionable merge-blocking risk remains beyond normal checks and review. ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
code/renderers/vue3/src/docgen/follow-re-export.test.ts (1)
37-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the event-description contract.
The new resolution path changes the source used for event-description recovery. This fixture has no component event. The assertions cannot detect an event-description regression for barrel imports. Add a documented event to
Badge.vueand assert equivalent direct and barrel event metadata.As per coding guidelines, test public contracts and externally observable side effects rather than private implementation details.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@code/renderers/vue3/src/docgen/follow-re-export.test.ts` around lines 37 - 52, Extend the follow-re-export fixture by documenting a public event in Badge.vue, then update the test case around docgenFor to assert that direct and barrel imports expose equivalent event metadata, including the event description. Preserve the existing prop assertions and compare externally observable event data rather than resolution internals.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@code/renderers/vue3/src/docgen/__testfixtures__/barrel/src/Barrel.stories.ts`:
- Line 1: Update the fixture’s tsconfig.json to enable noEmit and
allowImportingTsExtensions, then change the import in Barrel.stories.ts to
reference ./index.ts so the TypeScript extension import is accepted.
---
Nitpick comments:
In `@code/renderers/vue3/src/docgen/follow-re-export.test.ts`:
- Around line 37-52: Extend the follow-re-export fixture by documenting a public
event in Badge.vue, then update the test case around docgenFor to assert that
direct and barrel imports expose equivalent event metadata, including the event
description. Preserve the existing prop assertions and compare externally
observable event data rather than resolution internals.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2d819641-21b5-4cca-807a-f64b3cd050a3
📒 Files selected for processing (8)
code/renderers/vue3/src/docgen/__testfixtures__/barrel/src/Badge.vuecode/renderers/vue3/src/docgen/__testfixtures__/barrel/src/Barrel.stories.tscode/renderers/vue3/src/docgen/__testfixtures__/barrel/src/Direct.stories.tscode/renderers/vue3/src/docgen/__testfixtures__/barrel/src/index.tscode/renderers/vue3/src/docgen/__testfixtures__/barrel/tsconfig.jsoncode/renderers/vue3/src/docgen/build-docgen.tscode/renderers/vue3/src/docgen/follow-re-export.test.tscode/renderers/vue3/src/docgen/follow-re-export.ts
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
What is broken
A story that imports its component from a barrel file gets no docgen. The same component imported directly gets a full props table.
Captured from the fixture added in this PR, both run through
buildDocgenPayloadagainst one checker:Nothing about the component differs between those two runs. Only the specifier the story imports it through.
Importing from a public entry point is the normal shape for a design system, so this is not an edge case.
Why
The shared resolver answers "which module does the story import from" and correctly stops at
index.ts.vue-component-metais then handed that path, and its entry point looks for the declaration inside the file it is given:The fix
Resolve the alias to the declaring module before asking for meta. The Angular analyzer already does this for the same shape (
project.ts,extractViaModuleExports), and has tests for bothexport *and aliasedexport { X as Y }.followReExportreturnsundefinedwhen the file declares the export itself, which is the common case, so the path for a direct import is unchanged.Resolving before rather than after matters for a second reason:
applyTempFixForEventDescriptionsre-parses the file withvue-docgen-apito recover event descriptions. Handed the index file it would find nothing; handed the SFC it works.The change is in the server docgen path only. The legacy Vite plugin transforms component modules and explicitly excludes story files, so it never resolves through a barrel.
Checklist for contributors
Manual testing
Run from the repository root.
yarn vitest run code/renderers/vue3— expect 102 passing.followReExport(...) ?? {...}call inbuild-docgen.tswith the plain{ path: component.path, exportName: component.exportName }fallback and re-runyarn vitest run code/renderers/vue3/src/docgen/follow-re-export.test.ts. Expect:yarn nx check vue3— expect no type errors.Documentation