webpack 5.90.2 → 5.90.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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

@@ -1087,7 +1087,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1087
1087
  }
1088
1088
 
1089
1089
  /**
1090
- * @param {StatsOptions | string | undefined} optionsOrPreset stats option value
1090
+ * @param {string | boolean | StatsOptions | undefined} optionsOrPreset stats option value
1091
1091
  * @param {CreateStatsOptionsContext} context context
1092
1092
  * @returns {NormalizedStatsOptions} normalized options
1093
1093
  */
@@ -38,6 +38,7 @@ const makeSerializable = require("./util/makeSerializable");
38
38
  /** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
39
39
  /** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
40
40
  /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
41
+ /** @typedef {import("./Module").SourceTypes} SourceTypes */
41
42
  /** @typedef {import("./ModuleGraph")} ModuleGraph */
42
43
  /** @typedef {import("./RequestShortener")} RequestShortener */
43
44
  /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
@@ -144,7 +145,7 @@ class ContextModule extends Module {
144
145
  }
145
146
 
146
147
  /**
147
- * @returns {Set<string>} types available (do not mutate)
148
+ * @returns {SourceTypes} types available (do not mutate)
148
149
  */
149
150
  getSourceTypes() {
150
151
  return TYPES;
package/lib/CssModule.js CHANGED
@@ -151,9 +151,6 @@ class CssModule extends NormalModule {
151
151
  return obj;
152
152
  }
153
153
 
154
- /**
155
- * @param {ObjectDeserializerContext} context context
156
- */
157
154
  deserialize(context) {
158
155
  const { read } = context;
159
156
  this.cssLayer = read();
@@ -25,6 +25,7 @@ const makeSerializable = require("./util/makeSerializable");
25
25
  /** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
26
26
  /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
27
27
  /** @typedef {import("./Module").SourceContext} SourceContext */
28
+ /** @typedef {import("./Module").SourceTypes} SourceTypes */
28
29
  /** @typedef {import("./RequestShortener")} RequestShortener */
29
30
  /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
30
31
  /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
@@ -66,7 +67,7 @@ class DelegatedModule extends Module {
66
67
  }
67
68
 
68
69
  /**
69
- * @returns {Set<string>} types available (do not mutate)
70
+ * @returns {SourceTypes} types available (do not mutate)
70
71
  */
71
72
  getSourceTypes() {
72
73
  return TYPES;
package/lib/DllModule.js CHANGED
@@ -22,6 +22,7 @@ const makeSerializable = require("./util/makeSerializable");
22
22
  /** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
23
23
  /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
24
24
  /** @typedef {import("./Module").SourceContext} SourceContext */
25
+ /** @typedef {import("./Module").SourceTypes} SourceTypes */
25
26
  /** @typedef {import("./RequestShortener")} RequestShortener */
26
27
  /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
27
28
  /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
@@ -52,7 +53,7 @@ class DllModule extends Module {
52
53
  }
53
54
 
54
55
  /**
55
- * @returns {Set<string>} types available (do not mutate)
56
+ * @returns {SourceTypes} types available (do not mutate)
56
57
  */
57
58
  getSourceTypes() {
58
59
  return TYPES;
@@ -34,6 +34,7 @@ const { register } = require("./util/serialization");
34
34
  /** @typedef {import("./Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
35
35
  /** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
36
36
  /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
37
+ /** @typedef {import("./Module").SourceTypes} SourceTypes */
37
38
  /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
38
39
  /** @typedef {import("./RequestShortener")} RequestShortener */
39
40
  /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
@@ -415,7 +416,7 @@ class ExternalModule extends Module {
415
416
  }
416
417
 
417
418
  /**
418
- * @returns {Set<string>} types available (do not mutate)
419
+ * @returns {SourceTypes} types available (do not mutate)
419
420
  */
420
421
  getSourceTypes() {
421
422
  return this.externalType === "css-import" ? CSS_TYPES : TYPES;
package/lib/Module.js CHANGED
@@ -21,12 +21,14 @@ const makeSerializable = require("./util/makeSerializable");
21
21
  /** @typedef {import("./ChunkGroup")} ChunkGroup */
22
22
  /** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
23
23
  /** @typedef {import("./Compilation")} Compilation */
24
+ /** @typedef {import("./Compilation").AssetInfo} AssetInfo */
24
25
  /** @typedef {import("./ConcatenationScope")} ConcatenationScope */
25
26
  /** @typedef {import("./Dependency")} Dependency */
26
27
  /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
27
28
  /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
28
29
  /** @typedef {import("./ExportsInfo").UsageStateType} UsageStateType */
29
30
  /** @typedef {import("./FileSystemInfo")} FileSystemInfo */
31
+ /** @typedef {import("./FileSystemInfo").Snapshot} Snapshot */
30
32
  /** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
31
33
  /** @typedef {import("./ModuleTypeConstants").ModuleTypes} ModuleTypes */
32
34
  /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
@@ -100,6 +102,21 @@ const makeSerializable = require("./util/makeSerializable");
100
102
  * @property {boolean=} sideEffectFree
101
103
  */
102
104
 
105
+ /**
106
+ * @typedef {Object} KnownBuildInfo
107
+ * @property {boolean=} cacheable
108
+ * @property {boolean=} parsed
109
+ * @property {LazySet<string>=} fileDependencies
110
+ * @property {LazySet<string>=} contextDependencies
111
+ * @property {LazySet<string>=} missingDependencies
112
+ * @property {LazySet<string>=} buildDependencies
113
+ * @property {(Map<string, string | Set<string>>)=} valueDependencies
114
+ * @property {TODO=} hash
115
+ * @property {Record<string, Source>=} assets
116
+ * @property {Map<string, AssetInfo | undefined>=} assetsInfo
117
+ * @property {(Snapshot | null)=} snapshot
118
+ */
119
+
103
120
  /**
104
121
  * @typedef {Object} NeedBuildContext
105
122
  * @property {Compilation} compilation
@@ -108,13 +125,17 @@ const makeSerializable = require("./util/makeSerializable");
108
125
  */
109
126
 
110
127
  /** @typedef {KnownBuildMeta & Record<string, any>} BuildMeta */
111
- /** @typedef {Record<string, any>} BuildInfo */
128
+ /** @typedef {KnownBuildInfo & Record<string, any>} BuildInfo */
112
129
 
113
130
  /**
114
131
  * @typedef {Object} FactoryMeta
115
132
  * @property {boolean=} sideEffectFree
116
133
  */
117
134
 
135
+ /** @typedef {Set<string>} SourceTypes */
136
+
137
+ /** @typedef {{ factoryMeta: FactoryMeta | undefined, resolveOptions: ResolveOptions | undefined }} UnsafeCacheData */
138
+
118
139
  const EMPTY_RESOLVE_OPTIONS = {};
119
140
 
120
141
  let debugId = 1000;
@@ -812,7 +833,7 @@ class Module extends DependenciesBlock {
812
833
 
813
834
  /**
814
835
  * @abstract
815
- * @returns {Set<string>} types available (do not mutate)
836
+ * @returns {SourceTypes} types available (do not mutate)
816
837
  */
817
838
  getSourceTypes() {
818
839
  // Better override this method to return the correct types
@@ -956,7 +977,7 @@ class Module extends DependenciesBlock {
956
977
  /**
957
978
  * Module should be unsafe cached. Get data that's needed for that.
958
979
  * This data will be passed to restoreFromUnsafeCache later.
959
- * @returns {object} cached data
980
+ * @returns {UnsafeCacheData} cached data
960
981
  */
961
982
  getUnsafeCacheData() {
962
983
  return {
@@ -19,6 +19,7 @@ const ArrayQueue = require("./util/ArrayQueue");
19
19
  /** @typedef {import("./Compiler")} Compiler */
20
20
  /** @typedef {import("./Stats")} Stats */
21
21
  /** @typedef {import("./Watching")} Watching */
22
+ /** @typedef {import("./logging/Logger").Logger} Logger */
22
23
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
23
24
  /** @typedef {import("./util/fs").IntermediateFileSystem} IntermediateFileSystem */
24
25
  /** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
@@ -80,7 +81,7 @@ module.exports = class MultiCompiler {
80
81
  this.dependencies = new WeakMap();
81
82
  this.running = false;
82
83
 
83
- /** @type {Stats[]} */
84
+ /** @type {(Stats | null)[]} */
84
85
  const compilerStats = this.compilers.map(() => null);
85
86
  let doneCompilers = 0;
86
87
  for (let index = 0; index < this.compilers.length; index++) {
@@ -94,7 +95,9 @@ module.exports = class MultiCompiler {
94
95
  }
95
96
  compilerStats[compilerIndex] = stats;
96
97
  if (doneCompilers === this.compilers.length) {
97
- this.hooks.done.call(new MultiStats(compilerStats));
98
+ this.hooks.done.call(
99
+ new MultiStats(/** @type {Stats[]} */ (compilerStats))
100
+ );
98
101
  }
99
102
  });
100
103
  compiler.hooks.invalid.tap("MultiCompiler", () => {
@@ -180,6 +183,10 @@ module.exports = class MultiCompiler {
180
183
  }
181
184
  }
182
185
 
186
+ /**
187
+ * @param {string | (function(): string)} name name of the logger, or function called once to get the logger name
188
+ * @returns {Logger} a logger with that name
189
+ */
183
190
  getInfrastructureLogger(name) {
184
191
  return this.compilers[0].getInfrastructureLogger(name);
185
192
  }
@@ -202,6 +209,10 @@ module.exports = class MultiCompiler {
202
209
  const edges = new Set();
203
210
  /** @type {string[]} */
204
211
  const missing = [];
212
+ /**
213
+ * @param {Compiler} compiler compiler
214
+ * @returns {boolean} target was found
215
+ */
205
216
  const targetFound = compiler => {
206
217
  for (const edge of edges) {
207
218
  if (edge.target === compiler) {
@@ -274,6 +285,10 @@ module.exports = class MultiCompiler {
274
285
  runWithDependencies(compilers, fn, callback) {
275
286
  const fulfilledNames = new Set();
276
287
  let remainingCompilers = compilers;
288
+ /**
289
+ * @param {string} d dependency
290
+ * @returns {boolean} when dependency was fulfilled
291
+ */
277
292
  const isDependencyFulfilled = d => fulfilledNames.has(d);
278
293
  const getReadyCompilers = () => {
279
294
  let readyCompilers = [];
@@ -291,6 +306,10 @@ module.exports = class MultiCompiler {
291
306
  }
292
307
  return readyCompilers;
293
308
  };
309
+ /**
310
+ * @param {Callback<MultiStats>} callback callback
311
+ * @returns {void}
312
+ */
294
313
  const runCompilers = callback => {
295
314
  if (remainingCompilers.length === 0) return callback();
296
315
  asyncLib.map(
@@ -302,7 +321,7 @@ module.exports = class MultiCompiler {
302
321
  runCompilers(callback);
303
322
  });
304
323
  },
305
- callback
324
+ /** @type {Callback<TODO>} */ (callback)
306
325
  );
307
326
  };
308
327
  runCompilers(callback);
@@ -316,7 +335,7 @@ module.exports = class MultiCompiler {
316
335
  * @returns {SetupResult[]} result of setup
317
336
  */
318
337
  _runGraph(setup, run, callback) {
319
- /** @typedef {{ compiler: Compiler, setupResult: SetupResult, result: Stats, state: "pending" | "blocked" | "queued" | "starting" | "running" | "running-outdated" | "done", children: Node[], parents: Node[] }} Node */
338
+ /** @typedef {{ compiler: Compiler, setupResult: undefined | SetupResult, result: undefined | Stats, state: "pending" | "blocked" | "queued" | "starting" | "running" | "running-outdated" | "done", children: Node[], parents: Node[] }} Node */
320
339
 
321
340
  // State transitions for nodes:
322
341
  // -> blocked (initial)
@@ -341,12 +360,14 @@ module.exports = class MultiCompiler {
341
360
  }));
342
361
  /** @type {Map<string, Node>} */
343
362
  const compilerToNode = new Map();
344
- for (const node of nodes) compilerToNode.set(node.compiler.name, node);
363
+ for (const node of nodes) {
364
+ compilerToNode.set(/** @type {string} */ (node.compiler.name), node);
365
+ }
345
366
  for (const node of nodes) {
346
367
  const dependencies = this.dependencies.get(node.compiler);
347
368
  if (!dependencies) continue;
348
369
  for (const dep of dependencies) {
349
- const parent = compilerToNode.get(dep);
370
+ const parent = /** @type {Node} */ (compilerToNode.get(dep));
350
371
  node.parents.push(parent);
351
372
  parent.children.push(node);
352
373
  }
@@ -361,10 +382,10 @@ module.exports = class MultiCompiler {
361
382
  }
362
383
  let errored = false;
363
384
  let running = 0;
364
- const parallelism = this._options.parallelism;
385
+ const parallelism = /** @type {number} */ (this._options.parallelism);
365
386
  /**
366
387
  * @param {Node} node node
367
- * @param {Error=} err error
388
+ * @param {(Error | null)=} err error
368
389
  * @param {Stats=} stats result
369
390
  * @returns {void}
370
391
  */
@@ -440,6 +461,7 @@ module.exports = class MultiCompiler {
440
461
  }
441
462
  };
442
463
 
464
+ /** @type {SetupResult[]} */
443
465
  const setupResults = [];
444
466
  nodes.forEach((node, i) => {
445
467
  setupResults.push(
@@ -461,7 +483,7 @@ module.exports = class MultiCompiler {
461
483
  };
462
484
  const processQueueWorker = () => {
463
485
  while (running < parallelism && queue.length > 0 && !errored) {
464
- const node = queue.dequeue();
486
+ const node = /** @type {Node} */ (queue.dequeue());
465
487
  if (
466
488
  node.state === "queued" ||
467
489
  (node.state === "blocked" &&
@@ -469,7 +491,11 @@ module.exports = class MultiCompiler {
469
491
  ) {
470
492
  running++;
471
493
  node.state = "starting";
472
- run(node.compiler, node.setupResult, nodeDone.bind(null, node));
494
+ run(
495
+ node.compiler,
496
+ /** @type {SetupResult} */ (node.setupResult),
497
+ nodeDone.bind(null, node)
498
+ );
473
499
  node.state = "running";
474
500
  }
475
501
  }