fix: serialize each route view path once - #11
Closed
kavhnr wants to merge 1 commit into
Closed
Conversation
Author
|
Closing after further review. The existing generated code has correct runtime behavior and produces no verified compiler or build failure. This change would add route objects and spreads without a public behavior fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
path.pageRoutesobject.Root cause
The Vite adapter serialized each complete flat manifest entry into a shared binding.
serializeTreespread that binding into a page route and then added the adjusted tree path. Thus, the spread first assigned the original flat path, and the explicitpathfield replaced it.This shape is valid JavaScript. A minimal Vite 8 build, TypeScript, and esbuild accept it. The problem is an unwanted assignment in generated source, not a duplicate-key syntax error.
The shared binding now contains only fields common to both views. The flat route adds its original path, while the nested page route adds its adjusted path. This keeps route-group removal and parent-relative nesting. It also keeps IDs, children, module refs, and other nested values. The two views still share these non-path values.
Tests
The regression test inspects the generated shared bindings and evaluates the generated module. It covers:
pageRoutes;The test fails on base commit
4ff503fand passes with this change.Validation with Node 24.15.0 and pnpm 11.1.1:
pnpm install --frozen-lockfile— passedpnpm vitest run test/vite.spec.ts -t 'assigns each route view its own path once'— passedpnpm test— passed, 104 testspnpm build— passedpnpm typecheck:dist— passednpm pack --dry-run— passedpnpm prettier --check src/vite/index.ts test/vite.spec.ts .changeset/clean-page-route-paths.md— passedFixes #10