UNPKG

velund

Version:

Модульная UI-система на Vite для полиглотных бэкендов

28 lines (26 loc) 731 B
function defineVelundApp(components, routes = []) { const preparedRoutes = []; for (const route of routes) { if (typeof route.component === "string") { const routeComp = components.find( (comp) => comp.name === route.component ); if (!routeComp) { console.warn( `[WARN] Undefined component for route ${route.path} (${route.component})` ); continue; } preparedRoutes.push({ ...route, component: routeComp }); continue; } preparedRoutes.push(route); } const app = { components: components || [], routes: preparedRoutes }; Object.assign(globalThis, { __APP__: app }); return app; } export { defineVelundApp as default };