@tanstack/router-core 1.158.4 → 1.159.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
- "version": "1.158.4",
3
+ "version": "1.159.6",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
package/src/router.ts CHANGED
@@ -1070,6 +1070,7 @@ export class RouterCore<
1070
1070
  let processRouteTreeResult: ProcessRouteTreeResult<TRouteTree>
1071
1071
  if (
1072
1072
  (isServer ?? this.isServer) &&
1073
+ process.env.NODE_ENV !== 'development' &&
1073
1074
  globalThis.__TSR_CACHE__ &&
1074
1075
  globalThis.__TSR_CACHE__.routeTree === this.routeTree
1075
1076
  ) {
@@ -1082,6 +1083,7 @@ export class RouterCore<
1082
1083
  // only cache if nothing else is cached yet
1083
1084
  if (
1084
1085
  (isServer ?? this.isServer) &&
1086
+ process.env.NODE_ENV !== 'development' &&
1085
1087
  globalThis.__TSR_CACHE__ === undefined
1086
1088
  ) {
1087
1089
  globalThis.__TSR_CACHE__ = {
@@ -1401,6 +1403,10 @@ export class RouterCore<
1401
1403
 
1402
1404
  const matches = new Array<AnyRouteMatch>(matchedRoutes.length)
1403
1405
 
1406
+ const previousMatchesByRouteId = new Map(
1407
+ this.state.matches.map((match) => [match.routeId, match]),
1408
+ )
1409
+
1404
1410
  for (let index = 0; index < matchedRoutes.length; index++) {
1405
1411
  const route = matchedRoutes[index]!
1406
1412
  // Take each matched route and resolve + validate its search params
@@ -1484,9 +1490,7 @@ export class RouterCore<
1484
1490
 
1485
1491
  const existingMatch = this.getMatch(matchId)
1486
1492
 
1487
- const previousMatch = this.state.matches.find(
1488
- (d) => d.routeId === route.id,
1489
- )
1493
+ const previousMatch = previousMatchesByRouteId.get(route.id)
1490
1494
 
1491
1495
  const strictParams = existingMatch?._strictParams ?? usedParams
1492
1496
 
@@ -1520,9 +1524,7 @@ export class RouterCore<
1520
1524
  match = {
1521
1525
  ...existingMatch,
1522
1526
  cause,
1523
- params: previousMatch
1524
- ? replaceEqualDeep(previousMatch.params, routeParams)
1525
- : routeParams,
1527
+ params: previousMatch?.params ?? routeParams,
1526
1528
  _strictParams: strictParams,
1527
1529
  search: previousMatch
1528
1530
  ? replaceEqualDeep(previousMatch.search, preMatchSearch)
@@ -1543,9 +1545,7 @@ export class RouterCore<
1543
1545
  ssr: (isServer ?? this.isServer) ? undefined : route.options.ssr,
1544
1546
  index,
1545
1547
  routeId: route.id,
1546
- params: previousMatch
1547
- ? replaceEqualDeep(previousMatch.params, routeParams)
1548
- : routeParams,
1548
+ params: previousMatch?.params ?? routeParams,
1549
1549
  _strictParams: strictParams,
1550
1550
  pathname: interpolatedPath,
1551
1551
  updatedAt: Date.now(),
@@ -1605,7 +1605,11 @@ export class RouterCore<
1605
1605
  const route = this.looseRoutesById[match.routeId]!
1606
1606
  const existingMatch = this.getMatch(match.id)
1607
1607
 
1608
- // only execute `context` if we are not calling from router.buildLocation
1608
+ // Update the match's params
1609
+ const previousMatch = previousMatchesByRouteId.get(match.routeId)
1610
+ match.params = previousMatch
1611
+ ? replaceEqualDeep(previousMatch.params, routeParams)
1612
+ : routeParams
1609
1613
 
1610
1614
  if (!existingMatch) {
1611
1615
  const parentMatch = matches[index - 1]