-
-
Notifications
You must be signed in to change notification settings - Fork 388
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
Empty module ID causes unreliable file hashes #308
Comments
@erykpiast please create minimum reproducible test repo |
@evilebottnawi Have you had time to look at example I've created? |
@erykpiast sorry, no, working on |
Sure, I understand. The thing is I actually have a solution (as described in the issue itself), but I need some people with knowledge and authority to judge if it's OK conceptually. |
@erykpiast I took a look at your repo and there are a couple of issues. First, both the identifier and context contain the full disk path. These are the ones causing the issue because even if you change the Second, there is an issue with the order as you mentioned. From I can't speak for what possible issues changing Hope that helps everyone! |
@lfre i am very busy, feel free to send a PR if you have ideas how we can fix it |
Fixed in webpack@5 |
Output:
|
After investigation I want to say it is realy hard to fix on webpack@4 due some internal problems, and it can even break the hashes for other cases, so my recommendation - consider to update webpack to v5, anyway if you faced with the same problem again please open a new issue |
Perfect! Thank you for handling this @evilebottnawi ❤️ |
Original discussion: #284
ID of
CssModule
is currently set to empty string during initialization. When module ID is somehow empty,NamedModulesPlugin
inside webpack creates name like?abcdef
. For regular ones (orNormal
in webpack's nomenclature) it outputs something like./foo/bar/baz.js?abcdef
. Until that?...
hash is based on FULL request path (ex./home/user/projects/foo/bar/baz.js
), it's different for different repository clones, ex. on different workstations and on CI. It makes file hashes quite unpredictable as sorting modules by id gives different results on different machines and hash calculation depends on that order (hash.update('a') && hash.update('b')
gives different results thanhash.update('b') && hash.update('a')
). It may be an issue even on CI, if repository is cloned to directory prefixed with build ID, so absolute path differs from build to build. In the worst case, file hash changes when its contents did not change, so the whole idea of hashing loses its sense.The issue was discussed already in
https://github.com/webpack-contrib/mini-css-extract-plugin/issues/281#issuecomment-423300860
, but for some not obvious reason soultion proposed by @lfre was rejected.The text was updated successfully, but these errors were encountered: