UNPKG

vue-styleguidist

Version:
34 lines (33 loc) 1.11 kB
import "core-js/modules/es.function.name.js"; import "core-js/modules/es.object.to-string.js"; import "core-js/modules/web.dom-collections.for-each.js"; import { cleanName, isVue3, Vue2 } from 'vue-inbrowser-compiler-utils'; import { addGlobalComponentToRegistration } from './globalComponents'; var isEs6Export = function isEs6Export(module) { return !!module["default"]; }; /** * Expose component as global variables. * * @param {Object} component */ export default function globalizeComponent(component) { var displayName = component.props.displayName || ''; if (!component.name) { return; } var configComponent = isEs6Export(component.module) ? component.module["default"] : component.module; if (configComponent) { if (isVue3) { addGlobalComponentToRegistration(cleanName(displayName), configComponent); } else { // @ts-ignore this is to keep vue 2 compatibility Vue2.component(cleanName(displayName), configComponent); } } if (component.subComponents) { component.subComponents.forEach(function (c) { return globalizeComponent(c); }); } }