You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/contribute/plugin-patterns.mdx
+34-6Lines changed: 34 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ contributors:
5
5
- nveenjain
6
6
- EugeneHlushko
7
7
- benglynn
8
+
- raj-sapalya
8
9
---
9
10
10
11
Plugins grant unlimited opportunity to perform customizations within the webpack build system. This allows you to create custom asset types, perform unique build modifications, or even enhance the webpack runtime while using middleware. The following are some features of webpack that become useful while writing plugins.
@@ -93,7 +94,13 @@ W> Since webpack 5, `compilation.fileDependencies`, `compilation.contextDependen
93
94
94
95
## Changed chunks
95
96
96
-
Similar to the watch graph, you can monitor changed chunks (or modules, for that matter) within a compilation by tracking their hashes.
97
+
Similar to the watch graph, you can monitor changed chunks within a compilation by tracking their content hashes.
98
+
99
+
W> `compilation.chunks` is a `Set`, not an array. Calling `.filter()` or `.map()` directly on it throws a `TypeError`.
100
+
Use `for...of` or spread it into an array first.
101
+
102
+
W> `chunk.hash` is not defined on chunk objects. Use `chunk.contentHash.javascript` instead.
103
+
Accessing `chunk.hash` returns `undefined`, causing every chunk to appear changed on every rebuild.
0 commit comments