Repository navigation
fix(router-plugin): preserve generated route state for aliased HMR imports - #7560
Conversation
|
Too much diff to scan? Review this PR in Change Stack to start with the highest-impact changes. 📝 WalkthroughWalkthroughThis PR fixes hot-reload behavior for TanStack Router routes imported via aliases. Route properties ( ChangesRouter-plugin HMR aliased import fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 7cb2f05
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version Preview1 package(s) bumped directly, 6 bumped as dependents. 🟩 Patch bumps
|
Bundle Size Benchmarks
Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better. |
More templates
@tanstack/arktype-adapter
@tanstack/eslint-plugin-router
@tanstack/eslint-plugin-start
@tanstack/history
@tanstack/nitro-v2-vite-plugin
@tanstack/react-router
@tanstack/react-router-devtools
@tanstack/react-router-ssr-query
@tanstack/react-start
@tanstack/react-start-client
@tanstack/react-start-rsc
@tanstack/react-start-server
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-devtools-core
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-ssr-query-core
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/solid-router
@tanstack/solid-router-devtools
@tanstack/solid-router-ssr-query
@tanstack/solid-start
@tanstack/solid-start-client
@tanstack/solid-start-server
@tanstack/start-client-core
@tanstack/start-fn-stubs
@tanstack/start-plugin-core
@tanstack/start-server-core
@tanstack/start-static-server-functions
@tanstack/start-storage-context
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/vue-router
@tanstack/vue-router-devtools
@tanstack/vue-router-ssr-query
@tanstack/vue-start
@tanstack/vue-start-client
@tanstack/vue-start-server
@tanstack/zod-adapter
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@e2e/react-start/hmr/tests/app.spec.ts`:
- Around line 30-31: The new editable aliased route panels
(aliasedRouteImportParentPanel and aliasedRouteImportChildPanel) lack entries in
the routeFileRestoreChecks map so waitForRestoredRouteFile returns immediately;
add routeFileRestoreChecks entries for both aliasedRouteImportParentPanel and
aliasedRouteImportChildPanel that point to their component file paths
(components/AliasedRouteImportParentPanel.tsx and
components/AliasedRouteImportChildPanel.tsx) and provide appropriate
content/match checks (the same style used by other entries) so
waitForRestoredRouteFile blocks until HMR restore is observed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0e497855-910d-40d8-bc3f-c85aaf87f835
📒 Files selected for processing (21)
.changeset/fix-route-hmr-aliased-imports.mde2e/react-start/hmr/src/components/AliasedRouteImportChildPanel.tsxe2e/react-start/hmr/src/components/AliasedRouteImportParentPanel.tsxe2e/react-start/hmr/src/routeTree.gen.tse2e/react-start/hmr/src/routes/aliased-route-imports.$id.child.tsxe2e/react-start/hmr/src/routes/aliased-route-imports.$id.tsxe2e/react-start/hmr/tests/app.spec.tspackages/router-plugin/src/core/hmr/handle-route-update.tspackages/router-plugin/src/core/hmr/vite-adapter.tspackages/router-plugin/tests/add-hmr.test.tspackages/router-plugin/tests/add-hmr/snapshots/react/[email protected]packages/router-plugin/tests/add-hmr/snapshots/react/[email protected]packages/router-plugin/tests/add-hmr/snapshots/react/[email protected]packages/router-plugin/tests/add-hmr/snapshots/react/[email protected]packages/router-plugin/tests/add-hmr/snapshots/react/[email protected]packages/router-plugin/tests/add-hmr/snapshots/react/[email protected]packages/router-plugin/tests/add-hmr/snapshots/react/[email protected]packages/router-plugin/tests/add-hmr/snapshots/react/[email protected]packages/router-plugin/tests/add-hmr/snapshots/react/[email protected]packages/router-plugin/tests/add-hmr/snapshots/solid/[email protected]packages/router-plugin/tests/handle-route-update.test.ts
| aliasedRouteImportParentPanel: 'components/AliasedRouteImportParentPanel.tsx', | ||
| aliasedRouteImportChildPanel: 'components/AliasedRouteImportChildPanel.tsx', |
There was a problem hiding this comment.
Add restore checks for the new aliased route panel files.
aliasedRouteImportParentPanel and aliasedRouteImportChildPanel are now editable/restored, but they have no routeFileRestoreChecks entries. That makes waitForRestoredRouteFile return early for these keys, so subsequent tests can run before restore HMR settles.
Suggested patch
const routeFileRestoreChecks: Partial<
Record<
RouteFileKey,
{
url: string
testId: string
text: string
assert?: (page: Page) => Promise<void>
}
>
> = {
+ aliasedRouteImportParentPanel: {
+ url: '/aliased-route-imports/A',
+ testId: 'aliased-parent-marker',
+ text: 'aliased-parent-baseline',
+ },
+ aliasedRouteImportChildPanel: {
+ url: '/aliased-route-imports/A/child',
+ testId: 'aliased-child-marker',
+ text: 'aliased-child-baseline',
+ },
index: {
url: '/',
testId: 'marker',
text: 'baseline',Also applies to: 229-236
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@e2e/react-start/hmr/tests/app.spec.ts` around lines 30 - 31, The new editable
aliased route panels (aliasedRouteImportParentPanel and
aliasedRouteImportChildPanel) lack entries in the routeFileRestoreChecks map so
waitForRestoredRouteFile returns immediately; add routeFileRestoreChecks entries
for both aliasedRouteImportParentPanel and aliasedRouteImportChildPanel that
point to their component file paths
(components/AliasedRouteImportParentPanel.tsx and
components/AliasedRouteImportChildPanel.tsx) and provide appropriate
content/match checks (the same style used by other entries) so
waitForRestoredRouteFile blocks until HMR restore is observed.
Merging this PR will not alter performance
Comparing Footnotes
|
fixes #4303
Summary by CodeRabbit
Bug Fixes
Tests