Skip to content

componentRegistry(options?) ​

Scans .vue/.tsx/.jsx components and generates named exports, instance types, global registration, and Vue global declarations.

ts
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),
});
OptionTypeDefaultDescription
dirsstring | readonly string[]"src/components"Scan directory
outputstring | false"src/components/index.ts"Component entry output; false disables
dtsstring | false"types/components.d.ts"Global type output; false disables
deepbooleantrueRecursive scanning
extensionsreadonly string[]vue, tsx, jsxExtensions 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
debouncenumber80Development 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 ​

ts
export function componentRegistry(options: ComponentRegistryPluginOptions = {}): Plugin;

Example ​

ts
import { componentRegistry } from "fast-vite-plugins";

const plugin = componentRegistry({ dirs: ["src/components"], output: "src/components/index.ts" });

export default { plugins: [plugin] };

Input ​

InputTypeRequired / defaultDescription
optionsComponentRegistryPluginOptionsOptional; defaults to {}Scan directory, outputs, filtering, naming, and collision policy.

Returns ​

ValueTypeDescription
pluginPluginComponent-entry generation plugin for Vite plugins.