0
Fork 0
mirror of https://github.com/TanStack/router.git synced 2026-11-18 19:34:24 +00:00
Commit graph

248 commits

Author SHA1 Message Date
Manuel Schiller
1ab8d26826 Merge remote-tracking branch 'origin/main' into HEAD 2025-08-20 18:32:40 +02:00
Tanner Linsley
83ab17331b release: v1.131.27 2025-08-19 06:53:58 +00:00
Flo
a7504ae79e
refactor(router-core): simplify defaultParseSearch & defaultStringifySearch (#4985)
Wait for this PR before merging:
https://github.com/TanStack/router/pull/4987. It adds unit tests that
should help make sure we're not breaking anything here.

--- 

The functions used to serialize and deserialize search params are called
*a lot*, but they are creating many unnecessary objects. This PR
refactors
- `encode` to be only as generic as what we need => in practice we only
need to handle 1 value per key (i.e. `.set()` and not `.append()`) so we
don't need a special case for arrays
- `decode` can avoid creating many arrays
- `stringifySearchWith` (and `defaultStringifySearch`) don't need to
pre-stringify the input into a `<string,string>` dictionary as `encode`
now accepts a stringifier function


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- Breaking Changes
- Removed encode and decode from React Router and Solid Router public
exports.
  - Query string prefix support removed in encode/decode.
- Refactor
- Updated query string handling: arrays encode as comma-separated
values; duplicate keys decode into arrays.
- Streamlined error handling and avoided input mutation; consistent
leading “?” management.
- Tests
- Updated tests to match new encoding/decoding behavior and removed
prefix-related cases.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-19 08:42:53 +02:00
Manuel Schiller
43c01fb9d2 rename 2025-08-18 19:37:35 +02:00
Tanner Linsley
f2190d77ba release: v1.131.26 2025-08-18 07:56:53 +00:00
Manuel Schiller
a75e1913bf custom transformers 2025-08-18 00:52:23 +02:00
Tanner Linsley
fa3f8faf45 release: v1.131.25 2025-08-17 19:27:38 +00:00
Flo
a7b1667827
refactor(router-core): remove pick utility in favor of direct object manipulation (#4983)
Based on the current usage of `pick`, directly addinf the picked keys to
the objects will be less overhead with the same result.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- Refactor
- Simplified internal routing logic related to navigation options; no
change to runtime behavior.
- Chores
  - Removed an internal utility no longer used.
- Public API
- One non-essential utility export was removed from package entry
points, slightly reducing the public API surface.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-17 21:26:07 +02:00
Tanner Linsley
472cac4ae4 release: v1.131.24 2025-08-17 16:43:55 +00:00
Flo
642964e4e3
refactor(router-core): reduce buildLocation object allocations (#4981)
When we can (and it's reasonable), it's always beneficial to reduce the
number of objects we create in JS, so as to minimize the memory pressure
and the GC work.

`buildLocation` gets called pretty often, so removing a few object
allocations can be very beneficial (especially inside loops).

Also, from a purely "immediate performance" point of view,
`Object.assign` tends to be faster than `{...foo}`.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Refactor**
* Route parameter and search handling now use in-place updates to reduce
allocations and streamline iteration/control flow; behavior and public
API remain unchanged.
* **Tests**
* Updated tests to capture cloned parameter objects and assert on exact
values rather than relying on mock call history, preventing
mutation-related flakiness.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-17 18:35:45 +02:00
Tanner Linsley
b953a37860 release: v1.131.23 2025-08-17 16:32:35 +00:00
Flo
9437fee5c7
refactor(router-core,react-router,solid-router): avoid copying arrays just to .reverse() them (#4980)
The pattern of copying an array just to `.reverse()` it and iterate it
from the end ends up creating a transient object (a copy of the array)
that needs to be garbage collected.

For example:
```ts
[...array].reverse().find(() => {/*...*/})
```
or
```ts
[...array].reverse().forEach(() => {/*...*/})
```

Instead we can use a regular `for` loop to iterate it from the end. This
will be mostly beneficial in `router-core > router > buildLocation` that
gets called pretty often.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Improved head metadata processing in React and Solid routers to be
more efficient and readable, reducing work for large route metadata
sets.
- Simplified route matching logic to consistently pick the last relevant
match, improving clarity and maintainability.

- **Chores**
- Added a utility to locate the last list item meeting a condition,
supporting cleaner routing internals.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-17 18:30:59 +02:00
Tanner Linsley
72b65cfcca release: v1.131.22 2025-08-16 19:08:03 +00:00
Manuel Schiller
0383286742 Merge remote-tracking branch 'origin/main' into HEAD 2025-08-16 20:19:21 +02:00
Tanner Linsley
cb6d34aa95 release: v1.131.21 2025-08-16 17:42:54 +00:00
Tanner Linsley
5c59e429a8 release: v1.131.20 2025-08-16 17:29:16 +00:00
Gürkan Sevil
2c24acbd06
fix(solid-router): correctly assign createLazyFileRoute on window (#4956) 2025-08-16 19:15:58 +02:00
Manuel Schiller
bcfe15e676 Merge remote-tracking branch 'origin/main' into HEAD 2025-08-16 19:14:18 +02:00
Tanner Linsley
35485bb328 release: v1.131.19 2025-08-16 15:33:56 +00:00
Tanner Linsley
74be2861ca release: v1.131.18 2025-08-16 12:04:58 +00:00
Tanner Linsley
1ccf7c827a release: v1.131.17 2025-08-16 08:50:25 +00:00
Tanner Linsley
4dd0cbeb3e release: v1.131.16 2025-08-15 21:21:30 +00:00
Flo
d6a77e1d6b
refactor(router-core): flatten loadMatches (#4961)
This PR *should* be a no-op. Just restructuring the code to have all the
functions used by `loadMatches` at the same level, instead of nested
callbacks. In order to still have access to the data that was previously
in scope because of nesting, we use a `innerLoadContext` object, which
is basically just the arguments of `loadMatches`, and a few mutables.

However, in order to do so, we have to rearrange promises in an area
that is sensitive to any microtask order change, and we did change some
of them. So this is not *really* a no-op, even though this does not
attempt any optimization.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- New Features
- Smoother navigations with predictable pending states and minimum
display durations.
  - More consistent head/meta updates after route loading.
- Bug Fixes
- More reliable redirects and 404 handling, including during preloading
and SSR.
  - Reduced UI flicker by refining pending and preloading behavior.
- Refactor
- Reworked the routing load pipeline for improved performance,
stability, and SSR behavior.
- Streamlined before-load steps for clearer, more consistent execution.
- Tests
  - Updated tests to reflect the new loading flow.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-15 23:19:56 +02:00
Tanner Linsley
be3931bf4b release: v1.131.14 2025-08-15 14:43:10 +00:00
Flo
fe3bb45a7c
refactor(router-core): skip loader and store update if nothing to await (#4926)
Following https://github.com/TanStack/router/pull/4916 and
https://github.com/TanStack/router/pull/4925, this PR keeps reducing the
number of store updates (`__store.setState` through `updateMatch`).

Reduce amount of work in `runLoader`:
- don't `updateMatch` to set `isFetching: 'loader'` if we know the
entire function will be synchronous
- don't await `route.options.loader()` if it is synchronous
- don't update store with `loaderData` if `route.options.loader` is not
defined
- don't `await route._lazyPromise` if it has already resolved
- don't `await route._componentsPromise` if it has already resolved
- don't `await minPendingPromise` if it is not defined or has already
resolved

For a sync `loader`, with already loaded route chunks, `runLoader`
should be synchronous and trigger a single `updateMatch` call.

---

The `store-updates-during-navigation` test tracking the number of
executions of a `useRouterState > select` method during a navigation
goes from **19 calls** without this PR, to **17 calls** with this PR.

---

Should be a partial improvement of
https://github.com/TanStack/router/issues/4359

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-15 16:41:41 +02:00
Tanner Linsley
191ad1eda4 release: v1.131.13 2025-08-15 07:51:01 +00:00
Tanner Linsley
e8e7a74b20 release: v1.131.12 2025-08-15 07:39:21 +00:00
Tanner Linsley
1c2977cd47 release: v1.132.0-alpha.1 2025-08-13 21:07:17 +00:00
Tanner Linsley
69c1d753ac release: v1.131.9 2025-08-13 20:47:33 +00:00
Brenley Dueck
e86dfea947
fix: remount deps for solid (#4947) 2025-08-13 22:41:56 +02:00
Sean Cassiere
63c6df8d13
test(solid-router): add test from #4930 (#4941) 2025-08-13 13:36:12 +12:00
Tanner Linsley
1707df15c4 release: v1.131.8 2025-08-13 01:07:21 +00:00
jihoon
638a902ee6
fix(router-plugin): add support for boolean and null literals in code splitter (#4915)
Co-authored-by: SeanCassiere <33615041+SeanCassiere@users.noreply.github.com>
2025-08-13 13:01:57 +12:00
Tanner Linsley
4266be986c release: v1.132.0-alpha.0 2025-08-12 18:16:03 +00:00
Tanner Linsley
82f309bf98 release: v1.121.0-alpha.28 2025-08-12 17:49:31 +00:00
Tanner Linsley
38abdc2869 release: v1.131.7 2025-08-12 07:21:13 +00:00
Manuel Schiller
c0f6a35f17 remove unused exports 2025-08-11 21:55:42 +02:00
Tanner Linsley
93c624c5d3 release: v1.131.5 2025-08-11 14:06:14 +00:00
Flo
94ea50ff19
refactor(react-router,solid-router): Minor simplification of MatchInner match logic in select (#4921)
We don't need the `matchIndex` in `Match > MatchInner > useRouterState >
select`. It must have been left after a previous refactor.
2025-08-11 15:58:39 +02:00
Tanner Linsley
b84a5ce0c1 release: v1.131.4 2025-08-11 12:01:14 +00:00
Flo
916253ad2d
refactor(router-core): Reduce navigation work by making some properties non-reactive (#4916)
Some of the properties of a route match in the store do not need to be
reactive (i.e. reactive = trigger the execution of all subscribers when
they change).

This PR proposes we add a `_nonReactive` key for storing these
properties.

Changes to properties in `_nonReactive` can be made like on a regular
object, without the need to call `__store.setState`, and without making
a shallow copy of the object.

The following properties were moved to `_nonReactive` (but more would be
welcome if we can find which ones):
- `beforeLoadPromise`
- `loaderPromise`
- `pendingTimeout`
- `loadPromise`
- `displayPendingPromise`
- `minPendingPromise`
- `dehydrated`

This results in the removal of 4 `updateMatch` calls in `router-core`.
At least 1 of which is in the hot-path of a navigation (`loadMatches` >
`validResolvedMatches.forEach`). And the removal of 2 `updateMatch`
calls in `packages/react-router/src/Match.tsx` (and solid-router too).

The `ssr` property was also updated to not be reactive, but kept outside
of `_nonReactive` because it is part of the public API. This removes
another call to `updateMatch`. This key is an exception, and if in the
future we find a need to have more "public but non-reactive" properties,
we could consider
- hiding internal props in a separate type, or
- adding a dev proxy to ensure non-reactive props aren't accessed inside
`select` functions

---

This PR adds a unit-test in `react-router` that counts how many times
the `select` inside a `useRouterState` hook is called during a
navigation. Without this PR, the result of this test is **26 calls**.
With this PR, we're down to **19 calls**.

---

Should be a partial improvement of
https://github.com/TanStack/router/issues/4359

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-11 13:59:36 +02:00
Tanner Linsley
cf99c6a3f4 release: v1.131.3 2025-08-10 21:40:01 +00:00
Manuel Schiller
f436579232 Merge remote-tracking branch 'origin/main' into HEAD 2025-08-09 12:13:50 +02:00
Tanner Linsley
ef74fc661b release: v1.131.2 2025-08-08 23:39:20 +00:00
Manuel Schiller
fa7a554c49 don't reexport invariant/warning 2025-08-09 01:00:47 +02:00
Manuel Schiller
af0cd986c2 Revert "fix: do not pre-decodeURI before passing to createMemoryHistory (#4893)"
This reverts commit e75531647a.
2025-08-09 00:35:19 +02:00
Manuel Schiller
4d0eca241a bump vite-plugin-solid
this brings compatibility with vite 7
2025-08-09 00:11:38 +02:00
Tanner Linsley
cc499c3b92 release: v1.130.17 2025-08-08 21:37:57 +00:00
Tanner Linsley
e75531647a
fix: do not pre-decodeURI before passing to createMemoryHistory (#4893)
fixes #4514
2025-08-08 15:36:37 -06:00
Tanner Linsley
cd1de7edb7 release: v1.130.12 2025-08-01 20:38:24 +00:00