From f218ac6e697c789272048a38048ae1a6a58cba85 Mon Sep 17 00:00:00 2001 From: "bert.hausmans" Date: Tue, 12 May 2026 07:47:06 +0200 Subject: [PATCH] fix(primevue): switch installer to named export to stop double-registration main.ts explicitly calls installPrimeVue(app) AFTER registerPlugins(app) per the comment in main.ts ("so PrimeVue lives outside the Vuexy @core machine"). The intent was a single registration site outside the auto-discovery loop. Bug: registerPlugins (src/@core/utils/plugins.ts) globs plugins/*/index.{ts,js} eagerly and invokes the `default` export of each match. plugins/primevue/index.ts was exporting installPrimeVue as the default, so registerPlugins also picked it up and called it. End result: PrimeVue and its three services (Toast, Confirmation, Dialog) were each registered twice on every app boot. Visible symptoms: duplicate Toast emissions on a single Toast.add() call, and ConfirmationService callbacks firing twice for one user confirmation. Fix: convert `export default function installPrimeVue` to a NAMED export, and update main.ts's import to `{ installPrimeVue }`. The registerPlugins glob still picks up the module path but the `pluginImportModule.default?.(app)` invocation becomes a no-op via optional chaining (no default export to call). main.ts remains the single registration site. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/app/src/main.ts | 2 +- apps/app/src/plugins/primevue/index.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/app/src/main.ts b/apps/app/src/main.ts index 8b66ae9e..85ae2154 100644 --- a/apps/app/src/main.ts +++ b/apps/app/src/main.ts @@ -12,7 +12,7 @@ import { router } from '@/plugins/1.router' import App from '@/App.vue' import { registerPlugins } from '@core/utils/plugins' -import installPrimeVue from '@/plugins/primevue' +import { installPrimeVue } from '@/plugins/primevue' // Styles import '@styles/tailwind.css' diff --git a/apps/app/src/plugins/primevue/index.ts b/apps/app/src/plugins/primevue/index.ts index 83f00a39..6d3ead79 100644 --- a/apps/app/src/plugins/primevue/index.ts +++ b/apps/app/src/plugins/primevue/index.ts @@ -6,6 +6,16 @@ // Per RFC-WS-FRONTEND-PRIMEVUE AD-2: darkModeSelector matches Vuexy's // `.dark` class convention so existing skin-toggle plumbing continues // to work during the F3–F6 parallel-mode window. +// +// Exported as a NAMED function (no `export default`) on purpose: the +// Vuexy registerPlugins() helper (src/@core/utils/plugins.ts) globs +// plugins/*/index.{ts,js} and invokes the `default` export of each +// match. A default export here would cause PrimeVue + its three +// services to register twice — once via registerPlugins, once via the +// explicit installPrimeVue(app) call in main.ts. The named export +// keeps the explicit installer in main.ts as the single registration +// site, which is the design intent (decouple PrimeVue from the Vuexy +// @core machine so F6 can delete @core/ without affecting PrimeVue). import type { App } from 'vue' import PrimeVue from 'primevue/config' @@ -17,7 +27,7 @@ import nl from 'primelocale/nl.json' import { CrewliPreset } from './theme' import { ptDefaults } from './defaults' -export default function installPrimeVue(app: App) { +export function installPrimeVue(app: App) { app.use(PrimeVue, { theme: { preset: CrewliPreset,