fix(rsc): align export async function checks#1169
Merged
hi-ogawa merged 5 commits intovitejs:mainfrom Apr 6, 2026
Merged
Conversation
hi-ogawa
approved these changes
Apr 6, 2026
Contributor
hi-ogawa
left a comment
There was a problem hiding this comment.
Thanks for the fix! I move the util and unify the two test cases.
There was a problem hiding this comment.
Pull request overview
This PR unifies how wrap-export and proxy-export validate exported async functions in the RSC transform pipeline, making the checks consistent and more permissive where appropriate (including handling class expressions), which should address the reported mismatch behavior.
Changes:
- Centralize
rejectNonAsyncFunctionvalidation intotransforms/utils.tsand reuse it from both transforms. - Align
proxy-exportvalidation behavior withwrap-export(and add rejection for class expressions when enabled). - Move/expand the validation test coverage into a shared
utils.test.tsthat exercises both transforms.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/plugin-rsc/src/transforms/wrap-export.ts | Removes local validation helper and delegates to shared validateNonAsyncFunction. |
| packages/plugin-rsc/src/transforms/wrap-export.test.ts | Removes the now-redundant per-transform validation test. |
| packages/plugin-rsc/src/transforms/utils.ts | Adds shared validateNonAsyncFunction implementation (including class expressions). |
| packages/plugin-rsc/src/transforms/utils.test.ts | Adds consolidated tests verifying accepted/rejected patterns for both transforms. |
| packages/plugin-rsc/src/transforms/proxy-export.ts | Replaces stricter bespoke validation with shared logic; validates variable initializers individually. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Description
The wrap-export and proxy-export files were both checking async functions slightly differently. The proxy-export file's version was less permissive than the wrap-export one. This changes them to share the same logic (and adds class expressions as well at the same time).
I believe this was the cause of cloudflare/vinext#722 and should potentially fix it.