UNPKG

bootstrap-vue-next

Version:

Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development

87 lines (86 loc) 3.15 kB
import { t as __exportAll } from "../../chunk-D1SwGrFN.mjs"; import { a as directiveNames, n as componentsWithExternalPath, o as directivesWithExternalPath, t as componentNames } from "../../BootstrapVueOptions-D3flIVqU.mjs"; //#region src/resolvers/index.ts var resolvers_exports = /* @__PURE__ */ __exportAll({ BootstrapVueNextResolver: () => BootstrapVueNextResolver }); var bvKey = "bootstrap-vue-next"; var parseActiveImports = (options, values) => { const { all, ...others } = options; const valuesCopy = {}; if (all) values.forEach((el) => { valuesCopy[el] = all; }); const merge = { ...valuesCopy, ...others }; return Object.entries(merge).filter(([name, value]) => !!value && values.includes(name)).map(([name]) => name); }; var usedComponents = /* @__PURE__ */ new Set(); var usedDirectives = /* @__PURE__ */ new Set(); /** * Resolver for unplugin-vue-components * * Contains two hidden properties `__usedComponents` and `__usedDirectives` (both are `Set<string>`) * which are used to get the list of used components and directives.. You can use this list of used components. * It may not be fully accurate. It can be used to get a list of stuff to trim down, like css * @example * ```ts * const bootstrapVueNextResolver = BootstrapVueNextResolver() * console.info(bootstrapVueNextResolver.__usedComponents) * console.info(bootstrapVueNextResolver.__usedDirectives) * * // ... blah blah blah, `plugins: [Components({resolvers: [bootstrapVueNextResolver]})]` ... * ``` */ var BootstrapVueNextResolver = Object.assign(({ aliases = {}, directives = true, components = true } = {}) => { const compImports = parseActiveImports(typeof components === "boolean" ? { all: components } : components, componentNames).reduce((map, name) => { map.set(name, `${bvKey}${componentsWithExternalPath[name]}`); return map; }, /* @__PURE__ */ new Map()); const dirImports = parseActiveImports(typeof directives === "boolean" ? { all: directives } : directives, directiveNames).reduce((map, directive) => { const key = directive.toLowerCase().startsWith("v") ? directive : `v${directive}`; map.set(key, `${bvKey}${directivesWithExternalPath[key]}`); return map; }, /* @__PURE__ */ new Map()); return [{ type: "component", resolve(name) { const destination = compImports.get(name); const aliasDestination = aliases[name] === void 0 ? void 0 : compImports.get(aliases[name]); if (aliasDestination) { const val = aliases[name]; if (val !== void 0) usedComponents.add(val); return { name: val, from: aliasDestination }; } if (destination) { usedComponents.add(name); return { name, from: destination }; } } }, { type: "directive", resolve(name) { const prefixedName = `v${name}`; const destination = dirImports.get(prefixedName); if (destination) { usedDirectives.add(prefixedName); return { name: prefixedName, from: destination }; } } }]; }, { __usedComponents: usedComponents, __usedDirectives: usedDirectives }); //#endregion export { BootstrapVueNextResolver, resolvers_exports as t }; //# sourceMappingURL=index.mjs.map