Closed cedeber closed 1 year ago
Ah yeah I've should have use the jsxInject parameter.
I will probably push an update for it, but the next version of the plugin that will be released with Vite 4 will be automatic jsx runtime only, so if you can you should migrate to it. The React core team published a codemod that can help you: https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#removing-unused-react-imports
We already use the automatic mode, although we still have all the import, but I tried to make preact signals React hooks work with react-router and one suggestion was to come back to the classic mode. This is how I discover that. It doesn't help unfortunately, so we are not currently blocked. The use of signals was just a quick try.
Thanks for the link to the tool, it will be useful!
Hi!
After discussion with the core team, we decided to make this plugin official and remove the option for classic runtime.
You can read more about the upcoming alpha release here
Thanks for the info. Happy to see it as an official plugin. No problem for me, I finally removed all import of React anyways.
Does it mean that the v3 of this plugin will be released in the same time of Vite v4, then?
Oh, I didn't see that the repo has been moved 😅👍
Yes it exactly the alpha will be released in few days and the stable version when Vite 4 is stable
When using
esbuild
withjsx: transform
, this plugin automatically injectimport React from "react"
which is probably not a good idea as the "classic" mode always required it. In other words, it breaks the build.https://github.com/ArnaudBarre/vite-plugin-swc-react-refresh/blob/317a2bfadf2d2207fb866288bb7b4f00a9fe0fd2/src/index.ts#L94
It is maybe a good idea to rely on
config.esbuild.jsxInject
instead and let the dev decides what he wants to import, don't you think?