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
React Hot Reloader + webpack-dev-server doesn't update after a syntax error is fixed #655
Comments
This might be related to webpack/webpack#2117. |
@SpaceK33z Looks like the fix only went into webpack v2.1.0-beta.x 👎 |
You're free to back port it to v1 with a PR. Closing because it has been fixed in v2. |
I have the same issue. Could you point me to the fix in the beta? |
@koddo, it's called |
I wonder why noErrorsPlugin doesn't work. It should stop any emitting, but it doesn't. |
When using the noErrorsPlugin, after making an error and then fixing it, module.hot.status() returns "check", when it should return "idle". So, basically it gets stuck somewhere, I can't figure out. |
Ok, a tiny monkey patch for this issue. I have webpack v1.13.2 with I know this is an awful hack, please don't hate me. First, add the module.exports = function() {
// ...
function hotCreateRequire(moduleId) {
// ...
setStatus: function(s) {
hotSetStatus(s);
},
// ... Second, call it in the if(module.hot) {
var check = function check() {
module.hot.check(function(err, updatedModules) {
if(err) {
// ...
} else {
console.warn("[HMR] Update check failed: " + err.stack || err.message);
module.hot.setStatus("idle"); // <<<---------- here it is !!!
}
return;
}
// ... |
@koddo I tried both this hack and upgrading to the latest beta webpack-dev-server and webpack releases. The red box is shown if you break a dependency e.g. try and use instead of , but if you actually break the JSX tag e.g. 'Link>', an error is raised in the console but no further updates actually seem to hot reload on the page. |
@mikeengland, what is a red box? I only have errors in the console. I see syntax errors in jsx, fix them, and then it hot reloads. I understand this feeling of helplessness because of lack of live reload in the twenty first century, so I'm willing to help. Do you use webpack v1.13.2 with |
@mikeengland, |
@koddo Same issue with you. The |
@mrdulin, please try the hack I've posted above. I'd share it, but I'll have to create a hundred megabytes repo with all those Before doing the following steps from scratch, try to add an error handler to the @mikeengland: I forgot to mention that callback for To make it work I did |
@koddo I tried this but I couldn't get it working if a compilation error occurs. Note, I am not using Create-React-App. One thing I did not do is add const HotContainer = ({store}) => <AppContainer><Root store={store}/></AppContainer>;
if (module.hot) {
module.hot.accept(Root, () => {
render(<HotContainer store={store}/>, document.getElementById('app-root'));
});
} |
@mikeengland, hm, I've just checked, this line has no effect, hmr doesn't break without it. So, I've found the only configuration that works for me. Sorry, can't help you with the hot reloader. |
I encountered this same problem, and I discovered it was because in my server (nodejs/express) I defined my webpack /build/ directory to be a static directory served by Express: app.use(express.static('/build', '../public/build')); But the new webpack-dev-server and hot-loader need to be the one serving your build directory while in development mode. So my solution was to enable static delivery of my build directory when not in development mode: if (process.env.NODE_ENV != 'dev') { And then in my webpack config I set publicPath to be '/build': var config = { So now in dev mode, the bundle and the .hot-update.json files are served by webpack-dev-server: http://localhost:8000/build/bundle.js |
I'm submitting a bug report
webpack and webpack-dev-server version:
webpack: 1.13.1
webpack-dev-server: 1.14.1
Please tell us about your environment:
OSX 10.11
Current behavior:
I am using the React Hot Reloader (v3.0.0-beta.5) with the webpack-dev-server. It works as expected if no errors occur. If an error occurs, for example due to an invalid JSX tag, an error is displayed in the console. This is great, however when the code is fixed and valid, the hot reloader says it is recompiling and then ready, but any future changes are not 'hot reloaded' and are not shown on the screen.
An issue was raised on react-hot-loader about this. One of the contributors closed the issue
and said
This is an issue with Webpack Dev Server, and I recommend using webpack-dev-middleware/webpack-hot-middleware
.gaearon/react-hot-loader#389
I can see the updated code in the hot-update.js response however, so I am not sure if this is an issue with the React hot reloader not picking it up.
Note: I also added the noErrorsPlugin, which seems to stop emitting if a compilation error occurs, however, the hot reloader still does not update properly once this is fixed.
When I fix the error, I receive a 404 on the hot-update.json file. Maybe this is causing the issue?
Please can someone advise?
Thanks!
The text was updated successfully, but these errors were encountered: