Skip to content

Commit 05648d0

Browse files
perf(frontend): stop sharing lucide-react over Module Federation (#2516)
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 <noreply@anthropic.com>
1 parent b1dbe6c commit 05648d0

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

frontend/module-federation.config.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ export const moduleFederationConfig: ModuleFederationPluginOptions = {
6969
singleton: true,
7070
requiredVersion: deps.zod,
7171
},
72-
'lucide-react': {
73-
singleton: true,
74-
requiredVersion: deps['lucide-react'],
75-
eager: false,
76-
},
72+
// lucide-react is intentionally NOT shared. It is stateless SVG components
73+
// (no context/hooks), so it has no singleton requirement. Sharing it as a
74+
// singleton forced the whole package (~1.5 MiB / 1700+ icons) into a shared
75+
// chunk regardless of which icons are used; unshared, this remote tree-shakes
76+
// to only the icons it imports and can upgrade lucide independently of the
77+
// cloud-ui host. The host and the adp-ui remote unshare it too.
7778
'class-variance-authority': {
7879
singleton: false,
7980
requiredVersion: deps['class-variance-authority'],

0 commit comments

Comments
 (0)