Skip to content
Source
Sign inSign up
TanStack/router

fix(router-plugin): export a shared binding as-is when a split route option uses it #8773

Opendasjideepak(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/8773/headopened

Showing 3 changed files with 75 additions and 0 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/shared-split-target-export.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/router-plugin': patch
+---
+​
+fix(router-plugin): export a shared binding as-is when a split route option uses it
11 additions and 0 deletionspackages/router-plugin/src/core/code-splitter/compilers.tsModified
View file
@@ -1009,6 +1009,17 @@
originalIdentName = splitNode.name
+ // A shared binding's declaration was removed above and is imported
+ // from the shared module, so export that import as-is
+ if (
+ originalIdentName &&
+ opts.sharedBindings?.has(originalIdentName)
+ ) {
+ splitMeta.localExporterIdent = originalIdentName
+ splitMeta.shouldRemoveNode = false
+ splitNode = undefined
+ }
+​
while (t.isIdentifier(splitNode)) {
const binding = programPath.scope.getBinding(splitNode.name)