-
Notifications
You must be signed in to change notification settings - Fork 801
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
Stops live updating on WebPack error. #29
Comments
From what I've been able to figure out. Given the following code from index.js. 'if (module.hot) {',
' module.hot.accept(function (err) {',
' if (err) {',
' console.error("Cannot not apply hot update to " + ' + JSON.stringify(filename) + ' + ": " + err.message);',
' }',
' });',
' module.hot.dispose(function () {',
' var nextTick = require(' + JSON.stringify(require.resolve('next-tick')) + ');',
' nextTick(__hotUpdateAPI.updateMountedInstances);',
' });',
'}'
|
This problem only occurs when I get the "Cannot not apply hot update..." error, e.g. /** @jsx React.DOM */
'use strict';
var React = require('react');
kjdfngdskfgjn / asd
var App = React.createClass({
render() {
return (
<h1>Hello, world!</h1>
);
}
});
module.exports = App; Which only seems to occur for certain types of code errors (e.g. https://github.com/js-next/react-style/issues/51). In other cases errors are simply ignored and the above message is never displayed, e.g. if I remove the |
I've tried this with "webpack": "1.4.1-beta1"
"webpack-dev-server": "1.6.4" |
Have you tried using They should solve your problem. |
Ah I see, you're already using them. |
Have you managed to reproduce the issue with the sample? |
Yes, just did, thanks for the repro. |
@sokra explains why this happens in this comment.
Now I'm not sure if there is a way for us to gracefully handle this—need to experiment a little bit. |
I'm not actually sure why HMR can't live with the previous version in this case (if we promise our component definitions don't have side effects). We could of course wrap the whole module in try-catch and cache previous result but if feels hackish. |
It doesn't really have to render anything meaningful (such as the previous version) on an error the important part is that you can fix it and continue working without having to reload. |
While this could work, I'd prefer fixing this without "injecting ourselves" into the app. |
Actually it seems like the main problem in this case being the final block ( If I move return [
'var __hotUpdateAPI = (function () {',
' var React = require("react");',
' var getHotUpdateAPI = require(' + JSON.stringify(require.resolve('./getHotUpdateAPI')) + ');',
' return getHotUpdateAPI(React, ' + JSON.stringify(filename) + ', module.id);',
'})();',
'if (module.hot) {',
' module.hot.accept(function (err) {',
' if (err) {',
' console.error("Cannot not apply hot update to " + ' + JSON.stringify(filename) + ' + ": " + err.message);',
' }',
' });',
' module.hot.dispose(function () {',
' var nextTick = require(' + JSON.stringify(require.resolve('next-tick')) + ');',
' nextTick(__hotUpdateAPI.updateMountedInstances);',
' });',
'}',
processedSource
].join('\n'); Can you verify whether this solves your initial problem? |
That seems to have solved it. Good work! |
Thank you for reporting this and specifying the exact repro case. |
See: https://github.com/js-next/react-style/issues/51
The text was updated successfully, but these errors were encountered: