Skip to content

k-funk/vite-plugin-react-bug1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript 5.3.3 + @vitejs/plugin-react-swc 4.2.2 Incompatibility

This is a minimal reproduction of a TypeScript compatibility issue.

The Problem

@vitejs/plugin-react-swc version 4.x uses string literal export names in its type definitions:

export { pluginForCjs as "module.exports" };

This syntax was introduced in TypeScript 5.5, but this project uses TypeScript 5.3.3.

Important: The error only occurs when vite.config.ts is included in the TypeScript compilation (via tsconfig.json include array). When TypeScript checks the config file, it also type-checks the imported plugin types, which triggers the incompatibility.

Reproduce the Error

  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.
    

Solutions

Option 1: Upgrade TypeScript (Recommended)

npm install typescript@^5.5.0

Option 2: Downgrade the plugin

npm install @vitejs/plugin-react-swc@^3.9.0

Note: This loses Vite 7 compatibility.

Option 3: Disable TypeScript checking in vite.config.ts

checker({
  typescript: false, // Temporary workaround
})

References

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors