Skip to content
Source
Sign inSign up
TanStack/router

fix(router-plugin): preserve shared bindings during React HMR #8455

OpenSheraff(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromfix/router-plugin-hmr-shared-destructuringopened

Showing 17 changed files with 26 additions and 3 deletions (loading 14).

x
0 of 17 viewed, 17 left
5 additions and 0 deletions.changeset/bumpy-socks-find.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/router-plugin': patch
+---
+​
+Preserve shared binding names during React route HMR so destructured component helpers are initialized once instead of causing duplicate declaration errors.
12 additions and 3 deletionspackages/router-plugin/src/core/code-splitter/plugins/react-refresh-route-components.tsModified
View file
@@ -35,7 +35,10 @@
return key && REACT_REFRESH_ROUTE_COMPONENT_IDENTS.has(key) ? key : undefined
​
-function prepareRouteComponentsForReactRefresh(ctx: RouteComponentContext) {
+function prepareRouteComponentsForReactRefresh(
+ ctx: RouteComponentContext,
+ sharedBindings?: Set<string>,
+) {
const hoistedDeclarations: Array<t.VariableDeclaration> = []
let modified = false
​
@@ -51,7 +54,13 @@
​