Skip to content

fix: initialize import.meta.hot.data before storing stable split componts#7074

Merged
schiller-manuel merged 2 commits intomainfrom
fix-7073
Mar 30, 2026
Merged

fix: initialize import.meta.hot.data before storing stable split componts#7074
schiller-manuel merged 2 commits intomainfrom
fix-7073

Conversation

@schiller-manuel
Copy link
Copy Markdown
Contributor

@schiller-manuel schiller-manuel commented Mar 30, 2026

fixes #7073

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a crash in Vitest when using hot module replacement with stable split route components by ensuring proper initialization of HMR metadata before use.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud bot commented Mar 30, 2026

View your CI Pipeline Execution ↗ for commit f719ce9

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 1m 33s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 4s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-30 15:46:58 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

🚀 Changeset Version Preview

1 package(s) bumped directly, 5 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/router-plugin 1.167.9 → 1.167.10 Changeset
@tanstack/react-start 1.167.13 → 1.167.14 Dependent
@tanstack/router-vite-plugin 1.166.24 → 1.166.25 Dependent
@tanstack/solid-start 1.167.12 → 1.167.13 Dependent
@tanstack/start-plugin-core 1.167.14 → 1.167.15 Dependent
@tanstack/vue-start 1.167.12 → 1.167.13 Dependent

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3f1cef6b-a350-41be-a34c-1da43e917ba0

📥 Commits

Reviewing files that changed from the base of the PR and between 30835cb and 7baf2f6.

📒 Files selected for processing (7)
  • .changeset/five-sheep-grin.md
  • packages/router-plugin/src/core/code-splitter/plugins/react-stable-hmr-split-route-components.ts
  • packages/router-plugin/tests/add-hmr.test.ts
  • packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@true.tsx
  • packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@true.tsx
  • packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@true.tsx
  • packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@true.tsx

📝 Walkthrough

Walkthrough

A bug fix was implemented to prevent vitest crashes when using autoCodeSplitting. The stable HMR split route components code generator now initializes import.meta.hot.data before writing to it, addressing cases where the property is undefined in test environments.

Changes

Cohort / File(s) Summary
Changeset
.changeset/five-sheep-grin.md
Documents patch release for @tanstack/router-plugin with the HMR data initialization fix.
Core Logic
packages/router-plugin/src/core/code-splitter/plugins/react-stable-hmr-split-route-components.ts
Adds import.meta.hot.data ??= {} guard to initialize the HMR data object before assigning split component entries.
Test Case
packages/router-plugin/tests/add-hmr.test.ts
New unit test verifying that generated output includes the import.meta.hot.data ??= {} initialization and validates the subsequent component assignment.
Test Snapshots
packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@true.tsx, function-declaration@true.tsx, multi-component@true.tsx, string-literal-keys@true.tsx
Updated snapshot expectations to reflect the added import.meta.hot.data ??= {} initialization lines in generated HMR code blocks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A hop, a fix, a safeguard true,
Where data was undefined in vitest's view,
Now ??= {} stands guard with care,
HMR flows smooth through the testing air,
Split components stable, no crash in sight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: initializing import.meta.hot.data before storing stable split components, which directly addresses the root cause of issue #7073.
Linked Issues check ✅ Passed The pull request successfully implements the fix for issue #7073 by adding import.meta.hot.data initialization in the generated HMR code, preventing TypeError when import.meta.hot.data is undefined.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the HMR data initialization issue: the core plugin fix, test case validation, and snapshot updates are all in scope for issue #7073.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-7073

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

Bundle Size Benchmarks

  • Commit: 30835cb8e935
  • Measured at: 2026-03-30T15:46:23.461Z
  • Baseline source: history:30835cb8e935
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Raw Brotli Trend
react-router.minimal 87.47 KiB 0 B (0.00%) 275.68 KiB 75.93 KiB █▄▄▂▂▂▂▁▁▁▁
react-router.full 90.76 KiB 0 B (0.00%) 286.86 KiB 78.87 KiB █▃▃▂▂▂▂▁▁▁▁
solid-router.minimal 35.51 KiB 0 B (0.00%) 107.04 KiB 31.87 KiB ███▃▃▃▃▁▁▁▁
solid-router.full 39.99 KiB 0 B (0.00%) 120.58 KiB 35.89 KiB ███▆▆▆▆▁▁▁▁
vue-router.minimal 53.36 KiB 0 B (0.00%) 152.97 KiB 47.88 KiB █▂▂▂▂▂▂▁▁▁▁
vue-router.full 58.22 KiB 0 B (0.00%) 168.43 KiB 52.08 KiB █▃▃▂▂▂▂▁▁▁▁
react-start.minimal 102.00 KiB 0 B (0.00%) 323.92 KiB 88.17 KiB █▃▃▂▂▂▂▁▁▁▁
react-start.full 105.36 KiB 0 B (0.00%) 334.27 KiB 91.01 KiB █▃▃▂▂▂▂▁▁▁▁
solid-start.minimal 49.61 KiB 0 B (0.00%) 153.29 KiB 43.75 KiB ███▄▄▄▄▁▁▁▁
solid-start.full 55.10 KiB 0 B (0.00%) 169.53 KiB 48.46 KiB ███▅▅▅▅▁▁▁▁

Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 30, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@7074

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@7074

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@7074

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@7074

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@7074

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@7074

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@7074

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@7074

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@7074

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@7074

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@7074

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@7074

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@7074

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@7074

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@7074

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@7074

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@7074

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@7074

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@7074

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@7074

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@7074

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@7074

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@7074

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@7074

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@7074

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@7074

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@7074

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@7074

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@7074

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@7074

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@7074

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@7074

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@7074

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@7074

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@7074

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@7074

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@7074

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@7074

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@7074

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@7074

commit: f719ce9

Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 30, 2026

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing fix-7073 (f719ce9) with main (30835cb)

Open in CodSpeed

@schiller-manuel schiller-manuel merged commit f8351a8 into main Mar 30, 2026
17 checks passed
@schiller-manuel schiller-manuel deleted the fix-7073 branch March 30, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

autoCodeSplitting breaks vitest: Cannot set properties of undefined (setting 'tsr-split-component:component')

1 participant