From 856fd642f237a9d3dbb6789b160cd16a32c71616 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 24 Feb 2024 23:40:19 +0530 Subject: [PATCH] docs: add note for non extensibility of hooks --- src/content/api/compilation-hooks.mdx | 3 +++ src/content/api/compiler-hooks.mdx | 5 ++++- src/content/api/parser.mdx | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/content/api/compilation-hooks.mdx b/src/content/api/compilation-hooks.mdx index 95ac7df24302..47186f3624a5 100644 --- a/src/content/api/compilation-hooks.mdx +++ b/src/content/api/compilation-hooks.mdx @@ -11,6 +11,7 @@ contributors: - EugeneHlushko - chenxsan - jamesgeorge007 + - snitin315 --- The `Compilation` module is used by the `Compiler` to create new compilations @@ -30,6 +31,8 @@ compilation.hooks.someHook.tap(/* ... */); As with the `compiler`, `tapAsync` and `tapPromise` may also be available depending on the type of hook. +W> Since webpack 5, `hooks` are no longer extendable. Use a `WeakMap` to add custom hooks. + ### buildModule `SyncHook` diff --git a/src/content/api/compiler-hooks.mdx b/src/content/api/compiler-hooks.mdx index 3f107f5f5a5c..447e38eb8851 100644 --- a/src/content/api/compiler-hooks.mdx +++ b/src/content/api/compiler-hooks.mdx @@ -10,6 +10,7 @@ contributors: - EugeneHlushko - superburrito - chenxsan + - snitin315 --- The `Compiler` module is the main engine that creates a compilation instance @@ -17,7 +18,9 @@ with all the options passed through the [CLI](/api/cli) or [Node API](/api/node) `Tapable` class in order to register and call plugins. Most user-facing plugins are first registered on the `Compiler`. -When developing a plugin for webpack, you might want to know where each hook is called. To learn this, search for `hooks..call` across the webpack source +When developing a plugin for webpack, you might want to know where each hook is called. To learn this, search for `hooks..call` across the webpack source. + +W> Since webpack 5, `hooks` are no longer extendable. Use a `WeakMap` to add custom hooks. ## Watching diff --git a/src/content/api/parser.mdx b/src/content/api/parser.mdx index 493c80d9df98..dc3e4ddaa42d 100644 --- a/src/content/api/parser.mdx +++ b/src/content/api/parser.mdx @@ -8,6 +8,7 @@ contributors: - misterdev - EugeneHlushko - chenxsan + - snitin315 --- The `parser` instance, found in the `compiler`, is used to parse each module @@ -36,6 +37,8 @@ depending on the type of hook. The following lifecycle hooks are exposed by the `parser` and can be accessed as such: +W> Since webpack 5, `hooks` are no longer extendable. Use a `WeakMap` to add custom hooks. + ### evaluateTypeof `SyncBailHook`