Skip to content

fix(contribute): fix webpack 4 patterns in plugin-patterns Changed chunks section#8167

Closed
raj-sapalya wants to merge 1 commit intowebpack:mainfrom
raj-sapalya:fix/plugin-patterns-webpack5-chunks
Closed

fix(contribute): fix webpack 4 patterns in plugin-patterns Changed chunks section#8167
raj-sapalya wants to merge 1 commit intowebpack:mainfrom
raj-sapalya:fix/plugin-patterns-webpack5-chunks

Conversation

@raj-sapalya
Copy link
Copy Markdown
Contributor

Problem

The "Changed chunks" example contains webpack 4 patterns that break in webpack 5:

1. compilation.chunks.filter() throws a TypeError
compilation.chunks is a Set in webpack 5, not an array. Calling .filter() throws TypeError: compilation.chunks.filter is not a function.

2. chunk.hash is no longer valid
chunk.hash was removed in webpack 5. Using it causes the comparison to always evaluate as changed, so every chunk appears updated on every rebuild.

Changes

  • Replace .filter() with for...of iteration
  • Replace chunk.hash with chunk.contentHash.javascript
  • Use chunk.id ?? chunk.name as the tracking key
  • Skip chunks without a JavaScript content hash
  • Add warnings explaining the webpack 5 API changes
  • Add a tip explaining the key choice and guard

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
webpack-js-org Ready Ready Preview, Comment Apr 4, 2026 6:49pm

Request Review

@evenstensberg
Copy link
Copy Markdown
Member

use pr template please.

@raj-sapalya
Copy link
Copy Markdown
Contributor Author

use pr template please.

Sorry about that! I missed the PR template. Reopening now with the proper format.

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