Skip to content
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

Manifest chunk hash not updated #9

Open
jouni-kantola opened this issue Jan 1, 2017 · 13 comments
Open

Manifest chunk hash not updated #9

jouni-kantola opened this issue Jan 1, 2017 · 13 comments

Comments

@jouni-kantola
Copy link

If a separate manifest chunk is built with webpack, it's important that the manifest file's chunk hash changes when other content is updated, if one does not rely on inlining the manifest. However, as it is now, the manifest chunk isn't updated when using webpack-md5-hash. Since the hash isn't updated, a user's manifest will reference old chunks.

To reproduce it:

  1. Pull the following repo:
    https://github.com/jouni-kantola/webpack-output-by-build-type
  2. Checkout the branch manifest-md5-chunk-hash
  3. npm run build
  4. manifest chunk results in: manifest.d41d8cd98f00b204e980.dev.js
  5. Update index.js and remove i.e. console.dir(config);
  6. npm run build
  7. manifest chunk hash still d41d8cd98f00b204e980

In step 4 and 7 the contents of manifest.d41d8cd98f00b204e980.dev.js differ, but the files hash is the same.

Step 4, the chunks are referenced like this in the manifest file:

script.src = __webpack_require__.p + "" + chunkId + "." + ({"3":"dev-debug","4":"always-debug","6":"vendor","7":"app"}[chunkId]||chunkId) + "." + {"0":"54ff91330501e270913a","1":"fe3f496e1bee6abf3c8b","2":"52b9240b3a48bd45f6b2","3":"1d340785218727e69e26","4":"47a0bd6038e6bac6aba0","6":"ab3c1652eb7b852b49a5",**"7":"b322ecf5dda7980e9390"**}[chunkId] + ".dev.js";

In step 7 references are:

script.src = __webpack_require__.p + "" + chunkId + "." + ({"3":"dev-debug","4":"always-debug","6":"vendor","7":"app"}[chunkId]||chunkId) + "." + {"0":"54ff91330501e270913a","1":"fe3f496e1bee6abf3c8b","2":"52b9240b3a48bd45f6b2","3":"1d340785218727e69e26","4":"47a0bd6038e6bac6aba0","6":"ab3c1652eb7b852b49a5",**"7":"47159d1b554b86f0584f"**}[chunkId] + ".dev.js";
@rockybean
Copy link

@jouni-kantola How is the problem now?

I encounter this problem too. Finally,I remove webpack-md5-hash and then everything goes to be OK

@jouni-kantola
Copy link
Author

jouni-kantola commented Mar 8, 2017

@rockybean: It really only becomes a problem if the contents are not inlined.

As the repro branch is still up, I updated to webpack v2.2.1 and went through the steps again. The result is still the same; the manifest js file's hash isn't updated.

@rockybean
Copy link

@jouni-kantola Try to not use webpack-md5-hash plugin.

@jouni-kantola
Copy link
Author

jouni-kantola commented Mar 9, 2017 via email

@IamKritika
Copy link

@jouni-kantola so removing webpack-md5-hash plugin is the only solution?? or you found any alternative for this?

@jouni-kantola
Copy link
Author

@IamKritika: I recommend to inline the parts that vary into the page. This is one approach for doing that:
https://github.com/jouni-kantola/inline-chunk-manifest-html-webpack-plugin

@IamKritika
Copy link

@jouni-kantola when we try to use this plugin, it gives us some compatibility errors.I guess it has to do something with webpack version.

Can we go ahead by just removing md5?

@jouni-kantola
Copy link
Author

@IamKritika: Yeah, you can leave the chunk hashing to webpack. If you want more info regarding what changes hashes in webpack you can look at (for webpack 2 in particular): webpack/webpack.js.org#652 (comment)

@ismay
Copy link

ismay commented Jun 30, 2017

Besides not updating the manifest chunk hash when the contents of the manifest change, this plugin also does not update the chunk hash when the global variable name that references the inlined manifest changes.

So when inlining the manifest, and you change the global variable that contains said manifest, your app breaks for users that still have the old manifest cached (since it'll reference the old variable name).

Yeah, you can leave the chunk hashing to webpack.

I assume that that isn't meant to be the resolution to this issue, but just to @IamKritika's usecase right? Because as it is this bug is quite serious in my opinion.

@huangshuwei
Copy link

@jouni-kantola

@jouni-kantola Try to not use webpack-md5-hash plugin.

there is other problem when I don't use webpack-md5-hash plugin or webpack-chunk-hash plugin .
because if I add a js file or delete a js file, other hash of the assets(js、css、vendors) will be change.

@DCtheTall
Copy link

DCtheTall commented Jul 18, 2017

We (my team at work) have also had a problem with this package updating hashing. We have found that the hash will only update consistently if you put this plugin first in the plugins array in webpack.config.js (or at least so we think so far).

@nnghuy
Copy link

nnghuy commented Jul 19, 2017

@DCtheTall Putting this plugin first in line did not resolve the issue for our build. We are omitting this plugin for now.

@mdownes
Copy link

mdownes commented Oct 16, 2018

This plugin is useless because of this major design flaw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants