mirror of
https://github.com/hanzoai/frappe.git
synced 2026-11-09 14:28:40 +00:00
Add the @framework/ui/vite dedupe plugin (and its subpath export) that forces shared singletons to the host's single instance. vuedraggable is not shipped by frappe-ui, so move it from peerDependencies to this package's own dependencies and drop it from the dedupe list — it resolves by realpath like the leaflet family instead of deduping to a host copy that does not exist.
33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
// Vite plugin for apps that consume @framework/ui.
|
|
//
|
|
// @framework/ui ships raw .vue/.ts source and is linked into the host app by
|
|
// symlink, so the host bundler compiles it in place. Its bare imports of shared
|
|
// singletons therefore resolve by realpath into a *second* copy unless deduped,
|
|
// which breaks provide/inject context (reka-ui especially) and doubles vue.
|
|
// This plugin forces those singletons to the host's single instance.
|
|
//
|
|
// Opt-in: add `frameworkUI()` to a consuming app's vite `plugins`. Apps that do
|
|
// not use @framework/ui need not add it. Pass `{ dedupe: [...] }` to extend the
|
|
// list with app-specific raw-source singletons.
|
|
//
|
|
// Note: genuinely external deps @framework/ui owns (leaflet, vuedraggable, …)
|
|
// are NOT listed here — they ship in this package's own node_modules and resolve
|
|
// by realpath, so they must NOT be deduped to the host (the host does not have
|
|
// them). frappe-ui notably does not ship vuedraggable, so it lives in this
|
|
// package's dependencies, not the host's.
|
|
|
|
const SINGLETONS = ["vue", "vue-router", "frappe-ui", "reka-ui", "dompurify"];
|
|
|
|
export default function frameworkUI(options = {}) {
|
|
const extra = options.dedupe ?? [];
|
|
const dedupe = [...new Set([...SINGLETONS, ...extra])];
|
|
return {
|
|
name: "framework-ui-dedupe",
|
|
config() {
|
|
return {
|
|
resolve: { dedupe },
|
|
};
|
|
},
|
|
};
|
|
}
|