-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Version 4 should still support disabling fastRefresh #151
Comments
It's strange for me that In the SWC plugin I don't include this block at all when not in a HMR context code My idea is that this testing mode should be detected by the plugin, so everyone using it don't have to configure it. If you could provide a small repro it would help to craft the right condition to handle your use case |
Hello @kherock. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
i have the same problem trying to run react (and jsx) in a web worker pmndrs/react-three-offscreen#2 it tries to inject something into an environment that doesn't have window and document defined. getting the same preamble error. previously the solution was to disable fast refresh: https://stackoverflow.com/questions/73815639/how-to-use-jsx-in-a-web-worker-with-vite |
the workaround currently is to use 3.x :( https://github.com/pmndrs/react-three-offscreen#vite ...
export default defineConfig({
plugins: [react({ fastRefresh: false })],
worker: { plugins: [react()] },
}) i also don't understand why it has to be disabled in plugins and not just in worker. |
So this is quite tricky. And what's funny is that using There are two solutions to fix this:
I will discuss both options wit the team. |
We have the same issue with
Seems to work fine. 🤷♂️ |
Yeah still not sure how to best support test mode by default. More complex given that the testing environment can now also be a browser. I'm surprised you need a rollup plugin though. The default esbuild plugin from Vite core should be enough. |
@ArnaudBarre Ah you're correct, I just had to tweak the tsconfig's |
Two of the current needs for this (web workers and testing) have been addressed in the latest version. For a real support of HMR inside web worker see vitejs/vite#5396 |
Describe the bug
I'm using Vitest to test my React code, and it does this by hosting a Vite dev server without a HTML entrypoint. With fast refresh automatically enabled, I get this error
Maybe there's a way to get fast refresh to work on Vitest with my test rendering setup, but I'd rather just disable it since I don't need it.
Reproduction
This should be reproducible on a basic vitest project with @testing-library/react. I'll include one in the coming days if this report seems wrong.
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: