-
-
Notifications
You must be signed in to change notification settings - Fork 433
Usage with Hot Module Replacement #180
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
Comments
Now, I'm absolutely sure it's a bug, found that var redux_1 = __webpack_require__(45);
var thunk = __webpack_require__(233);
var index_1 = __webpack_require__(74);
function configureStore(initialState) {
var store = redux_1.createStore(index_1.default, initialState, redux_1.applyMiddleware(thunk));
if (true) {
// Enable Webpack hot module replacement for reducers
module.hot.accept(7474, function () {
var nextRootReducer = __webpack_require__(74).default;
store.replaceReducer(nextRootReducer);
});
}
return store;
} It should be Any ideas how can I solve this? |
Guys, I finally could solve the problem! 👯 Firstly, the problem was happening because since there is no Webpack HMR has a transformer which looks for I fixed that by creating a interface NodeModule {
hot: { accept: Function };
} Then, the other problem was that I was using the HotModuleReplacement plugin twice, and then Webpack was doubling the moduleIds. After fixing both things, everything started working as expected! :) PS: The main reason it was not working in my first post in this issue is because I was using |
TL;DR
I am trying to use this (or any other) typescript loader combined with vanilla's Webpack HMR, but I'm stuck with the method
hot.module.accept
. It seems that TypeScript modules don't play well with it.I spent many hours on this, but still couldn't figure out what's going on (although I think I'm really close).
I was trying to implement HMR in a TS project I have, and wasn't advancing, so I decided to take a simpler approach:
I have an ES6 project here that I'm able to use webpack's HMR, e.g:
With the code above, if I change any file in my project, HMR replaces the dependent modules, reloads my previous state, and everything works as I expect.
Then, I ported this ES6 project to TypeScript, so I could try to use HMR in a smaller project - but for some reason - the
hot.module.accept
doesn't work well with it.If I create a generic approach for
hot.module.accept
, e.g:Doing this way, HMR replaces my modules correctly, but it destroys my state, since I have another rule for updating it.
So, I'd like to know what's the correct approach to use
hot.module.accept
with the typescript loader, since I can use it smoothly with babel.I'd already tried all the typescript loaders, but none seems to be compatible with
hot.module.accept
. Any thoughts?PS: Already tried to use Babel as an intermmediary in all the imaginable ways, but same problem persists. I hope you have some simple and magical solution for this :)
PS2: Already tried all the examples mentioned in the other issue, but none of them works with vanilla HMR.
The text was updated successfully, but these errors were encountered: