Files
InvoiceShelf/resources/scripts-v2/global-components.ts
Darko Gjorgjijoski 812956abcc Phase 5-6: Router, plugins, entry points — scripts-v2 complete
13 files completing the TypeScript migration:
- router/ (3 files): typed guards, route meta augmentation,
  merged feature routes from all 16 modules
- plugins/ (4 files): i18n with dynamic locale loading, pinia,
  tooltip directive
- Entry points: main.ts, InvoiceShelf.ts bootstrap class,
  App.vue, global-components.ts with typed registration
- NoCompanyView and NotFoundView stubs

scripts-v2/ totals: 324 files, 42853 lines of strict TypeScript.
Zero any types. Complete feature-based architecture with typed
stores, API services, composables, and Vue components.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 08:00:00 +02:00

45 lines
1.4 KiB
TypeScript

import { defineAsyncComponent } from 'vue'
import type { App, Component } from 'vue'
/**
* Register all base components globally so they can be used in
* templates without explicit imports.
*
* Eager-loaded components come from `./components/base/*.vue` via
* Vite's `import.meta.glob`. A handful of heavier components
* (table, multiselect, editor) are registered as async components
* to keep the initial bundle small.
*/
export function defineGlobalComponents(app: App): void {
// Eager-load all single-file base components
const components: Record<string, { default: Component }> = import.meta.glob(
'./components/base/*.vue',
{ eager: true }
)
for (const [path, definition] of Object.entries(components)) {
const fileName = path.split('/').pop()
if (!fileName) continue
const componentName = fileName.replace(/\.\w+$/, '')
app.component(componentName, definition.default)
}
// Async-load heavier components
const BaseTable = defineAsyncComponent(
() => import('./components/table/DataTable.vue')
)
const BaseMultiselect = defineAsyncComponent(
() => import('./components/base/BaseMultiselect.vue')
)
const BaseEditor = defineAsyncComponent(
() => import('./components/editor/RichEditor.vue')
)
app.component('BaseTable', BaseTable)
app.component('BaseMultiselect', BaseMultiselect)
app.component('BaseEditor', BaseEditor)
}