Skip to content

Commit 72c6288

Browse files
authored
docs: add note for non extensibility of hooks (#7160)
1 parent 78effa2 commit 72c6288

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/content/api/compilation-hooks.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ contributors:
1111
- EugeneHlushko
1212
- chenxsan
1313
- jamesgeorge007
14+
- snitin315
1415
---
1516

1617
The `Compilation` module is used by the `Compiler` to create new compilations
@@ -30,6 +31,8 @@ compilation.hooks.someHook.tap(/* ... */);
3031
As with the `compiler`, `tapAsync` and `tapPromise` may also be available
3132
depending on the type of hook.
3233

34+
W> Since webpack 5, `hooks` are no longer extendable. Use a `WeakMap` to add custom hooks.
35+
3336
### buildModule
3437

3538
`SyncHook`

src/content/api/compiler-hooks.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ contributors:
1010
- EugeneHlushko
1111
- superburrito
1212
- chenxsan
13+
- snitin315
1314
---
1415

1516
The `Compiler` module is the main engine that creates a compilation instance
1617
with all the options passed through the [CLI](/api/cli) or [Node API](/api/node). It extends the
1718
`Tapable` class in order to register and call plugins. Most user-facing plugins
1819
are first registered on the `Compiler`.
1920

20-
When developing a plugin for webpack, you might want to know where each hook is called. To learn this, search for `hooks.<hook name>.call` across the webpack source
21+
When developing a plugin for webpack, you might want to know where each hook is called. To learn this, search for `hooks.<hook name>.call` across the webpack source.
22+
23+
W> Since webpack 5, `hooks` are no longer extendable. Use a `WeakMap` to add custom hooks.
2124

2225
## Watching
2326

src/content/api/parser.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ contributors:
88
- misterdev
99
- EugeneHlushko
1010
- chenxsan
11+
- snitin315
1112
---
1213

1314
The `parser` instance, found in the `compiler`, is used to parse each module
@@ -36,6 +37,8 @@ depending on the type of hook.
3637
The following lifecycle hooks are exposed by the `parser` and can be accessed
3738
as such:
3839

40+
W> Since webpack 5, `hooks` are no longer extendable. Use a `WeakMap` to add custom hooks.
41+
3942
### evaluateTypeof
4043

4144
`SyncBailHook`

0 commit comments

Comments
 (0)