Skip to content

Commit 3427ea4

Browse files
committed
docs(plugin): unify dependency explanation and use ESM syntax
1 parent b895e37 commit 3427ea4

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/content/contribute/writing-a-plugin.mdx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -340,19 +340,16 @@ module.exports = WatchNotifierPlugin;
340340
If your plugin reads external files (config files, templates, etc.)
341341
that webpack does not track by default, you must tell webpack to watch them.
342342

343-
The `compilation.fileDependencies` set allows you to add such files.
343+
The `compilation.fileDependencies` set allows you to add files that your plugin depends on, so webpack can trigger a rebuild when those files change.
344344

345-
In addition to individual files, you can also tell webpack to watch
346-
directories and files that do not yet exist:
345+
You can also extend this behavior to other types of dependencies:
347346

348-
- `compilation.contextDependencies` is used to watch directories so that
349-
any change inside them triggers a rebuild
347+
- `compilation.contextDependencies` is used to watch directories, so any change inside them triggers a rebuild
350348

351-
- `compilation.missingDependencies` is used to track files that are currently missing,
352-
so webpack can trigger a rebuild when they are created
349+
- `compilation.missingDependencies` is used to track files that are currently missing, so webpack can trigger a rebuild when they are created
353350

354351
```js
355-
const path = require("node:path");
352+
import path from "node:path";
356353

357354
class TemplateWatchPlugin {
358355
apply(compiler) {
@@ -373,7 +370,7 @@ class TemplateWatchPlugin {
373370
}
374371
}
375372

376-
module.exports = TemplateWatchPlugin;
373+
export default TemplateWatchPlugin;
377374
```
378375

379376
Without calling `fileDependencies.add()`, webpack will not trigger

0 commit comments

Comments
 (0)