@tanstack/react-router 1.57.17 → 1.58.1

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.
@@ -17,6 +17,15 @@ const componentTypes = [
17
17
  "pendingComponent",
18
18
  "notFoundComponent"
19
19
  ];
20
+ function routeNeedsPreload(route) {
21
+ var _a;
22
+ for (const componentType of componentTypes) {
23
+ if ((_a = route.options[componentType]) == null ? void 0 : _a.preload) {
24
+ return true;
25
+ }
26
+ }
27
+ return false;
28
+ }
20
29
  function createRouter(options) {
21
30
  return new Router(options);
22
31
  }
@@ -225,7 +234,7 @@ class Router {
225
234
  };
226
235
  this.buildLocation = (opts) => {
227
236
  const build = (dest = {}, matches) => {
228
- var _a, _b, _c, _d;
237
+ var _a, _b, _c, _d, _e;
229
238
  const fromMatches = dest._fromLocation ? this.matchRoutes(dest._fromLocation) : this.state.matches;
230
239
  const fromMatch = dest.from != null ? fromMatches.find(
231
240
  (d) => path.matchPathname(this.basepath, path.trimPathRight(d.pathname), {
@@ -239,16 +248,16 @@ class Router {
239
248
  dest.from == null || fromMatch != null,
240
249
  "Could not find match for from: " + dest.from
241
250
  );
242
- const fromSearch = this.state.pendingMatches ? (_a = utils.last(this.state.pendingMatches)) == null ? void 0 : _a.search : ((_b = utils.last(fromMatches)) == null ? void 0 : _b.search) || this.latestLocation.search;
251
+ const fromSearch = ((_a = this.state.pendingMatches) == null ? void 0 : _a.length) ? (_b = utils.last(this.state.pendingMatches)) == null ? void 0 : _b.search : ((_c = utils.last(fromMatches)) == null ? void 0 : _c.search) || this.latestLocation.search;
243
252
  const stayingMatches = matches == null ? void 0 : matches.filter(
244
253
  (d) => fromMatches.find((e) => e.routeId === d.routeId)
245
254
  );
246
- const fromRouteByFromPathRouteId = this.routesById[(_c = stayingMatches == null ? void 0 : stayingMatches.find((d) => d.pathname === fromPath)) == null ? void 0 : _c.routeId];
255
+ const fromRouteByFromPathRouteId = this.routesById[(_d = stayingMatches == null ? void 0 : stayingMatches.find((d) => d.pathname === fromPath)) == null ? void 0 : _d.routeId];
247
256
  let pathname = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(
248
257
  fromPath,
249
258
  (fromRouteByFromPathRouteId == null ? void 0 : fromRouteByFromPathRouteId.to) ?? fromPath
250
259
  );
251
- const prevParams = { ...(_d = utils.last(fromMatches)) == null ? void 0 : _d.params };
260
+ const prevParams = { ...(_e = utils.last(fromMatches)) == null ? void 0 : _e.params };
252
261
  let nextParams = (dest.params ?? true) === true ? prevParams : { ...prevParams, ...utils.functionalUpdate(dest.params, prevParams) };
253
262
  if (Object.keys(nextParams).length > 0) {
254
263
  matches == null ? void 0 : matches.map((d) => {
@@ -1371,7 +1380,7 @@ class Router {
1371
1380
  params: routeParams
1372
1381
  };
1373
1382
  } else {
1374
- const status = route.options.loader || route.options.beforeLoad || route.lazyFn ? "pending" : "success";
1383
+ const status = route.options.loader || route.options.beforeLoad || route.lazyFn || routeNeedsPreload(route) ? "pending" : "success";
1375
1384
  match = {
1376
1385
  id: matchId,
1377
1386
  index,