-
-
Notifications
You must be signed in to change notification settings - Fork 469
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 does not work as of 1.0.0 #422
Comments
@phaistonian anyway please create reproducible test repo to ensure it is situation described above |
So, HMR will be working as it should when webpack 5 is released and until then we should revert to a version < 1.0, yes? |
@phaistonian hmr works fine if you don't use |
@evilebottnawi Will try to - once I get some free time. Thank you. ps: I am not using CSS modules, the setting in |
@phaistonian should work, maybe bug, wait reproducible test repo and help you |
It's also broken for me. Just using |
PLEASE create minimum reproducible test repo, message like |
I agree. Previous version of style-loader works fine even with css-modules. HMR in the version 1.0.0 doesn't work as expected only with css-modules. I'm frustrated of this. Css-modules mustHave for me and I can't work without HMR at all. And I've never had potentially breaking app in some cases in dev mode with previous versions. Can it be fixed for the latest version? |
@Yegorich555 previously version style-loader didn’t work correctly, even if everything seemed to be right for you, technically it was done incorrectly and led to problems in many places, it can be fixed only introducing new hot api, and in theory can be done for webpack@5. What is problem? Refreshing is very fast |
The main problem is not in the speed of refreshing but in refreshing in general. For example I'm developing some view or component which is deeply nested and with refreshing everything is lost. And I need to go to the exact view by clicking 4 times (on some buttons) and filling forms and submitting 2 forms, for example. You can imagine how much time I spend with such refreshes (during the css bug-fixing for example). So I got your point on the latest update and it's fine that it works in the right way, but hot-reload with css-modules is not only convenient but it decreases time of developing also. In this case I can't use the latest update. Time of developing is number 1 for me. Could you add some points in Readme and Changelog that can clarify breaking changes for css-modules hot reload? |
@Yegorich555 yep, in near future, maybe we can implement new hot API for webpack@5 and do backport for webpack@4 it is allow to improve this, but unfortunately i don't have enough time and it can take a lot of time |
So, to recap:
yes?:) |
@phaistonian yes, or we can implement new api in webpack@4 and implement this in |
@evilebottnawi I am not sure it makes much sense developing (i.e in local environment) and not having HMR on css. It's definetely a deal-breaker in our cases and that's why we downgraded to the previous version across all our repos. My suggestion is to do so and support webpack 5 later - if more work is needed. |
@phaistonian I will have a discussion with sokra about it, maybe we can return this faster than you think, in my todo |
@evilebottnawi do you have any updates on this? Thank you! |
@chybisov right now no, sorry, we have new HMR api for webpack@5, maybe we should start to backport it for webpack@4 |
As we're using a new api introduced in 1.x, we unfortunately cannot downgrade |
emm...I use the |
I think we can implement it now https://github.com/webpack/webpack/releases/tag/v4.43.0 |
@evilebottnawi great news! Will you be able to implement this in the near future? Thank you! |
I believe something along these lines would fix the behavior for webpack 4.43+: diff --git a/src/index.js b/src/index.js
index 5907d16..ca87820 100644
--- a/src/index.js
+++ b/src/index.js
@@ -187,7 +187,7 @@ ${esModule ? 'export default' : 'module.exports ='} exported;`;
const hmrCode = this.hot
? `
if (module.hot) {
- if (!content.locals) {
+ if (module.hot.invalidate || !content.locals) {
module.hot.accept(
${loaderUtils.stringifyRequest(this, `!!${request}`)},
function () {
@@ -205,6 +205,30 @@ if (module.hot) {
newContent = [[module.id, newContent, '']];
}
+ if (content.locals) {
+ if (!newContent.locals) {
+ module.hot.invalidate();
+ return;
+ }
+
+ var oldKeys = Object.keys(content.locals),
+ newKeys = Object.keys(newContent.locals);
+ if (oldKeys.length !== newKeys.length) {
+ module.hot.invalidate();
+ return;
+ }
+
+ for (var idx = 0; idx < oldKeys.length; idx++) {
+ var key = oldKeys[idx];
+ if (content.locals[key] === newContent.locals[key]) {
+ continue;
+ }
+
+ module.hot.invalidate();
+ return;
+ }
+ }
+
update(newContent);`
}
} |
I will implement it today |
Release will be tomorrow, need write a lot of tests |
Do not forget that change locals (for example change |
It seems that the issue is still there - for me. Changing a .styl file still triggers a full-page reload whereas this was not the case in version < 1.0.0. |
@evilebottnawi As noted in my previous comment, I had to downgrade to 0.23.1 - again. It seems the newest version did not the trick. |
@phaistonian for css and scss files it works great. |
@chybisov I am quite sure this has nothing to do with stylus (and stylus loader) because the input to style loader is always CSS (string). |
@phaistonian Please create reproducible test repo |
@evilebottnawi Busy times down here - so it might take a while. Note that the error, this time, is not |
@phaistonian Sorry without reproducible test repo I can't help, you can provide webpack config |
Expected Behavior
HTR to work as before 1.0.0
Actual Behavior
Ignored an update to unaccepted module
kind of errors are thrown and full-reload takes place whenever a change is made in content passed to style-loader.How Do We Reproduce?
Not sure - I guess try changing css content using the latest version of style-loader.
The text was updated successfully, but these errors were encountered: