Uh oh!
There was an error while loading. Please reload this page.
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. |
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/arrow-function@true.tsxpackages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@webpack-hot.tsxpackages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@true.tsxpackages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@true.tsxpackages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@true.tsxpackages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@true.tsxpackages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@true.tsxpackages/router-plugin/tests/add-hmr/snapshots/react/multi-component@true.tsxpackages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@true.tsxpackages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@true.tsxpackages/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.
Uh oh!
There was an error while loading. Please reload this page.
Merging this PR will not alter performance
Comparing Footnotes
|
fixes#4303
Summary by CodeRabbit
Bug Fixes
Tests