mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #155] [MERGED] fix: pre-bundle react/jsx-runtime to prevent CJS-in-browser errors #355
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#355
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/155
Author: @FredKSchott
Created: 2/27/2026
Status: ✅ Merged
Merged: 2/28/2026
Merged by: @southpolesteve
Base:
main← Head:fix/prebundle-jsx-runtime📝 Commits (1)
e3241b1fix: pre-bundle react/jsx-runtime to prevent CJS-in-browser errors📊 Changes
1 file changed (+9 additions, -5 deletions)
View changed files
📝
packages/vinext/src/index.ts(+9 -5)📄 Description
Summary
react/jsx-runtimeandreact/jsx-dev-runtimetooptimizeDeps.includein the client environment configProblem
Vite's dependency scanner can miss
react/jsx-runtimeduring initial crawl when entry points are virtual modules (as vinext uses). When this happens, the raw CJS file is served to the browser, producing:This affects all JSX in the app — user components and vinext shims alike.
Fix
Explicitly listing these modules in
optimizeDeps.includeensures Vite always pre-bundles them into proper ESM. This is the same pattern already used forreact,react-dom, andreact-dom/client.This is the correct root-cause fix for #25, superseding the approach in #45 and #136 which worked around the issue by converting individual shim files from JSX to
React.createElement. That approach only fixed vinext's own shims while leaving user code broken.Fixes #25
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
usePathname/useSearchParamsReact error) #505