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

use consistent chunk ids #1534

Merged
merged 1 commit into from Jul 19, 2017

Conversation

stevensurgnier
Copy link
Contributor

Consistent chunk ids are generated by truncating the md5 of the chunk name to a 64 bit integer.

truncate the md5 of the chunk name to a 64 bit integer
@KyleAMathews
Copy link
Contributor

@gatsbybot
Copy link
Collaborator

Deploy preview ready!

Built with commit a63f1a7

https://deploy-preview-1534--using-drupal.netlify.com

@gatsbybot
Copy link
Collaborator

Deploy preview ready!

Built with commit a63f1a7

https://deploy-preview-1534--gatsbyjs.netlify.com

@gatsbybot
Copy link
Collaborator

Deploy preview ready!

Built with commit a63f1a7

https://deploy-preview-1534--gatsbygram.netlify.com

@craigmulligan
Copy link

craigmulligan commented Jul 17, 2017

Hey @stevensurgnier doesn't the webpack-md5-hash plugin cover this? Or is it doing something else?

@stevensurgnier
Copy link
Contributor Author

The webpack-md5-hash produces the chunkhash - a hash of the chunk's content. This PR modifies the chunk id - an internal webpack id. By default the chunk id is represented as a sequential integer. You can see it in the manifest and a final chunk file. The problem I ran into is that the chunk id can change when you add more chunks. However, the chunkhash is a function of the chunk content not the file content. Thus, the file can change while the chunkhash remains the same. If you're caching based on chunkhash (or filename) this will cause big problems. This PR provides a consistent chunk id based on chunk name. Unfortunately, the version of webpack we're on requires the chunk id to be an integer. Thus, the not so ideal amount of entropy used in this PR.

@KyleAMathews
Copy link
Contributor

This is awesome! Thanks for researching the fix and creating the PR.

@KyleAMathews KyleAMathews merged commit f0fccb0 into gatsbyjs:master Jul 19, 2017
@craigmulligan
Copy link

@stevensurgnier, Hmm I didn't consider that, super interesting thanks for the explanation 👍

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.

None yet

4 participants