Skip to content

Typescript 5.5+ required for plugin-react-swc 4.x #985

@k-funk

Description

@k-funk

Related plugins

Describe the bug

Today I bumped my vite from 6.x, and @vitejs/plugin-react-swc to 4.x.

My build is now failing due to [this line](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-
react-swc/src/index.ts#L321).

$ npm run build
...

58 export { react as default, pluginForCjs as "module.exports" };
                                              ~~~~~~~~~~~~~~~~
node_modules/@vitejs/plugin-react-swc/index.d.ts:58:61 - error TS1128: Declaration or statement expected.

58 export { react as default, pluginForCjs as "module.exports" };
                                                               ~
Found 2 errors in the same file, starting at: node_modules/@vitejs/plugin-react-swc/index.d.ts:58

✓ 5421 modules transformed.

My team is using TS 5.3.3, and it's a difficult upgrade for us.

The "module.exports" syntax (string literal as export name) was introduced in TypeScript 5.5.

Was the TS 5.5+ requirement an intentional change?

Reproduction

https://github.com/k-funk/vite-plugin-react-bug1

Steps to reproduce

  1. Install dependencies:

    npm install
  2. Run the build:

    npm run build
  3. You'll see these errors:

    node_modules/@vitejs/plugin-react-swc/index.d.ts(58,44): error TS1003: Identifier expected.
    node_modules/@vitejs/plugin-react-swc/index.d.ts(58,61): error TS1128: Declaration or statement expected.
    

System Info

System:
    OS: macOS 26.1
    CPU: (16) arm64 Apple M4 Max
    Memory: 1.83 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.6.0 - /Users/kfunk/.nvm/versions/node/v24.6.0/bin/node
    npm: 11.5.1 - /Users/kfunk/.nvm/versions/node/v24.6.0/bin/npm
  Browsers:
    Chrome: 142.0.7444.162
    Firefox: 144.0.2
    Safari: 26.1
  npmPackages:
    @vitejs/plugin-react-swc: ^4.2.2 => 4.2.2
    vite: ^7.2.2 => 7.2.2

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