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
+27-24Lines changed: 27 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,37 +1,40 @@
1
1
---
2
-
title: Plugin Patterns
2
+
title: 插件模式
3
3
sort: 5
4
4
contributors:
5
5
- nveenjain
6
6
- EugeneHlushko
7
7
- benglynn
8
+
- Yucohny
9
+
translators:
10
+
- jsbugwang
8
11
---
9
12
10
-
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.
W> **Deprecation warning**: Array functions will still work.
51
+
W> **弃用警告**:数组函数依然可用。
49
52
50
-
-`module.fileDependencies`: An array of source file paths included into a module. This includes the source JavaScript file itself (ex: `index.js`), and all dependency asset files (stylesheets, images, etc) that it has required. Reviewing dependencies is useful for seeing what source files belong to a module.
51
-
-`compilation.chunks`: A set of chunks (build outputs) in the compilation. Each chunk manages the composition of a final rendered assets.
W> **Deprecation warning**: Array functions will still work.
56
+
W> **弃用警告**:数组函数依然可用。
54
57
55
-
-`chunk.getModules()`: An array of modules that are included into a chunk. By extension, you may look through each module's dependencies to see what raw source files fed into a chunk.
56
-
-`chunk.files`: A Set of output filenames generated by the chunk. You may access these asset sources from the `compilation.assets`table.
### Monitoring the watch graph $#monitoring-the-watch-graph$
61
+
### 监听观察图的修改 $#monitoring-the-watch-graph$
59
62
60
-
While running webpack middleware, each compilation includes a `fileDependencies``Set` (what files are being watched) and a `fileTimestamps``Map` that maps watched file paths to a timestamp. These are extremely useful for detecting what files have changed within the compilation:
You may also feed new file paths into the watch graph to receive compilation triggers when those files change. Add valid file paths into the `compilation.fileDependencies``Set`to add them to the watched files.
T> The `fileDependencies``Set`is rebuilt in each compilation, so your plugin must add its own watched dependencies into each compilation to keep them under watch.
W> Since webpack 5, `compilation.fileDependencies`, `compilation.contextDependencies`and`compilation.missingDependencies`are now a `Set`instead of a `Sortable Set` and thus no longer sorted.
0 commit comments