Closed Arilas closed 1 month ago
Why do you want to use this for just transpiling TSX? What's needed that's not done by the default esbuild pipeline which ships with Vite and so vitest?
I'm closing this. 90% of this plugin is about adding HMR to React, and 10% is about switching esbuild to SWC in dev. I don't see any reason to extract this 10% into a plugin, mostly because a part from fast refresh support I don't see good reason to use SWC in place a esbuild (there is almost no speed difference in real world apps) and because this as already been done in other plugins like https://www.npmjs.com/package/vite-plugin-swc-transform or https://www.npmjs.com/package/unplugin-swc
This plugin is really good not only for a react project, but also for a project that only use
vitest
as a test runner and doesn't use react and/or front-end at all.So it's a little strange when on a back-end project you see a vitest config with a react plugin in it.
So it's makes sense to separate basic swc usage into a separate plugin, and make a react plugin just a wrapper around swc plugin which add hmr logic and configures defaults for react.