webpack 5.99.7 → 5.99.8

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 (132) hide show
  1. package/lib/Compilation.js +12 -7
  2. package/lib/ContextModule.js +1 -1
  3. package/lib/ContextModuleFactory.js +1 -2
  4. package/lib/ContextReplacementPlugin.js +2 -1
  5. package/lib/DefinePlugin.js +2 -2
  6. package/lib/DelegatedModule.js +18 -8
  7. package/lib/DelegatedModuleFactoryPlugin.js +9 -7
  8. package/lib/EvalSourceMapDevToolPlugin.js +1 -1
  9. package/lib/ExportsInfo.js +35 -16
  10. package/lib/ExternalModule.js +6 -5
  11. package/lib/FileSystemInfo.js +2 -2
  12. package/lib/LibManifestPlugin.js +2 -2
  13. package/lib/ModuleFilenameHelpers.js +8 -4
  14. package/lib/NormalModule.js +8 -7
  15. package/lib/SourceMapDevToolPlugin.js +2 -3
  16. package/lib/WebpackOptionsApply.js +1 -4
  17. package/lib/asset/AssetGenerator.js +2 -2
  18. package/lib/config/defaults.js +10 -6
  19. package/lib/config/normalization.js +5 -5
  20. package/lib/css/CssModulesPlugin.js +2 -2
  21. package/lib/debug/ProfilingPlugin.js +18 -21
  22. package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -1
  23. package/lib/dependencies/ContextElementDependency.js +1 -1
  24. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
  25. package/lib/dependencies/RequireContextPlugin.js +2 -1
  26. package/lib/dependencies/WorkerPlugin.js +2 -2
  27. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +0 -1
  28. package/lib/index.js +11 -0
  29. package/lib/javascript/JavascriptModulesPlugin.js +2 -2
  30. package/lib/json/JsonModulesPlugin.js +4 -4
  31. package/lib/library/AbstractLibraryPlugin.js +1 -1
  32. package/lib/node/nodeConsole.js +3 -2
  33. package/lib/optimize/AggressiveSplittingPlugin.js +1 -1
  34. package/lib/optimize/ConcatenatedModule.js +3 -1
  35. package/lib/optimize/ModuleConcatenationPlugin.js +2 -2
  36. package/lib/optimize/RuntimeChunkPlugin.js +5 -6
  37. package/lib/optimize/SideEffectsFlagPlugin.js +9 -6
  38. package/lib/optimize/SplitChunksPlugin.js +2 -2
  39. package/lib/rules/BasicEffectRulePlugin.js +1 -2
  40. package/lib/rules/ObjectMatcherRulePlugin.js +2 -1
  41. package/lib/rules/RuleSetCompiler.js +19 -5
  42. package/lib/rules/UseEffectRulePlugin.js +4 -6
  43. package/lib/schemes/HttpUriPlugin.js +154 -149
  44. package/lib/util/createHash.js +3 -3
  45. package/package.json +33 -29
  46. package/schemas/WebpackOptions.check.d.ts +1 -1
  47. package/schemas/WebpackOptions.check.js +2 -2
  48. package/schemas/WebpackOptions.json +243 -24
  49. package/schemas/plugins/BannerPlugin.check.d.ts +1 -1
  50. package/schemas/plugins/BannerPlugin.check.js +1 -1
  51. package/schemas/plugins/DllPlugin.check.d.ts +1 -1
  52. package/schemas/plugins/DllPlugin.check.js +1 -1
  53. package/schemas/plugins/DllReferencePlugin.check.d.ts +1 -1
  54. package/schemas/plugins/DllReferencePlugin.check.js +1 -1
  55. package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +1 -1
  56. package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
  57. package/schemas/plugins/IgnorePlugin.check.d.ts +1 -1
  58. package/schemas/plugins/IgnorePlugin.check.js +1 -1
  59. package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +1 -1
  60. package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
  61. package/schemas/plugins/ProgressPlugin.check.d.ts +1 -1
  62. package/schemas/plugins/ProgressPlugin.check.js +1 -1
  63. package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +1 -1
  64. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  65. package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
  66. package/schemas/plugins/WatchIgnorePlugin.check.d.ts +1 -1
  67. package/schemas/plugins/WatchIgnorePlugin.check.js +1 -1
  68. package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +1 -1
  69. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  70. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +1 -1
  71. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
  72. package/schemas/plugins/asset/AssetParserOptions.check.d.ts +1 -1
  73. package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
  74. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +1 -1
  75. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  76. package/schemas/plugins/container/ContainerPlugin.check.d.ts +1 -1
  77. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  78. package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +1 -1
  79. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  80. package/schemas/plugins/container/ExternalsType.check.d.ts +1 -1
  81. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  82. package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +1 -1
  83. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  84. package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +1 -1
  85. package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
  86. package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +1 -1
  87. package/schemas/plugins/css/CssAutoParserOptions.check.js +1 -1
  88. package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +1 -1
  89. package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
  90. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +1 -1
  91. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
  92. package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +1 -1
  93. package/schemas/plugins/css/CssGlobalParserOptions.check.js +1 -1
  94. package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +1 -1
  95. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  96. package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +1 -1
  97. package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
  98. package/schemas/plugins/css/CssParserOptions.check.d.ts +1 -1
  99. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  100. package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +1 -1
  101. package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
  102. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +1 -1
  103. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +1 -1
  104. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +1 -1
  105. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +1 -1
  106. package/schemas/plugins/json/JsonModulesPluginGenerator.check.d.ts +7 -0
  107. package/schemas/plugins/{JsonModulesPluginGenerator.check.js → json/JsonModulesPluginGenerator.check.js} +1 -1
  108. package/schemas/plugins/json/JsonModulesPluginGenerator.json +3 -0
  109. package/schemas/plugins/json/JsonModulesPluginParser.check.d.ts +7 -0
  110. package/schemas/plugins/{JsonModulesPluginParser.check.js → json/JsonModulesPluginParser.check.js} +1 -1
  111. package/schemas/plugins/json/JsonModulesPluginParser.json +3 -0
  112. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +1 -1
  113. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
  114. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +1 -1
  115. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
  116. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +1 -1
  117. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +1 -1
  118. package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +1 -1
  119. package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
  120. package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +1 -1
  121. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  122. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +1 -1
  123. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +1 -1
  124. package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +1 -1
  125. package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +1 -1
  126. package/schemas/plugins/sharing/SharePlugin.check.d.ts +1 -1
  127. package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
  128. package/types.d.ts +437 -150
  129. package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +0 -7
  130. package/schemas/plugins/JsonModulesPluginGenerator.json +0 -11
  131. package/schemas/plugins/JsonModulesPluginParser.check.d.ts +0 -7
  132. package/schemas/plugins/JsonModulesPluginParser.json +0 -16
