mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 09:14:08 +00:00
from eager glob, clean up dynamic import conflicts - Add missing isImageFile() to format-money utils - Exclude BaseMultiselect, InvoicePublicPage, InvoiceInformationCard from eager glob in global-components.ts using negative patterns - Short-circuit English locale in i18n to avoid redundant dynamic import - Only en.json warning remains (intentional: English bundled inline) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { defineAsyncComponent } from 'vue'
|
|
import type { App, Component } from 'vue'
|
|
|
|
/**
|
|
* Exclude list for components that should be async-loaded or are
|
|
* not needed as global registrations.
|
|
*/
|
|
const EXCLUDE = new Set([
|
|
'BaseMultiselect',
|
|
'InvoicePublicPage',
|
|
'InvoiceInformationCard',
|
|
])
|
|
|
|
/**
|
|
* Register all base components globally so they can be used in
|
|
* templates without explicit imports.
|
|
*/
|
|
export function defineGlobalComponents(app: App): void {
|
|
// Eager-load base components (excluding heavy/page-level ones)
|
|
const components: Record<string, { default: Component }> = import.meta.glob(
|
|
[
|
|
'./components/base/*.vue',
|
|
'!./components/base/BaseMultiselect.vue',
|
|
'!./components/base/InvoicePublicPage.vue',
|
|
'!./components/base/InvoiceInformationCard.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
|
|
app.component(
|
|
'BaseTable',
|
|
defineAsyncComponent(() => import('./components/table/DataTable.vue'))
|
|
)
|
|
|
|
app.component(
|
|
'BaseMultiselect',
|
|
defineAsyncComponent(() => import('./components/base/BaseMultiselect.vue'))
|
|
)
|
|
|
|
app.component(
|
|
'BaseEditor',
|
|
defineAsyncComponent(() => import('./components/editor/RichEditor.vue'))
|
|
)
|
|
}
|