webpack 5.101.3 → 5.102.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 (322) 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 +35 -25
  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 +2 -1
  13. package/lib/CompatibilityPlugin.js +29 -12
  14. package/lib/Compilation.js +204 -185
  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 +22 -20
  21. package/lib/ContextModuleFactory.js +30 -11
  22. package/lib/ContextReplacementPlugin.js +38 -15
  23. package/lib/DefinePlugin.js +4 -8
  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 +1 -3
  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 +96 -78
  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 +41 -24
  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 +145 -88
  63. package/lib/NormalModuleFactory.js +59 -40
  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 +12 -11
  75. package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
  76. package/lib/SourceMapDevToolPlugin.js +6 -11
  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 +166 -0
  85. package/lib/asset/AssetBytesParser.js +37 -0
  86. package/lib/asset/AssetGenerator.js +20 -34
  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/config/defaults.js +155 -21
  98. package/lib/config/normalization.js +18 -3
  99. package/lib/container/ContainerEntryDependency.js +0 -1
  100. package/lib/container/ContainerEntryModule.js +3 -7
  101. package/lib/container/ContainerPlugin.js +1 -2
  102. package/lib/container/ContainerReferencePlugin.js +0 -1
  103. package/lib/container/FallbackDependency.js +2 -1
  104. package/lib/container/FallbackModule.js +6 -7
  105. package/lib/container/ModuleFederationPlugin.js +0 -1
  106. package/lib/container/RemoteModule.js +8 -8
  107. package/lib/container/RemoteRuntimeModule.js +2 -2
  108. package/lib/css/CssGenerator.js +3 -6
  109. package/lib/css/CssLoadingRuntimeModule.js +6 -9
  110. package/lib/css/CssModulesPlugin.js +11 -13
  111. package/lib/css/CssParser.js +3 -3
  112. package/lib/css/walkCssTokens.js +1 -1
  113. package/lib/debug/ProfilingPlugin.js +35 -8
  114. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
  115. package/lib/dependencies/AMDPlugin.js +2 -2
  116. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
  117. package/lib/dependencies/CachedConstDependency.js +0 -4
  118. package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
  119. package/lib/dependencies/CommonJsExportsDependency.js +2 -1
  120. package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
  121. package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
  122. package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
  123. package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
  124. package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
  125. package/lib/dependencies/ConstDependency.js +2 -2
  126. package/lib/dependencies/ContextDependency.js +9 -4
  127. package/lib/dependencies/ContextDependencyHelpers.js +2 -2
  128. package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
  129. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
  130. package/lib/dependencies/ContextElementDependency.js +22 -11
  131. package/lib/dependencies/CssIcssImportDependency.js +0 -2
  132. package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
  133. package/lib/dependencies/CssImportDependency.js +0 -8
  134. package/lib/dependencies/CssLocalIdentifierDependency.js +3 -4
  135. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
  136. package/lib/dependencies/CssUrlDependency.js +0 -6
  137. package/lib/dependencies/ExportsInfoDependency.js +7 -9
  138. package/lib/dependencies/ExternalModuleDependency.js +0 -3
  139. package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
  140. package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
  141. package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
  142. package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
  143. package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
  144. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
  145. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
  146. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
  147. package/lib/dependencies/HarmonyImportDependency.js +30 -14
  148. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
  149. package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
  150. package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
  151. package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
  152. package/lib/dependencies/ImportDependency.js +18 -6
  153. package/lib/dependencies/ImportEagerDependency.js +2 -3
  154. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
  155. package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
  156. package/lib/dependencies/ImportMetaPlugin.js +2 -1
  157. package/lib/dependencies/ImportParserPlugin.js +288 -45
  158. package/lib/dependencies/ImportWeakDependency.js +2 -3
  159. package/lib/dependencies/JsonExportsDependency.js +0 -1
  160. package/lib/dependencies/LoaderDependency.js +0 -3
  161. package/lib/dependencies/LoaderImportDependency.js +0 -3
  162. package/lib/dependencies/LoaderPlugin.js +11 -5
  163. package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
  164. package/lib/dependencies/ModuleDependency.js +3 -9
  165. package/lib/dependencies/NullDependency.js +2 -0
  166. package/lib/dependencies/ProvidedDependency.js +6 -8
  167. package/lib/dependencies/PureExpressionDependency.js +0 -1
  168. package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
  169. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
  170. package/lib/dependencies/RequireIncludeDependency.js +2 -2
  171. package/lib/dependencies/RequireResolveDependency.js +2 -2
  172. package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
  173. package/lib/dependencies/StaticExportsDependency.js +3 -5
  174. package/lib/dependencies/URLDependency.js +2 -7
  175. package/lib/dependencies/URLPlugin.js +1 -2
  176. package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
  177. package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
  178. package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
  179. package/lib/dependencies/WorkerDependency.js +2 -3
  180. package/lib/dependencies/WorkerPlugin.js +3 -9
  181. package/lib/dependencies/processExportInfo.js +2 -3
  182. package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
  183. package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
  184. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
  185. package/lib/hmr/LazyCompilationPlugin.js +6 -4
  186. package/lib/hmr/lazyCompilationBackend.js +13 -10
  187. package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
  188. package/lib/ids/NamedChunkIdsPlugin.js +1 -6
  189. package/lib/ids/NamedModuleIdsPlugin.js +1 -5
  190. package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
  191. package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
  192. package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
  193. package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
  194. package/lib/ids/SyncModuleIdsPlugin.js +4 -3
  195. package/lib/index.js +8 -7
  196. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
  197. package/lib/javascript/BasicEvaluatedExpression.js +13 -6
  198. package/lib/javascript/ChunkFormatHelpers.js +1 -1
  199. package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
  200. package/lib/javascript/JavascriptGenerator.js +2 -3
  201. package/lib/javascript/JavascriptModulesPlugin.js +44 -21
  202. package/lib/javascript/JavascriptParser.js +119 -54
  203. package/lib/javascript/JavascriptParserHelpers.js +2 -2
  204. package/lib/javascript/StartupHelpers.js +2 -4
  205. package/lib/json/JsonData.js +1 -1
  206. package/lib/json/JsonGenerator.js +4 -5
  207. package/lib/json/JsonModulesPlugin.js +0 -3
  208. package/lib/json/JsonParser.js +4 -2
  209. package/lib/library/AbstractLibraryPlugin.js +2 -2
  210. package/lib/library/AmdLibraryPlugin.js +0 -1
  211. package/lib/library/AssignLibraryPlugin.js +23 -12
  212. package/lib/library/EnableLibraryPlugin.js +7 -11
  213. package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
  214. package/lib/library/JsonpLibraryPlugin.js +5 -2
  215. package/lib/library/ModuleLibraryPlugin.js +88 -43
  216. package/lib/library/SystemLibraryPlugin.js +0 -1
  217. package/lib/library/UmdLibraryPlugin.js +12 -18
  218. package/lib/logging/Logger.js +12 -10
  219. package/lib/logging/createConsoleLogger.js +15 -14
  220. package/lib/logging/truncateArgs.js +1 -1
  221. package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
  222. package/lib/node/NodeWatchFileSystem.js +4 -4
  223. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
  224. package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
  225. package/lib/node/nodeConsole.js +2 -2
  226. package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
  227. package/lib/optimize/ConcatenatedModule.js +142 -100
  228. package/lib/optimize/InnerGraph.js +17 -11
  229. package/lib/optimize/InnerGraphPlugin.js +0 -3
  230. package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
  231. package/lib/optimize/RuntimeChunkPlugin.js +0 -1
  232. package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
  233. package/lib/optimize/SplitChunksPlugin.js +46 -40
  234. package/lib/performance/SizeLimitsPlugin.js +2 -1
  235. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
  236. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
  237. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
  238. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
  239. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
  240. package/lib/rules/BasicMatcherRulePlugin.js +0 -2
  241. package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
  242. package/lib/rules/RuleSetCompiler.js +8 -6
  243. package/lib/runtime/BaseUriRuntimeModule.js +2 -2
  244. package/lib/runtime/CompatRuntimeModule.js +0 -1
  245. package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
  246. package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
  247. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
  248. package/lib/runtime/PublicPathRuntimeModule.js +2 -2
  249. package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
  250. package/lib/runtime/SystemContextRuntimeModule.js +0 -2
  251. package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
  252. package/lib/schemes/DataUriPlugin.js +2 -28
  253. package/lib/schemes/FileUriPlugin.js +5 -2
  254. package/lib/schemes/HttpUriPlugin.js +4 -2
  255. package/lib/schemes/VirtualUrlPlugin.js +11 -11
  256. package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
  257. package/lib/serialization/ObjectMiddleware.js +30 -19
  258. package/lib/serialization/SerializerMiddleware.js +1 -3
  259. package/lib/serialization/types.js +1 -1
  260. package/lib/sharing/ConsumeSharedModule.js +3 -5
  261. package/lib/sharing/ConsumeSharedPlugin.js +2 -4
  262. package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
  263. package/lib/sharing/ProvideSharedModule.js +3 -7
  264. package/lib/sharing/SharePlugin.js +0 -2
  265. package/lib/sharing/ShareRuntimeModule.js +4 -1
  266. package/lib/sharing/resolveMatchedConfigs.js +14 -6
  267. package/lib/sharing/utils.js +0 -6
  268. package/lib/stats/DefaultStatsFactoryPlugin.js +178 -94
  269. package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
  270. package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
  271. package/lib/stats/StatsFactory.js +14 -11
  272. package/lib/url/URLParserPlugin.js +2 -4
  273. package/lib/util/ArrayHelpers.js +4 -4
  274. package/lib/util/AsyncQueue.js +1 -0
  275. package/lib/util/LazySet.js +2 -2
  276. package/lib/util/StackedCacheMap.js +0 -2
  277. package/lib/util/TupleSet.js +9 -4
  278. package/lib/util/URLAbsoluteSpecifier.js +0 -1
  279. package/lib/util/WeakTupleMap.js +1 -1
  280. package/lib/util/chainedImports.js +3 -1
  281. package/lib/util/cleverMerge.js +15 -18
  282. package/lib/util/comparators.js +2 -4
  283. package/lib/util/compileBooleanMatcher.js +11 -9
  284. package/lib/util/concatenate.js +1 -2
  285. package/lib/util/create-schema-validation.js +0 -1
  286. package/lib/util/dataURL.js +39 -0
  287. package/lib/util/deprecation.js +29 -31
  288. package/lib/util/deterministicGrouping.js +34 -30
  289. package/lib/util/extractSourceMap.js +319 -0
  290. package/lib/util/findGraphRoots.js +15 -5
  291. package/lib/util/fs.js +29 -8
  292. package/lib/util/semver.js +9 -8
  293. package/lib/util/smartGrouping.js +41 -26
  294. package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
  295. package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
  296. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
  297. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
  298. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
  299. package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -1
  300. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
  301. package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
  302. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
  303. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
  304. package/lib/wasm-sync/WebAssemblyParser.js +1 -4
  305. package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
  306. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
  307. package/lib/web/JsonpTemplatePlugin.js +0 -1
  308. package/lib/webpack.js +21 -8
  309. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
  310. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  311. package/package.json +12 -12
  312. package/schemas/WebpackOptions.check.js +1 -1
  313. package/schemas/WebpackOptions.json +77 -93
  314. package/schemas/plugins/BannerPlugin.check.js +1 -1
  315. package/schemas/plugins/BannerPlugin.json +4 -0
  316. package/schemas/plugins/IgnorePlugin.json +1 -1
  317. package/schemas/plugins/ProgressPlugin.json +1 -1
  318. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  319. package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
  320. package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
  321. package/types.d.ts +1129 -530
  322. package/SECURITY.md +0 -9
