-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Vite plugin does not accept options #12352
Comments
Currently, it takes no options, so that would be the place to start. Unfortunately, it doesn't look like an easy task. |
Thanks for weighing in! Yeah, that much is clear from looking at the source code. Whether it is an easy task or not is harder for me to tell. I'm not sure why/if it would be difficult to accept the same arguments as the |
I also need to pass the babel option in order to use styled-components, so I think is a must for a lot of users |
We also need babel options because we are using react compiler |
This comment was marked as off-topic.
This comment was marked as off-topic.
I'll shortly send a PR link on how to add this to your project |
forge-42/supabase-realtime#6 |
Thanks @AlemTuzlak, looks promising! I'll report back here once I've had the opportunity to test it, and confirmed that it covers my use cases, including Lingui. |
Documenting as I go:
This unblocks me and lets me continue my migration (which I don't have the time to finalize right now). Unclear so far for me if I need to add I'll update this later as I find the time to finalize the migration, but this is very promising. Hopefully we can add this to the documentation once we've validated it works widely. |
Note that having multiple plugins will instantiate multiple copies of Babel, transform your code multiple times, and result in both memory bloat and slower performance. That is why the official React plugin takes these options. We should do the same so builds remain as fast as possible. |
@timdorr I'm not sure that's the case? It runs a single transform with multiple plugins from what I saw while trying it out? |
The React Router plugin runs its own Babel instance and transforms, depending on the module type: react-router/packages/react-router-dev/vite/plugin.ts Lines 1444 to 1453 in 9819f96
react-router/packages/react-router-dev/vite/plugin.ts Lines 1523 to 1534 in 9819f96
But this is also what the official React plugin does: So, you're creating at least two instances of Babel. It would be far better for us to just take options directly so that transform step is done one time. |
This would be useful for react compiler |
Stumbled upon this while also hoping for a simple way to implement React Compiler. Would love to see the Otherwise I will keep playing with the workaround while patiently wait for this |
Thanks for starting this thread. I also noticed that when I'm migrating from Remix to RRv7, there is no option to pass presets, which makes it difficult to implement PWA using @vite-pwa/remix. |
I also have this problem,How to have a pwa application in RRv7 ? |
Same, this is a big blocker. I was pretty interested in how RR7 is using a plugin to handle type safety, etc. but now seeing that it replaces the base I'm sure there's some technical reasons but it's not very confidence inducing that the plugin seemingly doesn't wrap the react plugin in some way or this isn't made available as it's own babel transform. Def know the team needs time, so I am patient and curious to see what the team comes up with, but I think a pressing question is how will the plugin keep up with features/optimizations done in the official vite react plugin? And in the most sincere way, since Vite + RR seems like the main/recommended candidate for framework mode it's troubling how this was missed when making the decision to use a plugin? |
Stumbled upon this issue via: https://react.dev/learn/react-compiler#usage-with-vite |
Doesn't work with RR7 as expected. Causes randomly Invalid Hook Call errors during navigation. |
Describe what's incorrect/missing in the documentation
https://reactrouter.com/upgrading/router-provider#2-install-the-vite-plugin describes how to adopt the new React Router framework, coming from RouterProvider.
I started this migration, but ran into issues when I realized that the
reactRouter
plugin does not accept the same options as thereact
plugin, which stopped me in my tracks.Specifically, I have the need to add babel plugins both for React compiler: https://react.dev/learn/react-compiler#usage-with-vite and Lingui: https://lingui.dev/tutorials/setup-vite.
In Discord, Kosire suggested I could patch the plugin: https://discord.com/channels/770287896669978684/1309472866453946368/1309472866453946368, which would probably work, but is not very accessible to the average user of the library, and would also be a significant maintenance burden over time, so it's not something I would like to do without being sure it is the only way.
Is this the state of things? Or is there a more appropriate way to handle this scenario, which could then be added to the documentation?
The text was updated successfully, but these errors were encountered: