componentRegistry(options?)
Scans .vue/.tsx/.jsx components and generates named exports, instance types, global registration, and Vue global declarations.
componentRegistry({
dirs: ["src/components", "src/features"],
output: "src/components/index.ts",
dts: "types/components.d.ts",
name: ({ defaultName, relativePath }) => (relativePath.startsWith("admin/") ? `Admin${defaultName}` : defaultName),
});| Option | Type | Default | Description |
|---|---|---|---|
dirs | string | readonly string[] | "src/components" | Scan directory |
output | string | false | "src/components/index.ts" | Component entry output; false disables |
dts | string | false | "types/components.d.ts" | Global type output; false disables |
deep | boolean | true | Recursive scanning |
extensions | readonly string[] | vue, tsx, jsx | Extensions with or without a leading dot |
include | (context) => boolean | - | Return false to exclude a file |
name | (context) => string | - | Custom export identifier |
conflict | "error" | "warn" | "overwrite" | "error" | Duplicate-name policy |
debounce | number | 80 | Development watch debounce in milliseconds |
Generated modules export an instance type for each component, using ComponentNameInstance = InstanceType<typeof ComponentName>.
registerComponents(app) calls app.component(Component.name, Component) directly, without fallback names or registration-time checks/warnings. Generation warns if it can statically prove a component lacks a runtime name, but retains it. Uncertain cases are treated as declared.
index.vue defaults to its parent directory name. Generated names must be unique valid ECMAScript identifiers. output and dts cannot both be disabled.
componentRegistry Registry
Scans Vue/TSX/JSX components and generates named exports, instance types, global registration, and global component types.
Signature
export function componentRegistry(options: ComponentRegistryPluginOptions = {}): Plugin;Example
import { componentRegistry } from "fast-vite-plugins";
const plugin = componentRegistry({ dirs: ["src/components"], output: "src/components/index.ts" });
export default { plugins: [plugin] };Input
| Input | Type | Required / default | Description |
|---|---|---|---|
options | ComponentRegistryPluginOptions | Optional; defaults to {} | Scan directory, outputs, filtering, naming, and collision policy. |
Returns
| Value | Type | Description |
|---|---|---|
plugin | Plugin | Component-entry generation plugin for Vite plugins. |
