From 81a05e620761829a92808c7a00215c755ebb55e5 Mon Sep 17 00:00:00 2001 From: Beniamin Malinski Date: Thu, 18 Jun 2026 09:32:07 +0200 Subject: [PATCH] perf(frontend): stop sharing lucide-react over Module Federation lucide-react was a Module Federation shared singleton in the console remote. Sharing a package as a singleton forces its whole entry (all ~1700 icon modules, ~1.5 MiB) into the shared chunk regardless of how few icons are used, because the shared module is the package entry and any consumer might import any icon. lucide-react is stateless SVG components with no context or hooks, so unlike react/react-dom/@tanstack/react-query/react-router it has no singleton requirement. Removing it from `shared` lets this remote tree-shake to only the icons it imports (184 named import sites, no barrels) and upgrade lucide independently of the cloud-ui host. When loaded with a host that no longer provides lucide, this remote uses its own bundled copy (safe for stateless components). The cloud-ui host and the adp-ui remote unshare it in the cloudv2 repo, so no full lucide copy remains in the embedded scene. Co-Authored-By: Claude Opus 4.8 --- frontend/module-federation.config.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/module-federation.config.ts b/frontend/module-federation.config.ts index 88bc72a424..de899de413 100644 --- a/frontend/module-federation.config.ts +++ b/frontend/module-federation.config.ts @@ -69,11 +69,12 @@ export const moduleFederationConfig: ModuleFederationPluginOptions = { singleton: true, requiredVersion: deps.zod, }, - 'lucide-react': { - singleton: true, - requiredVersion: deps['lucide-react'], - eager: false, - }, + // lucide-react is intentionally NOT shared. It is stateless SVG components + // (no context/hooks), so it has no singleton requirement. Sharing it as a + // singleton forced the whole package (~1.5 MiB / 1700+ icons) into a shared + // chunk regardless of which icons are used; unshared, this remote tree-shakes + // to only the icons it imports and can upgrade lucide independently of the + // cloud-ui host. The host and the adp-ui remote unshare it too. 'class-variance-authority': { singleton: false, requiredVersion: deps['class-variance-authority'],