fix: only enforce split route modules during builds - #15333
Draft
comp615 wants to merge 2 commits into
Draft
Conversation
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.
Fixes #15332.
Observed behavior
With Vite 8 and
@vitejs/plugin-react, the development transform can introduce a shared module-level_jsxFileNamebinding when multiple route exports contain JSX. The dev manifest's route-chunk analysis treats that generated binding as shared route code and rejectsHydrateFallbackundersplitRouteModules: "enforce".The same route successfully splits in a production build because the production JSX transform does not produce the same shared development metadata. The regression test covers both outcomes: the build must succeed and the Vite dev server must render the route.
Proposed change
Skip
splitRouteModules: "enforce"validation while generating the non-RSC development manifest. Production enforcement remains in both existing build paths, including the assertion that genuinely shared route code cannot be split.Design rationale (open to maintainer feedback)
This patch assumes the production build is the authoritative enforcement boundary because:
"enforce"as causing build failures;The tradeoff is that a genuinely unsplittable route will now fail at build time rather than during dev-manifest generation. If early dev rejection is intended to be part of the contract, this patch is likely too broad. In that case, the alternative would be to analyze production-equivalent transformed code in development. I avoided special-casing
_jsxFileNamebecause it is generated transform output and would narrowly address only the currently observed shape.Tests
pnpm buildpnpm test:integration:run bug-report --project chromiumpnpm test:integration:run split-route-modules --project chromiumpnpm run typecheckpnpm run lint(no errors; unrelated existing warnings remain)pnpm exec prettier --check packages/react-router-dev/vite/plugin.ts integration/bug-report-test.ts🤖 This pull request and its implementation were prepared with AI assistance.