-
Notifications
You must be signed in to change notification settings - Fork 296
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
HMR client not starting #101
Comments
This seems to be happening to a bunch of people, most commonly on Windows. I've never been able to reproduce it myself, so info you can provide is much appreciated! Can you see anything in the network tab of chrome related to There might be some stuff you can try in #36 |
Viewing I don't see anything in the network tab related to If I include a conditional |
Ah, interesting - can you share your |
Here it is:
It's more or less the same as the boilerplate version: https://github.com/choonkending/react-webpack-node/blob/master/webpack/webpack.config.dev-client.js, except I've added a few additional loaders. Does anything look obviously amiss? |
That all looks fine, if you open up the bundle in a text editor can you see the HMR client code? Does it show up in the browser debugger? Can you put a breakpoint around the point it tries to connect to the server? |
Sorry - which bundle? I've verified that the reference to client.js is correct in my project. I also added a console.log to the top of that file, which doesn't appear on run - so it does appear that the client isn't getting bundled. |
The bundle produced by webpack. I can't see any reason that would fail quietly - it should either blow up because it can't find |
I was afraid you were going to say that :D Another oddity is the app.js bundle is minified, when really it shouldn't be. Starting to wonder whether my problem is related to environment variables... |
Double-checked it's nothing in /app by copying in the folder from the working boilerplate. Still no HMR so that narrows it down a bit more. |
Can you share your server code, or a larger sample? Are you definitely passing that config through to the webpack compiler intact? |
I wondered that too - I've previously added a console.log() to the dev client webpack config to verify that it is the one being used - and that does appear to be the case. Also if I deliberately supply a bad path to HMR client.js in the Webpack dev config, the dev task immediately fails - which also points to the config being at least looked at by the compiler(?) My server code is here: https://github.com/ReallySmall/react-node-stackduino/blob/master/server/index.js |
I suspect you might have a similar issue to #84 from when you bundle the server code. |
Thanks for that, I'll have a read through. Interestingly if I paste the dev client config into the dev server config, HMR then sort of works - in the sense that the client then appears in the console/ network, although nothing quite works as it should. I think the client config is meant to over-ride the dev server config when invoked, but for some reason it isn't. |
More specifically, if I run dev server first, then over-write the dev-server config with the dev-client config, when the task restarts, HMR then works perfectly. I can't quite work out why at the moment, but I'm much closer to solving it now - thanks very much for all the feedback! |
From what I can tell, the Dev server bundle bundles the server code, which you then run. The compiled server code then uses webpack middleware to serve up the client bundle. Bundling the sever code can mangle the config file, so the fix is to exclude client config from the sever bundle. |
Ok, thank you. I think I sort of understand, but perhaps not as it seems to me that the client config is already excluded from the server bundle - in the sense that it isn't included until run-time? If I am misunderstanding (quite likely), how would I go about excluding it? |
This task Creates a webpack bundle of your server code with server/index.js as the entry point. This means the client config gets evaluated at server build time, which can lead to problems. To exclude it you need to use the |
Hi, This strange bug had happened to me too. I'm using Windows 10 on two different machines and the same setup works on an older and slower PC and it doesn't work on a new and much powerful laptop. I found that when starting the server with:
the If I remove the
... it works as expected on both machines. I can reproduce it with this repo: https://github.com/knowbody/react-boilerplate, which has a very simple setup. By reproducing I mean, it works on the PC but not on the laptop, unless I remove the host parameter. Hope it helps, |
Just adding, I have problems on my macbook with HMR in an angular2-webpack project |
@raulmatei comment fixed my issue! Great stuff. I'd like to know why this is happening though |
There is also a similar issue, removing the /cc @glenjamin Edit: Updated CC |
Hi! I've encounted the same problem. Fortunately, I've solved my problem. Previously, I believed that the Win10 led to the bug that HMR not trigger . Now since I've experienced on my colleague's Mac and use vscode instead of webstorm, the key is the "autosave" of the webstorm. I think if u use vscode sublime autom etc, your HMR will reburn |
Hi, Actually I'm encountering the |
Hello, i had the same problem, and i just needed to remove the definePlugin from webpack to make HMR work .. |
Just a heads up I spent way too long figuring out that I had been mixing up |
Hi, I'm wondering if I can get some help with debugging an issue I have with HMR?
My machine is Windows 10 and my project uses webpack-dev-middleware and webpack-hot-middleware, based on this boilerplate: https://github.com/choonkending/react-webpack-node/
If I pull a fresh copy of that repo, HMR works exactly as it should, so the problem appears to be something I've added or changed, but I'm having trouble figuring out what that is.
In my project (https://github.com/ReallySmall/react-node-stackduino), the server side of HMR appears to still be working as expected. if I go to /__webpack_hmr I see the heartbeat - and whenever I update code I see that change reflected at /__webpack_hmr and in my cmd window I get the 'webpack built' notification.
However in my Chrome console I don't see any HMR activity at all - none of the usual messages to say HMR is initialised, connected or updated. The console remains blank. So HMR is all happening in the background, but the front end client isn't initialising.
Are there any common reasons why the HMR client would fail to start?
Thanks in advance for any help.
Cheers
Richard
The text was updated successfully, but these errors were encountered: