webpack 5.98.0 → 5.99.0

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 (251) hide show
  1. package/README.md +7 -3
  2. package/lib/AsyncDependenciesBlock.js +3 -1
  3. package/lib/BannerPlugin.js +1 -1
  4. package/lib/Cache.js +9 -7
  5. package/lib/CacheFacade.js +5 -5
  6. package/lib/Chunk.js +2 -2
  7. package/lib/ChunkGraph.js +21 -16
  8. package/lib/ChunkTemplate.js +6 -6
  9. package/lib/CleanPlugin.js +10 -10
  10. package/lib/CodeGenerationResults.js +4 -3
  11. package/lib/CompatibilityPlugin.js +4 -1
  12. package/lib/Compilation.js +326 -152
  13. package/lib/Compiler.js +13 -18
  14. package/lib/ConditionalInitFragment.js +1 -1
  15. package/lib/ConstPlugin.js +5 -3
  16. package/lib/ContextModule.js +4 -2
  17. package/lib/ContextModuleFactory.js +3 -3
  18. package/lib/ContextReplacementPlugin.js +43 -16
  19. package/lib/DefinePlugin.js +25 -24
  20. package/lib/DelegatedModule.js +4 -2
  21. package/lib/DelegatedModuleFactoryPlugin.js +2 -1
  22. package/lib/Dependency.js +19 -13
  23. package/lib/DependencyTemplates.js +4 -3
  24. package/lib/DllModule.js +4 -2
  25. package/lib/DllModuleFactory.js +2 -2
  26. package/lib/DllReferencePlugin.js +2 -1
  27. package/lib/DynamicEntryPlugin.js +1 -1
  28. package/lib/EnvironmentPlugin.js +4 -2
  29. package/lib/ExportsInfo.js +72 -40
  30. package/lib/ExternalModule.js +14 -5
  31. package/lib/ExternalModuleFactoryPlugin.js +24 -12
  32. package/lib/FileSystemInfo.js +129 -94
  33. package/lib/FlagDependencyExportsPlugin.js +6 -4
  34. package/lib/FlagDependencyUsagePlugin.js +1 -1
  35. package/lib/Generator.js +29 -1
  36. package/lib/HookWebpackError.js +2 -2
  37. package/lib/HotModuleReplacementPlugin.js +3 -9
  38. package/lib/IgnoreErrorModuleFactory.js +2 -2
  39. package/lib/IgnorePlugin.js +0 -5
  40. package/lib/InitFragment.js +1 -1
  41. package/lib/LoaderOptionsPlugin.js +8 -5
  42. package/lib/MainTemplate.js +7 -7
  43. package/lib/Module.js +40 -17
  44. package/lib/ModuleBuildError.js +3 -1
  45. package/lib/ModuleDependencyError.js +4 -3
  46. package/lib/ModuleDependencyWarning.js +4 -3
  47. package/lib/ModuleFactory.js +9 -3
  48. package/lib/ModuleFilenameHelpers.js +13 -13
  49. package/lib/ModuleGraph.js +20 -14
  50. package/lib/ModuleGraphConnection.js +7 -13
  51. package/lib/ModuleNotFoundError.js +1 -1
  52. package/lib/ModuleParseError.js +2 -1
  53. package/lib/ModuleSourceTypesConstants.js +11 -0
  54. package/lib/ModuleTemplate.js +5 -5
  55. package/lib/ModuleTypeConstants.js +15 -0
  56. package/lib/MultiCompiler.js +4 -4
  57. package/lib/MultiStats.js +1 -1
  58. package/lib/NormalModule.js +101 -54
  59. package/lib/NormalModuleFactory.js +38 -33
  60. package/lib/NormalModuleReplacementPlugin.js +3 -2
  61. package/lib/NullFactory.js +2 -2
  62. package/lib/Parser.js +4 -3
  63. package/lib/ProgressPlugin.js +1 -2
  64. package/lib/RawModule.js +4 -2
  65. package/lib/RecordIdsPlugin.js +6 -2
  66. package/lib/RequestShortener.js +3 -1
  67. package/lib/ResolverFactory.js +12 -9
  68. package/lib/RuntimeModule.js +4 -2
  69. package/lib/RuntimeTemplate.js +2 -1
  70. package/lib/SelfModuleFactory.js +2 -2
  71. package/lib/SourceMapDevToolPlugin.js +0 -8
  72. package/lib/Template.js +6 -5
  73. package/lib/TemplatedPathPlugin.js +15 -12
  74. package/lib/WebpackOptionsApply.js +1 -1
  75. package/lib/asset/AssetGenerator.js +237 -170
  76. package/lib/asset/AssetModulesPlugin.js +50 -8
  77. package/lib/asset/AssetSourceGenerator.js +18 -0
  78. package/lib/asset/RawDataUrlModule.js +4 -2
  79. package/lib/buildChunkGraph.js +14 -4
  80. package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
  81. package/lib/cache/PackFileCacheStrategy.js +137 -121
  82. package/lib/cache/ResolverCachePlugin.js +15 -7
  83. package/lib/cache/getLazyHashedEtag.js +4 -3
  84. package/lib/cli.js +23 -15
  85. package/lib/config/defaults.js +93 -26
  86. package/lib/config/normalization.js +14 -13
  87. package/lib/config/target.js +8 -8
  88. package/lib/container/ContainerEntryModule.js +4 -2
  89. package/lib/container/ContainerEntryModuleFactory.js +2 -2
  90. package/lib/container/FallbackModule.js +4 -2
  91. package/lib/container/FallbackModuleFactory.js +2 -2
  92. package/lib/container/RemoteModule.js +4 -2
  93. package/lib/container/options.js +5 -5
  94. package/lib/css/CssGenerator.js +71 -9
  95. package/lib/css/CssModulesPlugin.js +30 -5
  96. package/lib/css/CssParser.js +37 -17
  97. package/lib/css/walkCssTokens.js +17 -17
  98. package/lib/debug/ProfilingPlugin.js +98 -38
  99. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +10 -4
  100. package/lib/dependencies/AMDPlugin.js +5 -2
  101. package/lib/dependencies/AMDRequireArrayDependency.js +4 -3
  102. package/lib/dependencies/AMDRequireContextDependency.js +2 -1
  103. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +15 -7
  104. package/lib/dependencies/AMDRuntimeModules.js +3 -1
  105. package/lib/dependencies/CommonJsExportRequireDependency.js +4 -5
  106. package/lib/dependencies/CommonJsExportsParserPlugin.js +3 -3
  107. package/lib/dependencies/CommonJsImportsParserPlugin.js +8 -7
  108. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -1
  109. package/lib/dependencies/ContextDependencyHelpers.js +13 -6
  110. package/lib/dependencies/CssIcssExportDependency.js +15 -12
  111. package/lib/dependencies/CssIcssImportDependency.js +4 -1
  112. package/lib/dependencies/CssLocalIdentifierDependency.js +17 -14
  113. package/lib/dependencies/ExportsInfoDependency.js +6 -1
  114. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +5 -5
  115. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +22 -15
  116. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +23 -8
  117. package/lib/dependencies/HarmonyExportSpecifierDependency.js +2 -2
  118. package/lib/dependencies/HarmonyImportDependency.js +8 -6
  119. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -14
  120. package/lib/dependencies/HarmonyImportSpecifierDependency.js +5 -5
  121. package/lib/dependencies/ImportContextDependency.js +2 -1
  122. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -4
  123. package/lib/dependencies/JsonExportsDependency.js +24 -8
  124. package/lib/dependencies/LoaderPlugin.js +4 -14
  125. package/lib/dependencies/RequireContextDependency.js +2 -1
  126. package/lib/dependencies/RequireContextDependencyParserPlugin.js +6 -3
  127. package/lib/dependencies/RequireEnsureDependenciesBlock.js +3 -2
  128. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +11 -5
  129. package/lib/dependencies/RequireResolveContextDependency.js +1 -1
  130. package/lib/dependencies/WebAssemblyExportImportedDependency.js +1 -1
  131. package/lib/dependencies/WorkerDependency.js +6 -3
  132. package/lib/dependencies/WorkerPlugin.js +100 -41
  133. package/lib/esm/ModuleChunkFormatPlugin.js +5 -0
  134. package/lib/hmr/HotModuleReplacement.runtime.js +1 -0
  135. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +1 -0
  136. package/lib/hmr/LazyCompilationPlugin.js +32 -24
  137. package/lib/hmr/lazyCompilationBackend.js +1 -1
  138. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  139. package/lib/ids/HashedModuleIdsPlugin.js +2 -1
  140. package/lib/ids/IdHelpers.js +15 -14
  141. package/lib/ids/SyncModuleIdsPlugin.js +9 -5
  142. package/lib/index.js +5 -5
  143. package/lib/javascript/BasicEvaluatedExpression.js +6 -6
  144. package/lib/javascript/JavascriptGenerator.js +11 -1
  145. package/lib/javascript/JavascriptModulesPlugin.js +51 -31
  146. package/lib/javascript/JavascriptParser.js +272 -188
  147. package/lib/javascript/JavascriptParserHelpers.js +10 -9
  148. package/lib/javascript/StartupHelpers.js +4 -1
  149. package/lib/json/JsonData.js +4 -4
  150. package/lib/json/JsonGenerator.js +54 -22
  151. package/lib/json/JsonModulesPlugin.js +16 -2
  152. package/lib/json/JsonParser.js +8 -4
  153. package/lib/library/AbstractLibraryPlugin.js +7 -3
  154. package/lib/library/AssignLibraryPlugin.js +29 -1
  155. package/lib/library/EnableLibraryPlugin.js +7 -10
  156. package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
  157. package/lib/library/ModuleLibraryPlugin.js +121 -15
  158. package/lib/logging/Logger.js +2 -2
  159. package/lib/logging/createConsoleLogger.js +4 -4
  160. package/lib/node/NodeEnvironmentPlugin.js +6 -2
  161. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -2
  162. package/lib/node/ReadFileCompileWasmPlugin.js +1 -2
  163. package/lib/node/nodeConsole.js +3 -1
  164. package/lib/optimize/AggressiveSplittingPlugin.js +1 -1
  165. package/lib/optimize/ConcatenatedModule.js +19 -12
  166. package/lib/optimize/InnerGraph.js +3 -2
  167. package/lib/optimize/InnerGraphPlugin.js +13 -7
  168. package/lib/optimize/LimitChunkCountPlugin.js +20 -0
  169. package/lib/optimize/ModuleConcatenationPlugin.js +10 -7
  170. package/lib/optimize/RealContentHashPlugin.js +8 -4
  171. package/lib/optimize/SideEffectsFlagPlugin.js +4 -2
  172. package/lib/optimize/SplitChunksPlugin.js +87 -65
  173. package/lib/rules/BasicEffectRulePlugin.js +9 -1
  174. package/lib/rules/BasicMatcherRulePlugin.js +15 -4
  175. package/lib/rules/ObjectMatcherRulePlugin.js +12 -3
  176. package/lib/rules/RuleSetCompiler.js +25 -14
  177. package/lib/rules/UseEffectRulePlugin.js +47 -17
  178. package/lib/runtime/GetChunkFilenameRuntimeModule.js +6 -6
  179. package/lib/schemes/HttpUriPlugin.js +38 -17
  180. package/lib/serialization/BinaryMiddleware.js +52 -19
  181. package/lib/serialization/FileMiddleware.js +78 -48
  182. package/lib/serialization/ObjectMiddleware.js +78 -29
  183. package/lib/serialization/PlainObjectSerializer.js +1 -1
  184. package/lib/serialization/Serializer.js +15 -10
  185. package/lib/serialization/SerializerMiddleware.js +80 -41
  186. package/lib/serialization/SingleItemMiddleware.js +10 -7
  187. package/lib/serialization/types.js +1 -1
  188. package/lib/sharing/ConsumeSharedModule.js +4 -2
  189. package/lib/sharing/ProvideSharedModule.js +4 -2
  190. package/lib/sharing/ProvideSharedModuleFactory.js +5 -3
  191. package/lib/sharing/utils.js +2 -2
  192. package/lib/stats/DefaultStatsFactoryPlugin.js +80 -78
  193. package/lib/stats/DefaultStatsPresetPlugin.js +43 -23
  194. package/lib/stats/DefaultStatsPrinterPlugin.js +85 -43
  195. package/lib/stats/StatsFactory.js +11 -11
  196. package/lib/stats/StatsPrinter.js +7 -7
  197. package/lib/util/ArrayHelpers.js +2 -4
  198. package/lib/util/ArrayQueue.js +1 -1
  199. package/lib/util/AsyncQueue.js +4 -4
  200. package/lib/util/IterableHelpers.js +1 -1
  201. package/lib/util/LazyBucketSortedSet.js +41 -23
  202. package/lib/util/LazySet.js +3 -2
  203. package/lib/util/MapHelpers.js +1 -1
  204. package/lib/util/ParallelismFactorCalculator.js +1 -1
  205. package/lib/util/Semaphore.js +3 -3
  206. package/lib/util/SetHelpers.js +1 -1
  207. package/lib/util/SortableSet.js +9 -7
  208. package/lib/util/TupleQueue.js +9 -8
  209. package/lib/util/TupleSet.js +2 -2
  210. package/lib/util/WeakTupleMap.js +12 -11
  211. package/lib/util/binarySearchBounds.js +2 -1
  212. package/lib/util/cleverMerge.js +84 -54
  213. package/lib/util/comparators.js +22 -21
  214. package/lib/util/compileBooleanMatcher.js +3 -3
  215. package/lib/util/concatenate.js +6 -4
  216. package/lib/util/create-schema-validation.js +4 -4
  217. package/lib/util/createHash.js +2 -2
  218. package/lib/util/deprecation.js +35 -33
  219. package/lib/util/deterministicGrouping.js +6 -6
  220. package/lib/util/findGraphRoots.js +1 -1
  221. package/lib/util/fs.js +39 -39
  222. package/lib/util/hash/wasm-hash.js +2 -2
  223. package/lib/util/identifier.js +15 -18
  224. package/lib/util/makeSerializable.js +1 -1
  225. package/lib/util/memoize.js +4 -1
  226. package/lib/util/objectToMap.js +3 -2
  227. package/lib/util/processAsyncTree.js +2 -2
  228. package/lib/util/propertyName.js +0 -1
  229. package/lib/util/registerExternalSerializer.js +15 -18
  230. package/lib/util/removeBOM.js +25 -0
  231. package/lib/util/runtime.js +34 -27
  232. package/lib/util/serialization.js +5 -16
  233. package/lib/util/smartGrouping.js +3 -3
  234. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
  235. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +11 -0
  236. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +10 -0
  237. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -0
  238. package/lib/wasm-sync/WebAssemblyGenerator.js +28 -12
  239. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +10 -0
  240. package/lib/wasm-sync/WebAssemblyParser.js +9 -4
  241. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -0
  242. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +30 -25
  243. package/package.json +19 -17
  244. package/schemas/WebpackOptions.check.js +1 -1
  245. package/schemas/WebpackOptions.json +48 -13
  246. package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +7 -0
  247. package/schemas/plugins/JsonModulesPluginGenerator.check.js +6 -0
  248. package/schemas/plugins/JsonModulesPluginGenerator.json +11 -0
  249. package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
  250. package/types.d.ts +918 -615
  251. package/lib/library/ModernModuleLibraryPlugin.js +0 -144
package/lib/cli.js CHANGED
@@ -8,23 +8,25 @@
8
8
  const path = require("path");
9
9
  const webpackSchema = require("../schemas/WebpackOptions.json");
10
10
 
11
- /** @typedef {TODO & { absolutePath: boolean, instanceof: string, cli: { helper?: boolean, exclude?: boolean } }} Schema */
11
+ /** @typedef {Parameters<import("schema-utils").validate>[0] & { absolutePath: boolean, instanceof: string, cli: { helper?: boolean, exclude?: boolean, description?: string, negatedDescription?: string, resetDescription?: string } }} Schema */
12
12
 
13
13
  // TODO add originPath to PathItem for better errors
14
14
  /**
15
15
  * @typedef {object} PathItem
16
- * @property {any} schema the part of the schema
16
+ * @property {Schema} schema the part of the schema
17
17
  * @property {string} path the path in the config
18
18
  */
19
19
 
20
20
  /** @typedef {"unknown-argument" | "unexpected-non-array-in-path" | "unexpected-non-object-in-path" | "multiple-values-unexpected" | "invalid-value"} ProblemType */
21
21
 
22
+ /** @typedef {string | number | boolean | RegExp} Value */
23
+
22
24
  /**
23
25
  * @typedef {object} Problem
24
26
  * @property {ProblemType} type
25
27
  * @property {string} path
26
28
  * @property {string} argument
27
- * @property {any=} value
29
+ * @property {Value=} value
28
30
  * @property {number=} index
29
31
  * @property {string=} expected
30
32
  */
