webpack 5.99.5 → 5.99.7

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.
Files changed (169) hide show
  1. package/README.md +1 -1
  2. package/lib/APIPlugin.js +2 -2
  3. package/lib/AutomaticPrefetchPlugin.js +21 -22
  4. package/lib/BannerPlugin.js +31 -35
  5. package/lib/Cache.js +1 -1
  6. package/lib/Chunk.js +12 -9
  7. package/lib/CleanPlugin.js +5 -3
  8. package/lib/Compilation.js +45 -35
  9. package/lib/Compiler.js +6 -4
  10. package/lib/ContextExclusionPlugin.js +4 -2
  11. package/lib/ContextModule.js +2 -1
  12. package/lib/ContextReplacementPlugin.js +5 -3
  13. package/lib/DelegatedPlugin.js +4 -2
  14. package/lib/DllEntryPlugin.js +4 -2
  15. package/lib/DllPlugin.js +5 -3
  16. package/lib/DllReferencePlugin.js +56 -60
  17. package/lib/DynamicEntryPlugin.js +4 -2
  18. package/lib/EntryOptionPlugin.js +3 -1
  19. package/lib/EntryPlugin.js +4 -2
  20. package/lib/EnvironmentPlugin.js +4 -2
  21. package/lib/EvalDevToolModulePlugin.js +9 -7
  22. package/lib/EvalSourceMapDevToolPlugin.js +137 -138
  23. package/lib/ExternalsPlugin.js +3 -1
  24. package/lib/FlagDependencyExportsPlugin.js +2 -1
  25. package/lib/HotModuleReplacementPlugin.js +3 -3
  26. package/lib/IgnorePlugin.js +6 -4
  27. package/lib/IgnoreWarningsPlugin.js +4 -2
  28. package/lib/LibManifestPlugin.js +3 -4
  29. package/lib/LoaderOptionsPlugin.js +4 -2
  30. package/lib/LoaderTargetPlugin.js +4 -2
  31. package/lib/Module.js +29 -14
  32. package/lib/ModuleFilenameHelpers.js +1 -1
  33. package/lib/ModuleGraph.js +15 -10
  34. package/lib/ModuleInfoHeaderPlugin.js +11 -12
  35. package/lib/MultiCompiler.js +5 -3
  36. package/lib/NoEmitOnErrorsPlugin.js +5 -3
  37. package/lib/NormalModule.js +6 -2
  38. package/lib/NormalModuleReplacementPlugin.js +33 -36
  39. package/lib/PlatformPlugin.js +3 -1
  40. package/lib/PrefetchPlugin.js +5 -3
  41. package/lib/ProgressPlugin.js +23 -26
  42. package/lib/RecordIdsPlugin.js +73 -103
  43. package/lib/RuntimePlugin.js +34 -32
  44. package/lib/SourceMapDevToolPlugin.js +8 -6
  45. package/lib/Template.js +1 -1
  46. package/lib/WarnCaseSensitiveModulesPlugin.js +36 -37
  47. package/lib/WarnNoModeSetPlugin.js +3 -1
  48. package/lib/WatchIgnorePlugin.js +3 -1
  49. package/lib/WebpackError.js +11 -3
  50. package/lib/WebpackOptionsApply.js +22 -5
  51. package/lib/async-modules/InferAsyncModulesPlugin.js +25 -26
  52. package/lib/buildChunkGraph.js +7 -2
  53. package/lib/cache/IdleFileCachePlugin.js +12 -13
  54. package/lib/cache/MemoryCachePlugin.js +2 -1
  55. package/lib/cache/MemoryWithGcCachePlugin.js +10 -7
  56. package/lib/cache/PackFileCacheStrategy.js +13 -21
  57. package/lib/cache/ResolverCachePlugin.js +22 -22
  58. package/lib/cli.js +8 -4
  59. package/lib/config/defaults.js +2 -2
  60. package/lib/config/normalization.js +9 -3
  61. package/lib/config/target.js +6 -6
  62. package/lib/container/ContainerReferencePlugin.js +24 -26
  63. package/lib/container/ModuleFederationPlugin.js +2 -1
  64. package/lib/css/CssGenerator.js +1 -1
  65. package/lib/css/CssModulesPlugin.js +6 -4
  66. package/lib/css/CssParser.js +1 -1
  67. package/lib/debug/ProfilingPlugin.js +1 -1
  68. package/lib/dependencies/ContextDependencyHelpers.js +1 -1
  69. package/lib/dependencies/CssIcssImportDependency.js +3 -2
  70. package/lib/dependencies/HarmonyDetectionParserPlugin.js +9 -15
  71. package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
  72. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -1
  73. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +1 -1
  74. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -15
  75. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -2
  76. package/lib/dependencies/JsonExportsDependency.js +1 -1
  77. package/lib/dependencies/LoaderPlugin.js +5 -3
  78. package/lib/dependencies/LocalModulesHelpers.js +1 -1
  79. package/lib/dependencies/RequireContextDependencyParserPlugin.js +46 -46
  80. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +94 -100
  81. package/lib/dependencies/RequireResolveDependency.js +1 -1
  82. package/lib/dependencies/WorkerPlugin.js +2 -2
  83. package/lib/esm/ModuleChunkLoadingPlugin.js +76 -57
  84. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +11 -9
  85. package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
  86. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +0 -1
  87. package/lib/hmr/LazyCompilationPlugin.js +17 -18
  88. package/lib/ids/ChunkModuleIdRangePlugin.js +6 -6
  89. package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
  90. package/lib/ids/DeterministicModuleIdsPlugin.js +48 -49
  91. package/lib/ids/HashedModuleIdsPlugin.js +4 -2
  92. package/lib/ids/NamedChunkIdsPlugin.js +6 -4
  93. package/lib/ids/NamedModuleIdsPlugin.js +6 -4
  94. package/lib/ids/NaturalChunkIdsPlugin.js +4 -2
  95. package/lib/ids/NaturalModuleIdsPlugin.js +4 -2
  96. package/lib/ids/OccurrenceChunkIdsPlugin.js +4 -2
  97. package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -2
  98. package/lib/index.js +1 -1
  99. package/lib/javascript/BasicEvaluatedExpression.js +2 -2
  100. package/lib/javascript/JavascriptParser.js +670 -688
  101. package/lib/library/EnableLibraryPlugin.js +15 -2
  102. package/lib/library/ModuleLibraryPlugin.js +66 -43
  103. package/lib/logging/createConsoleLogger.js +0 -1
  104. package/lib/node/CommonJsChunkLoadingPlugin.js +71 -75
  105. package/lib/node/NodeEnvironmentPlugin.js +3 -1
  106. package/lib/node/NodeTemplatePlugin.js +2 -2
  107. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -2
  108. package/lib/node/ReadFileCompileWasmPlugin.js +3 -3
  109. package/lib/optimize/AggressiveMergingPlugin.js +1 -1
  110. package/lib/optimize/AggressiveSplittingPlugin.js +224 -232
  111. package/lib/optimize/ConcatenatedModule.js +12 -15
  112. package/lib/optimize/FlagIncludedChunksPlugin.js +92 -97
  113. package/lib/optimize/LimitChunkCountPlugin.js +4 -2
  114. package/lib/optimize/MangleExportsPlugin.js +15 -16
  115. package/lib/optimize/MinChunkSizePlugin.js +4 -2
  116. package/lib/optimize/ModuleConcatenationPlugin.js +4 -2
  117. package/lib/optimize/RealContentHashPlugin.js +4 -2
  118. package/lib/optimize/RemoveEmptyChunksPlugin.js +5 -3
  119. package/lib/optimize/RemoveParentModulesPlugin.js +4 -2
  120. package/lib/optimize/RuntimeChunkPlugin.js +17 -18
  121. package/lib/optimize/SplitChunksPlugin.js +9 -6
  122. package/lib/performance/SizeLimitsPlugin.js +3 -1
  123. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -62
  124. package/lib/runtime/GetChunkFilenameRuntimeModule.js +3 -4
  125. package/lib/runtime/StartupChunkDependenciesPlugin.js +39 -42
  126. package/lib/schemes/DataUriPlugin.js +5 -3
  127. package/lib/schemes/FileUriPlugin.js +5 -3
  128. package/lib/schemes/HttpUriPlugin.js +32 -39
  129. package/lib/serialization/AggregateErrorSerializer.js +42 -0
  130. package/lib/serialization/BinaryMiddleware.js +22 -38
  131. package/lib/serialization/ErrorObjectSerializer.js +7 -2
  132. package/lib/serialization/FileMiddleware.js +29 -33
  133. package/lib/serialization/ObjectMiddleware.js +42 -30
  134. package/lib/serialization/Serializer.js +29 -18
  135. package/lib/serialization/SerializerMiddleware.js +105 -72
  136. package/lib/serialization/SingleItemMiddleware.js +4 -5
  137. package/lib/sharing/ProvideSharedPlugin.js +6 -4
  138. package/lib/stats/DefaultStatsFactoryPlugin.js +128 -57
  139. package/lib/stats/DefaultStatsPresetPlugin.js +25 -20
  140. package/lib/stats/DefaultStatsPrinterPlugin.js +486 -334
  141. package/lib/stats/StatsFactory.js +47 -10
  142. package/lib/stats/StatsPrinter.js +52 -31
  143. package/lib/util/ArrayQueue.js +1 -1
  144. package/lib/util/AsyncQueue.js +1 -1
  145. package/lib/util/TupleQueue.js +9 -7
  146. package/lib/util/TupleSet.js +37 -18
  147. package/lib/util/WeakTupleMap.js +50 -37
  148. package/lib/util/cleverMerge.js +2 -2
  149. package/lib/util/comparators.js +1 -1
  150. package/lib/util/concatenate.js +4 -2
  151. package/lib/util/createHash.js +1 -1
  152. package/lib/util/fs.js +1 -1
  153. package/lib/util/makeSerializable.js +1 -1
  154. package/lib/util/runtime.js +1 -0
  155. package/lib/util/serialization.js +50 -42
  156. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
  157. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -1
  158. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
  159. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
  160. package/lib/wasm-sync/WebAssemblyGenerator.js +1 -1
  161. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
  162. package/lib/web/FetchCompileWasmPlugin.js +2 -2
  163. package/lib/web/JsonpChunkLoadingPlugin.js +73 -74
  164. package/lib/webpack.js +1 -1
  165. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +77 -78
  166. package/package.json +4 -3
  167. package/schemas/WebpackOptions.check.js +1 -1
  168. package/schemas/WebpackOptions.json +24 -2
  169. package/types.d.ts +273 -128
@@ -35,6 +35,8 @@ const devtoolWarning = new RawSource(`/*
35
35
  */
36
36
  `);
37
37
 
38
+ const PLUGIN_NAME = "EvalSourceMapDevToolPlugin";
39
+
38
40
  class EvalSourceMapDevToolPlugin {
39
41
  /**
40
42
  * @param {SourceMapDevToolPluginOptions|string} inputOptions Options object
@@ -67,160 +69,157 @@ class EvalSourceMapDevToolPlugin {
67
69
  */
68
70
  apply(compiler) {
69
71
  const options = this.options;
70
- compiler.hooks.compilation.tap(
71
- "EvalSourceMapDevToolPlugin",
72
- compilation => {
73
- const hooks = JavascriptModulesPlugin.getCompilationHooks(compilation);
74
- new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation);
75
- const matchModule = ModuleFilenameHelpers.matchObject.bind(
76
- ModuleFilenameHelpers,
77
- options
78
- );
79
- hooks.renderModuleContent.tap(
80
- "EvalSourceMapDevToolPlugin",
81
- (source, m, { chunk, runtimeTemplate, chunkGraph }) => {
82
- const cachedSource = cache.get(source);
83
- if (cachedSource !== undefined) {
84
- return cachedSource;
85
- }
72
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
73
+ const hooks = JavascriptModulesPlugin.getCompilationHooks(compilation);
74
+ new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation);
75
+ const matchModule = ModuleFilenameHelpers.matchObject.bind(
76
+ ModuleFilenameHelpers,
77
+ options
78
+ );
79
+ hooks.renderModuleContent.tap(
80
+ PLUGIN_NAME,
81
+ (source, m, { chunk, runtimeTemplate, chunkGraph }) => {
82
+ const cachedSource = cache.get(source);
83
+ if (cachedSource !== undefined) {
84
+ return cachedSource;
85
+ }
86
86
 
87
- /**
88
- * @param {Source} r result
89
- * @returns {Source} result
90
- */
91
- const result = r => {
92
- cache.set(source, r);
93
- return r;
94
- };
95
-
96
- if (m instanceof NormalModule) {
97
- const module = /** @type {NormalModule} */ (m);
87
+ /**
88
+ * @param {Source} r result
89
+ * @returns {Source} result
90
+ */
91
+ const result = r => {
92
+ cache.set(source, r);
93
+ return r;
94
+ };
95
+
96
+ if (m instanceof NormalModule) {
97
+ const module = /** @type {NormalModule} */ (m);
98
+ if (!matchModule(module.resource)) {
99
+ return result(source);
100
+ }
101
+ } else if (m instanceof ConcatenatedModule) {
102
+ const concatModule = /** @type {ConcatenatedModule} */ (m);
103
+ if (concatModule.rootModule instanceof NormalModule) {
104
+ const module = /** @type {NormalModule} */ (
105
+ concatModule.rootModule
106
+ );
98
107
  if (!matchModule(module.resource)) {
99
108
  return result(source);
100
109
  }
101
- } else if (m instanceof ConcatenatedModule) {
102
- const concatModule = /** @type {ConcatenatedModule} */ (m);
103
- if (concatModule.rootModule instanceof NormalModule) {
104
- const module = /** @type {NormalModule} */ (
105
- concatModule.rootModule
106
- );
107
- if (!matchModule(module.resource)) {
108
- return result(source);
109
- }
110
- } else {
111
- return result(source);
112
- }
113
110
  } else {
114
111
  return result(source);
115
112
  }
113
+ } else {
114
+ return result(source);
115
+ }
116
116
 
117
- const namespace = compilation.getPath(this.namespace, {
118
- chunk
119
- });
120
- /** @type {SourceMap} */
121
- let sourceMap;
122
- let content;
123
- if (source.sourceAndMap) {
124
- const sourceAndMap = source.sourceAndMap(options);
125
- sourceMap = /** @type {SourceMap} */ (sourceAndMap.map);
126
- content = sourceAndMap.source;
127
- } else {
128
- sourceMap = /** @type {SourceMap} */ (source.map(options));
129
- content = source.source();
130
- }
131
- if (!sourceMap) {
132
- return result(source);
133
- }
117
+ const namespace = compilation.getPath(this.namespace, {
118
+ chunk
119
+ });
120
+ /** @type {SourceMap} */
121
+ let sourceMap;
122
+ let content;
123
+ if (source.sourceAndMap) {
124
+ const sourceAndMap = source.sourceAndMap(options);
125
+ sourceMap = /** @type {SourceMap} */ (sourceAndMap.map);
126
+ content = sourceAndMap.source;
127
+ } else {
128
+ sourceMap = /** @type {SourceMap} */ (source.map(options));
129
+ content = source.source();
130
+ }
131
+ if (!sourceMap) {
132
+ return result(source);
133
+ }
134
134
 
135
- // Clone (flat) the sourcemap to ensure that the mutations below do not persist.
136
- sourceMap = { ...sourceMap };
137
- const context = /** @type {string} */ (compiler.options.context);
138
- const root = compiler.root;
139
- const modules = sourceMap.sources.map(source => {
140
- if (!source.startsWith("webpack://")) return source;
141
- source = makePathsAbsolute(context, source.slice(10), root);
142
- const module = compilation.findModule(source);
143
- return module || source;
144
- });
145
- let moduleFilenames = modules.map(module =>
146
- ModuleFilenameHelpers.createFilename(
147
- module,
148
- {
149
- moduleFilenameTemplate: this.moduleFilenameTemplate,
150
- namespace
151
- },
152
- {
153
- requestShortener: runtimeTemplate.requestShortener,
154
- chunkGraph,
155
- hashFunction: compilation.outputOptions.hashFunction
156
- }
157
- )
158
- );
159
- moduleFilenames = ModuleFilenameHelpers.replaceDuplicates(
160
- moduleFilenames,
161
- (filename, i, n) => {
162
- for (let j = 0; j < n; j++) filename += "*";
163
- return filename;
135
+ // Clone (flat) the sourcemap to ensure that the mutations below do not persist.
136
+ sourceMap = { ...sourceMap };
137
+ const context = /** @type {string} */ (compiler.options.context);
138
+ const root = compiler.root;
139
+ const modules = sourceMap.sources.map(source => {
140
+ if (!source.startsWith("webpack://")) return source;
141
+ source = makePathsAbsolute(context, source.slice(10), root);
142
+ const module = compilation.findModule(source);
143
+ return module || source;
144
+ });
145
+ let moduleFilenames = modules.map(module =>
146
+ ModuleFilenameHelpers.createFilename(
147
+ module,
148
+ {
149
+ moduleFilenameTemplate: this.moduleFilenameTemplate,
150
+ namespace
151
+ },
152
+ {
153
+ requestShortener: runtimeTemplate.requestShortener,
154
+ chunkGraph,
155
+ hashFunction: compilation.outputOptions.hashFunction
164
156
  }
165
- );
166
- sourceMap.sources = moduleFilenames;
167
- if (options.noSources) {
168
- sourceMap.sourcesContent = undefined;
169
- }
170
- sourceMap.sourceRoot = options.sourceRoot || "";
171
- const moduleId =
172
- /** @type {ModuleId} */
173
- (chunkGraph.getModuleId(m));
174
- sourceMap.file =
175
- typeof moduleId === "number" ? `${moduleId}.js` : moduleId;
176
-
177
- if (options.debugIds) {
178
- sourceMap.debugId = generateDebugId(content, sourceMap.file);
157
+ )
158
+ );
159
+ moduleFilenames = ModuleFilenameHelpers.replaceDuplicates(
160
+ moduleFilenames,
161
+ (filename, i, n) => {
162
+ for (let j = 0; j < n; j++) filename += "*";
163
+ return filename;
179
164
  }
165
+ );
166
+ sourceMap.sources = moduleFilenames;
167
+ if (options.noSources) {
168
+ sourceMap.sourcesContent = undefined;
169
+ }
170
+ sourceMap.sourceRoot = options.sourceRoot || "";
171
+ const moduleId =
172
+ /** @type {ModuleId} */
173
+ (chunkGraph.getModuleId(m));
174
+ sourceMap.file =
175
+ typeof moduleId === "number" ? `${moduleId}.js` : moduleId;
180
176
 
181
- const footer = `${this.sourceMapComment.replace(
182
- /\[url\]/g,
183
- `data:application/json;charset=utf-8;base64,${Buffer.from(
184
- JSON.stringify(sourceMap),
185
- "utf8"
186
- ).toString("base64")}`
187
- )}\n//# sourceURL=webpack-internal:///${moduleId}\n`; // workaround for chrome bug
188
-
189
- return result(
190
- new RawSource(
191
- `eval(${
192
- compilation.outputOptions.trustedTypes
193
- ? `${RuntimeGlobals.createScript}(${JSON.stringify(
194
- content + footer
195
- )})`
196
- : JSON.stringify(content + footer)
197
- });`
198
- )
199
- );
177
+ if (options.debugIds) {
178
+ sourceMap.debugId = generateDebugId(content, sourceMap.file);
200
179
  }
201
- );
202
- hooks.inlineInRuntimeBailout.tap(
203
- "EvalDevToolModulePlugin",
204
- () => "the eval-source-map devtool is used."
205
- );
206
- hooks.render.tap(
207
- "EvalSourceMapDevToolPlugin",
208
- source => new ConcatSource(devtoolWarning, source)
209
- );
210
- hooks.chunkHash.tap("EvalSourceMapDevToolPlugin", (chunk, hash) => {
211
- hash.update("EvalSourceMapDevToolPlugin");
212
- hash.update("2");
213
- });
214
- if (compilation.outputOptions.trustedTypes) {
215
- compilation.hooks.additionalModuleRuntimeRequirements.tap(
216
- "EvalSourceMapDevToolPlugin",
217
- (module, set, context) => {
218
- set.add(RuntimeGlobals.createScript);
219
- }
180
+
181
+ const footer = `${this.sourceMapComment.replace(
182
+ /\[url\]/g,
183
+ `data:application/json;charset=utf-8;base64,${Buffer.from(
184
+ JSON.stringify(sourceMap),
185
+ "utf8"
186
+ ).toString("base64")}`
187
+ )}\n//# sourceURL=webpack-internal:///${moduleId}\n`; // workaround for chrome bug
188
+
189
+ return result(
190
+ new RawSource(
191
+ `eval(${
192
+ compilation.outputOptions.trustedTypes
193
+ ? `${RuntimeGlobals.createScript}(${JSON.stringify(
194
+ content + footer
195
+ )})`
196
+ : JSON.stringify(content + footer)
197
+ });`
198
+ )
220
199
  );
221
200
  }
201
+ );
202
+ hooks.inlineInRuntimeBailout.tap(
203
+ "EvalDevToolModulePlugin",
204
+ () => "the eval-source-map devtool is used."
205
+ );
206
+ hooks.render.tap(
207
+ PLUGIN_NAME,
208
+ source => new ConcatSource(devtoolWarning, source)
209
+ );
210
+ hooks.chunkHash.tap(PLUGIN_NAME, (chunk, hash) => {
211
+ hash.update(PLUGIN_NAME);
212
+ hash.update("2");
213
+ });
214
+ if (compilation.outputOptions.trustedTypes) {
215
+ compilation.hooks.additionalModuleRuntimeRequirements.tap(
216
+ PLUGIN_NAME,
217
+ (module, set, context) => {
218
+ set.add(RuntimeGlobals.createScript);
219
+ }
220
+ );
222
221
  }
223
- );
222
+ });
224
223
  }
225
224
  }
226
225
 
@@ -10,6 +10,8 @@ const ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin");
10
10
  /** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
11
11
  /** @typedef {import("./Compiler")} Compiler */
12
12
 
13
+ const PLUGIN_NAME = "ExternalsPlugin";
14
+
13
15
  class ExternalsPlugin {
14
16
  /**
15
17
  * @param {string | undefined} type default external type
@@ -26,7 +28,7 @@ class ExternalsPlugin {
26
28
  * @returns {void}
27
29
  */
28
30
  apply(compiler) {
29
- compiler.hooks.compile.tap("ExternalsPlugin", ({ normalModuleFactory }) => {
31
+ compiler.hooks.compile.tap(PLUGIN_NAME, ({ normalModuleFactory }) => {
30
32
  new ExternalModuleFactoryPlugin(this.type, this.externals).apply(
31
33
  normalModuleFactory
32
34
  );
@@ -369,7 +369,8 @@ class FlagDependencyExportsPlugin {
369
369
  (module, callback) => {
370
370
  if (
371
371
  typeof (
372
- /** @type {BuildInfo} */ (module.buildInfo).hash
372
+ /** @type {BuildInfo} */
373
+ (module.buildInfo).hash
373
374
  ) !== "string"
374
375
  ) {
375
376
  // not cacheable
@@ -376,11 +376,11 @@ class HotModuleReplacementPlugin {
376
376
  );
377
377
  }
378
378
  });
379
- /** @type {TupleSet<[Module, Chunk]>} */
379
+ /** @type {TupleSet<Module, Chunk>} */
380
380
  const updatedModules = new TupleSet();
381
- /** @type {TupleSet<[Module, Chunk]>} */
381
+ /** @type {TupleSet<Module, Chunk>} */
382
382
  const fullHashModules = new TupleSet();
383
- /** @type {TupleSet<[Module, RuntimeSpec]>} */
383
+ /** @type {TupleSet<Module, RuntimeSpec>} */
384
384
  const nonCodeGeneratedModules = new TupleSet();
385
385
  compilation.hooks.fullHash.tap(PLUGIN_NAME, hash => {
386
386
  const chunkGraph = compilation.chunkGraph;
@@ -22,6 +22,8 @@ const validate = createSchemaValidation(
22
22
  }
23
23
  );
24
24
 
25
+ const PLUGIN_NAME = "IgnorePlugin";
26
+
25
27
  class IgnorePlugin {
26
28
  /**
27
29
  * @param {IgnorePluginOptions} options IgnorePlugin options
@@ -69,8 +71,8 @@ class IgnorePlugin {
69
71
  * @returns {void}
70
72
  */
71
73
  apply(compiler) {
72
- compiler.hooks.normalModuleFactory.tap("IgnorePlugin", nmf => {
73
- nmf.hooks.beforeResolve.tap("IgnorePlugin", resolveData => {
74
+ compiler.hooks.normalModuleFactory.tap(PLUGIN_NAME, nmf => {
75
+ nmf.hooks.beforeResolve.tap(PLUGIN_NAME, resolveData => {
74
76
  const result = this.checkIgnore(resolveData);
75
77
 
76
78
  if (
@@ -88,8 +90,8 @@ class IgnorePlugin {
88
90
  return result;
89
91
  });
90
92
  });
91
- compiler.hooks.contextModuleFactory.tap("IgnorePlugin", cmf => {
92
- cmf.hooks.beforeResolve.tap("IgnorePlugin", this.checkIgnore);
93
+ compiler.hooks.contextModuleFactory.tap(PLUGIN_NAME, cmf => {
94
+ cmf.hooks.beforeResolve.tap(PLUGIN_NAME, this.checkIgnore);
93
95
  });
94
96
  }
95
97
  }
@@ -8,6 +8,8 @@
8
8
  /** @typedef {import("../declarations/WebpackOptions").IgnoreWarningsNormalized} IgnoreWarningsNormalized */
9
9
  /** @typedef {import("./Compiler")} Compiler */
10
10
 
11
+ const PLUGIN_NAME = "IgnoreWarningsPlugin";
12
+
11
13
  class IgnoreWarningsPlugin {
12
14
  /**
13
15
  * @param {IgnoreWarningsNormalized} ignoreWarnings conditions to ignore warnings
@@ -22,8 +24,8 @@ class IgnoreWarningsPlugin {
22
24
  * @returns {void}
23
25
  */
24
26
  apply(compiler) {
25
- compiler.hooks.compilation.tap("IgnoreWarningsPlugin", compilation => {
26
- compilation.hooks.processWarnings.tap("IgnoreWarningsPlugin", warnings =>
27
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
28
+ compilation.hooks.processWarnings.tap(PLUGIN_NAME, warnings =>
27
29
  warnings.filter(
28
30
  warning =>
29
31
  !this._ignoreWarnings.some(ignore => ignore(warning, compilation))
@@ -33,6 +33,8 @@ const { dirname, mkdirp } = require("./util/fs");
33
33
  * @property {string=} type Type of the dll bundle (external type, use value of 'output.libraryTarget').
34
34
  */
35
35
 
36
+ const PLUGIN_NAME = "LibManifestPlugin";
37
+
36
38
  class LibManifestPlugin {
37
39
  /**
38
40
  * @param {LibManifestPluginOptions} options the options
@@ -48,10 +50,7 @@ class LibManifestPlugin {
48
50
  */
49
51
  apply(compiler) {
50
52
  compiler.hooks.emit.tapAsync(
51
- {
52
- name: "LibManifestPlugin",
53
- stage: 110
54
- },
53
+ { name: PLUGIN_NAME, stage: 110 },
55
54
  (compilation, callback) => {
56
55
  const moduleGraph = compilation.moduleGraph;
57
56
  // store used paths to detect issue and output an error. #18200
@@ -28,6 +28,8 @@ const validate = createSchemaValidation(
28
28
  }
29
29
  );
30
30
 
31
+ const PLUGIN_NAME = "LoaderOptionsPlugin";
32
+
31
33
  class LoaderOptionsPlugin {
32
34
  /**
33
35
  * @param {LoaderOptionsPluginOptions & MatchObject} options options object
@@ -55,9 +57,9 @@ class LoaderOptionsPlugin {
55
57
  */
56
58
  apply(compiler) {
57
59
  const options = this.options;
58
- compiler.hooks.compilation.tap("LoaderOptionsPlugin", compilation => {
60
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
59
61
  NormalModule.getCompilationHooks(compilation).loader.tap(
60
- "LoaderOptionsPlugin",
62
+ PLUGIN_NAME,
61
63
  (context, module) => {
62
64
  const resource = module.resource;
63
65
  if (!resource) return;
@@ -9,6 +9,8 @@ const NormalModule = require("./NormalModule");
9
9
 
10
10
  /** @typedef {import("./Compiler")} Compiler */
11
11
 
12
+ const PLUGIN_NAME = "LoaderTargetPlugin";
13
+
12
14
  class LoaderTargetPlugin {
13
15
  /**
14
16
  * @param {string} target the target
@@ -23,9 +25,9 @@ class LoaderTargetPlugin {
23
25
  * @returns {void}
24
26
  */
25
27
  apply(compiler) {
26
- compiler.hooks.compilation.tap("LoaderTargetPlugin", compilation => {
28
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
27
29
  NormalModule.getCompilationHooks(compilation).loader.tap(
28
- "LoaderTargetPlugin",
30
+ PLUGIN_NAME,
29
31
  loaderContext => {
30
32
  loaderContext.target = this.target;
31
33
  }
package/lib/Module.js CHANGED
@@ -28,6 +28,7 @@ const makeSerializable = require("./util/makeSerializable");
28
28
  /** @typedef {import("./ConcatenationScope")} ConcatenationScope */
29
29
  /** @typedef {import("./Dependency")} Dependency */
30
30
  /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
31
+ /** @typedef {import("./DependencyTemplate").CssData} CssData */
31
32
  /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
32
33
  /** @typedef {import("./ExportsInfo").UsageStateType} UsageStateType */
33
34
  /** @typedef {import("./FileSystemInfo")} FileSystemInfo */
@@ -42,12 +43,20 @@ const makeSerializable = require("./util/makeSerializable");
42
43
  /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
43
44
  /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
44
45
  /** @typedef {import("./util/Hash")} Hash */
45
- /** @template T @typedef {import("./util/LazySet")<T>} LazySet<T> */
46
- /** @template T @typedef {import("./util/SortableSet")<T>} SortableSet<T> */
47
46
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
48
47
  /** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
49
48
  /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
50
49
 
50
+ /**
51
+ * @template T
52
+ * @typedef {import("./util/LazySet")<T>} LazySet<T>
53
+ */
54
+
55
+ /**
56
+ * @template T
57
+ * @typedef {import("./util/SortableSet")<T>} SortableSet<T>
58
+ */
59
+
51
60
  /**
52
61
  * @typedef {object} SourceContext
53
62
  * @property {DependencyTemplates} dependencyTemplates the dependency templates
@@ -112,19 +121,25 @@ const makeSerializable = require("./util/makeSerializable");
112
121
  * @typedef {object} KnownBuildInfo
113
122
  * @property {boolean=} cacheable
114
123
  * @property {boolean=} parsed
115
- * @property {string=} moduleArgument
116
- * @property {string=} exportsArgument
117
124
  * @property {boolean=} strict
118
- * @property {string=} moduleConcatenationBailout
119
- * @property {LazySet<string>=} fileDependencies
120
- * @property {LazySet<string>=} contextDependencies
121
- * @property {LazySet<string>=} missingDependencies
122
- * @property {LazySet<string>=} buildDependencies
123
- * @property {ValueCacheVersions=} valueDependencies
124
- * @property {TODO=} hash
125
- * @property {Record<string, Source>=} assets
126
- * @property {Map<string, AssetInfo | undefined>=} assetsInfo
127
- * @property {(Snapshot | null)=} snapshot
125
+ * @property {string=} moduleArgument using in AMD
126
+ * @property {string=} exportsArgument using in AMD
127
+ * @property {string=} moduleConcatenationBailout using in CommonJs
128
+ * @property {boolean=} needCreateRequire using in APIPlugin
129
+ * @property {string=} resourceIntegrity using in HttpUriPlugin
130
+ * @property {LazySet<string>=} fileDependencies using in NormalModule
131
+ * @property {LazySet<string>=} contextDependencies using in NormalModule
132
+ * @property {LazySet<string>=} missingDependencies using in NormalModule
133
+ * @property {LazySet<string>=} buildDependencies using in NormalModule
134
+ * @property {ValueCacheVersions=} valueDependencies using in NormalModule
135
+ * @property {Record<string, Source>=} assets using in NormalModule
136
+ * @property {string=} hash using in NormalModule
137
+ * @property {(Snapshot | null)=} snapshot using in ContextModule
138
+ * @property {string=} fullContentHash for assets modules
139
+ * @property {string=} filename for assets modules
140
+ * @property {Map<string, AssetInfo | undefined>=} assetsInfo for assets modules
141
+ * @property {boolean=} dataUrl for assets modules
142
+ * @property {CssData=} cssData for css modules
128
143
  */
129
144
 
130
145
  /** @typedef {Map<string, string | Set<string>>} ValueCacheVersions */
@@ -262,7 +262,7 @@ ModuleFilenameHelpers.createFilename = (
262
262
  * @template T
263
263
  * @param {T[]} array the array with duplicates to be replaced
264
264
  * @param {(duplicateItem: T, duplicateItemIndex: number, numberOfTimesReplaced: number) => T} fn callback function to generate new values for the duplicate items
265
- * @param {(firstElement:T, nextElement:T) => -1 | 0 | 1} [comparator] optional comparator function to sort the duplicate items
265
+ * @param {(firstElement:T, nextElement:T) => -1 | 0 | 1=} comparator optional comparator function to sort the duplicate items
266
266
  * @returns {T[]} the array with duplicates replaced
267
267
  * @example
268
268
  * ```js
@@ -143,7 +143,7 @@ class ModuleGraph {
143
143
  */
144
144
  this._metaMap = new WeakMap();
145
145
  /**
146
- * @type {WeakTupleMap<any[], any> | undefined}
146
+ * @type {WeakTupleMap<EXPECTED_ANY[], EXPECTED_ANY> | undefined}
147
147
  * @private
148
148
  */
149
149
  this._cache = undefined;
@@ -797,10 +797,10 @@ class ModuleGraph {
797
797
 
798
798
  /**
799
799
  * @template T
800
- * @template V
801
- * @param {(moduleGraph: ModuleGraph, ...args: T[]) => V} fn computer
800
+ * @template R
801
+ * @param {(moduleGraph: ModuleGraph, ...args: T[]) => R} fn computer
802
802
  * @param {...T} args arguments
803
- * @returns {V} computed value or cached
803
+ * @returns {R} computed value or cached
804
804
  */
805
805
  cached(fn, ...args) {
806
806
  if (this._cache === undefined) return fn(this, ...args);
@@ -815,16 +815,21 @@ class ModuleGraph {
815
815
  }
816
816
 
817
817
  /**
818
- * @param {Dependency} dependency dependency
819
- * @param {...any} args arguments, last argument is a function called with moduleGraph, dependency, ...args
820
- * @returns {any} computed value or cached
818
+ * @template {Dependency} D
819
+ * @template {EXPECTED_ANY[]} ARGS
820
+ * @template R
821
+ * @param {D} dependency dependency
822
+ * @param {[...ARGS, (moduleGraph: ModuleGraph, dependency: D, ...args: ARGS) => R]} args arguments, last argument is a function called with moduleGraph, dependency, ...args
823
+ * @returns {R} computed value or cached
821
824
  */
822
825
  dependencyCacheProvide(dependency, ...args) {
823
- /** @type {(moduleGraph: ModuleGraph, dependency: Dependency, ...args: any[]) => any} */
824
- const fn = args.pop();
826
+ const fn =
827
+ /** @type {(moduleGraph: ModuleGraph, dependency: D, ...args: EXPECTED_ANY[]) => R} */
828
+ (args.pop());
825
829
  if (this._moduleMemCaches && this._cacheStage) {
826
830
  const memCache = this._moduleMemCaches.get(
827
- /** @type {Module} */ (this.getParentModule(dependency))
831
+ /** @type {Module} */
832
+ (this.getParentModule(dependency))
828
833
  );
829
834
  if (memCache !== undefined) {
830
835
  return memCache.provide(dependency, this._cacheStage, ...args, () =>
@@ -149,6 +149,8 @@ const printExportsInfoToSource = (
149
149
  /** @type {WeakMap<RequestShortener, WeakMap<Module, { header: RawSource | undefined, full: WeakMap<Source, CachedSource> }>>} */
150
150
  const caches = new WeakMap();
151
151
 
152
+ const PLUGIN_NAME = "ModuleInfoHeaderPlugin";
153
+
152
154
  class ModuleInfoHeaderPlugin {
153
155
  /**
154
156
  * @param {boolean=} verbose add more information like exports, runtime requirements and bailouts
@@ -163,11 +165,11 @@ class ModuleInfoHeaderPlugin {
163
165
  */
164
166
  apply(compiler) {
165
167
  const { _verbose: verbose } = this;
166
- compiler.hooks.compilation.tap("ModuleInfoHeaderPlugin", compilation => {
168
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
167
169
  const javascriptHooks =
168
170
  JavascriptModulesPlugin.getCompilationHooks(compilation);
169
171
  javascriptHooks.renderModulePackage.tap(
170
- "ModuleInfoHeaderPlugin",
172
+ PLUGIN_NAME,
171
173
  (
172
174
  moduleSource,
173
175
  module,
@@ -246,16 +248,13 @@ class ModuleInfoHeaderPlugin {
246
248
  return cachedSource;
247
249
  }
248
250
  );
249
- javascriptHooks.chunkHash.tap(
250
- "ModuleInfoHeaderPlugin",
251
- (_chunk, hash) => {
252
- hash.update("ModuleInfoHeaderPlugin");
253
- hash.update("1");
254
- }
255
- );
251
+ javascriptHooks.chunkHash.tap(PLUGIN_NAME, (_chunk, hash) => {
252
+ hash.update(PLUGIN_NAME);
253
+ hash.update("1");
254
+ });
256
255
  const cssHooks = CssModulesPlugin.getCompilationHooks(compilation);
257
256
  cssHooks.renderModulePackage.tap(
258
- "ModuleInfoHeaderPlugin",
257
+ PLUGIN_NAME,
259
258
  (moduleSource, module, { runtimeTemplate }) => {
260
259
  const { requestShortener } = runtimeTemplate;
261
260
  let cacheEntry;
@@ -291,8 +290,8 @@ class ModuleInfoHeaderPlugin {
291
290
  return cachedSource;
292
291
  }
293
292
  );
294
- cssHooks.chunkHash.tap("ModuleInfoHeaderPlugin", (_chunk, hash) => {
295
- hash.update("ModuleInfoHeaderPlugin");
293
+ cssHooks.chunkHash.tap(PLUGIN_NAME, (_chunk, hash) => {
294
+ hash.update(PLUGIN_NAME);
296
295
  hash.update("1");
297
296
  });
298
297
  });