-
-
Notifications
You must be signed in to change notification settings - Fork 372
fix: Webpack hashes change for not changed chunks when new ones are added. #27
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
Conversation
lukeed
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Totally forgot that NamedModulesPlugin had a production counterpart.
|
This is beautiful. Think it would be worth using shorter hashes for chunk filenames? |
|
Idk, what's the benefit tough? |
|
I just figured it'd be nicer to look at haha. It does slightly trim down the HTML payload size, though I agree it's pretty minimal. Only raised the question because I've most often seen webpack hashes used truncated to 5 characters. Also I think there's a way to have the hash pass through base64? That means it'll contain more than just numbers, which would trim it down a bit in the first place. |
|
@developit I've looked into it and the docs don't mention base64 or smaller chunkhashes anywhere. I've also tried using stuff like I guess I could write a custom plugin which would trim down the length, don't know if it's worth the trouble. Your call though. |
|
Hmmm... I'll check for a recent project of mine that uses
|
|
Definitely not worth a custom plugin, just figured if there was a builtin we could use it. |
|
I went thru a few trials & the only combinations that work are |
|
@lukeed you are right! Must have messed up something previously. Anyway, I've set chunkhashes to 5 characters 🎉 |
developit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Currently all compilation chunks are changing when new chunk is added to bundle (possibly removed too). This can break long term caching for often changing apps.
This change introducing consistent hashes via HashedModuleIdsPlugin (kinda described here).
Example:
Default generated app with following in index.js
After running
npm run buildbuild dir looks like this:After adding new route:
route-home.chunk had hash cb9a97a68a24844cb988 now it has 6a92827b1cd9460beb95. Same goes for other chunks.
After the changes hashes are correctly preserved.
Before:
After:
Chunks that were not changed have same hashes ✨