Which project does this relate to?
Router
Describe the bug
After upgrading @tanstack/router-plugin from 1.166.12 to 1.167.9, all vitest tests that import the generated routeTree.gen.ts fail with:
TypeError: Cannot set properties of undefined (setting 'tsr-split-component:component')
❯ src/routes/login.tsx:1:57
❯ src/routeTree.gen.ts:12:1
The HMR state storage mechanism introduced in PR #7000 / #7005 (react-stable-hmr-split-route-components.ts) writes to import.meta.hot.data['tsr-split-component:component'], but in vitest import.meta.hot.data is undefined.
This affects any project using autoCodeSplitting: true with vitest.
Your Example Website or App
https://github.com/FredrikErikJohansson/tanstack-router-vitest-repro
Steps to Reproduce the Bug or Issue
- Clone the repro:
git clone https://github.com/FredrikErikJohansson/tanstack-router-vitest-repro
npm install
npm test → fails with TypeError: Cannot set properties of undefined (setting 'tsr-split-component:component')
- Downgrade:
npm install @tanstack/router-plugin@1.166.12 @tanstack/react-router@1.167.3
npm test → passes
Expected behavior
Tests should pass. The HMR code injected by react-stable-hmr-split-route-components.ts should guard against import.meta.hot.data being undefined in test environments.
Screenshots or Videos
No response
Platform
- Router Version:
@tanstack/router-plugin 1.167.9, @tanstack/react-router 1.168.8
- OS: macOS
- Bundler: Vite 6.4.1 (also reproduced with 8.0.3)
- Vitest: 3.2.x / 4.1.x
Additional context
Root cause: PR #7000 and #7005 introduced tsr-split-component HMR state caching for React Fast Refresh stability. The injected code accesses import.meta.hot.data without a null guard. In vitest, import.meta.hot exists but .data is undefined.
Suggested fix: Add optional chaining in react-stable-hmr-split-route-components.ts:
import.meta.hot?.data?.['tsr-split-component:component']
Workaround: Pin to @tanstack/router-plugin@1.166.12 / @tanstack/react-router@1.167.3.
Which project does this relate to?
Router
Describe the bug
After upgrading
@tanstack/router-pluginfrom1.166.12to1.167.9, all vitest tests that import the generatedrouteTree.gen.tsfail with:The HMR state storage mechanism introduced in PR #7000 / #7005 (
react-stable-hmr-split-route-components.ts) writes toimport.meta.hot.data['tsr-split-component:component'], but in vitestimport.meta.hot.dataisundefined.This affects any project using
autoCodeSplitting: truewith vitest.Your Example Website or App
https://github.com/FredrikErikJohansson/tanstack-router-vitest-repro
Steps to Reproduce the Bug or Issue
git clone https://github.com/FredrikErikJohansson/tanstack-router-vitest-repronpm installnpm test→ fails withTypeError: Cannot set properties of undefined (setting 'tsr-split-component:component')npm install @tanstack/router-plugin@1.166.12 @tanstack/react-router@1.167.3npm test→ passesExpected behavior
Tests should pass. The HMR code injected by
react-stable-hmr-split-route-components.tsshould guard againstimport.meta.hot.databeingundefinedin test environments.Screenshots or Videos
No response
Platform
@tanstack/router-plugin1.167.9,@tanstack/react-router1.168.8Additional context
Root cause: PR #7000 and #7005 introduced
tsr-split-componentHMR state caching for React Fast Refresh stability. The injected code accessesimport.meta.hot.datawithout a null guard. In vitest,import.meta.hotexists but.dataisundefined.Suggested fix: Add optional chaining in
react-stable-hmr-split-route-components.ts:Workaround: Pin to
@tanstack/router-plugin@1.166.12/@tanstack/react-router@1.167.3.