@@ -130,7 +130,7 @@ const { isSourceEqual } = require("./util/source");
130
130
  /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsModule} StatsModule */
131
131
  /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
132
132
  /** @typedef {import("./util/Hash")} Hash */
133
- /** @typedef {import("./util/createHash").Algorithm} Algorithm */
133
+ /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
134
134
  /**
135
135
  * @template T
136
136
  * @typedef {import("./util/deprecation").FakeHook<T>} FakeHook<T>
@@ -1520,7 +1520,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1520
1520
  this.options,
1521
1521
  this,
1522
1522
  this.resolverFactory.get("normal", module.resolveOptions),
1523
- /** @type {InputFileSystem} */ (this.inputFileSystem),
1523
+ /** @type {InputFileSystem} */
1524
+ (this.inputFileSystem),
1524
1525
  err => {
1525
1526
  if (currentProfile !== undefined) {
1526
1527
  currentProfile.markBuildingEnd();
@@ -4313,7 +4314,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4313
4314
  ) {
4314
4315
  let moduleHashDigest;
4315
4316
  try {
4316
- const moduleHash = createHash(/** @type {Algorithm} */ (hashFunction));
4317
+ const moduleHash = createHash(/** @type {HashFunction} */ (hashFunction));
4317
4318
  module.updateHash(moduleHash, {
4318
4319
  chunkGraph,
4319
4320
  runtime,
@@ -4341,7 +4342,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4341
4342
  const hashFunction = outputOptions.hashFunction;
4342
4343
  const hashDigest = outputOptions.hashDigest;
4343
4344
  const hashDigestLength = outputOptions.hashDigestLength;
4344
- const hash = createHash(/** @type {Algorithm} */ (hashFunction));
4345
+ const hash = createHash(/** @type {HashFunction} */ (hashFunction));
4345
4346
  if (outputOptions.hashSalt) {
4346
4347
  hash.update(outputOptions.hashSalt);
4347
4348
  }
@@ -4524,7 +4525,9 @@ This prevents using hashes of each other and should be avoided.`);
4524
4525
  this.logger.timeAggregate("hashing: hash runtime modules");
4525
4526
  try {
4526
4527
  this.logger.time("hashing: hash chunks");
4527
- const chunkHash = createHash(/** @type {Algorithm} */ (hashFunction));
4528
+ const chunkHash = createHash(
4529
+ /** @type {HashFunction} */ (hashFunction)
4530
+ );
4528
4531
  if (outputOptions.hashSalt) {
4529
4532
  chunkHash.update(outputOptions.hashSalt);
4530
4533
  }
@@ -4577,7 +4580,9 @@ This prevents using hashes of each other and should be avoided.`);
4577
4580
  for (const module of /** @type {Iterable<RuntimeModule>} */ (
4578
4581
  chunkGraph.getChunkFullHashModulesIterable(chunk)
4579
4582
  )) {
4580
- const moduleHash = createHash(/** @type {Algorithm} */ (hashFunction));
4583
+ const moduleHash = createHash(
4584
+ /** @type {HashFunction} */ (hashFunction)
4585
+ );
4581
4586
  module.updateHash(moduleHash, {
4582
4587
  chunkGraph,
4583
4588
  runtime: chunk.runtime,
@@ -4599,7 +4604,7 @@ This prevents using hashes of each other and should be avoided.`);
4599
4604
  (codeGenerationJobsMap.get(oldHash)).get(module)
4600
4605
  ).hash = moduleHashDigest;
4601
4606
  }
4602
- const chunkHash = createHash(/** @type {Algorithm} */ (hashFunction));
4607
+ const chunkHash = createHash(/** @type {HashFunction} */ (hashFunction));
4603
4608
  chunkHash.update(chunk.hash);
4604
4609
  chunkHash.update(this.hash);
4605
4610
  const chunkHashDigest =
@@ -81,7 +81,7 @@ const makeSerializable = require("./util/makeSerializable");
81
81
 
82
82
  /**
83
83
  * @typedef {object} ContextModuleOptionsExtras
84
- * @property {false|string|string[]} resource
84
+ * @property {false | string | string[]} resource
85
85
  * @property {string=} resourceQuery
86
86
  * @property {string=} resourceFragment
87
87
  * @property {ResolveOptions=} resolveOptions
@@ -397,8 +397,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
397
397
  /** @type {string} */
398
398
  (category),
399
399
  referencedExports,
400
- /** @type {TODO} */
401
- (obj.context),
400
+ obj.context,
402
401
  attributes
403
402
  );
404
403
  dep.optional = true;
@@ -190,7 +190,8 @@ const createResolveDependenciesFromContextMap =
190
190
  map[key] + options.resourceQuery + options.resourceFragment,
191
191
  key,
192
192
  options.typePrefix,
193
- /** @type {string} */ (options.category),
193
+ /** @type {string} */
194
+ (options.category),
194
195
  options.referencedExports
195
196
  )
196
197
  );
@@ -22,6 +22,7 @@ const {
22
22
  const createHash = require("./util/createHash");
23
23
 
24
24
  /** @typedef {import("estree").Expression} Expression */
25
+ /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
25
26
  /** @typedef {import("./Compiler")} Compiler */
26
27
  /** @typedef {import("./Module").BuildInfo} BuildInfo */
27
28
  /** @typedef {import("./Module").ValueCacheVersions} ValueCacheVersions */
@@ -31,7 +32,6 @@ const createHash = require("./util/createHash");
31
32
  /** @typedef {import("./javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */
32
33
  /** @typedef {import("./javascript/JavascriptParser").Range} Range */
33
34
  /** @typedef {import("./logging/Logger").Logger} Logger */
34
- /** @typedef {import("./util/createHash").Algorithm} Algorithm */
35
35
 
36
36
  /** @typedef {null | undefined | RegExp | EXPECTED_FUNCTION | string | number | boolean | bigint | undefined} CodeValuePrimitive */
37
37
  /** @typedef {RecursiveArrayOrRecord<CodeValuePrimitive | RuntimeValue>} CodeValue */
@@ -367,7 +367,7 @@ class DefinePlugin {
367
367
  const { runtimeTemplate } = compilation;
368
368
 
369
369
  const mainHash = createHash(
370
- /** @type {Algorithm} */
370
+ /** @type {HashFunction} */
371
371
  (compilation.outputOptions.hashFunction)
372
372
  );
373
373
  mainHash.update(
@@ -16,6 +16,7 @@ const makeSerializable = require("./util/makeSerializable");
16
16
 
17
17
  /** @typedef {import("webpack-sources").Source} Source */
18
18
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
19
+ /** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
19
20
  /** @typedef {import("./ChunkGraph")} ChunkGraph */
20
21
  /** @typedef {import("./Compilation")} Compilation */
21
22
  /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
@@ -23,6 +24,7 @@ const makeSerializable = require("./util/makeSerializable");
23
24
  /** @typedef {import("./Generator").SourceTypes} SourceTypes */
24
25
  /** @typedef {import("./LibManifestPlugin").ManifestModuleData} ManifestModuleData */
25
26
  /** @typedef {import("./Module").BuildCallback} BuildCallback */
27
+ /** @typedef {import("./Module").BuildMeta} BuildMeta */
26
28
  /** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
27
29
  /** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
28
30
  /** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
@@ -39,9 +41,16 @@ const makeSerializable = require("./util/makeSerializable");
39
41
  /** @typedef {import("./util/Hash")} Hash */
40
42
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
41
43
 
42
- /** @typedef {string} SourceRequest */
43
- /** @typedef {"require" | "object"} Type */
44
- /** @typedef {TODO} Data */
44
+ /** @typedef {string} DelegatedModuleSourceRequest */
45
+
46
+ /** @typedef {NonNullable<DllReferencePluginOptions["type"]>} DelegatedModuleType */
47
+
48
+ /**
49
+ * @typedef {object} DelegatedModuleData
50
+ * @property {BuildMeta=} buildMeta build meta
51
+ * @property {true | string[]=} exports exports
52
+ * @property {number | string} id module id
53
+ */
45
54
 
46
55
  const RUNTIME_REQUIREMENTS = new Set([
47
56
  RuntimeGlobals.module,
@@ -50,9 +59,9 @@ const RUNTIME_REQUIREMENTS = new Set([
50
59
 
51
60
  class DelegatedModule extends Module {
52
61
  /**
53
- * @param {SourceRequest} sourceRequest source request
54
- * @param {Data} data data
55
- * @param {Type} type type
62
+ * @param {DelegatedModuleSourceRequest} sourceRequest source request
63
+ * @param {DelegatedModuleData} data data
64
+ * @param {DelegatedModuleType} type type
56
65
  * @param {string} userRequest user request
57
66
  * @param {string | Module} originalRequest original request
58
67
  */
@@ -65,7 +74,6 @@ class DelegatedModule extends Module {
65
74
  this.delegationType = type;
66
75
  this.userRequest = userRequest;
67
76
  this.originalRequest = originalRequest;
68
- /** @type {ManifestModuleData | undefined} */
69
77
  this.delegateData = data;
70
78
 
71
79
  // Build info
@@ -255,7 +263,9 @@ class DelegatedModule extends Module {
255
263
  */
256
264
  cleanupForCache() {
257
265
  super.cleanupForCache();
258
- this.delegateData = undefined;
266
+ this.delegateData =
267
+ /** @type {EXPECTED_ANY} */
268
+ (undefined);
259
269
  }
260
270
  }
261
271
 
@@ -9,15 +9,14 @@ const DelegatedModule = require("./DelegatedModule");
9
9
 
10
10
  /** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
11
11
  /** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptionsContent} DllReferencePluginOptionsContent */
12
- /** @typedef {import("./DelegatedModule").Data} Data */
13
- /** @typedef {import("./DelegatedModule").SourceRequest} SourceRequest */
14
- /** @typedef {import("./DelegatedModule").Type} Type */
12
+ /** @typedef {import("./DelegatedModule").DelegatedModuleSourceRequest} DelegatedModuleSourceRequest */
13
+ /** @typedef {import("./DelegatedModule").DelegatedModuleType} DelegatedModuleType */
15
14
  /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
16
15
  /** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
17
16
 
18
17
  /**
19
18
  * @typedef {object} Options
20
- * @property {SourceRequest} source source
19
+ * @property {DelegatedModuleSourceRequest} source source
21
20
  * @property {NonNullable<DllReferencePluginOptions["context"]>} context absolute context path to which lib ident is relative to
22
21
  * @property {DllReferencePluginOptionsContent} content content
23
22
  * @property {DllReferencePluginOptions["type"]} type type
@@ -58,7 +57,8 @@ class DelegatedModuleFactoryPlugin {
58
57
  new DelegatedModule(
59
58
  this.options.source,
60
59
  resolved,
61
- /** @type {Type} */ (this.options.type),
60
+ /** @type {DelegatedModuleType} */
61
+ (this.options.type),
62
62
  innerRequest,
63
63
  request
64
64
  )
@@ -77,7 +77,8 @@ class DelegatedModuleFactoryPlugin {
77
77
  new DelegatedModule(
78
78
  this.options.source,
79
79
  resolved,
80
- /** @type {Type} */ (this.options.type),
80
+ /** @type {DelegatedModuleType} */
81
+ (this.options.type),
81
82
  requestPlusExt,
82
83
  request + extension
83
84
  )
@@ -98,7 +99,8 @@ class DelegatedModuleFactoryPlugin {
98
99
  return new DelegatedModule(
99
100
  this.options.source,
100
101
  resolved,
101
- /** @type {Type} */ (this.options.type),
102
+ /** @type {DelegatedModuleType} */
103
+ (this.options.type),
102
104
  request,
103
105
  module
104
106
  );
@@ -39,7 +39,7 @@ const PLUGIN_NAME = "EvalSourceMapDevToolPlugin";
39
39
 
40
40
  class EvalSourceMapDevToolPlugin {
41
41
  /**
42
- * @param {SourceMapDevToolPluginOptions|string} inputOptions Options object
42
+ * @param {SourceMapDevToolPluginOptions | string} inputOptions Options object
43
43
  */
44
44
  constructor(inputOptions) {
45
45
  /** @type {SourceMapDevToolPluginOptions} */
@@ -34,9 +34,18 @@ const RETURNS_TRUE = () => true;
34
34
 
35
35
  const CIRCULAR = Symbol("circular target");
36
36
 
37
+ /**
38
+ * @typedef {object} RestoreProvidedDataExports
39
+ * @property {ExportInfoName} name
40
+ * @property {ExportInfo["provided"]} provided
41
+ * @property {ExportInfo["canMangleProvide"]} canMangleProvide
42
+ * @property {ExportInfo["terminalBinding"]} terminalBinding
43
+ * @property {RestoreProvidedData | undefined} exportsInfo
44
+ */
45
+
37
46
  class RestoreProvidedData {
38
47
  /**
39
- * @param {TODO[]} exports exports
48
+ * @param {RestoreProvidedDataExports[]} exports exports
40
49
  * @param {ExportInfo["provided"]} otherProvided other provided
41
50
  * @param {ExportInfo["canMangleProvide"]} otherCanMangleProvide other can mangle provide
42
51
  * @param {ExportInfo["terminalBinding"]} otherTerminalBinding other terminal binding
@@ -78,7 +87,7 @@ makeSerializable(
78
87
  "RestoreProvidedData"
79
88
  );
80
89
 
81
- /** @typedef {Map<string, ExportInfo>} Exports */
90
+ /** @typedef {Map<ExportInfoName, ExportInfo>} Exports */
82
91
  /** @typedef {string | string[] | false} UsedName */
83
92
 
84
93
  class ExportsInfo {
@@ -131,6 +140,7 @@ class ExportsInfo {
131
140
  this._sortExports();
132
141
  }
133
142
  if (this._redirectTo !== undefined) {
143
+ /** @type {Exports} */
134
144
  const map = new Map(
135
145
  Array.from(this._redirectTo.orderedExports, item => [item.name, item])
136
146
  );
@@ -160,6 +170,7 @@ class ExportsInfo {
160
170
  */
161
171
  _sortExportsMap(exports) {
162
172
  if (exports.size > 1) {
173
+ /** @type {string[]} */
163
174
  const namesInOrder = [];
164
175
  for (const entry of exports.values()) {
165
176
  namesInOrder.push(entry.name);
@@ -229,7 +240,7 @@ class ExportsInfo {
229
240
  }
230
241
 
231
242
  /**
232
- * @param {string} name export name
243
+ * @param {ExportInfoName} name export name
233
244
  * @returns {ExportInfo} export info for this name
234
245
  */
235
246
  getOwnExportInfo(name) {
@@ -242,7 +253,7 @@ class ExportsInfo {
242
253
  }
243
254
 
244
255
  /**
245
- * @param {string} name export name
256
+ * @param {ExportInfoName} name export name
246
257
  * @returns {ExportInfo} export info for this name
247
258
  */
248
259
  getExportInfo(name) {
@@ -257,7 +268,7 @@ class ExportsInfo {
257
268
  }
258
269
 
259
270
  /**
260
- * @param {string} name export name
271
+ * @param {ExportInfoName} name export name
261
272
  * @returns {ExportInfo} export info for this name
262
273
  */
263
274
  getReadOnlyExportInfo(name) {
@@ -269,7 +280,7 @@ class ExportsInfo {
269
280
  }
270
281
 
271
282
  /**
272
- * @param {string[]} name export name
283
+ * @param {ExportInfoName[]} name export name
273
284
  * @returns {ExportInfo | undefined} export info for this name
274
285
  */
275
286
  getReadOnlyExportInfoRecursive(name) {
@@ -280,7 +291,7 @@ class ExportsInfo {
280
291
  }
281
292
 
282
293
  /**
283
- * @param {string[]=} name the export name
294
+ * @param {ExportInfoName[]=} name the export name
284
295
  * @returns {ExportsInfo | undefined} the nested exports info
285
296
  */
286
297
  getNestedExportsInfo(name) {
@@ -327,7 +338,8 @@ class ExportsInfo {
327
338
  if (targetKey) {
328
339
  exportInfo.setTarget(
329
340
  targetKey,
330
- /** @type {ModuleGraphConnection} */ (targetModule),
341
+ /** @type {ModuleGraphConnection} */
342
+ (targetModule),
331
343
  [exportInfo.name],
332
344
  -1
333
345
  );
@@ -552,6 +564,7 @@ class ExportsInfo {
552
564
  return true;
553
565
  }
554
566
  }
567
+ /** @type {string[]} */
555
568
  const array = [];
556
569
  if (!this._exportsAreOrdered) this._sortExports();
557
570
  for (const exportInfo of this._exports.values()) {
@@ -604,7 +617,7 @@ class ExportsInfo {
604
617
  }
605
618
 
606
619
  /**
607
- * @param {string | string[]} name the name of the export
620
+ * @param {ExportInfoName | ExportInfoName[]} name the name of the export
608
621
  * @returns {boolean | undefined | null} if the export is provided
609
622
  */
610
623
  isExportProvided(name) {
@@ -665,7 +678,7 @@ class ExportsInfo {
665
678
  }
666
679
 
667
680
  /**
668
- * @param {string | string[]} name export name
681
+ * @param {ExportInfoName | ExportInfoName[]} name export name
669
682
  * @param {RuntimeSpec} runtime check usage for this runtime only
670
683
  * @returns {UsageStateType} usage status
671
684
  */
@@ -683,7 +696,7 @@ class ExportsInfo {
683
696
  }
684
697
 
685
698
  /**
686
- * @param {string | string[]} name the export name
699
+ * @param {ExportInfoName | ExportInfoName[]} name the export name
687
700
  * @param {RuntimeSpec} runtime check usage for this runtime only
688
701
  * @returns {UsedName} the used name
689
702
  */
@@ -698,7 +711,7 @@ class ExportsInfo {
698
711
  const x = info.getUsedName(name[0], runtime);
699
712
  if (x === false) return false;
700
713
  const arr =
701
- /** @type {string[]} */
714
+ /** @type {ExportInfoName[]} */
702
715
  (x === name[0] && name.length === 1 ? name : [x]);
703
716
  if (name.length === 1) {
704
717
  return arr;
@@ -755,6 +768,7 @@ class ExportsInfo {
755
768
  const otherProvided = this._otherExportsInfo.provided;
756
769
  const otherCanMangleProvide = this._otherExportsInfo.canMangleProvide;
757
770
  const otherTerminalBinding = this._otherExportsInfo.terminalBinding;
771
+ /** @type {RestoreProvidedDataExports[]} */
758
772
  const exports = [];
759
773
  for (const exportInfo of this.orderedExports) {
760
774
  if (
@@ -827,19 +841,24 @@ class ExportsInfo {
827
841
  /** @typedef {(module: Module) => boolean} ValidTargetModuleFilter */
828
842
 
829
843
  /** @typedef {{ connection: ModuleGraphConnection, export: string[], priority: number }} TargetItem */
844
+
830
845
  /** @typedef {Map<Dependency | undefined, TargetItem>} Target */
831
846
 
847
+ /** @typedef {string} ExportInfoName */
848
+ /** @typedef {string | null} ExportInfoUsedName */
849
+ /** @typedef {boolean | null} ExportInfoProvided */
850
+
832
851
  class ExportInfo {
833
852
  /**
834
- * @param {string} name the original name of the export
853
+ * @param {ExportInfoName} name the original name of the export
835
854
  * @param {ExportInfo=} initFrom init values from this ExportInfo
836
855
  */
837
856
  constructor(name, initFrom) {
838
- /** @type {string} */
857
+ /** @type {ExportInfoName} */
839
858
  this.name = name;
840
859
  /**
841
860
  * @private
842
- * @type {string | null}
861
+ * @type {ExportInfoUsedName}
843
862
  */
844
863
  this._usedName = initFrom ? initFrom._usedName : null;
845
864
  /**
@@ -867,7 +886,7 @@ class ExportInfo {
867
886
  * false: it is not provided
868
887
  * null: only the runtime knows if it is provided
869
888
  * undefined: it was not determined if it is provided
870
- * @type {boolean | null | undefined}
889
+ * @type {ExportInfoProvided | undefined}
871
890
  */
872
891
  this.provided = initFrom ? initFrom.provided : undefined;
873
892
  /**
@@ -28,6 +28,7 @@ const propertyAccess = require("./util/propertyAccess");
28
28
  const { register } = require("./util/serialization");
29
29
 
30
30
  /** @typedef {import("webpack-sources").Source} Source */
31
+ /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
31
32
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
32
33
  /** @typedef {import("./Chunk")} Chunk */
33
34
  /** @typedef {import("./ChunkGraph")} ChunkGraph */
@@ -58,7 +59,6 @@ const { register } = require("./util/serialization");
58
59
  /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
59
60
  /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
60
61
  /** @typedef {import("./util/Hash")} Hash */
61
- /** @typedef {typeof import("./util/Hash")} HashConstructor */
62
62
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
63
63
  /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
64
64
 
@@ -215,9 +215,10 @@ const getSourceForImportExternal = (
215
215
  };
216
216
 
217
217
  /**
218
- * @param {string} key key
219
- * @param {TODO | undefined} value value
220
- * @returns {undefined | string} replaced value
218
+ * @template {{ [key: string]: string }} T
219
+ * @param {keyof T} key key
220
+ * @param {T[keyof T]} value value
221
+ * @returns {undefined | T[keyof T]} replaced value
221
222
  */
222
223
  const importAssertionReplacer = (key, value) => {
223
224
  if (key === "_isLegacyAssert") {
@@ -235,7 +236,7 @@ class ModuleExternalInitFragment extends InitFragment {
235
236
  * @param {string} request import source
236
237
  * @param {string=} ident recomputed ident
237
238
  * @param {ImportDependencyMeta=} dependencyMeta the dependency meta
238
- * @param {string | HashConstructor=} hashFunction the hash function to use
239
+ * @param {HashFunction=} hashFunction the hash function to use
239
240
  */
240
241
  constructor(
241
242
  request,
@@ -24,7 +24,7 @@ const processAsyncTree = require("./util/processAsyncTree");
24
24
  /** @typedef {import("./logging/Logger").Logger} Logger */
25
25
  /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
26
26
  /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
27
- /** @typedef {typeof import("./util/Hash")} Hash */
27
+ /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
28
28
  /** @typedef {import("./util/fs").IStats} IStats */
29
29
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
30
30
  /** @typedef {import("./util/fs").PathLike} PathLike */
@@ -1058,7 +1058,7 @@ class FileSystemInfo {
1058
1058
  * @param {Iterable<string | RegExp>=} options.managedPaths paths that are only managed by a package manager
1059
1059
  * @param {Iterable<string | RegExp>=} options.immutablePaths paths that are immutable
1060
1060
  * @param {Logger=} options.logger logger used to log invalid snapshots
1061
- * @param {string | Hash=} options.hashFunction the hash function to use
1061
+ * @param {HashFunction=} options.hashFunction the hash function to use
1062
1062
  */
1063
1063
  constructor(
1064
1064
  fs,
@@ -19,8 +19,8 @@ const { dirname, mkdirp } = require("./util/fs");
19
19
  /**
20
20
  * @typedef {object} ManifestModuleData
21
21
  * @property {string | number} id
22
- * @property {BuildMeta} buildMeta
23
- * @property {boolean | string[] | undefined} exports
22
+ * @property {BuildMeta=} buildMeta
23
+ * @property {boolean | string[]=} exports
24
24
  */
25
25
 
26
26
  /**
@@ -10,10 +10,11 @@ const { DEFAULTS } = require("./config/defaults");
10
10
  const createHash = require("./util/createHash");
11
11
  const memoize = require("./util/memoize");
12
12
 
13
+ /** @typedef {import("../declarations/WebpackOptions").DevtoolModuleFilenameTemplate} DevtoolModuleFilenameTemplate */
14
+ /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
13
15
  /** @typedef {import("./ChunkGraph")} ChunkGraph */
14
16
  /** @typedef {import("./Module")} Module */
15
17
  /** @typedef {import("./RequestShortener")} RequestShortener */
16
- /** @typedef {typeof import("./util/Hash")} Hash */
17
18
 
18
19
  /** @typedef {string | RegExp | (string | RegExp)[]} Matcher */
19
20
  /** @typedef {{ test?: Matcher, include?: Matcher, exclude?: Matcher }} MatchObject */
@@ -76,7 +77,7 @@ const getBefore = (strFn, token) => () => {
76
77
  /**
77
78
  * Returns a function that returns a hash of the string
78
79
  * @param {ReturnStringCallback} strFn the function to get the string
79
- * @param {string | Hash=} hashFunction the hash function to use
80
+ * @param {HashFunction=} hashFunction the hash function to use
80
81
  * @returns {ReturnStringCallback} a function that returns the hash of the string
81
82
  */
82
83
  const getHash =
@@ -117,10 +118,13 @@ const lazyObject = obj => {
117
118
 
118
119
  const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/gi;
119
120
 
121
+ /** @typedef {((context: TODO) => string)} ModuleFilenameTemplateFunction */
122
+ /** @typedef {string | ModuleFilenameTemplateFunction} ModuleFilenameTemplate */
123
+
120
124
  /**
121
125
  * @param {Module | string} module the module
122
- * @param {{ namespace?: string, moduleFilenameTemplate?: string | TODO }} options options
123
- * @param {{ requestShortener: RequestShortener, chunkGraph: ChunkGraph, hashFunction?: string | Hash }} contextInfo context info
126
+ * @param {{ namespace?: string, moduleFilenameTemplate?: ModuleFilenameTemplate }} options options
127
+ * @param {{ requestShortener: RequestShortener, chunkGraph: ChunkGraph, hashFunction?: HashFunction }} contextInfo context info
124
128
  * @returns {string} the filename
125
129
  */
126
130
  ModuleFilenameHelpers.createFilename = (
@@ -57,6 +57,7 @@ const memoize = require("./util/memoize");
57
57
  /** @typedef {import("../declarations/WebpackOptions").Mode} Mode */
58
58
  /** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
59
59
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
60
+ /** @typedef {import("../declarations/WebpackOptions").NoParse} NoParse */
60
61
  /** @typedef {import("./ChunkGraph")} ChunkGraph */
61
62
  /** @typedef {import("./Compiler")} Compiler */
62
63
  /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
@@ -92,7 +93,7 @@ const memoize = require("./util/memoize");
92
93
  /** @typedef {import("./util/Hash")} Hash */
93
94
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
94
95
  /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
95
- /** @typedef {import("./util/createHash").Algorithm} Algorithm */
96
+ /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
96
97
  /** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
97
98
  /**
98
99
  * @template T
@@ -649,13 +650,13 @@ class NormalModule extends Module {
649
650
  ? getContextifyInContext()(request)
650
651
  : getContextify()(context, request),
651
652
  /**
652
- * @param {(string | typeof import("./util/Hash"))=} type type
653
+ * @param {HashFunction=} type type
653
654
  * @returns {Hash} hash
654
655
  */
655
656
  createHash: type =>
656
657
  createHash(
657
658
  type ||
658
- /** @type {Algorithm} */
659
+ /** @type {HashFunction} */
659
660
  (compilation.outputOptions.hashFunction)
660
661
  )
661
662
  };
@@ -803,7 +804,7 @@ class NormalModule extends Module {
803
804
  webpack: true,
804
805
  sourceMap: Boolean(this.useSourceMap),
805
806
  mode: options.mode || "production",
806
- hashFunction: /** @type {TODO} */ (options.output.hashFunction),
807
+ hashFunction: /** @type {string} */ (options.output.hashFunction),
807
808
  hashDigest: /** @type {string} */ (options.output.hashDigest),
808
809
  hashDigestLength: /** @type {number} */ (options.output.hashDigestLength),
809
810
  hashSalt: /** @type {string} */ (options.output.hashSalt),
@@ -1079,7 +1080,7 @@ class NormalModule extends Module {
1079
1080
  }
1080
1081
 
1081
1082
  /**
1082
- * @param {TODO} rule rule
1083
+ * @param {Exclude<NoParse, EXPECTED_ANY[]>} rule rule
1083
1084
  * @param {string} content content
1084
1085
  * @returns {boolean} result
1085
1086
  */
@@ -1097,7 +1098,7 @@ class NormalModule extends Module {
1097
1098
  }
1098
1099
 
1099
1100
  /**
1100
- * @param {TODO} noParseRule no parse rule
1101
+ * @param {undefined | NoParse} noParseRule no parse rule
1101
1102
  * @param {string} request request
1102
1103
  * @returns {boolean} check if module should not be parsed, returns "true" if the module should !not! be parsed, returns "false" if the module !must! be parsed
1103
1104
  */
@@ -1132,7 +1133,7 @@ class NormalModule extends Module {
1132
1133
  */
1133
1134
  _initBuildHash(compilation) {
1134
1135
  const hash = createHash(
1135
- /** @type {Algorithm} */
1136
+ /** @type {HashFunction} */
1136
1137
  (compilation.outputOptions.hashFunction)
1137
1138
  );
1138
1139
  if (this._source) {
@@ -19,6 +19,7 @@ const { makePathsAbsolute } = require("./util/identifier");
19
19
 
20
20
  /** @typedef {import("webpack-sources").MapOptions} MapOptions */
21
21
  /** @typedef {import("webpack-sources").Source} Source */
22
+ /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
22
23
  /** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
23
24
  /** @typedef {import("./Cache").Etag} Etag */
24
25
  /** @typedef {import("./CacheFacade").ItemCacheFacade} ItemCacheFacade */
@@ -29,8 +30,6 @@ const { makePathsAbsolute } = require("./util/identifier");
29
30
  /** @typedef {import("./Module")} Module */
30
31
  /** @typedef {import("./NormalModule").SourceMap} SourceMap */
31
32
  /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
32
- /** @typedef {import("./util/Hash")} Hash */
33
- /** @typedef {import("./util/createHash").Algorithm} Algorithm */
34
33
  /** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
35
34
 
36
35
  const validate = createSchemaValidation(
@@ -489,7 +488,7 @@ class SourceMapDevToolPlugin {
489
488
  (
490
489
  usesContentHash &&
491
490
  createHash(
492
- /** @type {Algorithm} */
491
+ /** @type {HashFunction} */
493
492
  (compilation.outputOptions.hashFunction)
494
493
  )
495
494
  .update(sourceMapString)
@@ -504,10 +504,7 @@ class WebpackOptionsApply extends OptionsApply {
504
504
  }
505
505
  if (options.optimization.runtimeChunk) {
506
506
  const RuntimeChunkPlugin = require("./optimize/RuntimeChunkPlugin");
507
- new RuntimeChunkPlugin(
508
- /** @type {{ name?: (entrypoint: { name: string }) => string }} */
509
- (options.optimization.runtimeChunk)
510
- ).apply(compiler);
507
+ new RuntimeChunkPlugin(options.optimization.runtimeChunk).apply(compiler);
511
508
  }
512
509
  if (!options.optimization.emitOnErrors) {
513
510
  const NoEmitOnErrorsPlugin = require("./NoEmitOnErrorsPlugin");