Skip to content

Consolidate module federation on a single router with federated route contribution#913

Merged
tjementum merged 1 commit into
mainfrom
pp-1336-single-router-module-federation
Jul 6, 2026
Merged

Consolidate module federation on a single router with federated route contribution#913
tjementum merged 1 commit into
mainfrom
pp-1336-single-router-module-federation

Conversation

@tjementum

Copy link
Copy Markdown
Member

Summary & Motivation

The module federation setup ran two TanStack routers in one browser tab: the main host's browser-history router and a second memory-history router mounted by the account remote. The second router rendered a duplicate copy of the host's entire root shell inside the account subtree (verified by React fiber inspection), duplicating the invitation banner, page tracking, and provider stack, and causing the tenant-switching end-to-end test to fail on freshly opened tabs. Navigation between the two routers was kept in sync by hand with history mutations, a context bridge, and a global guard registry.

  • One router per page: the account system exposes its route subtree via a new ./routes federated module, and the main host grafts it under its root at startup. The nested router, blockable memory history, history sync listeners, navigation context bridge, global guard registry, and route prefix allowlist are deleted
  • Banner rendering is single-owner: BannerContainer (renamed from BannerPortal) renders banners as ordinary children instead of portals into a shared DOM node looked up by id
  • @tanstack/react-router and @tanstack/react-query are enforced module federation singletons, and the federation types generator emits a factory signature for the routes expose
  • Lint guards prevent reintroduction: createRouter is blocked outside the two router hosts, createPortal is blocked in application code, and direct history.pushState/replaceState mutation is blocked
  • Account keeps typed navigation and search parameters through a type-only router registration with no runtime router instance
  • Frontend rules documentation updated to the single-router model, including the route protection boundary (guards and flags only in beforeLoad, no data loading)

Checklist

  • I have added tests, or done manual regression tests
  • I have updated the documentation, if necessary

@tjementum tjementum added the Enhancement New feature or request label Jul 6, 2026
@tjementum tjementum self-assigned this Jul 6, 2026
@tjementum tjementum moved this to 🏗 In Progress in Kanban board Jul 6, 2026
@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

@linear

linear Bot commented Jul 6, 2026

Copy link
Copy Markdown

PP-1336

@tjementum tjementum merged commit 269de1c into main Jul 6, 2026
27 of 28 checks passed
@tjementum tjementum deleted the pp-1336-single-router-module-federation branch July 6, 2026 14:19
@github-project-automation github-project-automation Bot moved this from 🏗 In Progress to ✅ Done in Kanban board Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

1 participant