-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Chunk hash are not consistent on different machines #2215
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
bug, it was solved at different places by using a relative path. Do you want to create a PR? |
can u guys elaborate more on this issue. like giving an example? |
Is the bug still actual? I wanted to make a PR, started with reproducing the bug. ➜ webpack-hash-bug echo "$(cat src/index.js)"
require('./style.css');
const p = require('process');
document.write('hello, me bug?' + p.env);
➜ webpack-hash-bug echo "$(cat webpack.config.js)"
const path = require('path');
module.exports = {
entry: './src/index',
output: {
path: path.join(__dirname, 'public/'),
filename: 'app.js',
},
module: {
loaders: [
{
test: /\.css$/,
loader: 'style!css',
include: path.join(__dirname, 'src/'),
}
],
},
};
➜ webpack-hash-bug webpack
Hash: c15da39bb2ea9d2572df
Version: webpack 1.13.0
Time: 599ms
Asset Size Chunks Chunk Names
app.js 13.9 kB 0 [emitted] main
[0] ./src/index.js 96 bytes {0} [built]
+ 5 hidden modules
➜ webpack-hash-bug cd ../ && mkdir -p __tmp/a/b/c/d && cp -rf webpack-hash-bug __tmp/a/b/c/d && cd $_/webpack-hash-bug && webpack
Hash: c15da39bb2ea9d2572df
Version: webpack 1.13.0
Time: 458ms
Asset Size Chunks Chunk Names
app.js 13.9 kB 0 [emitted] main
[0] ./src/index.js 96 bytes {0} [built]
+ 5 hidden modules |
We're running into this issue right now. We're building our prod deploys using capistrano which dumps the source into a timestamped folder. So, the folder name is different on newly provisioned machines than it is on old machines. @sokra mentioned: "it was solved at different places by using a relative path." How do we use a relative path? I'm going to investigate and get it working, but I figured you might be able to direct me faster. Thanks! |
This is still an issue. Relevant file is https://github.com/webpack/webpack/blob/master/lib/node/NodeSourcePlugin.js The generated require calls need to be relative instead of absolute paths. One can use |
There is a workaround: get this from https://github.com/coryhouse/react-slingshot |
@sokra any idea where to look into to fix this issue? |
I wrote a fix in #3272, first time sending a PR to a serious project, please help me improve it if it's not good enough. |
* master: fix the appveyor build fixes webpack#3159 add test cases for webpack#3235 `--module-bind` automatically appends -loader added strictModuleExceptionHandling option Updated README with new donation info Update `-loader`error message 2.1.0-beta.27 add test with dynamic indexed access to imports fixes indexed import Prefix path with ./ Apply change to Buffer, setImmediate, clearImmediate too. Replace '\' with '/' to make windows generate same path string as other platforms. Change absolute path returned by getPathToModule() to relative path to fix issue webpack#2215
@zcfan I figured out that you made a pr and it was merged, however it is still a bug to me when running in different machines like Windows and Mac, and i found it that in latest version of webpack, i could not see your code, is it because your code gone missing that the bug is still open? |
@JoJoChilly I believe my code is still there, other contributor improved (and moved) it :-) Checkout the history of NodeSourcePlugin.js. |
This should be fixed. If you still see this issue file a new issue with a repro case. Please provide an example with raw webpack (not using plugins modifing how hashes are calculated, i. e. webpack-md5-hash). |
@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. |
I don't see why this was closed without being explained. @sokra can you explain what you mean with your comment "it was solved at different places by using a relative path. Do you want to create a PR?" I'm open to creating a PR if this issue can be explained a little more. There is 2.5 years of history at #1479, maybe this was just closed as a duplicate? |
We met the issue with different |
@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 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 |
I've written an article with results of my investigation. I hope once it will be helpful to someone. |
@the-teacher can you provide link on PRs? |
@evilebottnawi hey 👋 In my case there is no any issue in WebPack. Some plugins had / still have issues with this should-not-embed-absolute-paths part of the official documentation. I found some odd cases, bit I'm not sure in a nature of these issues. The best recipe I have now is:
2 broken plugins already have PRs to fix issues. Unfortunately no ones wants to merge them. But they worked for me very well. Probably there are some other broken plugins. But in my project I found just these. |
@the-teacher thanks for investigate, i ping authors of commits, let's wait 2-3 days, and do new PR if no reply |
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.
The text was updated successfully, but these errors were encountered: