When requiring shim for using process in browser, chunk hash variants on different machines.
In the module “lib/NodeSourcePlugin”, “getPathToModule” method will return an absolute path of node shim. This will cause different results depending on the path where your project exits on different machines. And when webpack injects variable dependencies such as ‘require(/path/to/node_modules/process/browser.js)’, the expression used to initialize DependenciesBlockVariable is changed, Which makes the hash of chunk changed too !
Is this a bug ? Or feature ? It is so disturbing that same code but gets different hash.
6 thoughts on “Chunk hash are not consistent on different machines”
Comments are closed.
bug, it was solved at different places by using a relative path. Do you want to create a PR?
@sokra can you link to the PR that fixed this issue? is it fixed on 3.4? I’m on 3.3 and it’s still not working
Using Webpack 3.6 I get different hashes when using CSS modules. When I build with the same config but without the components using CSS modules the hashes match across machines. This could mean a problem remains in the css-loader (or sass-loader etc.) rather than Webpack itself. I’ll create a repo where this can easily be reproduced and a new issue, but thought it might be worth mentioning here.
We met the issue with different
chankhash
names on different machines. It’s a big problem to reproduce it, because we face this issue on a huge amount of files and there is no any obvious way to reproduce it. Sometimes it happens, sometimes does not. looks likewebpack-md5-hash
is not a silver bullet also because it has its own issues and also looks abandoned.@dmitry @aguynamedben @thecalvinchan @lcxfs1991
Hey guys! I’ve made an example of this issue. Me and my colleges checked it already on many machines and all of us got different hashes.
My example uses a one of real examples with using
expose-loader
, but actuallyexpose-loader
is not a cause of this issue. It’s just a one way of many to reproduce it; But I hope it is already a good test case to start investigation.Could you guys check it and let me know about your results?
@sokra could we create a ticket for this issue? It’s really important because it affects production servers. It’s very unpleasant case when a few front-end servers have different
chunkhash
names and users can’t reach them only randomly though a load balancer.https://github.com/the-blog/WebpackChunkhashIssue
I’ve written an article with results of my investigation. I hope once it will be helpful to someone.
https://medium.com/@the_teacher/webpack-different-assets-hashes-on-different-machines-the-problem-the-solution-ec6383983b99