Skip to content

fix: only enforce split route modules during builds - #15333

Draft
comp615 wants to merge 2 commits into
remix-run:mainfrom
comp615:bug/split-route-modules-dev-jsx
Draft

fix: only enforce split route modules during builds#15333
comp615 wants to merge 2 commits into
remix-run:mainfrom
comp615:bug/split-route-modules-dev-jsx

Conversation

@comp615

@comp615 comp615 commented Jul 20, 2026

Copy link
Copy Markdown

Fixes #15332.

Observed behavior

With Vite 8 and @vitejs/plugin-react, the development transform can introduce a shared module-level _jsxFileName binding when multiple route exports contain JSX. The dev manifest's route-chunk analysis treats that generated binding as shared route code and rejects HydrateFallback under splitRouteModules: "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:

  • route module chunks are only generated in build mode;
  • the development manifest explicitly leaves split chunk module fields undefined;
  • the documented behavior describes "enforce" as causing build failures;
  • development and production plugin transforms can produce structurally different modules, so dev analysis is not necessarily predictive of the production chunks.

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 _jsxFileName because it is generated transform output and would narrowly address only the currently observed shape.

Tests

  • pnpm build
  • pnpm test:integration:run bug-report --project chromium
  • pnpm test:integration:run split-route-modules --project chromium
  • pnpm run typecheck
  • pnpm 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.

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.

[Bug]: splitRouteModules "enforce" falsely rejects JSX exports during Vite dev

2 participants