-
Notifications
You must be signed in to change notification settings - Fork 10
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
Confilt with @vitejs/plugin-react 2.0.0 + Vite 3 and breaks HMR #22
Comments
The README of React plugin mentioned this Error: Can't confirm if this is the cause of the problem though. |
I think the issue is that the react refresh script gets transform from: import RefreshRuntime from "/@react-refresh"
RefreshRuntime.injectIntoGlobalHook(window)
window.$RefreshReg$ = () => {}
window.$RefreshSig$ = () => (type) => type
window.__vite_plugin_react_preamble_installed__ = true to: import RefreshRuntime from "/@react-refresh"RefreshRuntime.injectIntoGlobalHook(window)window.$RefreshReg$ = () => {}window.$RefreshSig$ = () => (type) => typewindow.__vite_plugin_react_preamble_installed__ = true that makes |
Hi all, Problem is exactly what @yeion7 said. It is located in src/parse/index.js line 82 (in current master):
which removes all new lines. Since the code generated by plugin-react doesn't have semicolons, no delimiter remains between Removing this line directly in Now, depending on the reason for adding this line in the first place, the fix would be different. @lxs24sxl FYI |
Hi all, Many thanks, |
Sorry guys, busy with wedding stuff this month. I'll deal with those in the next few days. |
@lxs24sxl Reminder 😇 |
@mauro-ni @yeion7 @Bonnev @dsrkafuu Thanks for the feedback, I have solved this problem in version The plugin incorrectly parsed and integrated the code because the new version of the plugin <script type="module" src="/src/index.tsx">
import RefreshRuntime from "/@react-refresh"
RefreshRuntime.injectIntoGlobalHook(window)
window.$RefreshReg$ = () => {}
window.$RefreshSig$ = () => (type) => type
window.__vite_plugin_react_preamble_installed__ = true
</script> PS: Preparing for the wedding is really busy, but meaningful. 👀 |
@lxs24sxl I can confirm it works! PS: I'm sure it will be the best wedding! |
Reproduce:
Checkout the main branch of this project: https://github.com/dsrkafuu/skyline-overlay
Simply upgrade
vite
to^3.0.0
and@vitejs/plugin-react
to^2.0.0
, then start the dev server & open the browser.Removes the HtmlEnv plugin in
vite.config.js
, it works well.The text was updated successfully, but these errors were encountered: