Skip to content

React Compiler skips components with default destructured props when using @vitejs/plugin-react #1458

Description

@hazhirmohammadi

Related plugins

Describe the bug

When using React Compiler with @vitejs/plugin-react, components with destructured props that have default values, such as variant = 'primary', may be skipped by the compiler and not optimized as expected.

However, the same component works as expected in a Vite project using @vitejs/plugin-react. This issue was initially observed in a project created with the tsdown React Compiler template.

Reproduction

https://github.com/hazhirmohammadi/tsdown-react-compiler

Steps to reproduce

  1. Clone the reproduction repository.
  2. Install the dependencies:
    npm install
  3. Build the project:
    npm run build
  4. Inspect the generated output.
  5. Compare the compiled output of Button and Button2.
  6. Observe that Button is skipped by React Compiler when using the default destructured prop variant = 'primary', while Button2 without the default value is compiled/optimized.

The issue was initially observed in tsdown. Following the recommendation from the tsdown maintainers in the original issue, I tested the same case with Vite and @vitejs/plugin-react to determine whether the issue could be related to the React plugin.

The issue could not be reproduced in the Vite setup.

System Info

System:
    OS: Linux 6.17 Ubuntu 25.10 25.10 (Questing Quokka)
    CPU: (16) x64 Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
    Memory: 5.08 GB / 14.90 GB
    Container: Yes
    Shell: 5.2.37 - /bin/bash
  Binaries:
    Node: 24.20.0 - /home/hazhir/.local/share/pnpm/bin/node
    npm: 11.6.2 - /home/hazhir/.nvm/versions/node/v24.20.0/bin/npm
    pnpm: 11.25.0 - /home/hazhir/.local/share/pnpm/bin/pnpm
  Browsers:
    Chrome: 153.0.8010.36
    Firefox: 155.0.1
    Firefox Developer Edition: 155.0.1
  npmPackages:
    @vitejs/plugin-react: ^6.0.3 => 6.1.1 
    vite: ^8.1.4 => 8.3.0

Used Package Manager

npm

Logs

No response

Validations

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions