Closed ArnaudBarre closed 1 year ago
Is „refresh“ the option that injects react refresh into HTML? Can it only be configured by the plugin itself?
It's the option that enabled specific AST transformation for fast refresh (React HMR).
Then if this transformation is enabled and the output actually contains something React Refresh specific, we wrap the module with the import of the runtime code (which requires the transfromIndexHTML to run, which is not the case here)
My idea is to disable the HMR specific transform when running inside Vitest, and I wondering if process.env.TEST
is a good check
I wondering if
process.env.TEST
is a good check
If you only want to target Vitest, you can use process.env.VITEST
, but we also set process.env.TEST
, so it will work in Vitest.
Then if this transformation is enabled and the output actually contains something React Refresh specific, we wrap the module with the import of the runtime code (which requires the transfromIndexHTML to run, which is not the case here)
Interesting. I've been wondering how to disable this on our side in @vitejs/plugin-react
which I assume uses the same mechanism. 🤔 But I assume this PR fixes it?
The two plugins are independent but have the mechanism. I will update the Babel one just after.
I will go with process.env.TEST
because this condition is more related to testing in general than juts Vitest (the problem did not surface before because of the ssr flag is on wihtout the optimizer)
Fixes #111
To be validated by @sheremet-va