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