Skip to content

Respect my jsxRuntime configuration #10670

@zettadam

Description

@zettadam

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions