vue-component-meta is a library designed to statically extract rich metadata such as props, events, slots, and exposed properties from Vue Single File Components (SFCs). It is a core part of the official Vue Language Tools and Volar ecosystem, leveraging the TypeScript compiler for deep type inference. The current stable version is 3.2.7, with frequent patch releases indicating an active development cadence, often several times a month. This tool is invaluable for scenarios like auto-generating comprehensive component documentation (e.g., for Storybook), displaying component APIs in development tools, or for advanced static analysis of Vue projects. Its primary differentiator is its deep integration with TypeScript and the Vue Language Server, ensuring highly accurate and up-to-date metadata extraction that reflects modern Vue 3 features like `defineSlots` and `defineExpose`, which alternative tools like `vue-docgen-api` have struggled to keep up with.
npm install vue-component-metaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a metadata checker from a `tsconfig.json` file and extract comprehensive metadata for a Vue component, including props, events, slots, and exposed properties.
Ensure `typescript` is installed in your project: `npm install typescript` (or `yarn add typescript`). For monorepos, make sure the `typescript` version is resolvable and compatible with the project where `vue-component-meta` is used.
Verify that the `tsconfigPath` passed to `createChecker` is an absolute path to a valid `tsconfig.json`. Ensure your `tsconfig.json` includes `"vueCompilerOptions": { "target": "esnext" }` (or similar) and correctly includes your Vue files.If you encounter missing metadata for components organized in barrel files, try directly importing the component from its source file path instead of the barrel export. Monitor GitHub issues for updates on barrel file support.
Consider the trade-off between detail and performance. For basic documentation, `schema: false` might suffice. For deep type analysis, set `schema: true`. If performance is an issue with schema enabled, use the `ignore` option to exclude common or complex types like `HTMLElement` or internal utility types.
Double-check the `tsconfigPath` argument passed to `createChecker` to ensure it's an absolute and correct path to your project's `tsconfig.json`.
Verify that `typescript` is installed as a dependency (`npm install typescript`) and that your `tsconfig.json` is syntactically correct and includes valid configurations, especially for Vue language features.
Ensure your Vue component has a `default` export (which is common for SFCs). If it's a named export, pass the correct `exportName` string to `checker.getComponentMeta(filePath, 'MyNamedExport')`.