Skip to content

Support "use server" module directive with higher order function export? #618

@alexdo

Description

@alexdo

Related plugins

Description

As a developer using @vitejs/plugin-rsc, I want to be able to use React.cache in Server Components.

Right now, exporting React.cache from a Server Component throws unsupported non async function (via validateNonAsyncFunction()).

I made a reproducer based on a react-router example here. It has two routes, both have identical code except for one route using React.cache.

Suggested solution

I tried disabling the throw new Error-Part in both validateNonAsyncFunction functions and the route using React.cache is rendering fine. So maybe it'll be sufficient to conditionally throw the error? 🤔

Alternative

No response

Additional context

I just want to express my appreciation of all the work being done here on bringing RSCs to Vite. Amazing! 🙏

Validations

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions