[PR #18] [CLOSED] fix: auto-exclude react-server packages from RSC optimizeDeps #247

Closed
opened 2026-05-06 12:38:46 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/18
Author: @FredKSchott
Created: 2/24/2026
Status: Closed

Base: mainHead: fix/rsc-optimizedeps-react-server


📝 Commits (1)

  • e3b7ea2 fix: auto-exclude react-server packages from RSC optimizeDeps

📊 Changes

1 file changed (+103 additions, -1 deletions)

View changed files

📝 packages/vinext/src/index.ts (+103 -1)

📄 Description

Summary

Packages with a react-server export condition (e.g. swr) get pre-bundled with a stripped-down entry in the RSC environment, breaking client imports (like useSWR) before the RSC plugin's "use client" transform can strip them.

At startup, scan the project's direct dependencies for packages declaring a react-server export condition and automatically add them to environments.rsc.optimizeDeps.exclude.

Uses createRequire for resolution so it works across all package managers.

Ref: https://github.com/vitejs/vite-plugin-react/issues/736, https://github.com/vitejs/vite-plugin-react/issues/775


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/18 **Author:** [@FredKSchott](https://github.com/FredKSchott) **Created:** 2/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/rsc-optimizedeps-react-server` --- ### 📝 Commits (1) - [`e3b7ea2`](https://github.com/cloudflare/vinext/commit/e3b7ea29929a50c13a756f8fcce8e5604280f56c) fix: auto-exclude react-server packages from RSC optimizeDeps ### 📊 Changes **1 file changed** (+103 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/index.ts` (+103 -1) </details> ### 📄 Description ## Summary Packages with a `react-server` export condition (e.g. `swr`) get pre-bundled with a stripped-down entry in the RSC environment, breaking client imports (like `useSWR`) before the RSC plugin's `"use client"` transform can strip them. At startup, scan the project's direct dependencies for packages declaring a `react-server` export condition and automatically add them to `environments.rsc.optimizeDeps.exclude`. Uses `createRequire` for resolution so it works across all package managers. Ref: https://github.com/vitejs/vite-plugin-react/issues/736, https://github.com/vitejs/vite-plugin-react/issues/775 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:38:46 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#247
No description provided.