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
Hot reloading reloads the whole page #1704
Comments
Without the As for @JoviDeCroock Any chance you might know what's going on here? As far as I can tell we're following Prefresh's instructions for Webpack. We're not using |
I can take a look, I haven't generally been noticing any issues with webpack 4 but could be that something got broken. We used to have a test for webpack 4 and webpack 5 but looks like I removed the 4 one 😅 will try and take a look this weekend Generally though, you should be able to capture the error from here if you add a log in |
Thanks! I'll keep poking at it, but HMR is very much magic that I have not yet delved into. FWIW I'm not seeing any errors after adding a log, just full-page refresh on any change in a component. Might not be Prefresh in that case but a Webpack dev server thing? Edit: Found that explicitly setting |
Thanks for the quick responses!
Should |
Forgot to mention, you can fix this in your own // preact.config.js
export default (config, env, helpers) => {
config.devServer.liveReload = false;
}
...that's not a trivial task. #1645 exists to do that, but Webpack 5 would be behind a major version for CLI and there's some other things I'd like to do as well. Likely a long way off, due to my own time limits. |
Thanks a lot! Ah yeah, I figured that. We'll see what happens in the future then 😊 |
We're still seeing this locally with preact-cli v3.4.3 as well as adding the |
I can't reproduce. Are you using the Edit: To test, I've added a simple |
Yeah, we're using the When adding
which looks correct as for what I've seen in the thread here? We are running a fairly old project, so I'm wondering if there's other places that might be affecting this? Deconstructing it to get to figure out where things are going wrong seems like a pretty big job right now so I'm just wondering if there's anything immediately that would be an obvious place to check. |
Yeah, that looks like the vanilla config as is correct. The only immediate thoughts I have is do you have a default export for your component in your entrypoint (i.e., like this) and does your app have some sort of root HTML element (i.e., like this)? Some people do their own mounting which screws some things up and without a root element I know hydration can get borked. Not sure if either would actually affect HMR, but they're the only things that immediately come to mind. |
Yeah we do have those two things, but we also have a production only build process that separately compiles some of our components into stand-alone widgets. I wonder if that might be having an impact. I'll try to dig into that. Thanks for the fast response! |
Hm, if it's a prod-only build process, I don't imagine it'll be the cause of dev HMR issues? Sorry I can't be more help, but if you are able to provide a minimal repo I can take a look. |
What is the current behaviour?
When changing e.g. text in a component the whole page is reloaded and not just only the component.
Steps to Reproduce
Steps to reproduce the behavior:
npx preact-cli create typescript my-app
yarn dev
(I also updated all the packages to it's latest versions). Also tried
preact watch --refresh
without luck.What is the expected behaviour?
I expect only the changed component to be reloaded and the rest of the page state is kept.
Please mention any other relevant information
tsconfig.json
The text was updated successfully, but these errors were encountered: