webpack 5.101.3 → 5.102.1

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 (339) hide show
  1. package/README.md +21 -26
  2. package/lib/APIPlugin.js +30 -36
  3. package/lib/AsyncDependenciesBlock.js +1 -4
  4. package/lib/BannerPlugin.js +0 -1
  5. package/lib/Cache.js +7 -6
  6. package/lib/CacheFacade.js +0 -1
  7. package/lib/Chunk.js +49 -31
  8. package/lib/ChunkGraph.js +37 -27
  9. package/lib/ChunkGroup.js +8 -10
  10. package/lib/ChunkTemplate.js +1 -1
  11. package/lib/CleanPlugin.js +3 -3
  12. package/lib/CodeGenerationResults.js +3 -2
  13. package/lib/CompatibilityPlugin.js +29 -12
  14. package/lib/Compilation.js +209 -196
  15. package/lib/Compiler.js +36 -35
  16. package/lib/ConcatenationScope.js +6 -1
  17. package/lib/ConditionalInitFragment.js +1 -1
  18. package/lib/ConstPlugin.js +6 -5
  19. package/lib/ContextExclusionPlugin.js +0 -1
  20. package/lib/ContextModule.js +25 -21
  21. package/lib/ContextModuleFactory.js +30 -11
  22. package/lib/ContextReplacementPlugin.js +38 -15
  23. package/lib/DefinePlugin.js +5 -9
  24. package/lib/DelegatedModule.js +7 -11
  25. package/lib/DependenciesBlock.js +0 -2
  26. package/lib/Dependency.js +9 -11
  27. package/lib/DependencyTemplates.js +2 -4
  28. package/lib/DllModule.js +1 -7
  29. package/lib/DllReferencePlugin.js +2 -4
  30. package/lib/DynamicEntryPlugin.js +0 -2
  31. package/lib/EntryOptionPlugin.js +0 -5
  32. package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
  33. package/lib/EvalDevToolModulePlugin.js +4 -3
  34. package/lib/EvalSourceMapDevToolPlugin.js +3 -4
  35. package/lib/ExportsInfo.js +50 -49
  36. package/lib/ExternalModule.js +84 -52
  37. package/lib/ExternalModuleFactoryPlugin.js +27 -7
  38. package/lib/ExternalsPlugin.js +24 -17
  39. package/lib/FileSystemInfo.js +105 -90
  40. package/lib/FlagDependencyUsagePlugin.js +3 -4
  41. package/lib/Generator.js +2 -13
  42. package/lib/GraphHelpers.js +0 -3
  43. package/lib/HookWebpackError.js +0 -2
  44. package/lib/HotModuleReplacementPlugin.js +22 -24
  45. package/lib/HotUpdateChunk.js +0 -3
  46. package/lib/IgnorePlugin.js +5 -2
  47. package/lib/InitFragment.js +41 -29
  48. package/lib/InvalidDependenciesModuleWarning.js +0 -1
  49. package/lib/LibManifestPlugin.js +4 -6
  50. package/lib/LoaderOptionsPlugin.js +1 -10
  51. package/lib/MainTemplate.js +8 -19
  52. package/lib/Module.js +32 -20
  53. package/lib/ModuleFactory.js +1 -1
  54. package/lib/ModuleFilenameHelpers.js +42 -25
  55. package/lib/ModuleGraph.js +30 -16
  56. package/lib/ModuleInfoHeaderPlugin.js +0 -1
  57. package/lib/ModuleTemplate.js +0 -2
  58. package/lib/ModuleTypeConstants.js +11 -1
  59. package/lib/MultiCompiler.js +23 -15
  60. package/lib/MultiWatching.js +6 -10
  61. package/lib/NodeStuffPlugin.js +2 -10
  62. package/lib/NormalModule.js +146 -89
  63. package/lib/NormalModuleFactory.js +132 -42
  64. package/lib/OptionsApply.js +1 -1
  65. package/lib/Parser.js +1 -1
  66. package/lib/ProgressPlugin.js +6 -10
  67. package/lib/ProvidePlugin.js +5 -7
  68. package/lib/RawModule.js +1 -6
  69. package/lib/RecordIdsPlugin.js +10 -6
  70. package/lib/ResolverFactory.js +0 -2
  71. package/lib/RuntimeGlobals.js +5 -0
  72. package/lib/RuntimeModule.js +1 -3
  73. package/lib/RuntimePlugin.js +26 -22
  74. package/lib/RuntimeTemplate.js +22 -12
  75. package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
  76. package/lib/SourceMapDevToolPlugin.js +11 -18
  77. package/lib/Stats.js +0 -1
  78. package/lib/Template.js +6 -11
  79. package/lib/TemplatedPathPlugin.js +2 -1
  80. package/lib/WatchIgnorePlugin.js +2 -3
  81. package/lib/Watching.js +15 -15
  82. package/lib/WebpackIsIncludedPlugin.js +0 -2
  83. package/lib/WebpackOptionsApply.js +74 -107
  84. package/lib/asset/AssetBytesGenerator.js +167 -0
  85. package/lib/asset/AssetBytesParser.js +37 -0
  86. package/lib/asset/AssetGenerator.js +22 -37
  87. package/lib/asset/AssetModulesPlugin.js +34 -16
  88. package/lib/asset/AssetParser.js +7 -3
  89. package/lib/asset/AssetSourceGenerator.js +1 -1
  90. package/lib/asset/RawDataUrlModule.js +3 -2
  91. package/lib/async-modules/AsyncModuleHelpers.js +6 -4
  92. package/lib/buildChunkGraph.js +0 -1
  93. package/lib/cache/MemoryCachePlugin.js +0 -2
  94. package/lib/cache/MemoryWithGcCachePlugin.js +0 -2
  95. package/lib/cache/PackFileCacheStrategy.js +14 -1
  96. package/lib/cache/ResolverCachePlugin.js +9 -15
  97. package/lib/cache/getLazyHashedEtag.js +1 -1
  98. package/lib/config/browserslistTargetHandler.js +77 -76
  99. package/lib/config/defaults.js +162 -23
  100. package/lib/config/normalization.js +18 -3
  101. package/lib/config/target.js +1 -1
  102. package/lib/container/ContainerEntryDependency.js +0 -1
  103. package/lib/container/ContainerEntryModule.js +3 -7
  104. package/lib/container/ContainerPlugin.js +1 -2
  105. package/lib/container/ContainerReferencePlugin.js +0 -1
  106. package/lib/container/FallbackDependency.js +2 -1
  107. package/lib/container/FallbackModule.js +6 -7
  108. package/lib/container/ModuleFederationPlugin.js +0 -1
  109. package/lib/container/RemoteModule.js +8 -8
  110. package/lib/container/RemoteRuntimeModule.js +2 -2
  111. package/lib/css/CssGenerator.js +3 -6
  112. package/lib/css/CssLoadingRuntimeModule.js +6 -9
  113. package/lib/css/CssModulesPlugin.js +13 -19
  114. package/lib/css/CssParser.js +3 -3
  115. package/lib/css/walkCssTokens.js +2 -2
  116. package/lib/debug/ProfilingPlugin.js +35 -8
  117. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
  118. package/lib/dependencies/AMDPlugin.js +2 -2
  119. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
  120. package/lib/dependencies/CachedConstDependency.js +0 -4
  121. package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
  122. package/lib/dependencies/CommonJsExportsDependency.js +2 -1
  123. package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
  124. package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
  125. package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
  126. package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
  127. package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
  128. package/lib/dependencies/ConstDependency.js +2 -2
  129. package/lib/dependencies/ContextDependency.js +9 -4
  130. package/lib/dependencies/ContextDependencyHelpers.js +2 -2
  131. package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
  132. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
  133. package/lib/dependencies/ContextElementDependency.js +22 -11
  134. package/lib/dependencies/CssIcssImportDependency.js +0 -2
  135. package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
  136. package/lib/dependencies/CssImportDependency.js +0 -8
  137. package/lib/dependencies/CssLocalIdentifierDependency.js +4 -7
  138. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
  139. package/lib/dependencies/CssUrlDependency.js +0 -6
  140. package/lib/dependencies/ExportsInfoDependency.js +7 -9
  141. package/lib/dependencies/ExternalModuleDependency.js +0 -3
  142. package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
  143. package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
  144. package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
  145. package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
  146. package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
  147. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
  148. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
  149. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
  150. package/lib/dependencies/HarmonyImportDependency.js +33 -14
  151. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
  152. package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
  153. package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
  154. package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
  155. package/lib/dependencies/ImportContextDependency.js +13 -0
  156. package/lib/dependencies/ImportDependency.js +18 -6
  157. package/lib/dependencies/ImportEagerDependency.js +2 -3
  158. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
  159. package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
  160. package/lib/dependencies/ImportMetaPlugin.js +3 -2
  161. package/lib/dependencies/ImportParserPlugin.js +288 -45
  162. package/lib/dependencies/ImportWeakDependency.js +2 -3
  163. package/lib/dependencies/JsonExportsDependency.js +0 -1
  164. package/lib/dependencies/LoaderDependency.js +0 -3
  165. package/lib/dependencies/LoaderImportDependency.js +0 -3
  166. package/lib/dependencies/LoaderPlugin.js +11 -5
  167. package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
  168. package/lib/dependencies/ModuleDependency.js +3 -9
  169. package/lib/dependencies/NullDependency.js +2 -0
  170. package/lib/dependencies/ProvidedDependency.js +6 -8
  171. package/lib/dependencies/PureExpressionDependency.js +0 -1
  172. package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
  173. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
  174. package/lib/dependencies/RequireIncludeDependency.js +2 -2
  175. package/lib/dependencies/RequireResolveDependency.js +2 -2
  176. package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
  177. package/lib/dependencies/StaticExportsDependency.js +3 -5
  178. package/lib/dependencies/URLDependency.js +2 -7
  179. package/lib/dependencies/URLPlugin.js +1 -2
  180. package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
  181. package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
  182. package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
  183. package/lib/dependencies/WorkerDependency.js +2 -3
  184. package/lib/dependencies/WorkerPlugin.js +4 -12
  185. package/lib/dependencies/processExportInfo.js +2 -3
  186. package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
  187. package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
  188. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
  189. package/lib/hmr/LazyCompilationPlugin.js +6 -4
  190. package/lib/hmr/lazyCompilationBackend.js +13 -10
  191. package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
  192. package/lib/ids/HashedModuleIdsPlugin.js +5 -7
  193. package/lib/ids/IdHelpers.js +1 -1
  194. package/lib/ids/NamedChunkIdsPlugin.js +1 -6
  195. package/lib/ids/NamedModuleIdsPlugin.js +1 -5
  196. package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
  197. package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
  198. package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
  199. package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
  200. package/lib/ids/SyncModuleIdsPlugin.js +4 -3
  201. package/lib/index.js +8 -7
  202. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
  203. package/lib/javascript/BasicEvaluatedExpression.js +13 -6
  204. package/lib/javascript/ChunkFormatHelpers.js +1 -1
  205. package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
  206. package/lib/javascript/JavascriptGenerator.js +2 -3
  207. package/lib/javascript/JavascriptModulesPlugin.js +46 -24
  208. package/lib/javascript/JavascriptParser.js +120 -55
  209. package/lib/javascript/JavascriptParserHelpers.js +2 -2
  210. package/lib/javascript/StartupHelpers.js +2 -4
  211. package/lib/json/JsonData.js +1 -1
  212. package/lib/json/JsonGenerator.js +4 -5
  213. package/lib/json/JsonModulesPlugin.js +0 -3
  214. package/lib/json/JsonParser.js +4 -2
  215. package/lib/library/AbstractLibraryPlugin.js +2 -2
  216. package/lib/library/AmdLibraryPlugin.js +0 -1
  217. package/lib/library/AssignLibraryPlugin.js +23 -12
  218. package/lib/library/EnableLibraryPlugin.js +7 -11
  219. package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
  220. package/lib/library/JsonpLibraryPlugin.js +5 -2
  221. package/lib/library/ModuleLibraryPlugin.js +88 -43
  222. package/lib/library/SystemLibraryPlugin.js +15 -6
  223. package/lib/library/UmdLibraryPlugin.js +12 -18
  224. package/lib/logging/Logger.js +12 -10
  225. package/lib/logging/createConsoleLogger.js +15 -14
  226. package/lib/logging/truncateArgs.js +1 -1
  227. package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
  228. package/lib/node/NodeWatchFileSystem.js +4 -4
  229. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
  230. package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
  231. package/lib/node/nodeConsole.js +2 -2
  232. package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
  233. package/lib/optimize/ConcatenatedModule.js +142 -100
  234. package/lib/optimize/InnerGraph.js +17 -11
  235. package/lib/optimize/InnerGraphPlugin.js +0 -3
  236. package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
  237. package/lib/optimize/RealContentHashPlugin.js +5 -3
  238. package/lib/optimize/RuntimeChunkPlugin.js +0 -1
  239. package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
  240. package/lib/optimize/SplitChunksPlugin.js +46 -40
  241. package/lib/performance/SizeLimitsPlugin.js +2 -1
  242. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
  243. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
  244. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
  245. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
  246. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
  247. package/lib/rules/BasicMatcherRulePlugin.js +0 -2
  248. package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
  249. package/lib/rules/RuleSetCompiler.js +8 -6
  250. package/lib/runtime/BaseUriRuntimeModule.js +2 -2
  251. package/lib/runtime/CompatRuntimeModule.js +0 -1
  252. package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
  253. package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
  254. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
  255. package/lib/runtime/PublicPathRuntimeModule.js +2 -2
  256. package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
  257. package/lib/runtime/SystemContextRuntimeModule.js +0 -2
  258. package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
  259. package/lib/schemes/DataUriPlugin.js +2 -28
  260. package/lib/schemes/FileUriPlugin.js +5 -2
  261. package/lib/schemes/HttpUriPlugin.js +4 -2
  262. package/lib/schemes/VirtualUrlPlugin.js +11 -11
  263. package/lib/serialization/FileMiddleware.js +1 -1
  264. package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
  265. package/lib/serialization/ObjectMiddleware.js +31 -20
  266. package/lib/serialization/SerializerMiddleware.js +1 -3
  267. package/lib/serialization/types.js +1 -1
  268. package/lib/sharing/ConsumeSharedModule.js +3 -5
  269. package/lib/sharing/ConsumeSharedPlugin.js +2 -4
  270. package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
  271. package/lib/sharing/ProvideSharedModule.js +3 -7
  272. package/lib/sharing/SharePlugin.js +0 -2
  273. package/lib/sharing/ShareRuntimeModule.js +4 -1
  274. package/lib/sharing/resolveMatchedConfigs.js +14 -6
  275. package/lib/sharing/utils.js +0 -6
  276. package/lib/stats/DefaultStatsFactoryPlugin.js +179 -95
  277. package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
  278. package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
  279. package/lib/stats/StatsFactory.js +14 -11
  280. package/lib/url/URLParserPlugin.js +2 -4
  281. package/lib/util/ArrayHelpers.js +4 -4
  282. package/lib/util/AsyncQueue.js +1 -0
  283. package/lib/util/Hash.js +35 -5
  284. package/lib/util/LazySet.js +2 -2
  285. package/lib/util/StackedCacheMap.js +0 -2
  286. package/lib/util/TupleSet.js +9 -4
  287. package/lib/util/URLAbsoluteSpecifier.js +0 -1
  288. package/lib/util/WeakTupleMap.js +1 -1
  289. package/lib/util/chainedImports.js +3 -1
  290. package/lib/util/cleverMerge.js +15 -18
  291. package/lib/util/comparators.js +2 -4
  292. package/lib/util/compileBooleanMatcher.js +11 -9
  293. package/lib/util/concatenate.js +1 -2
  294. package/lib/util/create-schema-validation.js +1 -2
  295. package/lib/util/createHash.js +85 -15
  296. package/lib/util/dataURL.js +39 -0
  297. package/lib/util/deprecation.js +29 -31
  298. package/lib/util/deterministicGrouping.js +34 -30
  299. package/lib/util/extractSourceMap.js +319 -0
  300. package/lib/util/findGraphRoots.js +15 -5
  301. package/lib/util/fs.js +29 -8
  302. package/lib/util/hash/BatchedHash.js +47 -8
  303. package/lib/util/hash/wasm-hash.js +53 -13
  304. package/lib/util/semver.js +9 -8
  305. package/lib/util/smartGrouping.js +41 -26
  306. package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
  307. package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
  308. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
  309. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
  310. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
  311. package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -10
  312. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
  313. package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
  314. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
  315. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
  316. package/lib/wasm-sync/WebAssemblyParser.js +1 -13
  317. package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
  318. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
  319. package/lib/web/JsonpTemplatePlugin.js +0 -1
  320. package/lib/webpack.js +21 -8
  321. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
  322. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  323. package/package.json +21 -21
  324. package/schemas/WebpackOptions.check.js +1 -1
  325. package/schemas/WebpackOptions.json +93 -96
  326. package/schemas/plugins/BannerPlugin.check.js +1 -1
  327. package/schemas/plugins/BannerPlugin.json +4 -0
  328. package/schemas/plugins/IgnorePlugin.json +1 -1
  329. package/schemas/plugins/ProgressPlugin.json +1 -1
  330. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  331. package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
  332. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
  333. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
  334. package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
  335. package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
  336. package/types.d.ts +1699 -706
  337. package/SECURITY.md +0 -9
  338. package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +0 -7
  339. package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
