Vue3: Use component's name as displayName if available#34008
Conversation
|
View your CI Pipeline Execution ↗ for commit 8fbf977
☁️ Nx Cloud last updated this comment at |
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughMerge a computed Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@code/frameworks/vue3-vite/src/plugins/vue-component-meta.ts`:
- Around line 138-140: The generated Object.assign currently places
${JSON.stringify(meta)} last which overwrites the runtime displayName so update
the assignment to preserve runtime names by merging meta first and then the
runtime displayName (use an empty object target to avoid mutating meta). In
other words, change the Object.assign call that builds ${name}.__docgenInfo so
it merges {}, ${JSON.stringify(meta)}, and then { displayName: ${name}.name ??
${name}.__name } (so displayName from name/__name takes precedence).
In `@code/frameworks/vue3-vite/src/plugins/vue-docgen.ts`:
- Around line 22-24: The generated assignment to _sfc_main.__docgenInfo
currently does Object.assign({ displayName: runtime }, metaData) so
metaData.displayName overwrites the runtime/user name; change the merge order so
metaData is applied first and the runtime displayName wins — i.e. create the
docgen object by Object.assign({}, ${JSON.stringify(metaData)}, { displayName:
_sfc_main.name ?? _sfc_main.__name }) (update the s.append call that constructs
_sfc_main.__docgenInfo accordingly).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d65016f4-c4f9-4371-a25a-8f2532eef92e
📒 Files selected for processing (2)
code/frameworks/vue3-vite/src/plugins/vue-component-meta.tscode/frameworks/vue3-vite/src/plugins/vue-docgen.ts
Closes #30455
What I did
Hey 👋 this PR makes the vue-component-meta plugin use the component's name if provided at runtime. By default, Vue will auto fill the
__nameproperty of the component, users usually define thenameproperty directly#33428
Checklist for Contributors
Testing
It seems like there's no unit test for vue=-component-meta plugin.
The changes in this PR are covered in the following automated tests:
Manual testing
Caution
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This pull request has been released as version
0.0.0-pr-34008-sha-fc2f9bf0. Try it out in a new sandbox by runningnpx storybook@0.0.0-pr-34008-sha-fc2f9bf0 sandboxor in an existing project withnpx storybook@0.0.0-pr-34008-sha-fc2f9bf0 upgrade.More information
0.0.0-pr-34008-sha-fc2f9bf0fix/vue3_docgenfc2f9bf01772621509)To request a new release of this pull request, mention the
@storybookjs/coreteam.core team members can create a new canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=34008Summary by CodeRabbit
Summary by CodeRabbit