Grab-bag of small items from a library audit (see AUDIT.md on branch claude/library-audit-sxpugz, §1.10 / §3.10) that don't warrant individual issues. Each is independently actionable.
-
Cache compiled URLPatterns. matchPath constructs new URLPattern(...) per route per match attempt (packages/router/src/core/matchRoutes.ts). A module-level Map<string, URLPattern> keyed by the pattern string would cut per-navigation work; route tables are small and static so the map stays tiny.
-
idleController is module-level (packages/router/src/core/NavigationAPIAdapter.ts), shared across adapter instances. Two Routers on one page share and abort each other's initial-load signal. Making it an instance field matches the rest of the adapter's state.
-
locationInfo outlives the navigation. #currentNavigationInfo is only cleared when the next navigate event fires, so info (documented as "only available during navigation, not persisted") remains readable via context/props long after the navigation finished. Either clear it on navigatesuccess/currententrychange completion or soften the docs.
-
Export matchRoutes/matchPath (and possibly a memory adapter) for userland testing. Apps currently can't unit-test their route tables without mounting <Router> plus a Navigation API mock. A documented matchRoutes(routes, pathname) export (marked as not-semver-stable if preferred) would go a long way; a memory adapter would enable full component tests without the global mock.
-
The navigatesuccess subscriber fallback fires in all browsers, not just WebKit Private Browsing — currently harmless because the snapshot cache makes the second callback a no-op re-set, but it's an easy place for future regressions. A comment and/or a test pinning "no extra render on navigatesuccess in normal browsers" would guard it.
Grab-bag of small items from a library audit (see
AUDIT.mdon branchclaude/library-audit-sxpugz, §1.10 / §3.10) that don't warrant individual issues. Each is independently actionable.Cache compiled URLPatterns.
matchPathconstructsnew URLPattern(...)per route per match attempt (packages/router/src/core/matchRoutes.ts). A module-levelMap<string, URLPattern>keyed by the pattern string would cut per-navigation work; route tables are small and static so the map stays tiny.idleControlleris module-level (packages/router/src/core/NavigationAPIAdapter.ts), shared across adapter instances. Two Routers on one page share and abort each other's initial-load signal. Making it an instance field matches the rest of the adapter's state.locationInfooutlives the navigation.#currentNavigationInfois only cleared when the next navigate event fires, soinfo(documented as "only available during navigation, not persisted") remains readable via context/props long after the navigation finished. Either clear it onnavigatesuccess/currententrychangecompletion or soften the docs.Export
matchRoutes/matchPath(and possibly a memory adapter) for userland testing. Apps currently can't unit-test their route tables without mounting<Router>plus a Navigation API mock. A documentedmatchRoutes(routes, pathname)export (marked as not-semver-stable if preferred) would go a long way; a memory adapter would enable full component tests without the global mock.The
navigatesuccesssubscriber fallback fires in all browsers, not just WebKit Private Browsing — currently harmless because the snapshot cache makes the second callback a no-op re-set, but it's an easy place for future regressions. A comment and/or a test pinning "no extra render on navigatesuccess in normal browsers" would guard it.