Skip to content

Automatically skip react-compiler babel plugins on non client transform #627

@hi-ogawa

Description

@hi-ogawa

Related plugins

Describe the bug

The following pattern is tedious and I think it's safe to skip babel-plugin-react-compiler for non client transform.

react({
babel: { plugins: ['babel-plugin-react-compiler'] },
}).map((p) => ({
...p,
applyToEnvironment: (e) => e.name === 'client',
})),

For RSC, react compiler transform actually breaks app. For SSR, there's no benefit of react compiler and it should be skipped to avoid unnecessary transform.

Reproduction

https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-rsc/e2e/starter.test.ts

Steps to reproduce

No response

System Info

na

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions