webpack 5.108.1 → 5.108.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ const {
13
13
  RawSource,
14
14
  ReplaceSource
15
15
  } = require("webpack-sources");
16
- const Compilation = require("../Compilation");
16
+ /** @typedef {import("../Compilation")} Compilation */
17
17
  const HotUpdateChunk = require("../HotUpdateChunk");
18
18
  const { CSS_IMPORT_TYPE, CSS_TYPE } = require("../ModuleSourceTypeConstants");
19
19
  const {
@@ -37,6 +37,7 @@ const JavascriptModulesPlugin = require("../javascript/JavascriptModulesPlugin")
37
37
  const ConcatenatedModule = require("../optimize/ConcatenatedModule");
38
38
  const { compareModulesByFullName } = require("../util/comparators");
39
39
  const createHash = require("../util/createHash");
40
+ const createHooksRegistry = require("../util/createHooksRegistry");
40
41
  const { getUndoPath } = require("../util/identifier");
41
42
  const memoize = require("../util/memoize");
42
43
  const { digestNonNumericOnlyWithFull } = require("../util/nonNumericOnlyHash");
@@ -180,39 +181,9 @@ const generatorValidationOptions = {
180
181
  baseDataPath: "generator"
181
182
  };
182
183
 
183
- /** @type {WeakMap<Compilation, CompilationHooks>} */
184
- const compilationHooksMap = new WeakMap();
185
-
186
184
  const PLUGIN_NAME = "CssModulesPlugin";
187
185
 
188
186
  class CssModulesPlugin {
189
- /**
190
- * Returns the attached hooks.
191
- * @param {Compilation} compilation the compilation
192
- * @returns {CompilationHooks} the attached hooks
193
- */
194
- static getCompilationHooks(compilation) {
195
- if (!(compilation instanceof Compilation)) {
196
- throw new TypeError(
197
- "The 'compilation' argument must be an instance of Compilation"
198
- );
199
- }
200
- let hooks = compilationHooksMap.get(compilation);
201
- if (hooks === undefined) {
202
- hooks = {
203
- renderModulePackage: new SyncWaterfallHook([
204
- "source",
205
- "module",
206
- "renderContext"
207
- ]),
208
- chunkHash: new SyncHook(["chunk", "hash", "context"]),
209
- orderModules: new SyncBailHook(["chunk", "modules", "compilation"])
210
- };
211
- compilationHooksMap.set(compilation, hooks);
212
- }
213
- return hooks;
214
- }
215
-
216
187
  constructor() {
217
188
  /** @type {WeakMap<Source, ModuleFactoryCacheEntry>} */
218
189
  this._moduleFactoryCache = new WeakMap();
@@ -1164,4 +1135,17 @@ class CssModulesPlugin {
1164
1135
  }
1165
1136
  }
1166
1137
 
1138
+ CssModulesPlugin.getCompilationHooks = createHooksRegistry(
1139
+ () =>
1140
+ /** @type {CompilationHooks} */ ({
1141
+ renderModulePackage: new SyncWaterfallHook([
1142
+ "source",
1143
+ "module",
1144
+ "renderContext"
1145
+ ]),
1146
+ chunkHash: new SyncHook(["chunk", "hash", "context"]),
1147
+ orderModules: new SyncBailHook(["chunk", "modules", "compilation"])
1148
+ })
1149
+ );
1150
+
1167
1151
  module.exports = CssModulesPlugin;