-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Describe the bug
I am building a library of React components that I'd like to publish without automatic JSX runtime. In previous versions of vite and @vitejs/plugin-react I was able to build my library without vite polluting my dist directory with JSX runtime junk. I updated both vite and @vitejs/plugin-react and the option to use classic jsxRuntime does not work as expected in combination with jsx option in typescript.config.ts.
I have externalized both react and react-dom as described in the docs.
The option jsx: 'preserve' in typescript.config.ts returns a Rollup error.
The option jsx: 'react-jsx in typescript.config.ts pollutes my dist directory with JSX runtime junk.
The option jsx: 'react' keeps dist clean, but only in my reproduction case. Locally, where I have dozens of components, it adds JSX runtime junk.
This used to work in earlier versions of vite and @vitejs/plugin-react
Reproduction
https://stackblitz.com/edit/vitejs-vite-kosz8e?terminal=dev
Steps to reproduce
Go to reproduction link and run npm run build with different options described above.
System Info
"@vitejs/plugin-react": "2.2.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "4.6.4",
"vite": "3.2.0"Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.