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

Using contenthash instead of chunkhash #463

Closed
wants to merge 4 commits into from

Conversation

weaverryan
Copy link
Member

Since Webpack 4.3.0, a [contenthash] has existed, which is the recommended way of versioning your filenames. Previously, we used a special plugin that gave us a chunkhash, which worked around issues with hash changing unnecessarily. However, chunkhash actually created a bug - in #461, some chunk id's change unnecessarily. That's bad for caching, but the real problem was that [chunkhash] did not change, and so the filenames did not change. The filenames DO change with [contenthash].

Copy link
Collaborator

@Lyrkan Lyrkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for that change but there are several other places where we mention chunkhash that should probably be modified as well (mostly comments and tests).

Also, we recommended using it in configureFilenames() for the JS key:

* js: '[name].[chunkhash].js',

Wouldn't it be a good idea to add a warning if we detect [chunkhash] to inform users that it would be better to use [contenthash]?

@weaverryan
Copy link
Member Author

Good catch! I do need to change those!

Wouldn't it be a good idea to add a warning if we detect [chunkhash] to inform users that it would be better to use [contenthash]?

Good idea... which means that, for now, we'll need to continue adding the plugin that makes this possible.

@weaverryan
Copy link
Member Author

Test failure is due to a change to the hash calculation in Webpack 4.22.0. I'm going to ignore, so we can release these bug fixes as a patch release. Then, we can bump the minimum Webpack version from ^4.20.0 to ^4.22.0 in another PR for a minor release.

@weaverryan weaverryan deleted the use-content-hash branch August 9, 2019 02:04
weaverryan added a commit that referenced this pull request Aug 9, 2019
This PR was merged into the master branch.

Discussion
----------

Remove webpack-chunk-hash plugin

This PR removes the `webpack-chunk-hash` plugin since:

* using `[chunkhash]` was deprecated a while ago (in #463)
* it seems to be causing issues even when `[chunkhash]` is not used at all (fixes #605)

Commits
-------

b998ad2 Remove webpack-chunk-hash plugin
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

Successfully merging this pull request may close these issues.

2 participants