-
-
Notifications
You must be signed in to change notification settings - Fork 206
fix(oxc): disable refresh transform when server.hmr: false
#502
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
Conversation
|
This issue with this way of configuring refresh is that we are enabling it for ssr too, but other plugins don't do it |
|
Interesting point. It looks like rolldown-vite actually configures |
|
Ok so we need to find a way to make the tests works now |
|
How about adding a plugin like below? const viteConfigPost: Plugin = {
name: 'vite:react-oxc:config',
enforce: 'post',
config(userConfig) {
if (userConfig.oxc?.jsx && !userConfig.server.hmr) {
userConfig.oxc.jsx.refresh = false
}
}
} |
server.hmr: false
Co-authored-by: 翠 <green@sapphi.red>
| expect(await page.textContent('button')).toMatch('count is 0') | ||
| expect(await page.click('button')) | ||
| expect(await page.textContent('button')).toMatch('count is 1') | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add that for serve, edit to App.tsx does full page reload?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering about that too but it turns out server.hmr: false even disables full reload and test actually failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok let's keep it like this!
Description
$RefreshReg$ is not definederror when running tests with vitest and plugin-react-oxc #500I think another approach is to configureoxcinstead ofesbuildon Vitest side whenrolldown-viteis detected. Probably it makes more sense since we should migrate fromesbuildtooxceventually anyways.(Btw tests are failing becauseprocess.env.VITESTis true duringtest-servee2e 🙃)So, technically this is not Vitest specific issue. The same error would happen when
server.hmr: false.