webpack-md5-hash icon indicating copy to clipboard operation
webpack-md5-hash copied to clipboard

Base the hash on the output rather than the input

Open dobbym opened this issue 7 years ago • 2 comments

This will have a problem too. If the inputs stay the same but the modules which package the output change then the hash will stay the same but the output may differ.

For example, i change none of my inputs but Uglify changes, resulting in different output but the same hash.

Why not solve all these problems by basing the hash on the output rather than the inputs?

dobbym avatar Jul 21 '17 12:07 dobbym

Related: https://github.com/webpack/webpack/issues/4659

constfun avatar Apr 30 '18 16:04 constfun

I don't think those are problems but rather design choices.

One example: hashed images are referenced in module output. When the image changes the output based hashing would cause the module hash to change which would change the bundle hash. In this case the end user's cached image would be busted (good) but the entire cached bundle would also be busted (not good).

To your example, technically if the uglified code is different, it's functionality should be identical, meaning the hash should remain the same. If you want protection against a potential uglification bug then it's recommended to change the underlying code at the same time.

hdennen avatar May 04 '18 07:05 hdennen