Skip to content

Expose OXC config when using vite-plugin-react #874

@DamianPereira

Description

@DamianPereira

Related plugins

Description

Currently my vite config has this:

    react({
      babel: {
        plugins: [
          [
            'babel-plugin-styled-components',
            {
              displayName: true,
              ssr: true,
              pure: true,
            },
          ],
        ],
      },
    }),

Enabling the ssr and pure options is necessary for my setup. OXC supports styled components as a built in plugin: https://oxc.rs/docs/guide/usage/transformer.html#styled-components.

I am testing rolldown-vite, which should use oxc by default if no babel is provided, according to the depreaction notice of vite-plugin-react-oxc:

This package is deprecated. Please use @vitejs/plugin-react instead, which automatically enables Oxc-based Fast Refresh transform on rolldown-vite.

But currently vite-plugin-react does not allow any customization for inner OXC. Is there a way to accomplish this?

Suggested solution

Add a oxc key to the config, the same purpose as the babel one, which taps into the inner oxc transform config and allows customization. Or if one exists document it.

Also maybe add a explicit option to select which transformer to use instead of depending on which options are provided.

transform: 'babel' | 'oxc' | 'auto' (default)

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions