Fix build warnings: add isImageFile util, exclude heavy components

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>
This commit is contained in:
Darko Gjorgjijoski
2026-04-04 10:15:00 +02:00
parent af92a361a5
commit 97f88eaf2c
3 changed files with 40 additions and 17 deletions

View File

@@ -1,19 +1,29 @@
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.
*
* 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
// Eager-load base components (excluding heavy/page-level ones)
const components: Record<string, { default: Component }> = import.meta.glob(
'./components/base/*.vue',
[
'./components/base/*.vue',
'!./components/base/BaseMultiselect.vue',
'!./components/base/InvoicePublicPage.vue',
'!./components/base/InvoiceInformationCard.vue',
],
{ eager: true }
)
@@ -26,19 +36,18 @@ export function defineGlobalComponents(app: App): void {
}
// Async-load heavier components
const BaseTable = defineAsyncComponent(
() => import('./components/table/DataTable.vue')
app.component(
'BaseTable',
defineAsyncComponent(() => import('./components/table/DataTable.vue'))
)
const BaseMultiselect = defineAsyncComponent(
() => import('./components/base/BaseMultiselect.vue')
app.component(
'BaseMultiselect',
defineAsyncComponent(() => import('./components/base/BaseMultiselect.vue'))
)
const BaseEditor = defineAsyncComponent(
() => import('./components/editor/RichEditor.vue')
app.component(
'BaseEditor',
defineAsyncComponent(() => import('./components/editor/RichEditor.vue'))
)
app.component('BaseTable', BaseTable)
app.component('BaseMultiselect', BaseMultiselect)
app.component('BaseEditor', BaseEditor)
}

View File

@@ -27,6 +27,13 @@ async function loadLanguageMessages(
return languageCache.get(locale)!
}
// English is already statically imported — no dynamic import needed
if (locale === 'en') {
const messages = en as unknown as Record<string, unknown>
languageCache.set('en', messages)
return messages
}
const fileName = LOCALE_FILE_MAP[locale] ?? locale
try {

View File

@@ -76,6 +76,13 @@ export function formatMoney(
* @param currency - Currency configuration used for parsing
* @returns Amount in cents
*/
/**
* Check if a MIME type represents an image file.
*/
export function isImageFile(mimeType: string): boolean {
return mimeType.startsWith('image/')
}
export function parseMoneyCents(
formattedAmount: string,
currency: CurrencyConfig = DEFAULT_CURRENCY