[PR #731] [CLOSED] [codex] Fix wrapped use server exports #803

Closed
opened 2026-05-06 13:10:11 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/731
Author: @southpolesteve
Created: 3/31/2026
Status: Closed

Base: mainHead: codex/issue-722-next-safe-action


📝 Commits (1)

  • 6df0a2a fix wrapped use server exports

📊 Changes

3 files changed (+353 additions, -0 deletions)

View changed files

📝 packages/vinext/src/index.ts (+4 -0)
packages/vinext/src/plugins/fix-use-server-wrapped-exports.ts (+235 -0)
tests/use-server-wrapped-exports.test.ts (+114 -0)

📄 Description

Summary

Fix file-level "use server" exports that wrap an inline async action, such as next-safe-action's actionClient.action(async () => ...) pattern.

Root Cause

@vitejs/plugin-rsc validates file-level "use server" exports syntactically and rejects wrapped exports whose initializer is a call expression instead of a direct async function expression. That causes vinext to fail with unsupported non async function for valid Next.js-compatible patterns.

Changes

  • add a pre-transform plugin that rewrites wrapped file-level "use server" exports into local bindings plus export { ... }
  • register that plugin ahead of @vitejs/plugin-rsc
  • add a regression test covering the next-safe-action shape and the upstream strict proxy transform behavior

Validation

  • pnpm test tests/use-server-wrapped-exports.test.ts tests/use-server-closure-collision.test.ts
  • pnpm run check
  • built local vinext, linked it into the reporter's repro app from issue #722, and confirmed GET / changed from 500 unsupported non async function to 200

Closes #722.


🔄 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/731 **Author:** [@southpolesteve](https://github.com/southpolesteve) **Created:** 3/31/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `codex/issue-722-next-safe-action` --- ### 📝 Commits (1) - [`6df0a2a`](https://github.com/cloudflare/vinext/commit/6df0a2ae24580e4b99954ea6f5e27f926b50caab) fix wrapped use server exports ### 📊 Changes **3 files changed** (+353 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/index.ts` (+4 -0) ➕ `packages/vinext/src/plugins/fix-use-server-wrapped-exports.ts` (+235 -0) ➕ `tests/use-server-wrapped-exports.test.ts` (+114 -0) </details> ### 📄 Description ## Summary Fix file-level `"use server"` exports that wrap an inline async action, such as `next-safe-action`'s `actionClient.action(async () => ...)` pattern. ## Root Cause `@vitejs/plugin-rsc` validates file-level `"use server"` exports syntactically and rejects wrapped exports whose initializer is a call expression instead of a direct async function expression. That causes vinext to fail with `unsupported non async function` for valid Next.js-compatible patterns. ## Changes - add a pre-transform plugin that rewrites wrapped file-level `"use server"` exports into local bindings plus `export { ... }` - register that plugin ahead of `@vitejs/plugin-rsc` - add a regression test covering the `next-safe-action` shape and the upstream strict proxy transform behavior ## Validation - `pnpm test tests/use-server-wrapped-exports.test.ts tests/use-server-closure-collision.test.ts` - `pnpm run check` - built local `vinext`, linked it into the reporter's repro app from issue #722, and confirmed `GET /` changed from `500 unsupported non async function` to `200` Closes #722. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:10:11 +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#803
No description provided.