@@ -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: () =>
@@ -60,8 +60,9 @@ class WebAssemblyParser extends Parser {
60
60
  // parse it
61
61
  const program = decode(source, decoderOpts);
62
62
  const module = program.body[0];
63
- /** @type {Array<string>} */
63
+ /** @type {string[]} */
64
64
  const exports = [];
65
+
65
66
  t.traverse(module, {
66
67
  ModuleExport({ node }) {
67
68
  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);
@@ -13,12 +13,8 @@ const { compareModulesByIdOrIdentifier } = require("../util/comparators");
13
13
  const memoize = require("../util/memoize");
14
14
  const WebAssemblyInInitialChunkError = require("./WebAssemblyInInitialChunkError");
15
15
 
16
- /** @typedef {import("webpack-sources").Source} Source */
17
- /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputOptions */
18
16
  /** @typedef {import("../Compiler")} Compiler */
19
17
  /** @typedef {import("../Module")} Module */
20
- /** @typedef {import("../ModuleTemplate")} ModuleTemplate */
21
- /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */
22
18
 
23
19
  const getWebAssemblyGenerator = memoize(() =>
24
20
  require("./WebAssemblyGenerator")
@@ -92,9 +88,7 @@ class WebAssemblyModulesPlugin {
92
88
  compareModulesByIdOrIdentifier(chunkGraph)
93
89
  )) {
94
90
  if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) {
95
- const filenameTemplate =
96
- /** @type {NonNullable<OutputOptions["webassemblyModuleFilename"]>} */
97
- (outputOptions.webassemblyModuleFilename);
91
+ const filenameTemplate = outputOptions.webassemblyModuleFilename;
98
92
 
99
93
  result.push({
100
94
  render: () =>
@@ -123,6 +117,7 @@ class WebAssemblyModulesPlugin {
123
117
 
124
118
  compilation.hooks.afterChunks.tap(PLUGIN_NAME, () => {
125
119
  const chunkGraph = compilation.chunkGraph;
120
+ /** @type {Set<Module>} */
126
121
  const initialWasmModules = new Set();
127
122
  for (const chunk of compilation.chunks) {
128
123
  if (chunk.canBeInitial()) {
@@ -14,8 +14,6 @@ const WebAssemblyExportImportedDependency = require("../dependencies/WebAssembly
14
14
  const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
15
15
 
16
16
  /** @typedef {import("@webassemblyjs/ast").ModuleImport} ModuleImport */
17
- /** @typedef {import("@webassemblyjs/ast").NumberLiteral} NumberLiteral */
18
- /** @typedef {import("../Module")} Module */
19
17
  /** @typedef {import("../Module").BuildInfo} BuildInfo */
20
18
  /** @typedef {import("../Module").BuildMeta} BuildMeta */
21
19
  /** @typedef {import("../Parser").ParserState} ParserState */
@@ -132,8 +130,7 @@ class WebAssemblyParser extends Parser {
132
130
  exports.push(node.name);
133
131
 
134
132
  if (node.descr && node.descr.exportType === "Global") {
135
- const refNode =
136
- importedGlobals[/** @type {NumberLiteral} */ (node.descr.id).value];
133
+ const refNode = importedGlobals[node.descr.id.value];
137
134
  if (refNode) {
138
135
  const dep = new WebAssemblyExportImportedDependency(
139
136
  node.name,
@@ -10,6 +10,7 @@ const JsonpChunkLoadingRuntimeModule = require("./JsonpChunkLoadingRuntimeModule
10
10
 
11
11
  /** @typedef {import("../Chunk")} Chunk */
12
12
  /** @typedef {import("../Compiler")} Compiler */
13
+ /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
13
14
 
14
15
  const PLUGIN_NAME = "JsonpChunkLoadingPlugin";
15
16
 
@@ -37,7 +38,7 @@ class JsonpChunkLoadingPlugin {
37
38
  const onceForChunkSet = new WeakSet();
38
39
  /**
39
40
  * @param {Chunk} chunk chunk
40
- * @param {Set<string>} set runtime requirements
41
+ * @param {RuntimeRequirements} set runtime requirements
41
42
  */
42
43
  const handler = (chunk, set) => {
43
44
  if (onceForChunkSet.has(chunk)) return;
@@ -69,7 +69,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
69
69
  if (options && options.baseUri) {
70
70
  return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
71
71
  }
72
- return `${RuntimeGlobals.baseURI} = document.baseURI || self.location.href;`;
72
+ return `${RuntimeGlobals.baseURI} = (document && document.baseURI) || self.location.href;`;
73
73
  }
74
74
 
75
75
  /**
@@ -9,7 +9,6 @@ const ArrayPushCallbackChunkFormatPlugin = require("../javascript/ArrayPushCallb
9
9
  const EnableChunkLoadingPlugin = require("../javascript/EnableChunkLoadingPlugin");
10
10
  const JsonpChunkLoadingRuntimeModule = require("./JsonpChunkLoadingRuntimeModule");
11
11
 
12
- /** @typedef {import("../Chunk")} Chunk */
13
12
  /** @typedef {import("../Compilation")} Compilation */
14
13
  /** @typedef {import("../Compiler")} Compiler */
15
14
 
package/lib/webpack.js CHANGED
@@ -21,6 +21,7 @@ const memoize = require("./util/memoize");
21
21
 
22
22
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
23
23
  /** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
24
+ /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptionsNormalizedWithDefaults */
24
25
  /** @typedef {import("./Compiler").WatchOptions} WatchOptions */
25
26
  /** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */
26
27
  /** @typedef {import("./MultiCompiler").MultiWebpackOptions} MultiWebpackOptions */
@@ -31,12 +32,15 @@ const getValidateSchema = memoize(() => require("./validateSchema"));
31
32
 
32
33
  /**
33
34
  * @template T
35
+ * @template [R=void]
34
36
  * @callback Callback
35
37
  * @param {Error | null} err
36
- * @param {T=} stats
37
- * @returns {void}
38
+ * @param {T=} result
39
+ * @returns {R}
38
40
  */
39
41
 
42
+ /** @typedef {Callback<void>} ErrorCallback */
43
+
40
44
  /**
41
45
  * @param {ReadonlyArray<WebpackOptions>} childOptions options array
42
46
  * @param {MultiCompilerOptions} options options
@@ -92,7 +96,11 @@ const createCompiler = (rawOptions, compilerIndex) => {
92
96
  }
93
97
  compiler.hooks.environment.call();
94
98
  compiler.hooks.afterEnvironment.call();
95
- new WebpackOptionsApply().process(options, compiler);
99
+ new WebpackOptionsApply().process(
100
+ /** @type {WebpackOptionsNormalizedWithDefaults} */
101
+ (options),
102
+ compiler
103
+ );
96
104
  compiler.hooks.initialize.call();
97
105
  return compiler;
98
106
  };
@@ -113,8 +121,8 @@ const createCompiler = (rawOptions, compilerIndex) => {
113
121
 
114
122
  /**
115
123
  * @template T
116
- * @param {Array<T> | T} options options
117
- * @returns {Array<T>} array of options
124
+ * @param {T[] | T} options options
125
+ * @returns {T[]} array of options
118
126
  */
119
127
  const asArray = (options) =>
120
128
  Array.isArray(options) ? [...options] : [options];
@@ -130,7 +138,11 @@ const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
130
138
  /** @type {WebpackCallback} */
131
139
  (options, callback) => {
132
140
  const create = () => {
133
- if (!asArray(options).every(webpackOptionsSchemaCheck)) {
141
+ if (
142
+ !asArray(/** @type {WebpackOptions} */ (options)).every(
143
+ webpackOptionsSchemaCheck
144
+ )
145
+ ) {
134
146
  getValidateSchema()(webpackOptionsSchema, options);
135
147
  util.deprecate(
136
148
  () => {},
@@ -142,13 +154,14 @@ const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
142
154
  let compiler;
143
155
  /** @type {boolean | undefined} */
144
156
  let watch = false;
145
- /** @type {WatchOptions|WatchOptions[]} */
157
+ /** @type {WatchOptions | WatchOptions[]} */
146
158
  let watchOptions;
147
159
  if (Array.isArray(options)) {
148
160
  /** @type {MultiCompiler} */
149
161
  compiler = createMultiCompiler(
150
162
  options,
151
- /** @type {MultiCompilerOptions} */ (options)
163
+ /** @type {MultiCompilerOptions} */
164
+ (options)
152
165
  );
153
166
  watch = options.some((options) => options.watch);
154
167
  watchOptions = options.map((options) => options.watchOptions || {});
@@ -11,6 +11,7 @@ const ImportScriptsChunkLoadingRuntimeModule = require("./ImportScriptsChunkLoad
11
11
 
12
12
  /** @typedef {import("../Chunk")} Chunk */
13
13
  /** @typedef {import("../Compiler")} Compiler */
14
+ /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
14
15
 
15
16
  const PLUGIN_NAME = "ImportScriptsChunkLoadingPlugin";
16
17
 
@@ -42,7 +43,7 @@ class ImportScriptsChunkLoadingPlugin {
42
43
  const onceForChunkSet = new WeakSet();
43
44
  /**
44
45
  * @param {Chunk} chunk chunk
45
- * @param {Set<string>} set runtime requirements
46
+ * @param {RuntimeRequirements} set runtime requirements
46
47
  */
47
48
  const handler = (chunk, set) => {
48
49
  if (onceForChunkSet.has(chunk)) return;
@@ -54,7 +54,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
54
54
  );
55
55
  const rootOutputDir = getUndoPath(
56
56
  outputName,
57
- /** @type {string} */ (compilation.outputOptions.path),
57
+ compilation.outputOptions.path,
58
58
  false
59
59
  );
60
60
  return `${RuntimeGlobals.baseURI} = self.location + ${JSON.stringify(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.101.3",
3
+ "version": "5.102.0",
4
4
  "description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
5
5
  "homepage": "https://github.com/webpack/webpack",
6
6
  "bugs": "https://github.com/webpack/webpack/issues",
@@ -89,7 +89,7 @@
89
89
  "@webassemblyjs/wasm-parser": "^1.14.1",
90
90
  "acorn": "^8.15.0",
91
91
  "acorn-import-phases": "^1.0.3",
92
- "browserslist": "^4.24.0",
92
+ "browserslist": "^4.24.5",
93
93
  "chrome-trace-event": "^1.0.2",
94
94
  "enhanced-resolve": "^5.17.3",
95
95
  "es-module-lexer": "^1.2.1",
@@ -102,9 +102,9 @@
102
102
  "mime-types": "^2.1.27",
103
103
  "neo-async": "^2.6.2",
104
104
  "schema-utils": "^4.3.2",
105
- "tapable": "^2.1.1",
105
+ "tapable": "^2.2.3",
106
106
  "terser-webpack-plugin": "^5.3.11",
107
- "watchpack": "^2.4.1",
107
+ "watchpack": "^2.4.4",
108
108
  "webpack-sources": "^3.3.3"
109
109
  },
110
110
  "devDependencies": {
@@ -120,7 +120,7 @@
120
120
  "@types/mime-types": "^2.1.4",
121
121
  "@types/node": "^24.1.0",
122
122
  "@types/xxhashjs": "^0.2.4",
123
- "assemblyscript": "^0.28.2",
123
+ "assemblyscript": "^0.28.5",
124
124
  "babel-loader": "^10.0.0",
125
125
  "bundle-loader": "^0.5.6",
126
126
  "coffee-loader": "^5.0.0",
@@ -139,18 +139,18 @@
139
139
  "eslint-plugin-jsdoc": "^51.2.3",
140
140
  "eslint-plugin-n": "^17.21.0",
141
141
  "eslint-plugin-prettier": "^5.5.0",
142
- "eslint-plugin-unicorn": "^60.0.0",
142
+ "eslint-plugin-unicorn": "^61.0.1",
143
143
  "file-loader": "^6.0.0",
144
144
  "fork-ts-checker-webpack-plugin": "^9.0.2",
145
145
  "globals": "^16.0.0",
146
146
  "hash-wasm": "^4.9.0",
147
147
  "husky": "^9.0.11",
148
148
  "istanbul": "^0.4.5",
149
- "jest": "^30.0.5",
150
- "jest-circus": "^30.0.5",
151
- "jest-cli": "^30.0.5",
152
- "jest-diff": "^30.0.5",
153
- "jest-environment-node": "^30.0.5",
149
+ "jest": "^30.1.2",
150
+ "jest-circus": "^30.1.2",
151
+ "jest-cli": "^30.1.2",
152
+ "jest-diff": "^30.1.2",
153
+ "jest-environment-node": "^30.1.2",
154
154
  "jest-junit": "^16.0.0",
155
155
  "json-loader": "^0.5.7",
156
156
  "json5": "^2.1.3",
@@ -179,7 +179,7 @@
179
179
  "strip-ansi": "^6.0.0",
180
180
  "style-loader": "^4.0.0",
181
181
  "terser": "^5.43.1",
182
- "three": "^0.179.1",
182
+ "three": "^0.180.0",
183
183
  "tinybench": "^5.0.0",
184
184
  "toml": "^3.0.0",
185
185
  "tooling": "webpack/tooling#v1.24.3",