/** * Matches public Pimp components registered as PascalCase (`Cp*`). */ const PIMP_COMPONENTS = /^Cp[A-Z]/ export interface PimpResolverImport { from: string name: string } export type PimpComponentResolver = (name: string) => PimpResolverImport | undefined /** * Resolver for `unplugin-vue-components` so Pimp components can be auto-imported from named exports. * Install `unplugin-vue-components` in the consuming app, then add this resolver to the plugin options. */ export function PimpResolver(): PimpComponentResolver { return (name: string) => { if (!PIMP_COMPONENTS.test(name)) return return { from: '@citizenplane/pimp', name, } } }