fix(contribute): fix webpack 4 patterns in plugin-patterns Changed chunks section#8168
Merged
alexander-akait merged 3 commits intowebpack:mainfrom Apr 6, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| Calling `.filter()` or `.map()` directly on it throws a `TypeError`. | ||
| Use `for...of` or spread it into an array first. | ||
|
|
||
| W> `chunk.hash` was removed in webpack 5. Use `chunk.contentHash.javascript` instead. Using the old property returns `undefined`, causing every chunk to appear changed on every rebuild. |
Member
There was a problem hiding this comment.
Let's avoid using webpack@5 or webpack@4 and just describe the actual types now
Contributor
Author
There was a problem hiding this comment.
Good point — I’ve removed the version references and described the behavior directly. Updated!
alexander-akait
approved these changes
Apr 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Bug fix (documentation) — updates webpack 4 patterns that break in webpack 5.
Summary
The "Changed chunks" example has two bugs that cause incorrect behavior in webpack 5:
compilation.chunks.filter()throwsTypeError: compilation.chunks.filter is not a functionbecause
compilation.chunksis aSetin webpack 5, not an array.chunk.hashreturnsundefinedin webpack 5 — causing every chunk to appearchanged on every rebuild, even when nothing changed.
Changes
.filter()withfor...ofiterationchunk.hashwithchunk.contentHash.javascriptchunk.id ?? chunk.nameas the tracking keyW>warnings for both webpack 5 API changesT>tip explaining the key choice and guardReopening #8167 with contributing guidelines followed.