You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For performance reasons, I would like to not use Babel at all but let esbuild handle everything while still having support for fast refresh. By looking at the code it seems like fast refresh is the only reason that babel is invoked by default.
As a side effect, this would avoid problems like the one mentioned in #266
Suggested solution
If I understand correctly, vite-plugin-react-swc has a pure JS implementation of react refresh. By integrating that into this repository, the babel plugin react-refresh/babel becomes unnecessary and babel can be skipped by default. Maybe there is a reason this cannot be done though?
Alternative
Using plugin-react-swc would be an alternative but has other drawbacks for existing (aka old aka legacy) projects, such as the requirement to have useDefineForClassFields: true and that writing custom plugins in Rust cumbersome to many compared to a few lines of JS
If you need plugin in JS, you pay the cost a Babel, for now (SWC has support for JS plugins but it's incomplete and not guaranty to be performant if you hook into a lot o nodes)
In an ideal world you could use esbuild already used by Vite: Add Fast Refresh support evanw/esbuild#3449 (I could update the PR to improve a few things, but I'm working on other things because of no feedback from the author)
In our case we are trying to create a sensible configuration for our framework users which makes this a bit more tricky, as they might have a mix of old and new projects. What we really are trying to implement is a way for old projects to work and allow people to gradually migrate to (newer) standards.
The linked esbuild PR seems like exactly what we would be hoping for, let's see if that progresses.
Description
For performance reasons, I would like to not use Babel at all but let
esbuild
handle everything while still having support for fast refresh. By looking at the code it seems like fast refresh is the only reason that babel is invoked by default.As a side effect, this would avoid problems like the one mentioned in #266
Suggested solution
If I understand correctly,
vite-plugin-react-swc
has a pure JS implementation of react refresh. By integrating that into this repository, the babel pluginreact-refresh/babel
becomes unnecessary and babel can be skipped by default. Maybe there is a reason this cannot be done though?Alternative
Using
plugin-react-swc
would be an alternative but has other drawbacks for existing (aka old aka legacy) projects, such as the requirement to haveuseDefineForClassFields: true
and that writing custom plugins in Rust cumbersome to many compared to a few lines of JSAdditional context
No response
Validations
The text was updated successfully, but these errors were encountered: