When trying to hot-update React components with webpack-hot-middleware, I receive the following error every time:
Uncaught (in promise) Error: Aborted because ./SomeComponent.js is not accepted
I'm not exactly sure why that happens... But I've noticed that:
I can hot-update anything else (manually replacing my redux-reducer using module.hot.accept, reload css using style-loader, etc.).
Stepping through with the debugger, I can see that in file process-update.js line 32, The callback function given to module.hot.check is never called. It seems the hotCheck() function assigns its apply parameter (the callback) to a global hotApplyOnUpdate. This function is then given to hotApply() which expects to receive an options object, and not a callback.
Searching for all usages of hotApplyOnUpdate yields:
true;apply parameter every time hotCheck() is called.hotApply() inside hotUpdateDownloaded().So, is it a problem with webpack's HMR plugin?
I'm using:
[email protected]
[email protected]
[email protected]
"Not Accepted" errors are almost always because of a mistake or bug in the apply() code/handler.
Do you see the same issue on webpack v1? 2.0 is pretty new - I don't know whether the HMR code has changed much, but it could be related.
Update:
The issue doesn't appear when using [email protected].
But there are two small issues which I'm not sure are even solvable:
[HMR] The following modules couldn't be hot updated: (Full reload needed)
This is usually because the modules which have changed (and their parents) do not know how to hot reload themselves. See http://webpack.github.io/docs/hot-module-replacement-with-webpack.html for more details.
How much do you need the v2 changes? Sounds like it might be best to stay on v1 for now if you're pressed for time to deal with such issues.
Yeah, I've now already gone back to webpack v1. I'll upgrade when it is a bit more stable. Thank you!
Any news on this one?
I've not had a chance to look into any of the webpack 2 stuff yet.
Any help is appreciated.
As @sosz uncovered, the signature for module.hot.check has changed in webpack 2 to using promises instead of a callback. The new version of only-dev-server.js uses then() and catch() instead of a callback. I think it's possible to support both the webpack 1 callback and the webpack 2 promise. I submitted pull request #85. Hope that helps.
Keeping the issue open until the fix is confirmed. If anyone is able test the master branch and feed back that'd be great.
It turns out that the pull request I made only fixed this error message. There are other errors to get things working properly with webpack 2. I'm working through some of them. Hopefully they can all be done without breaking compatibility with webpack 1.
I submitted a new pull request to take care of the change in webpack 2 to module.hot.apply(). I don't see anything else in process-update.js that needs to be updated.
The master branch is working as designed for me. @sosz are you able to re-test? You would need to update your package.json to have the latest version of webpack 2 and webpack-hot-middleware pulled from the master branch.
"webpack": "^2.1.0-beta.4",
"webpack-hot-middleware": "git+https://github.com/glenjamin/webpack-hot-middleware"
I am working on a project that doesn't use react, but it uses monkey-hot-loader instead. I had to patch monkey-hot-loader to replace named export functions and be able to parse the es2015 source. https://github.com/jlongster/monkey-hot-loader/pull/5
Thank you! But I won't be able to test for a while.
@phaistonian would you be able to try this out and confirm its working ok?
I've done a bit of testing myself, looks to be working correctly on webpack 2 and webpack 1.
Will aim to release later today unless someone else spots an issue.
@glenjamin I will give it a try the soonest, though I am afraid the release will come first since I have a hectic day to deal with.
Released as 2.10.0
Most helpful comment
Released as
2.10.0