-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React-Plugin does not respect the jsxImportSource from TSConfig #9
Comments
Notes:
Did a go at it. const jsxImportSrc = tsBuildConfig.compilerOptions.jsxImportSource
const jsxOption = tsBuildConfig.compilerOptions.jsx === "react"
? {}
: jsxImportSrc === "react"
? {}
: { jsxRuntime: "automatic" as const, jsxImportSrc, }
ReactPlugin({ ...jsxOption, }) Worked perfectly with others, like "jsx": "react-jsx",
"jsxImportSource": "@emotion/react", and "jsx": "react-jsx",
"jsxImportSource": "react", |
Does esbuild support |
All the heavy lifting is already done by the React plugin, this is purely a convenience feature. Making sure that we don't repeat configs and keep one single source of truth. |
Yes, esbuild does support |
Now that jsx transformation is done by esbuild and that the esbuild plugin correctly read this options, it should be as easy as removing this line https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/src/index.ts#L152 for TS projects. This should also enable multiple runtime per app that someone asked in the discussions. But I don't know how to handle that for JS project (or more complicated, mixed projects) |
Hello @seivan. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
Hi! |
Description
A user shouldn't have to define
jsxImportSource
twice, if it's in aTSConfig
then it's already defined.ESBuild (and hopefully Vite) already respects that as far as I know for:
jsxFactory
jsxFragmentFactory
I think the plugin should do that for jsxImportSource as well.
Suggested solution
Read
TSConfig.compilerOptions.jsxImportSource ?? options?.jsxImportSource ?? "react"
Alternative
Building a shim for the auto-import and let ESBuild the whole thing instead of using the plugin.
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: