webpack 5.97.1 → 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 (262) hide show
  1. package/README.md +345 -392
  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 +343 -167
  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 +44 -21
  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 +21 -39
  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 +52 -10
  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 +104 -28
  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/CssLoadingRuntimeModule.js +5 -2
  96. package/lib/css/CssModulesPlugin.js +41 -9
  97. package/lib/css/CssParser.js +37 -17
  98. package/lib/css/walkCssTokens.js +17 -17
  99. package/lib/debug/ProfilingPlugin.js +98 -38
  100. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +10 -4
  101. package/lib/dependencies/AMDPlugin.js +5 -2
  102. package/lib/dependencies/AMDRequireArrayDependency.js +4 -3
  103. package/lib/dependencies/AMDRequireContextDependency.js +2 -1
  104. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +15 -7
  105. package/lib/dependencies/AMDRuntimeModules.js +3 -1
  106. package/lib/dependencies/CommonJsExportRequireDependency.js +4 -5
  107. package/lib/dependencies/CommonJsExportsParserPlugin.js +3 -3
  108. package/lib/dependencies/CommonJsImportsParserPlugin.js +38 -7
  109. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -1
  110. package/lib/dependencies/ContextDependencyHelpers.js +13 -6
  111. package/lib/dependencies/CssIcssExportDependency.js +15 -12
  112. package/lib/dependencies/CssIcssImportDependency.js +4 -1
  113. package/lib/dependencies/CssLocalIdentifierDependency.js +18 -15
  114. package/lib/dependencies/ExportsInfoDependency.js +6 -1
  115. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +5 -5
  116. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +22 -15
  117. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +23 -8
  118. package/lib/dependencies/HarmonyExportSpecifierDependency.js +2 -2
  119. package/lib/dependencies/HarmonyImportDependency.js +8 -6
  120. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -14
  121. package/lib/dependencies/HarmonyImportSpecifierDependency.js +5 -5
  122. package/lib/dependencies/ImportContextDependency.js +2 -1
  123. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -4
  124. package/lib/dependencies/JsonExportsDependency.js +49 -27
  125. package/lib/dependencies/LoaderPlugin.js +4 -14
  126. package/lib/dependencies/RequireContextDependency.js +2 -1
  127. package/lib/dependencies/RequireContextDependencyParserPlugin.js +6 -3
  128. package/lib/dependencies/RequireEnsureDependenciesBlock.js +3 -2
  129. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +11 -5
  130. package/lib/dependencies/RequireResolveContextDependency.js +1 -1
  131. package/lib/dependencies/WebAssemblyExportImportedDependency.js +1 -1
  132. package/lib/dependencies/WorkerDependency.js +6 -3
  133. package/lib/dependencies/WorkerPlugin.js +100 -41
  134. package/lib/esm/ModuleChunkFormatPlugin.js +5 -0
  135. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +3 -2
  136. package/lib/hmr/HotModuleReplacement.runtime.js +1 -0
  137. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +1 -0
  138. package/lib/hmr/LazyCompilationPlugin.js +32 -24
  139. package/lib/hmr/lazyCompilationBackend.js +1 -1
  140. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  141. package/lib/ids/HashedModuleIdsPlugin.js +2 -1
  142. package/lib/ids/IdHelpers.js +15 -14
  143. package/lib/ids/SyncModuleIdsPlugin.js +9 -5
  144. package/lib/index.js +5 -5
  145. package/lib/javascript/BasicEvaluatedExpression.js +6 -6
  146. package/lib/javascript/JavascriptGenerator.js +11 -1
  147. package/lib/javascript/JavascriptModulesPlugin.js +54 -34
  148. package/lib/javascript/JavascriptParser.js +272 -188
  149. package/lib/javascript/JavascriptParserHelpers.js +10 -9
  150. package/lib/javascript/StartupHelpers.js +4 -1
  151. package/lib/json/JsonData.js +4 -4
  152. package/lib/json/JsonGenerator.js +54 -22
  153. package/lib/json/JsonModulesPlugin.js +16 -3
  154. package/lib/json/JsonParser.js +10 -4
  155. package/lib/library/AbstractLibraryPlugin.js +7 -3
  156. package/lib/library/AssignLibraryPlugin.js +29 -1
  157. package/lib/library/EnableLibraryPlugin.js +7 -10
  158. package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
  159. package/lib/library/ModuleLibraryPlugin.js +121 -15
  160. package/lib/logging/Logger.js +2 -2
  161. package/lib/logging/createConsoleLogger.js +4 -4
  162. package/lib/node/NodeEnvironmentPlugin.js +6 -2
  163. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -2
  164. package/lib/node/ReadFileCompileWasmPlugin.js +1 -2
  165. package/lib/node/nodeConsole.js +3 -1
  166. package/lib/optimize/AggressiveSplittingPlugin.js +1 -1
  167. package/lib/optimize/ConcatenatedModule.js +19 -12
  168. package/lib/optimize/InnerGraph.js +3 -2
  169. package/lib/optimize/InnerGraphPlugin.js +13 -7
  170. package/lib/optimize/LimitChunkCountPlugin.js +20 -0
  171. package/lib/optimize/ModuleConcatenationPlugin.js +10 -7
  172. package/lib/optimize/RealContentHashPlugin.js +8 -4
  173. package/lib/optimize/SideEffectsFlagPlugin.js +4 -2
  174. package/lib/optimize/SplitChunksPlugin.js +90 -65
  175. package/lib/rules/BasicEffectRulePlugin.js +9 -1
  176. package/lib/rules/BasicMatcherRulePlugin.js +15 -4
  177. package/lib/rules/ObjectMatcherRulePlugin.js +12 -3
  178. package/lib/rules/RuleSetCompiler.js +25 -14
  179. package/lib/rules/UseEffectRulePlugin.js +47 -17
  180. package/lib/runtime/AutoPublicPathRuntimeModule.js +1 -1
  181. package/lib/runtime/GetChunkFilenameRuntimeModule.js +6 -6
  182. package/lib/schemes/HttpUriPlugin.js +38 -17
  183. package/lib/serialization/BinaryMiddleware.js +52 -19
  184. package/lib/serialization/FileMiddleware.js +78 -48
  185. package/lib/serialization/ObjectMiddleware.js +78 -29
  186. package/lib/serialization/PlainObjectSerializer.js +1 -1
  187. package/lib/serialization/Serializer.js +15 -10
  188. package/lib/serialization/SerializerMiddleware.js +80 -41
  189. package/lib/serialization/SingleItemMiddleware.js +10 -7
  190. package/lib/serialization/types.js +1 -1
  191. package/lib/sharing/ConsumeSharedModule.js +4 -2
  192. package/lib/sharing/ProvideSharedModule.js +4 -2
  193. package/lib/sharing/ProvideSharedModuleFactory.js +5 -3
  194. package/lib/sharing/utils.js +2 -2
  195. package/lib/stats/DefaultStatsFactoryPlugin.js +81 -79
  196. package/lib/stats/DefaultStatsPresetPlugin.js +43 -23
  197. package/lib/stats/DefaultStatsPrinterPlugin.js +85 -43
  198. package/lib/stats/StatsFactory.js +11 -11
  199. package/lib/stats/StatsPrinter.js +7 -7
  200. package/lib/util/ArrayHelpers.js +2 -4
  201. package/lib/util/ArrayQueue.js +1 -1
  202. package/lib/util/AsyncQueue.js +4 -4
  203. package/lib/util/IterableHelpers.js +1 -1
  204. package/lib/util/LazyBucketSortedSet.js +41 -23
  205. package/lib/util/LazySet.js +3 -2
  206. package/lib/util/MapHelpers.js +1 -1
  207. package/lib/util/ParallelismFactorCalculator.js +1 -1
  208. package/lib/util/Semaphore.js +3 -3
  209. package/lib/util/SetHelpers.js +1 -1
  210. package/lib/util/SortableSet.js +9 -7
  211. package/lib/util/TupleQueue.js +9 -8
  212. package/lib/util/TupleSet.js +2 -2
  213. package/lib/util/WeakTupleMap.js +12 -11
  214. package/lib/util/binarySearchBounds.js +2 -1
  215. package/lib/util/cleverMerge.js +84 -54
  216. package/lib/util/comparators.js +22 -21
  217. package/lib/util/compileBooleanMatcher.js +3 -3
  218. package/lib/util/concatenate.js +6 -4
  219. package/lib/util/create-schema-validation.js +4 -4
  220. package/lib/util/createHash.js +2 -2
  221. package/lib/util/deprecation.js +35 -33
  222. package/lib/util/deterministicGrouping.js +6 -6
  223. package/lib/util/findGraphRoots.js +1 -1
  224. package/lib/util/fs.js +39 -39
  225. package/lib/util/hash/wasm-hash.js +2 -2
  226. package/lib/util/identifier.js +15 -18
  227. package/lib/util/makeSerializable.js +1 -1
  228. package/lib/util/memoize.js +4 -1
  229. package/lib/util/objectToMap.js +3 -2
  230. package/lib/util/processAsyncTree.js +2 -2
  231. package/lib/util/propertyName.js +0 -1
  232. package/lib/util/registerExternalSerializer.js +15 -18
  233. package/lib/util/removeBOM.js +25 -0
  234. package/lib/util/runtime.js +34 -27
  235. package/lib/util/semver.js +18 -8
  236. package/lib/util/serialization.js +5 -16
  237. package/lib/util/smartGrouping.js +3 -3
  238. package/lib/validateSchema.js +4 -7
  239. package/lib/wasm/EnableWasmLoadingPlugin.js +2 -2
  240. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
  241. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +11 -0
  242. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +10 -0
  243. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -2
  244. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -0
  245. package/lib/wasm-sync/WebAssemblyGenerator.js +28 -12
  246. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +10 -0
  247. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
  248. package/lib/wasm-sync/WebAssemblyParser.js +9 -4
  249. package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -2
  250. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -0
  251. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +30 -25
  252. package/package.json +27 -26
  253. package/schemas/WebpackOptions.check.js +1 -1
  254. package/schemas/WebpackOptions.json +48 -13
  255. package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +7 -0
  256. package/schemas/plugins/JsonModulesPluginGenerator.check.js +6 -0
  257. package/schemas/plugins/JsonModulesPluginGenerator.json +11 -0
  258. package/schemas/plugins/JsonModulesPluginParser.check.js +1 -1
  259. package/schemas/plugins/JsonModulesPluginParser.json +4 -0
  260. package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
  261. package/types.d.ts +888 -583
  262. package/lib/library/ModernModuleLibraryPlugin.js +0 -144
@@ -8,6 +8,7 @@
8
8
  const { ConcatSource } = require("webpack-sources");
9
9
  const RuntimeGlobals = require("../RuntimeGlobals");
10
10
  const Template = require("../Template");
11
+ const ConcatenatedModule = require("../optimize/ConcatenatedModule");
11
12
  const propertyAccess = require("../util/propertyAccess");
12
13
  const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
13
14
 
@@ -18,9 +19,14 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
18
19
  /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */
19
20
  /** @typedef {import("../Compiler")} Compiler */
20
21
  /** @typedef {import("../Module")} Module */
22
+ /** @typedef {import("../Module").BuildMeta} BuildMeta */
21
23
  /** @typedef {import("../javascript/JavascriptModulesPlugin").StartupRenderContext} StartupRenderContext */
22
24
  /** @typedef {import("../util/Hash")} Hash */
23
- /** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */
25
+
26
+ /**
27
+ * @template T
28
+ * @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T>
29
+ */
24
30
 
25
31
  /**
26
32
  * @typedef {object} ModuleLibraryPluginOptions
@@ -30,6 +36,7 @@ const AbstractLibraryPlugin = require("./AbstractLibraryPlugin");
30
36
  /**
31
37
  * @typedef {object} ModuleLibraryPluginParsed
32
38
  * @property {string} name
39
+ * @property {string | string[]=} export
33
40
  */
34
41
 
35
42
  /**
@@ -47,6 +54,45 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
47
54
  });
48
55
  }
49
56
 
57
+ /**
58
+ * Apply the plugin
59
+ * @param {Compiler} compiler the compiler instance
60
+ * @returns {void}
61
+ */
62
+ apply(compiler) {
63
+ super.apply(compiler);
64
+
65
+ compiler.hooks.compilation.tap("ModernModuleLibraryPlugin", compilation => {
66
+ const { exportsDefinitions } =
67
+ ConcatenatedModule.getCompilationHooks(compilation);
68
+ exportsDefinitions.tap(
69
+ "ModernModuleLibraryPlugin",
70
+ (definitions, module) => {
71
+ // If we have connections not all modules were concatenated, so we need the wrapper
72
+ const connections =
73
+ compilation.moduleGraph.getIncomingConnections(module);
74
+
75
+ for (const connection of connections) {
76
+ if (connection.originModule) {
77
+ return false;
78
+ }
79
+ }
80
+
81
+ // Runtime and splitting chunks now requires the wrapper too
82
+ for (const chunk of compilation.chunkGraph.getModuleChunksIterable(
83
+ module
84
+ )) {
85
+ if (!chunk.hasRuntime()) {
86
+ return false;
87
+ }
88
+ }
89
+
90
+ return true;
91
+ }
92
+ );
93
+ });
94
+ }
95
+
50
96
  /**
51
97
  * @param {LibraryOptions} library normalized library option
52
98
  * @returns {T | false} preprocess as needed by overriding
@@ -60,7 +106,8 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
60
106
  }
61
107
  const _name = /** @type {string} */ (name);
62
108
  return {
63
- name: _name
109
+ name: _name,
110
+ export: library.export
64
111
  };
65
112
  }
66
113
 
@@ -78,30 +125,89 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
78
125
  { options, compilation }
79
126
  ) {
80
127
  const result = new ConcatSource(source);
81
- const exportsInfo = moduleGraph.getExportsInfo(module);
128
+ const exportsInfos = options.export
129
+ ? [
130
+ moduleGraph.getExportInfo(
131
+ module,
132
+ Array.isArray(options.export) ? options.export[0] : options.export
133
+ )
134
+ ]
135
+ : moduleGraph.getExportsInfo(module).orderedExports;
136
+ const definitions =
137
+ /** @type {BuildMeta} */
138
+ (module.buildMeta).exportsFinalName || {};
139
+ const shortHandedExports = [];
82
140
  const exports = [];
83
141
  const isAsync = moduleGraph.isAsync(module);
142
+
84
143
  if (isAsync) {
85
144
  result.add(
86
145
  `${RuntimeGlobals.exports} = await ${RuntimeGlobals.exports};\n`
87
146
  );
88
147
  }
89
- for (const exportInfo of exportsInfo.orderedExports) {
148
+
149
+ for (const exportInfo of exportsInfos) {
90
150
  if (!exportInfo.provided) continue;
91
- const varName = `${RuntimeGlobals.exports}${Template.toIdentifier(
92
- exportInfo.name
93
- )}`;
94
- result.add(
95
- `var ${varName} = ${RuntimeGlobals.exports}${propertyAccess([
96
- /** @type {string} */
97
- (exportInfo.getUsedName(exportInfo.name, chunk.runtime))
98
- ])};\n`
151
+
152
+ let shouldContinue = false;
153
+
154
+ const reexport = exportInfo.findTarget(moduleGraph, _m => true);
155
+
156
+ if (reexport) {
157
+ const exp = moduleGraph.getExportsInfo(reexport.module);
158
+
159
+ for (const reexportInfo of exp.orderedExports) {
160
+ if (
161
+ reexportInfo.provided === false &&
162
+ reexportInfo.name === /** @type {string[]} */ (reexport.export)[0]
163
+ ) {
164
+ shouldContinue = true;
165
+ }
166
+ }
167
+ }
168
+
169
+ if (shouldContinue) continue;
170
+
171
+ const webpackExportsProperty = exportInfo.getUsedName(
172
+ exportInfo.name,
173
+ chunk.runtime
99
174
  );
100
- exports.push(`${varName} as ${exportInfo.name}`);
175
+ const definition =
176
+ definitions[/** @type {string} */ (webpackExportsProperty)];
177
+ const finalName =
178
+ definition ||
179
+ `${RuntimeGlobals.exports}${Template.toIdentifier(exportInfo.name)}`;
180
+
181
+ if (!definition) {
182
+ result.add(
183
+ `var ${finalName} = ${RuntimeGlobals.exports}${propertyAccess([
184
+ /** @type {string} */
185
+ (exportInfo.getUsedName(exportInfo.name, chunk.runtime))
186
+ ])}\n`
187
+ );
188
+ }
189
+
190
+ if (finalName && (finalName.includes(".") || finalName.includes("["))) {
191
+ exports.push([exportInfo.name, finalName]);
192
+ } else {
193
+ shortHandedExports.push(
194
+ definition && finalName === exportInfo.name
195
+ ? finalName
196
+ : `${finalName} as ${exportInfo.name}`
197
+ );
198
+ }
101
199
  }
102
- if (exports.length > 0) {
103
- result.add(`export { ${exports.join(", ")} };\n`);
200
+
201
+ if (shortHandedExports.length > 0) {
202
+ result.add(`export { ${shortHandedExports.join(", ")} };\n`);
104
203
  }
204
+
205
+ for (const [exportName, final] of exports) {
206
+ result.add(
207
+ `export ${compilation.outputOptions.environment.const ? "const" : "var"} ${exportName} = ${final};\n`
208
+ );
209
+ }
210
+
105
211
  return result;
106
212
  }
107
213
  }
@@ -37,8 +37,8 @@ const TIMERS_AGGREGATES_SYMBOL = Symbol("webpack logger aggregated times");
37
37
 
38
38
  class WebpackLogger {
39
39
  /**
40
- * @param {function(LogTypeEnum, EXPECTED_ANY[]=): void} log log function
41
- * @param {function(string | function(): string): WebpackLogger} getChildLogger function to create child logger
40
+ * @param {(type: LogTypeEnum, args?: EXPECTED_ANY[]) => void} log log function
41
+ * @param {(name: string | (() => string)) => WebpackLogger} getChildLogger function to create child logger
42
42
  */
43
43
  constructor(log, getChildLogger) {
44
44
  this[LOG_SYMBOL] = log;
@@ -11,13 +11,13 @@ const { LogType } = require("./Logger");
11
11
  /** @typedef {import("../../declarations/WebpackOptions").FilterTypes} FilterTypes */
12
12
  /** @typedef {import("./Logger").LogTypeEnum} LogTypeEnum */
13
13
 
14
- /** @typedef {function(string): boolean} FilterFunction */
15
- /** @typedef {function(string, LogTypeEnum, EXPECTED_ANY[]=): void} LoggingFunction */
14
+ /** @typedef {(item: string) => boolean} FilterFunction */
15
+ /** @typedef {(value: string, type: LogTypeEnum, args?: EXPECTED_ANY[]) => void} LoggingFunction */
16
16
 
17
17
  /**
18
18
  * @typedef {object} LoggerConsole
19
- * @property {function(): void} clear
20
- * @property {function(): void} trace
19
+ * @property {() => void} clear
20
+ * @property {() => void} trace
21
21
  * @property {(...args: EXPECTED_ANY[]) => void} info
22
22
  * @property {(...args: EXPECTED_ANY[]) => void} log
23
23
  * @property {(...args: EXPECTED_ANY[]) => void} warn
@@ -15,10 +15,14 @@ const nodeConsole = require("./nodeConsole");
15
15
  /** @typedef {import("../Compiler")} Compiler */
16
16
  /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
17
17
 
18
+ /**
19
+ * @typedef {object} NodeEnvironmentPluginOptions
20
+ * @property {InfrastructureLogging} infrastructureLogging infrastructure logging options
21
+ */
22
+
18
23
  class NodeEnvironmentPlugin {
19
24
  /**
20
- * @param {object} options options
21
- * @param {InfrastructureLogging} options.infrastructureLogging infrastructure logging options
25
+ * @param {NodeEnvironmentPluginOptions} options options
22
26
  */
23
27
  constructor(options) {
24
28
  this.options = options;
@@ -50,8 +50,7 @@ class ReadFileCompileAsyncWasmPlugin {
50
50
  };
51
51
 
52
52
  /**
53
- * @param {string} path path to wasm file
54
- * @returns {string} generated code to load the wasm file
53
+ * @type {(path: string) => string} callback to generate code to load the wasm file
55
54
  */
56
55
  const generateLoadBinaryCode = this._import
57
56
  ? path =>
@@ -53,8 +53,7 @@ class ReadFileCompileWasmPlugin {
53
53
  };
54
54
 
55
55
  /**
56
- * @param {string} path path to wasm file
57
- * @returns {string} generated code to load the wasm file
56
+ * @type {(path: string) => string} callback to generate code to load the wasm file
58
57
  */
59
58
  const generateLoadBinaryCode = this.options.import
60
59
  ? path =>
@@ -10,6 +10,8 @@ const truncateArgs = require("../logging/truncateArgs");
10
10
 
11
11
  /** @typedef {import("../logging/createConsoleLogger").LoggerConsole} LoggerConsole */
12
12
 
13
+ /* eslint-disable no-console */
14
+
13
15
  /**
14
16
  * @param {object} options options
15
17
  * @param {boolean=} options.colors colors
@@ -67,7 +69,7 @@ module.exports = ({ colors, appendOnly, stream }) => {
67
69
  * @param {string} prefix prefix
68
70
  * @param {string} colorPrefix color prefix
69
71
  * @param {string} colorSuffix color suffix
70
- * @returns {(function(...EXPECTED_ANY[]): void)} function to write with colors
72
+ * @returns {(...args: EXPECTED_ANY[]) => void} function to write with colors
71
73
  */
72
74
  const writeColored =
73
75
  (prefix, colorPrefix, colorSuffix) =>
@@ -44,7 +44,7 @@ const moveModuleBetween = (chunkGraph, oldChunk, newChunk) => module => {
44
44
  /**
45
45
  * @param {ChunkGraph} chunkGraph the chunk graph
46
46
  * @param {Chunk} chunk the chunk
47
- * @returns {function(Module): boolean} filter for entry module
47
+ * @returns {(module: Module) => boolean} filter for entry module
48
48
  */
49
49
  const isNotAEntryModule = (chunkGraph, chunk) => module =>
50
50
  !chunkGraph.isEntryModuleInChunk(module, chunk);
@@ -20,6 +20,7 @@ const { JS_TYPES } = require("../ModuleSourceTypesConstants");
20
20
  const { JAVASCRIPT_MODULE_TYPE_ESM } = require("../ModuleTypeConstants");
21
21
  const RuntimeGlobals = require("../RuntimeGlobals");
22
22
  const Template = require("../Template");
23
+ const { DEFAULTS } = require("../config/defaults");
23
24
  const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
24
25
  const JavascriptParser = require("../javascript/JavascriptParser");
25
26
  const { equals } = require("../util/ArrayHelpers");
@@ -60,6 +61,7 @@ const {
60
61
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
61
62
  /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
62
63
  /** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
64
+ /** @typedef {import("../Module").BuildCallback} BuildCallback */
63
65
  /** @typedef {import("../Module").BuildInfo} BuildInfo */
64
66
  /** @typedef {import("../Module").BuildMeta} BuildMeta */
65
67
  /** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
@@ -84,6 +86,7 @@ const {
84
86
  /** @typedef {typeof import("../util/Hash")} HashConstructor */
85
87
  /** @typedef {import("../util/concatenate").UsedNames} UsedNames */
86
88
  /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
89
+ /** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
87
90
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
88
91
 
89
92
  /**
@@ -98,7 +101,7 @@ const {
98
101
 
99
102
  // fix eslint-scope to support class properties correctly
100
103
  // cspell:word Referencer
101
- const ReferencerClass = /** @type {any} */ (Referencer);
104
+ const ReferencerClass = /** @type {EXPECTED_ANY} */ (Referencer);
102
105
  if (!ReferencerClass.prototype.PropertyDefinition) {
103
106
  ReferencerClass.prototype.PropertyDefinition =
104
107
  ReferencerClass.prototype.Property;
@@ -600,7 +603,7 @@ const getFinalName = (
600
603
 
601
604
  /**
602
605
  * @typedef {object} ConcatenateModuleHooks
603
- * @property {SyncBailHook<[Record<string, string>], boolean | void>} exportsDefinitions
606
+ * @property {SyncBailHook<[Record<string, string>, ConcatenatedModule], boolean | void>} exportsDefinitions
604
607
  */
605
608
 
606
609
  /** @type {WeakMap<Compilation, ConcatenateModuleHooks>} */
@@ -612,7 +615,7 @@ class ConcatenatedModule extends Module {
612
615
  * @param {Set<Module>} modules all modules in the concatenation (including the root module)
613
616
  * @param {RuntimeSpec} runtime the runtime
614
617
  * @param {Compilation} compilation the compilation
615
- * @param {object=} associatedObjectForCache object for caching
618
+ * @param {AssociatedObjectForCache=} associatedObjectForCache object for caching
616
619
  * @param {string | HashConstructor=} hashFunction hash function to use
617
620
  * @returns {ConcatenatedModule} the module
618
621
  */
@@ -622,7 +625,7 @@ class ConcatenatedModule extends Module {
622
625
  runtime,
623
626
  compilation,
624
627
  associatedObjectForCache,
625
- hashFunction = "md4"
628
+ hashFunction = DEFAULTS.HASH_FUNCTION
626
629
  ) {
627
630
  const identifier = ConcatenatedModule._createIdentifier(
628
631
  rootModule,
@@ -647,7 +650,7 @@ class ConcatenatedModule extends Module {
647
650
  let hooks = compilationHooksMap.get(compilation);
648
651
  if (hooks === undefined) {
649
652
  hooks = {
650
- exportsDefinitions: new SyncBailHook(["definitions"])
653
+ exportsDefinitions: new SyncBailHook(["definitions", "module"])
651
654
  };
652
655
  compilationHooksMap.set(compilation, hooks);
653
656
  }
@@ -745,7 +748,7 @@ class ConcatenatedModule extends Module {
745
748
  * @param {Compilation} compilation the compilation
746
749
  * @param {ResolverWithOptions} resolver the resolver
747
750
  * @param {InputFileSystem} fs the file system
748
- * @param {function(WebpackError=): void} callback callback function
751
+ * @param {BuildCallback} callback callback function
749
752
  * @returns {void}
750
753
  */
751
754
  build(options, compilation, resolver, fs, callback) {
@@ -1040,7 +1043,7 @@ class ConcatenatedModule extends Module {
1040
1043
  /**
1041
1044
  * @param {Module} rootModule the root module of the concatenation
1042
1045
  * @param {Set<Module>} modules all modules in the concatenation (including the root module)
1043
- * @param {object=} associatedObjectForCache object for caching
1046
+ * @param {AssociatedObjectForCache=} associatedObjectForCache object for caching
1044
1047
  * @param {string | HashConstructor=} hashFunction hash function to use
1045
1048
  * @returns {string} the identifier
1046
1049
  */
@@ -1048,7 +1051,7 @@ class ConcatenatedModule extends Module {
1048
1051
  rootModule,
1049
1052
  modules,
1050
1053
  associatedObjectForCache,
1051
- hashFunction = "md4"
1054
+ hashFunction = DEFAULTS.HASH_FUNCTION
1052
1055
  ) {
1053
1056
  const cachedMakePathsRelative = makePathsRelative.bindContextCache(
1054
1057
  /** @type {string} */ (rootModule.context),
@@ -1418,7 +1421,7 @@ class ConcatenatedModule extends Module {
1418
1421
  }
1419
1422
 
1420
1423
  // Map with all root exposed used exports
1421
- /** @type {Map<string, function(RequestShortener): string>} */
1424
+ /** @type {Map<string, (requestShortener: RequestShortener) => string>} */
1422
1425
  const exportsMap = new Map();
1423
1426
 
1424
1427
  // Set with all root exposed unused exports
@@ -1485,7 +1488,8 @@ class ConcatenatedModule extends Module {
1485
1488
  // define exports
1486
1489
  if (exportsMap.size > 0) {
1487
1490
  const { exportsDefinitions } = ConcatenatedModule.getCompilationHooks(
1488
- /** @type {Compilation} */ (this.compilation)
1491
+ /** @type {Compilation} */
1492
+ (this.compilation)
1489
1493
  );
1490
1494
 
1491
1495
  const definitions = [];
@@ -1496,8 +1500,11 @@ class ConcatenatedModule extends Module {
1496
1500
  )}`
1497
1501
  );
1498
1502
  }
1499
- const shouldSkipRenderDefinitions =
1500
- exportsDefinitions.call(exportsFinalName);
1503
+
1504
+ const shouldSkipRenderDefinitions = exportsDefinitions.call(
1505
+ exportsFinalName,
1506
+ this
1507
+ );
1501
1508
 
1502
1509
  if (!shouldSkipRenderDefinitions) {
1503
1510
  runtimeRequirements.add(RuntimeGlobals.exports);
@@ -9,6 +9,7 @@ const { UsageState } = require("../ExportsInfo");
9
9
 
10
10
  /** @typedef {import("estree").Node} AnyNode */
11
11
  /** @typedef {import("../Dependency")} Dependency */
12
+ /** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
12
13
  /** @typedef {import("../Module")} Module */
13
14
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
14
15
  /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
@@ -18,7 +19,7 @@ const { UsageState } = require("../ExportsInfo");
18
19
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
19
20
 
20
21
  /** @typedef {Map<TopLevelSymbol | null, Set<string | TopLevelSymbol> | true | undefined>} InnerGraph */
21
- /** @typedef {function(boolean | Set<string> | undefined): void} UsageCallback */
22
+ /** @typedef {(value: boolean | Set<string> | undefined) => void} UsageCallback */
22
23
 
23
24
  /**
24
25
  * @typedef {object} StateObject
@@ -314,7 +315,7 @@ module.exports.isDependencyUsedByExports = (
314
315
  * @param {Dependency} dependency the dependency
315
316
  * @param {Set<string> | boolean | undefined} usedByExports usedByExports info
316
317
  * @param {ModuleGraph} moduleGraph moduleGraph
317
- * @returns {null | false | function(ModuleGraphConnection, RuntimeSpec): ConnectionState} function to determine if the connection is active
318
+ * @returns {null | false | GetConditionFn} function to determine if the connection is active
318
319
  */
319
320
  module.exports.getDependencyUsedByExportsCondition = (
320
321
  dependency,
@@ -15,8 +15,10 @@ const InnerGraph = require("./InnerGraph");
15
15
  /** @typedef {import("estree").ClassDeclaration} ClassDeclaration */
16
16
  /** @typedef {import("estree").ClassExpression} ClassExpression */
17
17
  /** @typedef {import("estree").Expression} Expression */
18
+ /** @typedef {import("estree").MaybeNamedClassDeclaration} MaybeNamedClassDeclaration */
19
+ /** @typedef {import("estree").MaybeNamedFunctionDeclaration} MaybeNamedFunctionDeclaration */
18
20
  /** @typedef {import("estree").Node} Node */
19
- /** @typedef {import("estree").VariableDeclarator} VariableDeclaratorNode */
21
+ /** @typedef {import("estree").VariableDeclarator} VariableDeclarator */
20
22
  /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
21
23
  /** @typedef {import("../Compiler")} Compiler */
22
24
  /** @typedef {import("../Dependency")} Dependency */
@@ -98,17 +100,17 @@ class InnerGraphPlugin {
98
100
  // 2. classes (class declaration, class expression)
99
101
  // 3. variable declarators (const x = ...)
100
102
 
101
- /** @type {WeakMap<Node, TopLevelSymbol>} */
103
+ /** @type {WeakMap<Node | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration, TopLevelSymbol>} */
102
104
  const statementWithTopLevelSymbol = new WeakMap();
103
- /** @type {WeakMap<Node, Node>} */
105
+ /** @type {WeakMap<Node | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration, Node>} */
104
106
  const statementPurePart = new WeakMap();
105
107
 
106
- /** @type {WeakMap<ClassExpression | ClassDeclaration, TopLevelSymbol>} */
108
+ /** @type {WeakMap<ClassExpression | ClassDeclaration | MaybeNamedClassDeclaration, TopLevelSymbol>} */
107
109
  const classWithTopLevelSymbol = new WeakMap();
108
110
 
109
- /** @type {WeakMap<VariableDeclaratorNode, TopLevelSymbol>} */
111
+ /** @type {WeakMap<VariableDeclarator, TopLevelSymbol>} */
110
112
  const declWithTopLevelSymbol = new WeakMap();
111
- /** @type {WeakSet<VariableDeclaratorNode>} */
113
+ /** @type {WeakSet<VariableDeclarator>} */
112
114
  const pureDeclarators = new WeakSet();
113
115
 
114
116
  // The following hooks are used during prewalking:
@@ -397,7 +399,11 @@ class InnerGraphPlugin {
397
399
  });
398
400
  }
399
401
  }
400
- parser.walkExpression(decl.init);
402
+ parser.walkExpression(
403
+ /** @type {NonNullable<VariableDeclarator["init"]>} */ (
404
+ decl.init
405
+ )
406
+ );
401
407
  InnerGraph.setTopLevelSymbol(parser.state, undefined);
402
408
  return true;
403
409
  } else if (
@@ -89,25 +89,44 @@ class LimitChunkCountPlugin {
89
89
  // this is large. Size = chunks * (chunks - 1) / 2
90
90
  // It uses a multi layer bucket sort plus normal sort in the last layer
91
91
  // It's also lazy so only accessed buckets are sorted
92
+ /** @type {LazyBucketSortedSet<ChunkCombination, number>} */
92
93
  const combinations = new LazyBucketSortedSet(
93
94
  // Layer 1: ordered by largest size benefit
94
95
  c => c.sizeDiff,
95
96
  (a, b) => b - a,
97
+
96
98
  // Layer 2: ordered by smallest combined size
97
99
  /**
98
100
  * @param {ChunkCombination} c combination
99
101
  * @returns {number} integrated size
100
102
  */
101
103
  c => c.integratedSize,
104
+ /**
105
+ * @param {number} a a
106
+ * @param {number} b b
107
+ * @returns {number} result
108
+ */
102
109
  (a, b) => a - b,
110
+
103
111
  // Layer 3: ordered by position difference in orderedChunk (-> to be deterministic)
104
112
  /**
105
113
  * @param {ChunkCombination} c combination
106
114
  * @returns {number} position difference
107
115
  */
108
116
  c => c.bIdx - c.aIdx,
117
+ /**
118
+ * @param {number} a a
119
+ * @param {number} b b
120
+ * @returns {number} result
121
+ */
109
122
  (a, b) => a - b,
123
+
110
124
  // Layer 4: ordered by position in orderedChunk (-> to be deterministic)
125
+ /**
126
+ * @param {ChunkCombination} a a
127
+ * @param {ChunkCombination} b b
128
+ * @returns {number} result
129
+ */
111
130
  (a, b) => a.bIdx - b.bIdx
112
131
  );
113
132
 
@@ -132,6 +151,7 @@ class LimitChunkCountPlugin {
132
151
 
133
152
  const aSize = chunkGraph.getChunkSize(a, options);
134
153
  const bSize = chunkGraph.getChunkSize(b, options);
154
+ /** @type {ChunkCombination} */
135
155
  const c = {
136
156
  deleted: false,
137
157
  sizeDiff: aSize + bSize - integratedSize,
@@ -8,6 +8,7 @@
8
8
  const asyncLib = require("neo-async");
9
9
  const ChunkGraph = require("../ChunkGraph");
10
10
  const ModuleGraph = require("../ModuleGraph");
11
+ const { JS_TYPE } = require("../ModuleSourceTypesConstants");
11
12
  const { STAGE_DEFAULT } = require("../OptimizationStages");
12
13
  const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
13
14
  const { compareModulesByIdentifier } = require("../util/comparators");
@@ -101,7 +102,7 @@ class ModuleConcatenationPlugin {
101
102
 
102
103
  /**
103
104
  * @param {Module} module the module
104
- * @param {Module | function(RequestShortener): string} problem the problem
105
+ * @param {Module | ((requestShortener: RequestShortener) => string)} problem the problem
105
106
  * @returns {(requestShortener: RequestShortener) => string} the reason
106
107
  */
107
108
  const formatBailoutWarning = (module, problem) => requestShortener => {
@@ -452,7 +453,7 @@ class ModuleConcatenationPlugin {
452
453
  chunkGraph.disconnectChunkAndModule(chunk, m);
453
454
  } else {
454
455
  const newSourceTypes = new Set(sourceTypes);
455
- newSourceTypes.delete("javascript");
456
+ newSourceTypes.delete(JS_TYPE);
456
457
  chunkGraph.setChunkModuleSourceTypes(
457
458
  chunk,
458
459
  m,
@@ -543,11 +544,11 @@ class ModuleConcatenationPlugin {
543
544
  * @param {RuntimeSpec} activeRuntime the runtime scope of the root module
544
545
  * @param {Set<Module>} possibleModules modules that are candidates
545
546
  * @param {Set<Module>} candidates list of potential candidates (will be added to)
546
- * @param {Map<Module, Module | function(RequestShortener): string>} failureCache cache for problematic modules to be more performant
547
+ * @param {Map<Module, Module | ((requestShortener: RequestShortener) => string)>} failureCache cache for problematic modules to be more performant
547
548
  * @param {ChunkGraph} chunkGraph the chunk graph
548
549
  * @param {boolean} avoidMutateOnFailure avoid mutating the config when adding fails
549
550
  * @param {Statistics} statistics gathering metrics
550
- * @returns {null | Module | function(RequestShortener): string} the problematic module
551
+ * @returns {null | Module | ((requestShortener: RequestShortener) => string)} the problematic module
551
552
  */
552
553
  _tryToAdd(
553
554
  compilation,
@@ -846,6 +847,8 @@ class ModuleConcatenationPlugin {
846
847
  }
847
848
  }
848
849
 
850
+ /** @typedef {Module | ((requestShortener: RequestShortener) => string)} Problem */
851
+
849
852
  class ConcatConfiguration {
850
853
  /**
851
854
  * @param {Module} rootModule the root module
@@ -857,7 +860,7 @@ class ConcatConfiguration {
857
860
  /** @type {Set<Module>} */
858
861
  this.modules = new Set();
859
862
  this.modules.add(rootModule);
860
- /** @type {Map<Module, Module | function(RequestShortener): string>} */
863
+ /** @type {Map<Module, Problem>} */
861
864
  this.warnings = new Map();
862
865
  }
863
866
 
@@ -882,14 +885,14 @@ class ConcatConfiguration {
882
885
 
883
886
  /**
884
887
  * @param {Module} module the module
885
- * @param {Module | function(RequestShortener): string} problem the problem
888
+ * @param {Problem} problem the problem
886
889
  */
887
890
  addWarning(module, problem) {
888
891
  this.warnings.set(module, problem);
889
892
  }
890
893
 
891
894
  /**
892
- * @returns {Map<Module, Module | function(RequestShortener): string>} warnings
895
+ * @returns {Map<Module, Problem>} warnings
893
896
  */
894
897
  getWarningsSorted() {
895
898
  return new Map(
@@ -38,7 +38,7 @@ const addToList = (itemOrItems, list) => {
38
38
  /**
39
39
  * @template T
40
40
  * @param {T[]} input list
41
- * @param {function(T): Buffer} fn map function
41
+ * @param {(item: T) => Buffer} fn map function
42
42
  * @returns {Buffer[]} buffers without duplicates
43
43
  */
44
44
  const mapAndDeduplicateBuffers = (input, fn) => {
@@ -107,6 +107,12 @@ const toCachedSource = source => {
107
107
  /** @type {WeakMap<Compilation, CompilationHooks>} */
108
108
  const compilationHooksMap = new WeakMap();
109
109
 
110
+ /**
111
+ * @typedef {object} RealContentHashPluginOptions
112
+ * @property {string | Hash} hashFunction the hash function to use
113
+ * @property {string=} hashDigest the hash digest to use
114
+ */
115
+
110
116
  class RealContentHashPlugin {
111
117
  /**
112
118
  * @param {Compilation} compilation the compilation
@@ -129,9 +135,7 @@ class RealContentHashPlugin {
129
135
  }
130
136
 
131
137
  /**
132
- * @param {object} options options object
133
- * @param {string | Hash} options.hashFunction the hash function to use
134
- * @param {string} options.hashDigest the hash digest to use
138
+ * @param {RealContentHashPluginOptions} options options
135
139
  */
136
140
  constructor({ hashFunction, hashDigest }) {
137
141
  this._hashFunction = hashFunction;