-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vue: Replace vue-docgen-api with Volar vue-component-meta #22285
Conversation
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. Ignoring: Next stepsTake a deeper look at the dependencyTake a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev. Remove the packageIf you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency. Mark a package as acceptable riskTo ignore an alert, reply with a comment starting with |
Unfortunately this didn't improve performance in my tests :/ |
@kasperpeulen As discussed:
|
Right, as it is not breaking anymore it doesn't have to be added to MIGRATION.md. |
It's fantastic to see this PR evolving nicely! Huge thanks to everyone involved for their contributions. While the documentation may need some refinement with @kylegach to fit into the official docs, I'm eager to assist with that. Additionally, I'm keen to collaborate on the blog post with @joevaugh4n. Big kudos to @kasperpeulen & @larsrickert for their efforts! 👍 🚀 |
i rather suggest to call it const config: StorybookConfig = {
framework: {
name: '@storybook/vue3-vite',
options: {
docgen: 'vue-component-meta', // defaults to vue-docgen-api
},
},
}; |
i think the actual problem with performance is due to files |
Interesting, let's experiment with that in 8.x. |
…okjs/storybook into chaks/vue-component-meta
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much @chakAs3 and @larsrickert
Thanks guys for all your work on it! |
Great that we got this PR ready 🚀 Special thanks to @kasperpeulen and @chakAs3 and everyone testing out the changes! tl;dr: To use the new improved docgen plugin, just set the following and enjoy (once its released^^): // .storybook/main.ts
import type { StorybookConfig } from '@storybook/vue3-vite';
const config: StorybookConfig = {
framework: {
name: '@storybook/vue3-vite',
options: {
docgen: "vue-component-meta"
},
},
};
export default config; |
Closes #22090 #21606 #23313 #25582 #25305 #24621 #22209 #21684 #19233 #16301
and other issues
Current PR status / open points
Status from: 18 February 2024
Volar can be enabled with:
What I did
replace vue-docgen-api with official vue language tools by Volar ( vue-meta-component ) with a better type definition, more features, and regular updates by @johnsoncodehk.
What benefits are we getting? :
Added Props type definition extraction
Added props description and tag annotation support :
This PR adds the ability to include descriptions and tag annotations for props in Vue components. The following examples demonstrate how to use this new feature:
Props Description
To provide a description for a prop, add a description property to the prop object. Here is an example:
Props Tag Annotation
To add a tag annotation to a prop, add a tags property to the prop object. This can be useful for documenting things like default values or required props. Here is an example:
These new features can make documentation more organized and useful for other developers, so be sure to take advantage of them in your Vue components.
Added support control generation
This new feature enables developers to generate Storybook controls for their Vue components, using simple props type definitions as a guide. Here's an example of how it might look like:
Events types extraction
Note:
Due to technical limitations of Volar / vue language features, JSDoc / descriptions for emits can not be extracted.
Added slots types definition extraction
we can get slots type definition from Vue component and display them on the component docs table
Added "Exposed" methods and properties types definition extraction
With the release of Vue 3.2 a new composition tool was made available for us, called expose.
to make methods and properties available to the parent. and made the type available #3399
Now we can extract these exposed and display them on docs table in section called exposed
In addition to generating Storybook controls for Vue components based on their props, events, slots and exposed type definitions, the new feature also allows this meta extraction from all types of Vue components, including functional, composition / options API components, and from both
.vue
or.ts
files. This makes it easier for developers to test their components and ensure that they are working as intended.Here's an example of a TypeScript Vue component:
Support for Named Export Component
The PR introduces support for named export components in Vue. With this enhancement, you can now have multiple components exported from a single file using named exports. This provides greater flexibility and organization in structuring your Vue components.
You can do something like this
Component Meta Extraction from Various File Types
The PR extends the component meta extraction functionality to support multiple file types, including .vue, .js, .ts, .tsx, and .jsx. Regardless of the file extension, you can now extract component metadata seamlessly. This improvement enables a unified approach to extracting component meta across different file formats, ensuring consistent and efficient development workflows.
so you can have something like :
By incorporating these new features, we aim to enhance the flexibility and extensibility of Vue components, making it easier to manage and extract metadata across various file types and export configurations.
Please review this PR and provide your feedback. Your contributions and suggestions are highly appreciated.
Thank you!
How to test
yarn task --task sandbox --start-from auto --template vue3-vite/default-ts
-->
Checklist
MIGRATION.MD
Maintainers
make sure to add the
ci:merged
orci:daily
GH label to it.["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]
This pull request has been released as version
0.0.0-pr-22285-sha-f910dccb
. Try it out in a new sandbox by runningnpx storybook@0.0.0-pr-22285-sha-f910dccb sandbox
or in an existing project withnpx storybook@0.0.0-pr-22285-sha-f910dccb upgrade
.More information
0.0.0-pr-22285-sha-f910dccb
chaks/vue-component-meta
f910dccb
1708702394
)To request a new release of this pull request, mention the
@storybookjs/core
team.core team members can create a new canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=22285