@@ -8,6 +8,8 @@
8
8
  const Hash = require("../Hash");
9
9
  const MAX_SHORT_STRING = require("./wasm-hash").MAX_SHORT_STRING;
10
10
 
11
+ /** @typedef {import("../../../declarations/WebpackOptions").HashDigest} Encoding */
12
+
11
13
  class BatchedHash extends Hash {
12
14
  /**
13
15
  * @param {Hash} hash hash
@@ -21,9 +23,22 @@ class BatchedHash extends Hash {
21
23
 
22
24
  /**
23
25
  * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
24
- * @param {string|Buffer} data data
25
- * @param {string=} inputEncoding data encoding
26
- * @returns {this} updated hash
26
+ * @overload
27
+ * @param {string | Buffer} data data
28
+ * @returns {Hash} updated hash
29
+ */
30
+ /**
31
+ * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
32
+ * @overload
33
+ * @param {string} data data
34
+ * @param {Encoding} inputEncoding data encoding
35
+ * @returns {Hash} updated hash
36
+ */
37
+ /**
38
+ * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
39
+ * @param {string | Buffer} data data
40
+ * @param {Encoding=} inputEncoding data encoding
41
+ * @returns {Hash} updated hash
27
42
  */
28
43
  update(data, inputEncoding) {
29
44
  if (this.string !== undefined) {
@@ -35,7 +50,11 @@ class BatchedHash extends Hash {
35
50
  this.string += data;
36
51
  return this;
37
52
  }
38
- this.hash.update(this.string, this.encoding);
53
+ if (this.encoding) {
54
+ this.hash.update(this.string, this.encoding);
55
+ } else {
56
+ this.hash.update(this.string);
57
+ }
39
58
  this.string = undefined;
40
59
  }
41
60
  if (typeof data === "string") {
@@ -46,8 +65,10 @@ class BatchedHash extends Hash {
46
65
  ) {
47
66
  this.string = data;
48
67
  this.encoding = inputEncoding;
49
- } else {
68
+ } else if (inputEncoding) {
50
69
  this.hash.update(data, inputEncoding);
70
+ } else {
71
+ this.hash.update(data);
51
72
  }
52
73
  } else {
53
74
  this.hash.update(data);
@@ -57,12 +78,30 @@ class BatchedHash extends Hash {
57
78
 
58
79
  /**
59
80
  * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
60
- * @param {string=} encoding encoding of the return value
61
- * @returns {string|Buffer} digest
81
+ * @overload
82
+ * @returns {Buffer} digest
83
+ */
84
+ /**
85
+ * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
86
+ * @overload
87
+ * @param {Encoding} encoding encoding of the return value
88
+ * @returns {string} digest
89
+ */
90
+ /**
91
+ * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
92
+ * @param {Encoding=} encoding encoding of the return value
93
+ * @returns {string | Buffer} digest
62
94
  */
63
95
  digest(encoding) {
64
96
  if (this.string !== undefined) {
65
- this.hash.update(this.string, this.encoding);
97
+ if (this.encoding) {
98
+ this.hash.update(this.string, this.encoding);
99
+ } else {
100
+ this.hash.update(this.string);
101
+ }
102
+ }
103
+ if (!encoding) {
104
+ return this.hash.digest();
66
105
  }
67
106
  return this.hash.digest(encoding);
68
107
  }
@@ -5,13 +5,15 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const Hash = require("../Hash");
9
+
8
10
  // 65536 is the size of a wasm memory page
9
11
  // 64 is the maximum chunk size for every possible wasm hash implementation
10
12
  // 4 is the maximum number of bytes per char for string encoding (max is utf-8)
11
13
  // ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
12
14
  const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
13
15
 
14
- class WasmHash {
16
+ class WasmHash extends Hash {
15
17
  /**
16
18
  * @param {WebAssembly.Instance} instance wasm instance
17
19
  * @param {WebAssembly.Instance[]} instancesPool pool of instances
@@ -19,6 +21,8 @@ class WasmHash {
19
21
  * @param {number} digestSize size of digest returned by wasm
20
22
  */
21
23
  constructor(instance, instancesPool, chunkSize, digestSize) {
24
+ super();
25
+
22
26
  const exports = /** @type {EXPECTED_ANY} */ (instance.exports);
23
27
  exports.init();
24
28
  this.exports = exports;
@@ -35,17 +39,39 @@ class WasmHash {
35
39
  }
36
40
 
37
41
  /**
38
- * @param {Buffer | string} data data
39
- * @param {BufferEncoding=} encoding encoding
40
- * @returns {this} itself
42
+ * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
43
+ * @overload
44
+ * @param {string | Buffer} data data
45
+ * @returns {Hash} updated hash
46
+ */
47
+ /**
48
+ * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
49
+ * @overload
50
+ * @param {string} data data
51
+ * @param {string=} inputEncoding data encoding
52
+ * @returns {this} updated hash
41
53
  */
42
- update(data, encoding) {
54
+ /**
55
+ * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
56
+ * @param {string | Buffer} data data
57
+ * @param {string=} inputEncoding data encoding
58
+ * @returns {this} updated hash
59
+ */
60
+ update(data, inputEncoding) {
43
61
  if (typeof data === "string") {
44
62
  while (data.length > MAX_SHORT_STRING) {
45
- this._updateWithShortString(data.slice(0, MAX_SHORT_STRING), encoding);
63
+ this._updateWithShortString(
64
+ data.slice(0, MAX_SHORT_STRING),
65
+ /** @type {NodeJS.BufferEncoding} */
66
+ (inputEncoding)
67
+ );
46
68
  data = data.slice(MAX_SHORT_STRING);
47
69
  }
48
- this._updateWithShortString(data, encoding);
70
+ this._updateWithShortString(
71
+ data,
72
+ /** @type {NodeJS.BufferEncoding} */
73
+ (inputEncoding)
74
+ );
49
75
  return this;
50
76
  }
51
77
  this._updateWithBuffer(data);
@@ -136,17 +162,31 @@ class WasmHash {
136
162
  }
137
163
 
138
164
  /**
139
- * @param {BufferEncoding} type type
140
- * @returns {Buffer | string} digest
165
+ * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
166
+ * @overload
167
+ * @returns {Buffer} digest
168
+ */
169
+ /**
170
+ * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
171
+ * @overload
172
+ * @param {string=} encoding encoding of the return value
173
+ * @returns {string} digest
174
+ */
175
+ /**
176
+ * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
177
+ * @param {string=} encoding encoding of the return value
178
+ * @returns {string | Buffer} digest
141
179
  */
142
- digest(type) {
180
+ digest(encoding) {
143
181
  const { exports, buffered, mem, digestSize } = this;
144
182
  exports.final(buffered);
145
183
  this.instancesPool.push(this);
146
184
  const hex = mem.toString("latin1", 0, digestSize);
147
- if (type === "hex") return hex;
148
- if (type === "binary" || !type) return Buffer.from(hex, "hex");
149
- return Buffer.from(hex, "hex").toString(type);
185
+ if (encoding === "hex") return hex;
186
+ if (encoding === "binary" || !encoding) return Buffer.from(hex, "hex");
187
+ return Buffer.from(hex, "hex").toString(
188
+ /** @type {NodeJS.BufferEncoding} */ (encoding)
189
+ );
150
190
  }
151
191
  }
152
192
 
@@ -6,7 +6,8 @@
6
6
  "use strict";
7
7
 
8
8
  /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
9
- /** @typedef {string | number | undefined} SemVerRangeItem */
9
+ /** @typedef {string | number} VersionValue */
10
+ /** @typedef {VersionValue | undefined} SemVerRangeItem */
10
11
  /** @typedef {(SemVerRangeItem | SemVerRangeItem[])[]} SemVerRange */
11
12
 
12
13
  /**
@@ -16,12 +17,12 @@
16
17
  const parseVersion = (str) => {
17
18
  /**
18
19
  * @param {str} str str
19
- * @returns {(string | number)[]} result
20
+ * @returns {VersionValue[]} result
20
21
  */
21
22
  var splitAndConvert = function (str) {
22
23
  return str.split(".").map(function (item) {
23
24
  // eslint-disable-next-line eqeqeq
24
- return +item == /** @type {EXPECTED_ANY} */ (item) ? +item : item;
25
+ return +item == /** @type {string | number} */ (item) ? +item : item;
25
26
  });
26
27
  };
27
28
 
@@ -29,7 +30,7 @@ const parseVersion = (str) => {
29
30
  /** @type {RegExpExecArray} */
30
31
  (/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(str));
31
32
 
32
- /** @type {(string | number | undefined | [])[]} */
33
+ /** @type {(VersionValue | undefined | [])[]} */
33
34
  var ver = match[1] ? splitAndConvert(match[1]) : [];
34
35
 
35
36
  if (match[2]) {
@@ -103,7 +104,7 @@ module.exports.versionLt = versionLt;
103
104
  module.exports.parseRange = (str) => {
104
105
  /**
105
106
  * @param {string} str str
106
- * @returns {(string | number)[]} result
107
+ * @returns {VersionValue[]} result
107
108
  */
108
109
  const splitAndConvert = (str) => {
109
110
  return str
@@ -429,7 +430,7 @@ const satisfy = (range, version) => {
429
430
  /** @type {"s" | "n" | "u" | ""} */
430
431
  (j < range.length ? (typeof range[j])[0] : "");
431
432
 
432
- /** @type {number | string | undefined} */
433
+ /** @type {VersionValue | undefined} */
433
434
  var versionValue;
434
435
  /** @type {"n" | "s" | "u" | "o" | undefined} */
435
436
  var versionType;
@@ -470,8 +471,8 @@ const satisfy = (range, version) => {
470
471
  // Handles "cmp" cases
471
472
  if (
472
473
  negated
473
- ? versionValue > /** @type {(number | string)[]} */ (range)[j]
474
- : versionValue < /** @type {(number | string)[]} */ (range)[j]
474
+ ? versionValue > /** @type {VersionValue[]} */ (range)[j]
475
+ : versionValue < /** @type {VersionValue[]} */ (range)[j]
475
476
  ) {
476
477
  return false;
477
478
  }
@@ -13,42 +13,53 @@
13
13
  */
14
14
 
15
15
  /**
16
- * @template T
17
- * @template R
16
+ * @template I
17
+ * @template G
18
18
  * @typedef {object} GroupConfig
19
- * @property {(item: T) => string[] | undefined} getKeys
20
- * @property {(key: string, children: (R | T)[], items: T[]) => R} createGroup
21
- * @property {(name: string, items: T[]) => GroupOptions=} getOptions
19
+ * @property {(item: I) => string[] | undefined} getKeys
20
+ * @property {(name: string, items: I[]) => GroupOptions=} getOptions
21
+ * @property {(key: string, children: I[], items: I[]) => G} createGroup
22
22
  */
23
23
 
24
24
  /**
25
- * @template T
26
- * @template R
25
+ * @template I
26
+ * @template G
27
+ * @typedef {{ config: GroupConfig<I, G>, name: string, alreadyGrouped: boolean, items: Items<I, G> | undefined }} Group
28
+ */
29
+
30
+ /**
31
+ * @template I, G
32
+ * @typedef {Set<Group<I, G>>} Groups
33
+ */
34
+
35
+ /**
36
+ * @template I
37
+ * @template G
27
38
  * @typedef {object} ItemWithGroups
28
- * @property {T} item
29
- * @property {Set<Group<T, R>>} groups
39
+ * @property {I} item
40
+ * @property {Groups<I, G>} groups
30
41
  */
31
42
 
32
43
  /**
33
- * @template T
34
- * @template R
35
- * @typedef {{ config: GroupConfig<T, R>, name: string, alreadyGrouped: boolean, items: Set<ItemWithGroups<T, R>> | undefined }} Group
44
+ * @template T, G
45
+ * @typedef {Set<ItemWithGroups<T, G>>} Items
36
46
  */
37
47
 
38
48
  /**
39
- * @template T
49
+ * @template I
50
+ * @template G
40
51
  * @template R
41
- * @param {T[]} items the list of items
42
- * @param {GroupConfig<T, R>[]} groupConfigs configuration
43
- * @returns {(R | T)[]} grouped items
52
+ * @param {I[]} items the list of items
53
+ * @param {GroupConfig<I, G>[]} groupConfigs configuration
54
+ * @returns {(I | G)[]} grouped items
44
55
  */
45
56
  const smartGrouping = (items, groupConfigs) => {
46
- /** @type {Set<ItemWithGroups<T, R>>} */
57
+ /** @type {Items<I, G>} */
47
58
  const itemsWithGroups = new Set();
48
- /** @type {Map<string, Group<T, R>>} */
59
+ /** @type {Map<string, Group<I, G>>} */
49
60
  const allGroups = new Map();
50
61
  for (const item of items) {
51
- /** @type {Set<Group<T, R>>} */
62
+ /** @type {Groups<I, G>} */
52
63
  const groups = new Set();
53
64
  for (let i = 0; i < groupConfigs.length; i++) {
54
65
  const groupConfig = groupConfigs[i];
@@ -77,9 +88,10 @@ const smartGrouping = (items, groupConfigs) => {
77
88
  groups
78
89
  });
79
90
  }
91
+
80
92
  /**
81
- * @param {Set<ItemWithGroups<T, R>>} itemsWithGroups input items with groups
82
- * @returns {(T | R)[]} groups items
93
+ * @param {Items<I, G>} itemsWithGroups input items with groups
94
+ * @returns {(I | G)[]} groups items
83
95
  */
84
96
  const runGrouping = (itemsWithGroups) => {
85
97
  const totalSize = itemsWithGroups.size;
@@ -94,7 +106,7 @@ const smartGrouping = (items, groupConfigs) => {
94
106
  }
95
107
  }
96
108
  }
97
- /** @type {Map<Group<T, R>, { items: Set<ItemWithGroups<T, R>>, options: GroupOptions | false | undefined, used: boolean }>} */
109
+ /** @type {Map<Group<I, G>, { items: Items<I, G>, options: GroupOptions | false | undefined, used: boolean }>} */
98
110
  const groupMap = new Map();
99
111
  for (const group of allGroups.values()) {
100
112
  if (group.items) {
@@ -107,13 +119,15 @@ const smartGrouping = (items, groupConfigs) => {
107
119
  });
108
120
  }
109
121
  }
110
- /** @type {(T | R)[]} */
122
+ /** @type {(I | G)[]} */
111
123
  const results = [];
112
124
  for (;;) {
113
- /** @type {Group<T, R> | undefined} */
125
+ /** @type {Group<I, G> | undefined} */
114
126
  let bestGroup;
115
127
  let bestGroupSize = -1;
128
+ /** @type {Items<I, G> | undefined} */
116
129
  let bestGroupItems;
130
+ /** @type {GroupOptions | false | undefined} */
117
131
  let bestGroupOptions;
118
132
  for (const [group, state] of groupMap) {
119
133
  const { items, used } = state;
@@ -192,8 +206,9 @@ const smartGrouping = (items, groupConfigs) => {
192
206
  bestGroup.alreadyGrouped = true;
193
207
  const children = groupChildren ? runGrouping(items) : allItems;
194
208
  bestGroup.alreadyGrouped = false;
195
-
196
- results.push(groupConfig.createGroup(key, children, allItems));
209
+ results.push(
210
+ groupConfig.createGroup(key, /** @type {I[]} */ (children), allItems)
211
+ );
197
212
  }
198
213
  for (const { item } of itemsWithGroups) {
199
214
  results.push(item);
@@ -0,0 +1,45 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ /** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperties} DestructuringAssignmentProperties */
9
+ /** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */
10
+
11
+ /**
12
+ * Deep first traverse the properties of a destructuring assignment.
13
+ * @param {DestructuringAssignmentProperties} properties destructuring assignment properties
14
+ * @param {((stack: DestructuringAssignmentProperty[]) => void) | undefined=} onLeftNode on left node callback
15
+ * @param {((stack: DestructuringAssignmentProperty[]) => void) | undefined=} enterNode enter node callback
16
+ * @param {((stack: DestructuringAssignmentProperty[]) => void) | undefined=} exitNode exit node callback
17
+ * @param {DestructuringAssignmentProperty[] | undefined=} stack stack of the walking nodes
18
+ */
19
+ function traverseDestructuringAssignmentProperties(
20
+ properties,
21
+ onLeftNode,
22
+ enterNode,
23
+ exitNode,
24
+ stack = []
25
+ ) {
26
+ for (const property of properties) {
27
+ stack.push(property);
28
+ if (enterNode) enterNode(stack);
29
+ if (property.pattern) {
30
+ traverseDestructuringAssignmentProperties(
31
+ property.pattern,
32
+ onLeftNode,
33
+ enterNode,
34
+ exitNode,
35
+ stack
36
+ );
37
+ } else if (onLeftNode) {
38
+ onLeftNode(stack);
39
+ }
40
+ if (exitNode) exitNode(stack);
41
+ stack.pop();
42
+ }
43
+ }
44
+
45
+ module.exports = traverseDestructuringAssignmentProperties;
@@ -5,16 +5,17 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- /** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
9
8
  /** @typedef {import("../../declarations/WebpackOptions").WasmLoadingType} WasmLoadingType */
10
9
  /** @typedef {import("../Compiler")} Compiler */
11
10
 
11
+ /** @typedef {Set<WasmLoadingType>} WasmLoadingTypes */
12
+
12
13
  /** @type {WeakMap<Compiler, Set<WasmLoadingType>>} */
13
14
  const enabledTypes = new WeakMap();
14
15
 
15
16
  /**
16
17
  * @param {Compiler} compiler compiler instance
17
- * @returns {Set<WasmLoadingType>} enabled types
18
+ * @returns {WasmLoadingTypes} enabled types
18
19
  */
19
20
  const getEnabledTypes = (compiler) => {
20
21
  let set = enabledTypes.get(compiler);
@@ -76,7 +76,11 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
76
76
  )})`
77
77
  ];
78
78
  const getStreaming = () => {
79
- const concat = (/** @type {string[]} */ ...text) => text.join("");
79
+ /**
80
+ * @param {string[]} text text
81
+ * @returns {string} merged text
82
+ */
83
+ const concat = (...text) => text.join("");
80
84
  return [
81
85
  this.generateBeforeLoadBinaryCode
82
86
  ? this.generateBeforeLoadBinaryCode(wasmModuleSrcPath)
@@ -14,27 +14,16 @@ const Template = require("../Template");
14
14
  const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
15
15
 
16
16
  /** @typedef {import("webpack-sources").Source} Source */
17
- /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputOptions */
18
- /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
19
17
  /** @typedef {import("../Generator").GenerateContext} GenerateContext */
20
18
  /** @typedef {import("../Module")} Module */
21
19
  /** @typedef {import("../Module").SourceTypes} SourceTypes */
22
20
  /** @typedef {import("../NormalModule")} NormalModule */
23
- /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
24
21
 
25
22
  /**
26
23
  * @typedef {{ request: string, importVar: string }} ImportObjRequestItem
27
24
  */
28
25
 
29
26
  class AsyncWebAssemblyJavascriptGenerator extends Generator {
30
- /**
31
- * @param {OutputOptions["webassemblyModuleFilename"]} filenameTemplate template for the WebAssembly module filename
32
- */
33
- constructor(filenameTemplate) {
34
- super();
35
- this.filenameTemplate = filenameTemplate;
36
- }
37
-
38
27
  /**
39
28
  * @param {NormalModule} module fresh module
40
29
  * @returns {SourceTypes} available types (do not mutate)
@@ -69,7 +58,7 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
69
58
  runtimeRequirements.add(RuntimeGlobals.moduleId);
70
59
  runtimeRequirements.add(RuntimeGlobals.exports);
71
60
  runtimeRequirements.add(RuntimeGlobals.instantiateWasm);
72
- /** @type {InitFragment<InitFragment<string>>[]} */
61
+ /** @type {InitFragment<GenerateContext>[]} */
73
62
  const initFragments = [];
74
63
  /** @type {Map<Module, ImportObjRequestItem>} */
75
64
  const depModules = new Map();
@@ -93,7 +82,7 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
93
82
  }
94
83
  }
95
84
 
96
- /** @type {Array<string>} */
85
+ /** @type {string[]} */
97
86
  const promises = [];
98
87
 
99
88
  const importStatements = Array.from(
@@ -15,7 +15,6 @@ const { compareModulesByIdOrIdentifier } = require("../util/comparators");
15
15
  const memoize = require("../util/memoize");
16
16
 
17
17
  /** @typedef {import("webpack-sources").Source} Source */
18
- /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputOptions */
19
18
  /** @typedef {import("../Chunk")} Chunk */
20
19
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
21
20
  /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
@@ -24,8 +23,6 @@ const memoize = require("../util/memoize");
24
23
  /** @typedef {import("../Module")} Module */
25
24
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
26
25
  /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
27
- /** @typedef {import("../Template").RenderManifestEntry} RenderManifestEntry */
28
- /** @typedef {import("../Template").RenderManifestOptions} RenderManifestOptions */
29
26
  /** @typedef {import("../WebpackError")} WebpackError */
30
27
 
31
28
  const getAsyncWebAssemblyGenerator = memoize(() =>
@@ -126,9 +123,7 @@ class AsyncWebAssemblyModulesPlugin {
126
123
  const AsyncWebAssemblyGenerator = getAsyncWebAssemblyGenerator();
127
124
 
128
125
  return Generator.byType({
129
- javascript: new AsyncWebAssemblyJavascriptGenerator(
130
- compilation.outputOptions.webassemblyModuleFilename
131
- ),
126
+ javascript: new AsyncWebAssemblyJavascriptGenerator(),
132
127
  webassembly: new AsyncWebAssemblyGenerator(this.options)
133
128
  });
134
129
  });
@@ -147,9 +142,7 @@ class AsyncWebAssemblyModulesPlugin {
147
142
  compareModulesByIdOrIdentifier(chunkGraph)
148
143
  )) {
149
144
  if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) {
150
- const filenameTemplate =
151
- /** @type {NonNullable<OutputOptions["webassemblyModuleFilename"]>} */
152
- (outputOptions.webassemblyModuleFilename);
145
+ const filenameTemplate = outputOptions.webassemblyModuleFilename;
153
146
 
154
147
  result.push({
155
148
  render: () =>
@@ -26,15 +26,6 @@ const decoderOpts = {
26
26
  };
27
27
 
28
28
  class WebAssemblyParser extends Parser {
29
- /**
30
- * @param {{}=} options parser options
31
- */
32
- constructor(options) {
33
- super();
34
- this.hooks = Object.freeze({});
35
- this.options = options;
36
- }
37
-
38
29
  /**
39
30
  * @param {string | Buffer | PreparsedAst} source the source to parse
40
31
  * @param {ParserState} state the parser state
@@ -60,8 +51,9 @@ class WebAssemblyParser extends Parser {
60
51
  // parse it
61
52
  const program = decode(source, decoderOpts);
62
53
  const module = program.body[0];
63
- /** @type {Array<string>} */
54
+ /** @type {string[]} */
64
55
  const exports = [];
56
+
65
57
  t.traverse(module, {
66
58
  ModuleExport({ node }) {
67
59
  exports.push(node.name);
@@ -46,12 +46,14 @@ const getAllWasmModules = (moduleGraph, chunkGraph, chunk) => {
46
46
  return array;
47
47
  };
48
48
 
49
+ /** @typedef {string[]} Declarations */
50
+
49
51
  /**
50
52
  * generates the import object function for a module
51
53
  * @param {ChunkGraph} chunkGraph the chunk graph
52
54
  * @param {Module} module the module
53
55
  * @param {boolean | undefined} mangle mangle imports
54
- * @param {string[]} declarations array where declarations are pushed to
56
+ * @param {Declarations} declarations array where declarations are pushed to
55
57
  * @param {RuntimeSpec} runtime the runtime
56
58
  * @returns {string} source code
57
59
  */
@@ -63,7 +65,7 @@ const generateImportObject = (
63
65
  runtime
64
66
  ) => {
65
67
  const moduleGraph = chunkGraph.moduleGraph;
66
- /** @type {Map<string, string | number>} */
68
+ /** @type {Map<string, ModuleId>} */
67
69
  const waitForInstances = new Map();
68
70
  const properties = [];
69
71
  const usedWasmDependencies = WebAssemblyUtils.getUsedDependencies(
@@ -146,7 +148,7 @@ const generateImportObject = (
146
148
  "};"
147
149
  ];
148
150
  } else {
149
- /** @type {Map<string, Array<{ name: string, value: string }>>} */
151
+ /** @type {Map<string, { name: string, value: string }[]>} */
150
152
  const propertiesByModule = new Map();
151
153
  for (const p of properties) {
152
154
  let list = propertiesByModule.get(p.module);
@@ -253,7 +255,7 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
253
255
  const chunk = /** @type {Chunk} */ (this.chunk);
254
256
  const wasmModules = getAllWasmModules(moduleGraph, chunkGraph, chunk);
255
257
  const { mangleImports } = this;
256
- /** @type {string[]} */
258
+ /** @type {Declarations} */
257
259
  const declarations = [];
258
260
  const importObjects = wasmModules.map((module) =>
259
261
  generateImportObject(
@@ -16,13 +16,11 @@ const WebAssemblyExportImportedDependency = require("../dependencies/WebAssembly
16
16
  const WebAssemblyUtils = require("./WebAssemblyUtils");
17
17
 
18
18
  /** @typedef {import("webpack-sources").Source} Source */
19
- /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
20
19
  /** @typedef {import("../Generator").GenerateContext} GenerateContext */
21
20
  /** @typedef {import("../Module")} Module */
22
21
  /** @typedef {import("../Module").SourceTypes} SourceTypes */
23
22
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
24
23
  /** @typedef {import("../NormalModule")} NormalModule */
25
- /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
26
24
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
27
25
  /** @typedef {import("./WebAssemblyUtils").UsedWasmDependency} UsedWasmDependency */
28
26
  /** @typedef {import("@webassemblyjs/ast").Instruction} Instruction */
@@ -175,7 +173,7 @@ const createDefaultInitForGlobal = (globalType) => {
175
173
  */
176
174
  const rewriteImportedGlobals = (state) => (bin) => {
177
175
  const additionalInitCode = state.additionalInitCode;
178
- /** @type {Array<t.Global>} */
176
+ /** @type {t.Global[]} */
179
177
  const newGlobals = [];
180
178
 
181
179
  bin = editWithAST(state.ast, bin, {
@@ -17,13 +17,10 @@ const WebAssemblyExportImportedDependency = require("../dependencies/WebAssembly
17
17
  const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
18
18
 
19
19
  /** @typedef {import("webpack-sources").Source} Source */
20
- /** @typedef {import("../Dependency")} Dependency */
21
- /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
22
20
  /** @typedef {import("../Generator").GenerateContext} GenerateContext */
23
21
  /** @typedef {import("../Module")} Module */
24
22
  /** @typedef {import("../Module").SourceTypes} SourceTypes */
25
23
  /** @typedef {import("../NormalModule")} NormalModule */
26
- /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
27
24
 
28
25
  class WebAssemblyJavascriptGenerator extends Generator {
29
26
  /**
@@ -56,7 +53,7 @@ class WebAssemblyJavascriptGenerator extends Generator {
56
53
  runtimeRequirements,
57
54
  runtime
58
55
  } = generateContext;
59
- /** @type {InitFragment<InitFragment<string>>[]} */
56
+ /** @type {InitFragment<GenerateContext>[]} */
60
57
  const initFragments = [];
61
58
 
62
59
  const exportsInfo = moduleGraph.getExportsInfo(module);