@@ -36,6 +38,10 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
36
38
  * @property {string=} expected
37
39
  */
38
40
 
41
+ /** @typedef {{ [key: string]: EnumValue }} EnumValueObject */
42
+ /** @typedef {EnumValue[]} EnumValueArray */
43
+ /** @typedef {string | number | boolean | EnumValueObject | EnumValueArray | null} EnumValue */
44
+
39
45
  /**
40
46
  * @typedef {object} ArgumentConfig
41
47
  * @property {string | undefined} description
@@ -43,7 +49,7 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
43
49
  * @property {string} path
44
50
  * @property {boolean} multiple
45
51
  * @property {"enum"|"string"|"path"|"number"|"boolean"|"RegExp"|"reset"} type
46
- * @property {any[]=} values
52
+ * @property {EnumValue[]=} values
47
53
  */
48
54
 
49
55
  /** @typedef {"string" | "number" | "boolean"} SimpleType */
@@ -56,8 +62,6 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
56
62
  * @property {ArgumentConfig[]} configs
57
63
  */
58
64
 
59
- /** @typedef {string | number | boolean | RegExp | (string | number | boolean | RegExp)} Value */
60
-
61
65
  /** @typedef {Record<string, Argument>} Flags */
62
66
 
63
67
  /**
@@ -93,7 +97,7 @@ const getArguments = (schema = webpackSchema) => {
93
97
  let schemaPart = schema;
94
98
 
95
99
  for (let i = 1; i < newPath.length; i++) {
96
- const inner = schemaPart[newPath[i]];
100
+ const inner = schemaPart[/** @type {keyof Schema} */ (newPath[i])];
97
101
 
98
102
  if (!inner) {
99
103
  break;
@@ -147,7 +151,7 @@ const getArguments = (schema = webpackSchema) => {
147
151
 
148
152
  /**
149
153
  * @param {Schema} schemaPart schema
150
- * @returns {Pick<ArgumentConfig, "type"|"values"> | undefined} partial argument config
154
+ * @returns {Pick<ArgumentConfig, "type" | "values"> | undefined} partial argument config
151
155
  */
152
156
  const schemaToArgumentConfig = schemaPart => {
153
157
  if (schemaPart.enum) {
@@ -272,7 +276,7 @@ const getArguments = (schema = webpackSchema) => {
272
276
  /**
273
277
  * @param {Schema} schemaPart the current schema
274
278
  * @param {string} schemaPath the current path in the schema
275
- * @param {{schema: object, path: string}[]} path all previous visited schemaParts
279
+ * @param {PathItem[]} path all previous visited schemaParts
276
280
  * @param {string | null} inArray if inside of an array, the path to the array
277
281
  * @returns {number} added arguments
278
282
  */
@@ -291,6 +295,7 @@ const getArguments = (schema = webpackSchema) => {
291
295
 
292
296
  if (schemaPart.cli && schemaPart.cli.exclude) return 0;
293
297
 
298
+ /** @type {PathItem[]} */
294
299
  const fullPath = [{ schema: schemaPart, path: schemaPath }, ...path];
295
300
 
296
301
  let addedArguments = 0;
@@ -423,7 +428,7 @@ const cliAddedItems = new WeakMap();
423
428
  * @param {Configuration} config configuration
424
429
  * @param {string} schemaPath path in the config
425
430
  * @param {number | undefined} index index of value when multiple values are provided, otherwise undefined
426
- * @returns {{ problem?: LocalProblem, object?: any, property?: Property, value?: any }} problem or object with property and value
431
+ * @returns {{ problem?: LocalProblem, object?: TODO, property?: Property, value?: EXPECTED_OBJECT | EXPECTED_ANY[] }} problem or object with property and value
427
432
  */
428
433
  const getObjectAndProperty = (config, schemaPath, index = 0) => {
429
434
  if (!schemaPath) return { value: config };
@@ -522,7 +527,7 @@ const getObjectAndProperty = (config, schemaPath, index = 0) => {
522
527
  /**
523
528
  * @param {Configuration} config configuration
524
529
  * @param {string} schemaPath path in the config
525
- * @param {any} value parsed value
530
+ * @param {ParsedValue} value parsed value
526
531
  * @param {number | undefined} index index of value when multiple values are provided, otherwise undefined
527
532
  * @returns {LocalProblem | null} problem or null for success
528
533
  */
@@ -587,10 +592,12 @@ const getExpectedValue = argConfig => {
587
592
  }
588
593
  };
589
594
 
595
+ /** @typedef {null | string | number | boolean | RegExp | EnumValue | []} ParsedValue */
596
+
590
597
  /**
591
598
  * @param {ArgumentConfig} argConfig processing instructions
592
599
  * @param {Value} value the value
593
- * @returns {any | undefined} parsed value
600
+ * @returns {ParsedValue | undefined} parsed value
594
601
  */
595
602
  const parseValueForArgumentConfig = (argConfig, value) => {
596
603
  switch (argConfig.type) {
@@ -627,9 +634,10 @@ const parseValueForArgumentConfig = (argConfig, value) => {
627
634
  break;
628
635
  case "enum": {
629
636
  const values =
630
- /** @type {NonNullable<ArgumentConfig["values"]>} */
637
+ /** @type {EnumValue[]} */
631
638
  (argConfig.values);
632
- if (values.includes(value)) return value;
639
+ if (values.includes(/** @type {Exclude<Value, RegExp>} */ (value)))
640
+ return value;
633
641
  for (const item of values) {
634
642
  if (`${item}` === value) return item;
635
643
  }
@@ -641,7 +649,7 @@ const parseValueForArgumentConfig = (argConfig, value) => {
641
649
  }
642
650
  };
643
651
 
644
- /** @typedef {any} Configuration */
652
+ /** @typedef {TODO} Configuration */
645
653
 
646
654
  /**
647
655
  * @param {Flags} args object of arguments
@@ -47,6 +47,7 @@ const {
47
47
  /** @typedef {import("../../declarations/WebpackOptions").GeneratorOptionsByModuleTypeKnown} GeneratorOptionsByModuleTypeKnown */
48
48
  /** @typedef {import("../../declarations/WebpackOptions").InfrastructureLogging} InfrastructureLogging */
49
49
  /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
50
+ /** @typedef {import("../../declarations/WebpackOptions").JsonGeneratorOptions} JsonGeneratorOptions */
50
51
  /** @typedef {import("../../declarations/WebpackOptions").Library} Library */
51
52
  /** @typedef {import("../../declarations/WebpackOptions").LibraryName} LibraryName */
52
53
  /** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
@@ -78,6 +79,10 @@ const {
78
79
 
79
80
  const NODE_MODULES_REGEXP = /[\\/]node_modules[\\/]/i;
80
81
  const DEFAULT_CACHE_NAME = "default";
82
+ const DEFAULTS = {
83
+ // TODO webpack 6 - use xxhash64
84
+ HASH_FUNCTION: "md4"
85
+ };
81
86
 
82
87
  /**
83
88
  * Sets a constant default value when undefined
@@ -100,7 +105,7 @@ const D = (obj, prop, value) => {
100
105
  * @template {keyof T} P
101
106
  * @param {T} obj an object
102
107
  * @param {P} prop a property of this object
103
- * @param {function(): T[P]} factory a default value factory for the property
108
+ * @param {() => T[P]} factory a default value factory for the property
104
109
  * @returns {void}
105
110
  */
106
111
  const F = (obj, prop, factory) => {
@@ -118,7 +123,7 @@ const F = (obj, prop, factory) => {
118
123
  * @template {keyof T} P
119
124
  * @param {T} obj an object
120
125
  * @param {P} prop a property of this object
121
- * @param {function(): T[P]} factory a default value factory for the property
126
+ * @param {() => T[P]} factory a default value factory for the property
122
127
  * @returns {void}
123
128
  */
124
129
  const A = (obj, prop, factory) => {
@@ -220,6 +225,7 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
220
225
  mode: mode || "production",
221
226
  development,
222
227
  cacheUnaffected: options.experiments.cacheUnaffected,
228
+ futureDefaults,
223
229
  compilerIndex
224
230
  });
225
231
  const cache = Boolean(options.cache);
@@ -261,7 +267,7 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
261
267
  (options.experiments.css),
262
268
  futureDefaults,
263
269
  isNode: targetProperties && targetProperties.node === true,
264
- uniqueName: options.output.uniqueName,
270
+ uniqueName: /** @type {string} */ (options.output.uniqueName),
265
271
  targetProperties,
266
272
  mode: options.mode
267
273
  });
@@ -397,6 +403,7 @@ const applyExperimentsDefaults = (
397
403
  * @param {object} options options
398
404
  * @param {string} options.name name
399
405
  * @param {Mode} options.mode mode
406
+ * @param {boolean} options.futureDefaults is future defaults enabled
400
407
  * @param {boolean} options.development is development mode
401
408
  * @param {number} [options.compilerIndex] index of compiler
402
409
  * @param {Experiments["cacheUnaffected"]} options.cacheUnaffected the cacheUnaffected experiment is enabled
@@ -404,7 +411,7 @@ const applyExperimentsDefaults = (
404
411
  */
405
412
  const applyCacheDefaults = (
406
413
  cache,
407
- { name, mode, development, cacheUnaffected, compilerIndex }
414
+ { name, mode, development, cacheUnaffected, compilerIndex, futureDefaults }
408
415
  ) => {
409
416
  if (cache === false) return;
410
417
  switch (cache.type) {
@@ -447,7 +454,7 @@ const applyCacheDefaults = (
447
454
  /** @type {NonNullable<FileCacheOptions["name"]>} */ (cache.name)
448
455
  )
449
456
  );
450
- D(cache, "hashAlgorithm", "md4");
457
+ D(cache, "hashAlgorithm", futureDefaults ? "xxhash64" : "md4");
451
458
  D(cache, "store", "pack");
452
459
  D(cache, "compression", false);
453
460
  D(cache, "profile", false);
@@ -581,6 +588,14 @@ const applyJavascriptParserOptionsDefaults = (
581
588
  if (futureDefaults) D(parserOptions, "exportsPresence", "error");
582
589
  };
583
590
 
591
+ /**
592
+ * @param {JsonGeneratorOptions} generatorOptions generator options
593
+ * @returns {void}
594
+ */
595
+ const applyJsonGeneratorOptionsDefaults = generatorOptions => {
596
+ D(generatorOptions, "JSONParse", true);
597
+ };
598
+
584
599
  /**
585
600
  * @param {CssGeneratorOptions} generatorOptions generator options
586
601
  * @param {object} options options
@@ -610,7 +625,7 @@ const applyCssGeneratorOptionsDefaults = (
610
625
  * @param {string} options.uniqueName the unique name
611
626
  * @param {boolean} options.isNode is node target platform
612
627
  * @param {TargetProperties | false} options.targetProperties target properties
613
- * @param {Mode} options.mode mode
628
+ * @param {Mode | undefined} options.mode mode
614
629
  * @returns {void}
615
630
  */
616
631
  const applyModuleDefaults = (
@@ -646,19 +661,19 @@ const applyModuleDefaults = (
646
661
 
647
662
  F(module.parser, ASSET_MODULE_TYPE, () => ({}));
648
663
  F(
649
- /** @type {NonNullable<ParserOptionsByModuleTypeKnown["asset"]>} */
664
+ /** @type {NonNullable<ParserOptionsByModuleTypeKnown[ASSET_MODULE_TYPE]>} */
650
665
  (module.parser[ASSET_MODULE_TYPE]),
651
666
  "dataUrlCondition",
652
667
  () => ({})
653
668
  );
654
669
  if (
655
670
  typeof (
656
- /** @type {NonNullable<ParserOptionsByModuleTypeKnown["asset"]>} */
671
+ /** @type {NonNullable<ParserOptionsByModuleTypeKnown[ASSET_MODULE_TYPE]>} */
657
672
  (module.parser[ASSET_MODULE_TYPE]).dataUrlCondition
658
673
  ) === "object"
659
674
  ) {
660
675
  D(
661
- /** @type {NonNullable<ParserOptionsByModuleTypeKnown["asset"]>} */
676
+ /** @type {NonNullable<ParserOptionsByModuleTypeKnown[ASSET_MODULE_TYPE]>} */
662
677
  (module.parser[ASSET_MODULE_TYPE]).dataUrlCondition,
663
678
  "maxSize",
664
679
  8096
@@ -682,17 +697,38 @@ const applyModuleDefaults = (
682
697
  }
683
698
  );
684
699
 
700
+ F(module.generator, "json", () => ({}));
701
+ applyJsonGeneratorOptionsDefaults(
702
+ /** @type {NonNullable<GeneratorOptionsByModuleTypeKnown["json"]>} */
703
+ (module.generator.json)
704
+ );
705
+
685
706
  if (css) {
686
707
  F(module.parser, CSS_MODULE_TYPE, () => ({}));
687
708
 
688
- D(module.parser[CSS_MODULE_TYPE], "import", true);
689
- D(module.parser[CSS_MODULE_TYPE], "url", true);
690
- D(module.parser[CSS_MODULE_TYPE], "namedExports", true);
709
+ D(
710
+ /** @type {NonNullable<ParserOptionsByModuleTypeKnown[CSS_MODULE_TYPE]>} */
711
+ (module.parser[CSS_MODULE_TYPE]),
712
+ "import",
713
+ true
714
+ );
715
+ D(
716
+ /** @type {NonNullable<ParserOptionsByModuleTypeKnown[CSS_MODULE_TYPE]>} */
717
+ (module.parser[CSS_MODULE_TYPE]),
718
+ "url",
719
+ true
720
+ );
721
+ D(
722
+ /** @type {NonNullable<ParserOptionsByModuleTypeKnown[CSS_MODULE_TYPE]>} */
723
+ (module.parser[CSS_MODULE_TYPE]),
724
+ "namedExports",
725
+ true
726
+ );
691
727
 
692
728
  F(module.generator, CSS_MODULE_TYPE, () => ({}));
693
729
 
694
730
  applyCssGeneratorOptionsDefaults(
695
- /** @type {NonNullable<GeneratorOptionsByModuleTypeKnown["css"]>} */
731
+ /** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE]>} */
696
732
  (module.generator[CSS_MODULE_TYPE]),
697
733
  { targetProperties }
698
734
  );
@@ -701,24 +737,46 @@ const applyModuleDefaults = (
701
737
  uniqueName.length > 0 ? "[uniqueName]-[id]-[local]" : "[id]-[local]";
702
738
 
703
739
  F(module.generator, CSS_MODULE_TYPE_AUTO, () => ({}));
704
- D(module.generator[CSS_MODULE_TYPE_AUTO], "localIdentName", localIdentName);
705
- D(module.generator[CSS_MODULE_TYPE_AUTO], "exportsConvention", "as-is");
740
+ D(
741
+ /** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_AUTO]>} */
742
+ (module.generator[CSS_MODULE_TYPE_AUTO]),
743
+ "localIdentName",
744
+ localIdentName
745
+ );
746
+ D(
747
+ /** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_AUTO]>} */
748
+ (module.generator[CSS_MODULE_TYPE_AUTO]),
749
+ "exportsConvention",
750
+ "as-is"
751
+ );
706
752
 
707
753
  F(module.generator, CSS_MODULE_TYPE_MODULE, () => ({}));
708
754
  D(
709
- module.generator[CSS_MODULE_TYPE_MODULE],
755
+ /** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]>} */
756
+ (module.generator[CSS_MODULE_TYPE_MODULE]),
710
757
  "localIdentName",
711
758
  localIdentName
712
759
  );
713
- D(module.generator[CSS_MODULE_TYPE_MODULE], "exportsConvention", "as-is");
760
+ D(
761
+ /** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]>} */
762
+ (module.generator[CSS_MODULE_TYPE_MODULE]),
763
+ "exportsConvention",
764
+ "as-is"
765
+ );
714
766
 
715
767
  F(module.generator, CSS_MODULE_TYPE_GLOBAL, () => ({}));
716
768
  D(
717
- module.generator[CSS_MODULE_TYPE_GLOBAL],
769
+ /** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_GLOBAL]>} */
770
+ (module.generator[CSS_MODULE_TYPE_GLOBAL]),
718
771
  "localIdentName",
719
772
  localIdentName
720
773
  );
721
- D(module.generator[CSS_MODULE_TYPE_GLOBAL], "exportsConvention", "as-is");
774
+ D(
775
+ /** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_GLOBAL]>} */
776
+ (module.generator[CSS_MODULE_TYPE_GLOBAL]),
777
+ "exportsConvention",
778
+ "as-is"
779
+ );
722
780
  }
723
781
 
724
782
  A(module, "defaultRules", () => {
@@ -1225,7 +1283,14 @@ const applyOutputDefaults = (
1225
1283
  );
1226
1284
  D(output, "workerPublicPath", "");
1227
1285
  D(output, "chunkLoadTimeout", 120000);
1228
- D(output, "hashFunction", futureDefaults ? "xxhash64" : "md4");
1286
+ F(output, "hashFunction", () => {
1287
+ if (futureDefaults) {
1288
+ DEFAULTS.HASH_FUNCTION = "xxhash64";
1289
+ return "xxhash64";
1290
+ }
1291
+
1292
+ return "md4";
1293
+ });
1229
1294
  D(output, "hashDigest", "hex");
1230
1295
  D(output, "hashDigestLength", futureDefaults ? 16 : 20);
1231
1296
  D(output, "strictModuleErrorHandling", false);
@@ -1244,7 +1309,7 @@ const applyOutputDefaults = (
1244
1309
  }
1245
1310
 
1246
1311
  /**
1247
- * @param {function(EntryDescription): void} fn iterator
1312
+ * @param {(entryDescription: EntryDescription) => void} fn iterator
1248
1313
  * @returns {void}
1249
1314
  */
1250
1315
  const forEachEntry = fn => {
@@ -1486,7 +1551,7 @@ const applyOptimizationDefaults = (
1486
1551
  passes: 2
1487
1552
  }
1488
1553
  }
1489
- }).apply(compiler);
1554
+ }).apply(/** @type {TODO} */ (compiler));
1490
1555
  }
1491
1556
  }
1492
1557
  ]);
@@ -1563,14 +1628,14 @@ const getResolveDefaults = ({
1563
1628
  const browserField =
1564
1629
  tp && tp.web && (!tp.node || (tp.electron && tp.electronRenderer));
1565
1630
 
1566
- /** @type {function(): ResolveOptions} */
1631
+ /** @type {() => ResolveOptions} */
1567
1632
  const cjsDeps = () => ({
1568
1633
  aliasFields: browserField ? ["browser"] : [],
1569
1634
  mainFields: browserField ? ["browser", "module", "..."] : ["module", "..."],
1570
1635
  conditionNames: ["require", "module", "..."],
1571
1636
  extensions: [...jsExtensions]
1572
1637
  });
1573
- /** @type {function(): ResolveOptions} */
1638
+ /** @type {() => ResolveOptions} */
1574
1639
  const esmDeps = () => ({
1575
1640
  aliasFields: browserField ? ["browser"] : [],
1576
1641
  mainFields: browserField ? ["browser", "module", "..."] : ["module", "..."],
@@ -1619,7 +1684,8 @@ const getResolveDefaults = ({
1619
1684
  styleConditions.push(mode === "development" ? "development" : "production");
1620
1685
  styleConditions.push("style");
1621
1686
 
1622
- resolveOptions.byDependency["css-import"] = {
1687
+ /** @type {NonNullable<ResolveOptions["byDependency"]>} */
1688
+ (resolveOptions.byDependency)["css-import"] = {
1623
1689
  // We avoid using any main files because we have to be consistent with CSS `@import`
1624
1690
  // and CSS `@import` does not handle `main` files in directories,
1625
1691
  // you should always specify the full URL for styles
@@ -1660,7 +1726,7 @@ const getResolveLoaderDefaults = ({ cache }) => {
1660
1726
  const applyInfrastructureLoggingDefaults = infrastructureLogging => {
1661
1727
  F(infrastructureLogging, "stream", () => process.stderr);
1662
1728
  const tty =
1663
- /** @type {any} */ (infrastructureLogging.stream).isTTY &&
1729
+ /** @type {EXPECTED_ANY} */ (infrastructureLogging.stream).isTTY &&
1664
1730
  process.env.TERM !== "dumb";
1665
1731
  D(infrastructureLogging, "level", "info");
1666
1732
  D(infrastructureLogging, "debug", false);
@@ -1671,3 +1737,4 @@ const applyInfrastructureLoggingDefaults = infrastructureLogging => {
1671
1737
  module.exports.applyWebpackOptionsBaseDefaults =
1672
1738
  applyWebpackOptionsBaseDefaults;
1673
1739
  module.exports.applyWebpackOptionsDefaults = applyWebpackOptionsDefaults;
1740
+ module.exports.DEFAULTS = DEFAULTS;
@@ -44,8 +44,8 @@ const handledDeprecatedNoEmitOnErrors = util.deprecate(
44
44
  /**
45
45
  * @template T
46
46
  * @template R
47
- * @param {T|undefined} value value or not
48
- * @param {function(T): R} fn nested handler
47
+ * @param {T | undefined} value value or not
48
+ * @param {(value: T) => R} fn nested handler
49
49
  * @returns {R} result value
50
50
  */
51
51
  const nestedConfig = (value, fn) =>
@@ -60,9 +60,9 @@ const cloneObject = value => /** @type {T} */ ({ ...value });
60
60
  /**
61
61
  * @template T
62
62
  * @template R
63
- * @param {T|undefined} value value or not
64
- * @param {function(T): R} fn nested handler
65
- * @returns {R|undefined} result value
63
+ * @param {T | undefined} value value or not
64
+ * @param {(value: T) => R} fn nested handler
65
+ * @returns {R | undefined} result value
66
66
  */
67
67
  const optionalNestedConfig = (value, fn) =>
68
68
  value === undefined ? undefined : fn(value);
@@ -70,18 +70,18 @@ const optionalNestedConfig = (value, fn) =>
70
70
  /**
71
71
  * @template T
72
72
  * @template R
73
- * @param {T[]|undefined} value array or not
74
- * @param {function(T[]): R[]} fn nested handler
75
- * @returns {R[]|undefined} cloned value
73
+ * @param {T[] | undefined} value array or not
74
+ * @param {(value: T[]) => R[]} fn nested handler
75
+ * @returns {R[] | undefined} cloned value
76
76
  */
77
77
  const nestedArray = (value, fn) => (Array.isArray(value) ? fn(value) : fn([]));
78
78
 
79
79
  /**
80
80
  * @template T
81
81
  * @template R
82
- * @param {T[]|undefined} value array or not
83
- * @param {function(T[]): R[]} fn nested handler
84
- * @returns {R[]|undefined} cloned value
82
+ * @param {T[] | undefined} value array or not
83
+ * @param {(value: T[]) => R[]} fn nested handler
84
+ * @returns {R[] | undefined} cloned value
85
85
  */
86
86
  const optionalNestedArray = (value, fn) =>
87
87
  Array.isArray(value) ? fn(value) : undefined;
@@ -90,8 +90,8 @@ const optionalNestedArray = (value, fn) =>
90
90
  * @template T
91
91
  * @template R
92
92
  * @param {Record<string, T>|undefined} value value or not
93
- * @param {function(T): R} fn nested handler
94
- * @param {Record<string, function(T): R>=} customKeys custom nested handler for some keys
93
+ * @param {(value: T) => R} fn nested handler
94
+ * @param {Record<string, (value: T) => R>=} customKeys custom nested handler for some keys
95
95
  * @returns {Record<string, R>} result value
96
96
  */
97
97
  const keyedNestedConfig = (value, fn, customKeys) => {
@@ -346,6 +346,7 @@ const getNormalizedWebpackOptions = config => ({
346
346
  importFunctionName: output.importFunctionName,
347
347
  importMetaName: output.importMetaName,
348
348
  scriptType: output.scriptType,
349
+ // TODO webpack6 remove `libraryTarget`/`auxiliaryComment`/`amdContainer`/etc in favor of the `library` option
349
350
  library: libraryBase && {
350
351
  type:
351
352
  output.libraryTarget !== undefined
@@ -22,12 +22,12 @@ const getDefaultTarget = context => {
22
22
 
23
23
  /**
24
24
  * @typedef {object} PlatformTargetProperties
25
- * @property {boolean | null} web web platform, importing of http(s) and std: is available
26
- * @property {boolean | null} browser browser platform, running in a normal web browser
27
- * @property {boolean | null} webworker (Web)Worker platform, running in a web/shared/service worker
28
- * @property {boolean | null} node node platform, require of node built-in modules is available
29
- * @property {boolean | null} nwjs nwjs platform, require of legacy nw.gui is available
30
- * @property {boolean | null} electron electron platform, require of some electron built-in modules is available
25
+ * @property {boolean | null} [web] web platform, importing of http(s) and std: is available
26
+ * @property {boolean | null} [browser] browser platform, running in a normal web browser
27
+ * @property {boolean | null} [webworker] (Web)Worker platform, running in a web/shared/service worker
28
+ * @property {boolean | null} [node] node platform, require of node built-in modules is available
29
+ * @property {boolean | null} [nwjs] nwjs platform, require of legacy nw.gui is available
30
+ * @property {boolean | null} [electron] electron platform, require of some electron built-in modules is available
31
31
  */
32
32
 
33
33
  /**
@@ -341,7 +341,7 @@ const mergeTargetProperties = targetProperties => {
341
341
  keys.add(/** @type {keyof TargetProperties} */ (key));
342
342
  }
343
343
  }
344
- /** @type {object} */
344
+ /** @type {TargetProperties} */
345
345
  const result = {};
346
346
  for (const key of keys) {
347
347
  let hasTrue = false;
@@ -361,7 +361,7 @@ const mergeTargetProperties = targetProperties => {
361
361
  /** @type {TargetProperties} */
362
362
  (result)[key] = hasFalse && hasTrue ? null : Boolean(hasTrue);
363
363
  }
364
- return /** @type {TargetProperties} */ (result);
364
+ return result;
365
365
  };
366
366
 
367
367
  /**
@@ -20,9 +20,11 @@ const ContainerExposedDependency = require("./ContainerExposedDependency");
20
20
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
21
21
  /** @typedef {import("../ChunkGroup")} ChunkGroup */
22
22
  /** @typedef {import("../Compilation")} Compilation */
23
+ /** @typedef {import("../Module").BuildCallback} BuildCallback */
23
24
  /** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
24
25
  /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
25
26
  /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
27
+ /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
26
28
  /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
27
29
  /** @typedef {import("../Module").SourceTypes} SourceTypes */
28
30
  /** @typedef {import("../RequestShortener")} RequestShortener */
@@ -91,7 +93,7 @@ class ContainerEntryModule extends Module {
91
93
 
92
94
  /**
93
95
  * @param {NeedBuildContext} context context info
94
- * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
96
+ * @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
95
97
  * @returns {void}
96
98
  */
97
99
  needBuild(context, callback) {
@@ -103,7 +105,7 @@ class ContainerEntryModule extends Module {
103
105
  * @param {Compilation} compilation the compilation
104
106
  * @param {ResolverWithOptions} resolver the resolver
105
107
  * @param {InputFileSystem} fs the file system
106
- * @param {function(WebpackError=): void} callback callback function
108
+ * @param {BuildCallback} callback callback function
107
109
  * @returns {void}
108
110
  */
109
111
  build(options, compilation, resolver, fs, callback) {
@@ -8,14 +8,14 @@
8
8
  const ModuleFactory = require("../ModuleFactory");
9
9
  const ContainerEntryModule = require("./ContainerEntryModule");
10
10
 
11
+ /** @typedef {import("../ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
11
12
  /** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
12
- /** @typedef {import("../ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
13
13
  /** @typedef {import("./ContainerEntryDependency")} ContainerEntryDependency */
14
14
 
15
15
  module.exports = class ContainerEntryModuleFactory extends ModuleFactory {
16
16
  /**
17
17
  * @param {ModuleFactoryCreateData} data data object
18
- * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
18
+ * @param {ModuleFactoryCallback} callback callback
19
19
  * @returns {void}
20
20
  */
21
21
  create({ dependencies: [dependency] }, callback) {
@@ -19,9 +19,11 @@ const FallbackItemDependency = require("./FallbackItemDependency");
19
19
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
20
20
  /** @typedef {import("../ChunkGroup")} ChunkGroup */
21
21
  /** @typedef {import("../Compilation")} Compilation */
22
+ /** @typedef {import("../Module").BuildCallback} BuildCallback */
22
23
  /** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
23
24
  /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
24
25
  /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
26
+ /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
25
27
  /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
26
28
  /** @typedef {import("../Module").SourceTypes} SourceTypes */
27
29
  /** @typedef {import("../RequestShortener")} RequestShortener */
@@ -80,7 +82,7 @@ class FallbackModule extends Module {
80
82
 
81
83
  /**
82
84
  * @param {NeedBuildContext} context context info
83
- * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
85
+ * @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
84
86
  * @returns {void}
85
87
  */
86
88
  needBuild(context, callback) {
@@ -92,7 +94,7 @@ class FallbackModule extends Module {
92
94
  * @param {Compilation} compilation the compilation
93
95
  * @param {ResolverWithOptions} resolver the resolver
94
96
  * @param {InputFileSystem} fs the file system
95
- * @param {function(WebpackError=): void} callback callback function
97
+ * @param {BuildCallback} callback callback function
96
98
  * @returns {void}
97
99
  */
98
100
  build(options, compilation, resolver, fs, callback) {
@@ -8,14 +8,14 @@
8
8
  const ModuleFactory = require("../ModuleFactory");
9
9
  const FallbackModule = require("./FallbackModule");
10
10
 
11
+ /** @typedef {import("../ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
11
12
  /** @typedef {import("../ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
12
- /** @typedef {import("../ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
13
13
  /** @typedef {import("./FallbackDependency")} FallbackDependency */
14
14
 
15
15
  module.exports = class FallbackModuleFactory extends ModuleFactory {
16
16
  /**
17
17
  * @param {ModuleFactoryCreateData} data data object
18
- * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
18
+ * @param {ModuleFactoryCallback} callback callback
19
19
  * @returns {void}
20
20
  */
21
21
  create({ dependencies: [dependency] }, callback) {
@@ -20,9 +20,11 @@ const RemoteToExternalDependency = require("./RemoteToExternalDependency");
20
20
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
21
21
  /** @typedef {import("../ChunkGroup")} ChunkGroup */
22
22
  /** @typedef {import("../Compilation")} Compilation */
23
+ /** @typedef {import("../Module").BuildCallback} BuildCallback */
23
24
  /** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
24
25
  /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
25
26
  /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
27
+ /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
26
28
  /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
27
29
  /** @typedef {import("../Module").SourceTypes} SourceTypes */
28
30
  /** @typedef {import("../RequestShortener")} RequestShortener */
@@ -80,7 +82,7 @@ class RemoteModule extends Module {
80
82
 
81
83
  /**
82
84
  * @param {NeedBuildContext} context context info
83
- * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
85
+ * @param {NeedBuildCallback} callback callback function, returns true, if the module needs a rebuild
84
86
  * @returns {void}
85
87
  */
86
88
  needBuild(context, callback) {
@@ -92,7 +94,7 @@ class RemoteModule extends Module {
92
94
  * @param {Compilation} compilation the compilation
93
95
  * @param {ResolverWithOptions} resolver the resolver
94
96
  * @param {InputFileSystem} fs the file system
95
- * @param {function(WebpackError=): void} callback callback function
97
+ * @param {BuildCallback} callback callback function
96
98
  * @returns {void}
97
99
  */
98
100
  build(options, compilation, resolver, fs, callback) {