Skip to content

perf(frontend): unshare lucide-react over Module Federation#2516

Merged
malinskibeniamin merged 1 commit into
masterfrom
ben/unshare-lucide-mf
Jun 19, 2026
Merged

perf(frontend): unshare lucide-react over Module Federation#2516
malinskibeniamin merged 1 commit into
masterfrom
ben/unshare-lucide-mf

Conversation

@malinskibeniamin

Copy link
Copy Markdown
Contributor

Stop sharing lucide-react over Module Federation

lucide-react is a Module Federation shared singleton in this remote
(singleton: true, eager: false). Sharing a package as a singleton forces its
entire entry into the shared chunk — all ~1700 icon modules (~1.5 MiB) —
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 (no context/hooks), so — unlike
react / react-dom / @tanstack/react-query / @tanstack/react-router — it has no
singleton requirement
. Removing it from shared:

  • lets this remote tree-shake to only the icons it imports (184 named imports, zero barrels), and
  • lets console upgrade lucide independently of the cloud-ui host (the shared singleton currently locks all federated apps to one lucide version).

When embedded in a host that no longer provides lucide, this remote uses its own
bundled copy — safe, because the components are stateless (no two-instance hazard
like hooks/context).

Coordinated change

The cloud-ui host and the adp-ui remote unshare lucide in the cloudv2 repo
(redpanda-data/cloudv2#27233), so once all three land, no full lucide copy
exists in the embedded scene
— each app ships only the icons it uses.

Verified: MF config lints clean (ultracite). Full build/e2e validated by CI.

🤖 Generated with Claude Code

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>
@malinskibeniamin malinskibeniamin marked this pull request as ready for review June 18, 2026 08:02
@malinskibeniamin malinskibeniamin self-assigned this Jun 18, 2026
@malinskibeniamin malinskibeniamin enabled auto-merge (squash) June 18, 2026 08:09
@malinskibeniamin malinskibeniamin merged commit 05648d0 into master Jun 19, 2026
16 checks passed
@malinskibeniamin malinskibeniamin deleted the ben/unshare-lucide-mf branch June 19, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants