@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.
@@ -107,14 +107,14 @@ class RouterCore {
107
107
  if (this.options.routeTree !== this.routeTree) {
108
108
  this.routeTree = this.options.routeTree;
109
109
  let processRouteTreeResult;
110
- if ((isServer ?? this.isServer) && globalThis.__TSR_CACHE__ && globalThis.__TSR_CACHE__.routeTree === this.routeTree) {
110
+ if ((isServer ?? this.isServer) && process.env.NODE_ENV !== "development" && globalThis.__TSR_CACHE__ && globalThis.__TSR_CACHE__.routeTree === this.routeTree) {
111
111
  const cached = globalThis.__TSR_CACHE__;
112
112
  this.resolvePathCache = cached.resolvePathCache;
113
113
  processRouteTreeResult = cached.processRouteTreeResult;
114
114
  } else {
115
115
  this.resolvePathCache = createLRUCache(1e3);
116
116
  processRouteTreeResult = this.buildRouteTree();
117
- if ((isServer ?? this.isServer) && globalThis.__TSR_CACHE__ === void 0) {
117
+ if ((isServer ?? this.isServer) && process.env.NODE_ENV !== "development" && globalThis.__TSR_CACHE__ === void 0) {
118
118
  globalThis.__TSR_CACHE__ = {
119
119
  routeTree: this.routeTree,
120
120
  processRouteTreeResult,
@@ -1127,6 +1127,9 @@ class RouterCore {
1127
1127
  }
1128
1128
  const globalNotFoundRouteId = isGlobalNotFound ? findGlobalNotFoundRouteId(this.options.notFoundMode, matchedRoutes) : void 0;
1129
1129
  const matches = new Array(matchedRoutes.length);
1130
+ const previousMatchesByRouteId = new Map(
1131
+ this.state.matches.map((match) => [match.routeId, match])
1132
+ );
1130
1133
  for (let index = 0; index < matchedRoutes.length; index++) {
1131
1134
  const route = matchedRoutes[index];
1132
1135
  const parentMatch = matches[index - 1];
@@ -1176,9 +1179,7 @@ class RouterCore {
1176
1179
  loaderDepsHash
1177
1180
  );
1178
1181
  const existingMatch = this.getMatch(matchId);
1179
- const previousMatch = this.state.matches.find(
1180
- (d) => d.routeId === route.id
1181
- );
1182
+ const previousMatch = previousMatchesByRouteId.get(route.id);
1182
1183
  const strictParams = existingMatch?._strictParams ?? usedParams;
1183
1184
  let paramsError = void 0;
1184
1185
  if (!existingMatch) {
@@ -1204,7 +1205,7 @@ class RouterCore {
1204
1205
  match = {
1205
1206
  ...existingMatch,
1206
1207
  cause,
1207
- params: previousMatch ? replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
1208
+ params: previousMatch?.params ?? routeParams,
1208
1209
  _strictParams: strictParams,
1209
1210
  search: previousMatch ? replaceEqualDeep(previousMatch.search, preMatchSearch) : replaceEqualDeep(existingMatch.search, preMatchSearch),
1210
1211
  _strictSearch: strictMatchSearch
@@ -1216,7 +1217,7 @@ class RouterCore {
1216
1217
  ssr: isServer ?? this.isServer ? void 0 : route.options.ssr,
1217
1218
  index,
1218
1219
  routeId: route.id,
1219
- params: previousMatch ? replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
1220
+ params: previousMatch?.params ?? routeParams,
1220
1221
  _strictParams: strictParams,
1221
1222
  pathname: interpolatedPath,
1222
1223
  updatedAt: Date.now(),
@@ -1263,6 +1264,8 @@ class RouterCore {
1263
1264
  const match = matches[index];
1264
1265
  const route = this.looseRoutesById[match.routeId];
1265
1266
  const existingMatch = this.getMatch(match.id);
1267
+ const previousMatch = previousMatchesByRouteId.get(match.routeId);
1268
+ match.params = previousMatch ? replaceEqualDeep(previousMatch.params, routeParams) : routeParams;
1266
1269
  if (!existingMatch) {
1267
1270
  const parentMatch = matches[index - 1];
1268
1271
  const parentContext = this.getParentContext(parentMatch);