webpack 5.104.1 → 5.105.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 (279) hide show
  1. package/bin/webpack.js +6 -3
  2. package/lib/APIPlugin.js +85 -15
  3. package/lib/AbstractMethodError.js +1 -0
  4. package/lib/AsyncDependenciesBlock.js +13 -1
  5. package/lib/AsyncDependencyToInitialChunkError.js +1 -0
  6. package/lib/AutomaticPrefetchPlugin.js +1 -1
  7. package/lib/BannerPlugin.js +2 -0
  8. package/lib/CacheFacade.js +2 -2
  9. package/lib/CaseSensitiveModulesWarning.js +1 -0
  10. package/lib/Chunk.js +8 -4
  11. package/lib/ChunkGraph.js +30 -9
  12. package/lib/ChunkGroup.js +6 -3
  13. package/lib/ChunkRenderError.js +2 -0
  14. package/lib/CleanPlugin.js +4 -1
  15. package/lib/CodeGenerationError.js +7 -1
  16. package/lib/CodeGenerationResults.js +10 -3
  17. package/lib/CommentCompilationWarning.js +2 -1
  18. package/lib/Compilation.js +280 -236
  19. package/lib/Compiler.js +3 -2
  20. package/lib/ConcatenationScope.js +2 -1
  21. package/lib/ConcurrentCompilationError.js +3 -3
  22. package/lib/ContextModule.js +248 -111
  23. package/lib/ContextModuleFactory.js +14 -2
  24. package/lib/DefinePlugin.js +3 -1
  25. package/lib/DelegatedModule.js +6 -0
  26. package/lib/DelegatedModuleFactoryPlugin.js +2 -0
  27. package/lib/Dependency.js +6 -1
  28. package/lib/DependencyTemplates.js +3 -2
  29. package/lib/DllModule.js +2 -0
  30. package/lib/DllReferencePlugin.js +1 -0
  31. package/lib/DotenvPlugin.js +11 -5
  32. package/lib/DynamicEntryPlugin.js +1 -0
  33. package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
  34. package/lib/EvalSourceMapDevToolPlugin.js +17 -13
  35. package/lib/ExportsInfo.js +8 -4
  36. package/lib/ExternalModule.js +16 -0
  37. package/lib/FalseIIFEUmdWarning.js +1 -0
  38. package/lib/FileSystemInfo.js +49 -25
  39. package/lib/FlagDependencyExportsPlugin.js +8 -1
  40. package/lib/FlagDependencyUsagePlugin.js +9 -7
  41. package/lib/HarmonyLinkingError.js +1 -0
  42. package/lib/HookWebpackError.js +2 -0
  43. package/lib/HotModuleReplacementPlugin.js +16 -2
  44. package/lib/InitFragment.js +1 -0
  45. package/lib/InvalidDependenciesModuleWarning.js +1 -0
  46. package/lib/LibManifestPlugin.js +1 -0
  47. package/lib/ManifestPlugin.js +4 -1
  48. package/lib/Module.js +7 -4
  49. package/lib/ModuleBuildError.js +3 -1
  50. package/lib/ModuleDependencyError.js +1 -0
  51. package/lib/ModuleDependencyWarning.js +1 -0
  52. package/lib/ModuleError.js +2 -1
  53. package/lib/ModuleFilenameHelpers.js +2 -1
  54. package/lib/ModuleGraph.js +3 -0
  55. package/lib/ModuleGraphConnection.js +10 -1
  56. package/lib/ModuleHashingError.js +2 -0
  57. package/lib/ModuleInfoHeaderPlugin.js +6 -1
  58. package/lib/ModuleNotFoundError.js +1 -0
  59. package/lib/ModuleParseError.js +5 -1
  60. package/lib/ModuleProfile.js +1 -1
  61. package/lib/ModuleRestoreError.js +2 -0
  62. package/lib/ModuleSourceTypeConstants.js +1 -11
  63. package/lib/ModuleStoreError.js +2 -0
  64. package/lib/ModuleWarning.js +3 -1
  65. package/lib/MultiCompiler.js +11 -7
  66. package/lib/MultiWatching.js +2 -2
  67. package/lib/NoModeWarning.js +1 -0
  68. package/lib/NodeStuffInWebError.js +1 -0
  69. package/lib/NormalModule.js +26 -5
  70. package/lib/NormalModuleFactory.js +20 -4
  71. package/lib/OptionsApply.js +3 -1
  72. package/lib/ProgressPlugin.js +4 -0
  73. package/lib/RawModule.js +2 -0
  74. package/lib/RuntimeModule.js +10 -0
  75. package/lib/RuntimePlugin.js +7 -9
  76. package/lib/RuntimeTemplate.js +14 -7
  77. package/lib/SourceMapDevToolPlugin.js +30 -23
  78. package/lib/Template.js +10 -5
  79. package/lib/TemplatedPathPlugin.js +4 -2
  80. package/lib/UnhandledSchemeError.js +1 -0
  81. package/lib/UnsupportedFeatureWarning.js +1 -0
  82. package/lib/WarnDeprecatedOptionPlugin.js +1 -0
  83. package/lib/WatchIgnorePlugin.js +1 -1
  84. package/lib/Watching.js +5 -0
  85. package/lib/WebpackError.js +4 -0
  86. package/lib/WebpackOptionsApply.js +60 -40
  87. package/lib/asset/AssetBytesGenerator.js +1 -0
  88. package/lib/asset/AssetGenerator.js +9 -3
  89. package/lib/asset/AssetModulesPlugin.js +33 -2
  90. package/lib/asset/AssetSourceGenerator.js +1 -0
  91. package/lib/asset/RawDataUrlModule.js +4 -0
  92. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
  93. package/lib/buildChunkGraph.js +31 -2
  94. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  95. package/lib/cache/PackFileCacheStrategy.js +41 -8
  96. package/lib/cache/getLazyHashedEtag.js +13 -4
  97. package/lib/cache/mergeEtags.js +3 -1
  98. package/lib/cli.js +3 -1
  99. package/lib/config/defaults.js +65 -44
  100. package/lib/config/normalization.js +96 -0
  101. package/lib/container/ContainerEntryModule.js +4 -0
  102. package/lib/container/FallbackModule.js +2 -0
  103. package/lib/container/HoistContainerReferencesPlugin.js +6 -0
  104. package/lib/container/RemoteModule.js +19 -0
  105. package/lib/css/CssGenerator.js +31 -4
  106. package/lib/css/CssModulesPlugin.js +26 -30
  107. package/lib/css/CssParser.js +12 -9
  108. package/lib/debug/ProfilingPlugin.js +1 -0
  109. package/lib/dependencies/AMDDefineDependency.js +3 -1
  110. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
  111. package/lib/dependencies/AMDPlugin.js +1 -1
  112. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
  113. package/lib/dependencies/CachedConstDependency.js +1 -0
  114. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
  115. package/lib/dependencies/CommonJsExportRequireDependency.js +1 -0
  116. package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
  117. package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -0
  118. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
  119. package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
  120. package/lib/dependencies/ConstDependency.js +1 -0
  121. package/lib/dependencies/ContextDependencyHelpers.js +11 -4
  122. package/lib/dependencies/ContextElementDependency.js +1 -0
  123. package/lib/dependencies/CriticalDependencyWarning.js +1 -0
  124. package/lib/dependencies/CssIcssExportDependency.js +5 -4
  125. package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
  126. package/lib/dependencies/CssUrlDependency.js +2 -3
  127. package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
  128. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
  129. package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
  130. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +1 -0
  131. package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
  132. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
  133. package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
  134. package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
  135. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +266 -5
  136. package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
  137. package/lib/dependencies/ImportDependency.js +1 -0
  138. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  139. package/lib/dependencies/ImportMetaPlugin.js +53 -11
  140. package/lib/dependencies/ImportParserPlugin.js +7 -12
  141. package/lib/dependencies/LoaderPlugin.js +3 -0
  142. package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
  143. package/lib/dependencies/ModuleDependency.js +1 -0
  144. package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
  145. package/lib/dependencies/ProvidedDependency.js +1 -0
  146. package/lib/dependencies/RequireContextPlugin.js +1 -0
  147. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
  148. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
  149. package/lib/dependencies/WorkerDependency.js +9 -3
  150. package/lib/dependencies/WorkerPlugin.js +1 -0
  151. package/lib/dependencies/getFunctionExpression.js +3 -1
  152. package/lib/errors/BuildCycleError.js +4 -1
  153. package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
  154. package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
  155. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
  156. package/lib/hmr/LazyCompilationPlugin.js +5 -0
  157. package/lib/hmr/lazyCompilationBackend.js +3 -2
  158. package/lib/ids/ChunkModuleIdRangePlugin.js +2 -0
  159. package/lib/ids/IdHelpers.js +10 -8
  160. package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -7
  161. package/lib/ids/SyncModuleIdsPlugin.js +5 -1
  162. package/lib/javascript/BasicEvaluatedExpression.js +1 -0
  163. package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
  164. package/lib/javascript/JavascriptModulesPlugin.js +29 -8
  165. package/lib/javascript/JavascriptParser.js +47 -14
  166. package/lib/json/JsonParser.js +6 -0
  167. package/lib/library/AbstractLibraryPlugin.js +4 -1
  168. package/lib/library/AmdLibraryPlugin.js +2 -1
  169. package/lib/library/AssignLibraryPlugin.js +6 -2
  170. package/lib/library/EnableLibraryPlugin.js +1 -0
  171. package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
  172. package/lib/library/JsonpLibraryPlugin.js +1 -1
  173. package/lib/library/ModuleLibraryPlugin.js +130 -13
  174. package/lib/library/SystemLibraryPlugin.js +4 -1
  175. package/lib/library/UmdLibraryPlugin.js +4 -3
  176. package/lib/logging/createConsoleLogger.js +3 -0
  177. package/lib/logging/truncateArgs.js +1 -1
  178. package/lib/node/CommonJsChunkLoadingPlugin.js +1 -0
  179. package/lib/node/NodeTargetPlugin.js +1 -0
  180. package/lib/node/NodeWatchFileSystem.js +3 -0
  181. package/lib/node/nodeConsole.js +18 -1
  182. package/lib/optimize/AggressiveMergingPlugin.js +2 -1
  183. package/lib/optimize/AggressiveSplittingPlugin.js +10 -6
  184. package/lib/optimize/ConcatenatedModule.js +33 -19
  185. package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
  186. package/lib/optimize/InnerGraph.js +5 -3
  187. package/lib/optimize/InnerGraphPlugin.js +25 -25
  188. package/lib/optimize/MangleExportsPlugin.js +14 -2
  189. package/lib/optimize/MergeDuplicateChunksPlugin.js +3 -0
  190. package/lib/optimize/MinChunkSizePlugin.js +5 -2
  191. package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
  192. package/lib/optimize/RealContentHashPlugin.js +35 -27
  193. package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
  194. package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
  195. package/lib/optimize/SplitChunksPlugin.js +14 -3
  196. package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
  197. package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
  198. package/lib/performance/NoAsyncChunksWarning.js +1 -0
  199. package/lib/rules/BasicEffectRulePlugin.js +2 -0
  200. package/lib/rules/BasicMatcherRulePlugin.js +3 -0
  201. package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
  202. package/lib/rules/RuleSetCompiler.js +2 -0
  203. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
  204. package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
  205. package/lib/runtime/CompatRuntimeModule.js +1 -0
  206. package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
  207. package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -0
  208. package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
  209. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
  210. package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
  211. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +15 -32
  212. package/lib/runtime/PublicPathRuntimeModule.js +1 -0
  213. package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
  214. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
  215. package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
  216. package/lib/schemes/HttpUriPlugin.js +27 -7
  217. package/lib/schemes/VirtualUrlPlugin.js +7 -2
  218. package/lib/serialization/BinaryMiddleware.js +4 -0
  219. package/lib/serialization/FileMiddleware.js +9 -4
  220. package/lib/serialization/ObjectMiddleware.js +34 -11
  221. package/lib/serialization/PlainObjectSerializer.js +2 -0
  222. package/lib/sharing/ConsumeSharedModule.js +60 -0
  223. package/lib/sharing/ConsumeSharedPlugin.js +5 -4
  224. package/lib/sharing/ProvideSharedModule.js +4 -0
  225. package/lib/sharing/ProvideSharedPlugin.js +24 -25
  226. package/lib/sharing/resolveMatchedConfigs.js +2 -2
  227. package/lib/sharing/utils.js +8 -6
  228. package/lib/stats/DefaultStatsFactoryPlugin.js +14 -12
  229. package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
  230. package/lib/stats/StatsFactory.js +2 -2
  231. package/lib/url/URLParserPlugin.js +4 -3
  232. package/lib/util/AppendOnlyStackedSet.js +57 -0
  233. package/lib/util/Hash.js +1 -0
  234. package/lib/util/IterableHelpers.js +1 -0
  235. package/lib/util/LazyBucketSortedSet.js +1 -0
  236. package/lib/util/LazySet.js +1 -0
  237. package/lib/util/ParallelismFactorCalculator.js +1 -0
  238. package/lib/util/SortableSet.js +1 -0
  239. package/lib/util/StringXor.js +1 -0
  240. package/lib/util/binarySearchBounds.js +15 -8
  241. package/lib/util/chainedImports.js +1 -1
  242. package/lib/util/cleverMerge.js +6 -1
  243. package/lib/util/comparators.js +21 -1
  244. package/lib/util/compileBooleanMatcher.js +3 -3
  245. package/lib/util/concatenate.js +3 -2
  246. package/lib/util/conventions.js +3 -2
  247. package/lib/util/deterministicGrouping.js +13 -1
  248. package/lib/util/extractSourceMap.js +12 -13
  249. package/lib/util/fs.js +15 -19
  250. package/lib/util/hash/BatchedHash.js +3 -0
  251. package/lib/util/hash/BulkUpdateHash.js +7 -1
  252. package/lib/util/hash/hash-digest.js +1 -0
  253. package/lib/util/hash/wasm-hash.js +16 -1
  254. package/lib/util/identifier.js +7 -2
  255. package/lib/util/magicComment.js +1 -1
  256. package/lib/util/propertyName.js +1 -1
  257. package/lib/util/registerExternalSerializer.js +1 -0
  258. package/lib/util/runtime.js +15 -1
  259. package/lib/util/semver.js +1 -0
  260. package/lib/util/serialization.js +2 -2
  261. package/lib/wasm/EnableWasmLoadingPlugin.js +1 -0
  262. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
  263. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
  264. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
  265. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
  266. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
  267. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
  268. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
  269. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
  270. package/lib/wasm-sync/WebAssemblyParser.js +3 -1
  271. package/lib/web/FetchCompileWasmPlugin.js +1 -0
  272. package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
  273. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
  274. package/lib/webpack.js +13 -3
  275. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  276. package/package.json +20 -28
  277. package/schemas/WebpackOptions.check.js +1 -1
  278. package/schemas/WebpackOptions.json +71 -5
  279. package/types.d.ts +339 -93
@@ -266,6 +266,7 @@ module.exports.parseRange = (str) => {
266
266
  const items = [];
267
267
  const r = /[-0-9A-Za-z]\s+/g;
268
268
  var start = 0;
269
+ /** @type {RegExpExecArray | null} */
269
270
  var match;
270
271
  while ((match = r.exec(str))) {
271
272
  const end = match.index + 1;
@@ -9,7 +9,7 @@ const memoize = require("./memoize");
9
9
 
10
10
  /** @typedef {import("../serialization/BinaryMiddleware").MEASURE_END_OPERATION_TYPE} MEASURE_END_OPERATION */
11
11
  /** @typedef {import("../serialization/BinaryMiddleware").MEASURE_START_OPERATION_TYPE} MEASURE_START_OPERATION */
12
- /** @typedef {typeof import("../util/Hash")} Hash */
12
+ /** @typedef {import("../util/Hash").HashFunction} HashFunction */
13
13
  /** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
14
14
 
15
15
  /**
@@ -111,7 +111,7 @@ module.exports = {
111
111
  /**
112
112
  * @template D, S, C
113
113
  * @param {IntermediateFileSystem} fs filesystem
114
- * @param {string | Hash} hashFunction hash function to use
114
+ * @param {HashFunction} hashFunction hash function to use
115
115
  * @returns {Serializer<D, S, C>} file serializer
116
116
  */
117
117
  createFileSerializer: (fs, hashFunction) => {
@@ -20,6 +20,7 @@ const enabledTypes = new WeakMap();
20
20
  const getEnabledTypes = (compiler) => {
21
21
  let set = enabledTypes.get(compiler);
22
22
  if (set === undefined) {
23
+ /** @type {WasmLoadingTypes} */
23
24
  set = new Set();
24
25
  enabledTypes.set(compiler, set);
25
26
  }
@@ -12,11 +12,15 @@ const Template = require("../Template");
12
12
  /** @typedef {import("../Chunk")} Chunk */
13
13
  /** @typedef {import("../Compilation")} Compilation */
14
14
 
15
+ /** @typedef {(wasmModuleSrcPath: string) => string} GenerateBeforeLoadBinaryCode */
16
+ /** @typedef {(wasmModuleSrcPath: string) => string} GenerateLoadBinaryCode */
17
+ /** @typedef {() => string} GenerateBeforeInstantiateStreaming */
18
+
15
19
  /**
16
20
  * @typedef {object} AsyncWasmLoadingRuntimeModuleOptions
17
- * @property {((wasmModuleSrcPath: string) => string)=} generateBeforeLoadBinaryCode
18
- * @property {(wasmModuleSrcPath: string) => string} generateLoadBinaryCode
19
- * @property {(() => string)=} generateBeforeInstantiateStreaming
21
+ * @property {GenerateLoadBinaryCode} generateLoadBinaryCode
22
+ * @property {GenerateBeforeLoadBinaryCode=} generateBeforeLoadBinaryCode
23
+ * @property {GenerateBeforeInstantiateStreaming=} generateBeforeInstantiateStreaming
20
24
  * @property {boolean} supportsStreaming
21
25
  */
22
26
 
@@ -31,10 +35,14 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
31
35
  supportsStreaming
32
36
  }) {
33
37
  super("wasm loading", RuntimeModule.STAGE_NORMAL);
38
+ /** @type {GenerateLoadBinaryCode} */
34
39
  this.generateLoadBinaryCode = generateLoadBinaryCode;
40
+ /** @type {generateBeforeLoadBinaryCode | undefined} */
35
41
  this.generateBeforeLoadBinaryCode = generateBeforeLoadBinaryCode;
42
+ /** @type {generateBeforeInstantiateStreaming | undefined} */
36
43
  this.generateBeforeInstantiateStreaming =
37
44
  generateBeforeInstantiateStreaming;
45
+ /** @type {boolean} */
38
46
  this.supportsStreaming = supportsStreaming;
39
47
  }
40
48
 
@@ -26,6 +26,7 @@ class AsyncWebAssemblyGenerator extends Generator {
26
26
  */
27
27
  constructor(options) {
28
28
  super();
29
+ /** @type {AsyncWebAssemblyGeneratorOptions} */
29
30
  this.options = options;
30
31
  }
31
32
 
@@ -11,7 +11,7 @@ const Generator = require("../Generator");
11
11
  const { tryRunOrWebpackError } = require("../HookWebpackError");
12
12
  const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
13
13
  const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
14
- const { compareModulesByIdOrIdentifier } = require("../util/comparators");
14
+ const { compareModulesByFullName } = require("../util/comparators");
15
15
  const memoize = require("../util/memoize");
16
16
 
17
17
  /** @typedef {import("webpack-sources").Source} Source */
@@ -89,6 +89,7 @@ class AsyncWebAssemblyModulesPlugin {
89
89
  * @param {AsyncWebAssemblyModulesPluginOptions} options options
90
90
  */
91
91
  constructor(options) {
92
+ /** @type {AsyncWebAssemblyModulesPluginOptions} */
92
93
  this.options = options;
93
94
  }
94
95
 
@@ -139,7 +140,7 @@ class AsyncWebAssemblyModulesPlugin {
139
140
 
140
141
  for (const module of chunkGraph.getOrderedChunkModulesIterable(
141
142
  chunk,
142
- compareModulesByIdOrIdentifier(chunkGraph)
143
+ compareModulesByFullName(compiler)
143
144
  )) {
144
145
  if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) {
145
146
  const filenameTemplate = outputOptions.webassemblyModuleFilename;
@@ -7,9 +7,13 @@
7
7
  const WebpackError = require("../WebpackError");
8
8
 
9
9
  module.exports = class UnsupportedWebAssemblyFeatureError extends WebpackError {
10
- /** @param {string} message Error message */
10
+ /**
11
+ * @param {string} message Error message
12
+ */
11
13
  constructor(message) {
12
14
  super(message);
15
+
16
+ /** @type {string} */
13
17
  this.name = "UnsupportedWebAssemblyFeatureError";
14
18
  this.hideStack = true;
15
19
  }
@@ -31,6 +31,7 @@ const WebAssemblyUtils = require("./WebAssemblyUtils");
31
31
  */
32
32
  const getAllWasmModules = (moduleGraph, chunkGraph, chunk) => {
33
33
  const wasmModules = chunk.getAllAsyncChunks();
34
+ /** @type {Module[]} */
34
35
  const array = [];
35
36
  for (const chunk of wasmModules) {
36
37
  for (const m of chunkGraph.getOrderedChunkModulesIterable(
@@ -67,6 +68,7 @@ const generateImportObject = (
67
68
  const moduleGraph = chunkGraph.moduleGraph;
68
69
  /** @type {Map<string, ModuleId>} */
69
70
  const waitForInstances = new Map();
71
+ /** @type {{ module: string, name: string, value: string }[]} */
70
72
  const properties = [];
71
73
  const usedWasmDependencies = WebAssemblyUtils.getUsedDependencies(
72
74
  moduleGraph,
@@ -136,6 +138,7 @@ const generateImportObject = (
136
138
  }
137
139
  }
138
140
 
141
+ /** @type {string[]} */
139
142
  let importObject;
140
143
  if (mangle) {
141
144
  importObject = [
@@ -102,6 +102,8 @@ Add an async split point (i. e. import()) somewhere between your entrypoint and
102
102
  ${moduleChains.map((s) => `* ${s}`).join("\n")}`;
103
103
 
104
104
  super(message);
105
+
106
+ /** @type {string} */
105
107
  this.name = "WebAssemblyInInitialChunkError";
106
108
  this.hideStack = true;
107
109
  this.module = module;
@@ -60,17 +60,21 @@ class WebAssemblyJavascriptGenerator extends Generator {
60
60
  const exportsInfo = moduleGraph.getExportsInfo(module);
61
61
 
62
62
  let needExportsCopy = false;
63
+ /** @typedef {{ dependency: ModuleDependency | undefined, importVar: string, index: number, request: string | undefined, names: Set<string>, reexports: string[] }} ImportData */
64
+ /** @type {Map<Module, ImportData>} */
63
65
  const importedModules = new Map();
66
+ /** @type {string[]} */
64
67
  const initParams = [];
65
68
  let index = 0;
66
69
  for (const dep of module.dependencies) {
67
70
  const moduleDep =
68
71
  dep && dep instanceof ModuleDependency ? dep : undefined;
69
- if (moduleGraph.getModule(dep)) {
70
- let importData = importedModules.get(moduleGraph.getModule(dep));
72
+ const mod = moduleGraph.getModule(dep);
73
+ if (mod) {
74
+ let importData = importedModules.get(mod);
71
75
  if (importData === undefined) {
72
76
  importedModules.set(
73
- moduleGraph.getModule(dep),
77
+ mod,
74
78
  (importData = {
75
79
  dependency: moduleDep,
76
80
  importVar: `m${index}`,
@@ -13,7 +13,7 @@ const {
13
13
  const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants");
14
14
  const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");
15
15
  const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency");
16
- const { compareModulesByIdOrIdentifier } = require("../util/comparators");
16
+ const { compareModulesByFullName } = require("../util/comparators");
17
17
  const memoize = require("../util/memoize");
18
18
  const WebAssemblyInInitialChunkError = require("./WebAssemblyInInitialChunkError");
19
19
 
@@ -89,7 +89,7 @@ class WebAssemblyModulesPlugin {
89
89
 
90
90
  for (const module of chunkGraph.getOrderedChunkModulesIterable(
91
91
  chunk,
92
- compareModulesByIdOrIdentifier(chunkGraph)
92
+ compareModulesByFullName(compiler)
93
93
  )) {
94
94
  if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) {
95
95
  const filenameTemplate = outputOptions.webassemblyModuleFilename;
@@ -92,7 +92,8 @@ class WebAssemblyParser extends Parser {
92
92
  /** @type {Record<string, string> | undefined} */
93
93
  let jsIncompatibleExports = (buildMeta.jsIncompatibleExports = undefined);
94
94
 
95
- /** @type {(ModuleImport | null)[]} */
95
+ /** @typedef {ModuleImport | null} ImportNode */
96
+ /** @type {ImportNode[]} */
96
97
  const importedGlobals = [];
97
98
 
98
99
  t.traverse(module, {
@@ -139,6 +140,7 @@ class WebAssemblyParser extends Parser {
139
140
  Global({ node }) {
140
141
  const init = node.init[0];
141
142
 
143
+ /** @type {ImportNode} */
142
144
  let importNode = null;
143
145
 
144
146
  if (init.id === "get_global") {
@@ -24,6 +24,7 @@ class FetchCompileWasmPlugin {
24
24
  * @param {FetchCompileWasmPluginOptions=} options options
25
25
  */
26
26
  constructor(options = {}) {
27
+ /** @type {FetchCompileWasmPluginOptions} */
27
28
  this.options = options;
28
29
  }
29
30
 
@@ -35,6 +35,7 @@ class JsonpChunkLoadingPlugin {
35
35
  : globalChunkLoading;
36
36
  return chunkLoading === "jsonp";
37
37
  };
38
+ /** @type {WeakSet<Chunk>} */
38
39
  const onceForChunkSet = new WeakSet();
39
40
  /**
40
41
  * @param {Chunk} chunk chunk
@@ -56,6 +56,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
56
56
  */
57
57
  constructor(runtimeRequirements) {
58
58
  super("jsonp chunk loading", RuntimeModule.STAGE_ATTACH);
59
+ /** @type {ReadOnlyRuntimeRequirements} */
59
60
  this._runtimeRequirements = runtimeRequirements;
60
61
  }
61
62
 
package/lib/webpack.js CHANGED
@@ -15,13 +15,17 @@ const {
15
15
  applyWebpackOptionsBaseDefaults,
16
16
  applyWebpackOptionsDefaults
17
17
  } = require("./config/defaults");
18
- const { getNormalizedWebpackOptions } = require("./config/normalization");
18
+ const {
19
+ applyWebpackOptionsInterception,
20
+ getNormalizedWebpackOptions
21
+ } = require("./config/normalization");
19
22
  const NodeEnvironmentPlugin = require("./node/NodeEnvironmentPlugin");
20
23
  const memoize = require("./util/memoize");
21
24
 
22
25
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
23
26
  /** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
24
27
  /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptionsNormalizedWithDefaults */
28
+ /** @typedef {import("./config/normalization").WebpackOptionsInterception} WebpackOptionsInterception */
25
29
  /** @typedef {import("./Compiler").WatchOptions} WatchOptions */
26
30
  /** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */
27
31
  /** @typedef {import("./MultiCompiler").MultiWebpackOptions} MultiWebpackOptions */
@@ -68,8 +72,13 @@ const createMultiCompiler = (childOptions, options) => {
68
72
  * @returns {Compiler} a compiler
69
73
  */
70
74
  const createCompiler = (rawOptions, compilerIndex) => {
71
- const options = getNormalizedWebpackOptions(rawOptions);
75
+ let options = getNormalizedWebpackOptions(rawOptions);
72
76
  applyWebpackOptionsBaseDefaults(options);
77
+
78
+ /** @type {WebpackOptionsInterception=} */
79
+ let interception;
80
+ ({ options, interception } = applyWebpackOptionsInterception(options));
81
+
73
82
  const compiler = new Compiler(
74
83
  /** @type {string} */ (options.context),
75
84
  options
@@ -99,7 +108,8 @@ const createCompiler = (rawOptions, compilerIndex) => {
99
108
  new WebpackOptionsApply().process(
100
109
  /** @type {WebpackOptionsNormalizedWithDefaults} */
101
110
  (options),
102
- compiler
111
+ compiler,
112
+ interception
103
113
  );
104
114
  compiler.hooks.initialize.call();
105
115
  return compiler;
@@ -40,6 +40,7 @@ class ImportScriptsChunkLoadingPlugin {
40
40
  : globalChunkLoading;
41
41
  return chunkLoading === "import-scripts";
42
42
  };
43
+ /** @type {WeakSet<Chunk>} */
43
44
  const onceForChunkSet = new WeakSet();
44
45
  /**
45
46
  * @param {Chunk} chunk chunk
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.104.1",
3
+ "version": "5.105.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",
@@ -42,7 +42,6 @@
42
42
  "lint:types-module-test": "tsc -p tsconfig.module.test.json",
43
43
  "lint:yarn": "yarn-deduplicate --fail --list -s highest yarn.lock",
44
44
  "lint:spellcheck": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
45
- "report:types": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html",
46
45
  "validate:types": "tsc -p tsconfig.validation.json",
47
46
  "fmt": "yarn fmt:base --log-level warn --write",
48
47
  "fmt:check": "yarn fmt:base --check",
@@ -55,25 +54,26 @@
55
54
  "benchmark": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation --hash-seed=1 --random-seed=1 --no-opt --predictable --predictable-gc-schedule --interpreted-frames-native-stack --allow-natives-syntax --expose-gc --no-concurrent-sweeping ./test/BenchmarkTestCases.benchmark.mjs",
56
55
  "pretest": "yarn lint",
57
56
  "test": "yarn test:base",
58
- "test:update-snapshots": "yarn test:base -u",
57
+ "test:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage",
59
58
  "test:basic": "yarn test:base --testMatch \"<rootDir>/test/*.basictest.js\"",
60
59
  "test:basic:deno": "yarn test:base:deno --testMatch \"<rootDir>/test/*.basictest.js\"",
61
60
  "test:unit": "yarn test:base --testMatch \"<rootDir>/test/*.unittest.js\"",
62
61
  "test:integration": "yarn test:base --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\"",
63
62
  "test:base:deno": "deno --allow-read --allow-env --allow-sys --allow-ffi --allow-write --allow-run --v8-flags='--max-old-space-size=4096' ./node_modules/jest-cli/bin/jest.js --logHeapUsage",
64
- "test:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage",
65
- "cover": "yarn cover:all && yarn cover:report",
66
- "cover:clean": "rimraf .nyc_output coverage",
63
+ "test:update-snapshots": "yarn test:base -u",
64
+ "report:cover": "nyc report --reporter=lcov --reporter=text -t coverage",
65
+ "report:cover:clean": "rimraf .nyc_output coverage",
66
+ "report:cover:merge": "yarn mkdirp .nyc_output && nyc merge .nyc_output coverage/coverage-nyc.json && rimraf .nyc_output",
67
+ "types:cover": "node node_modules/tooling/type-coverage",
68
+ "types:cover:report": "rimraf coverage && yarn types:cover && yarn report:cover && open-cli coverage/lcov-report/index.html",
69
+ "cover": "yarn cover:all && yarn report:cover",
70
+ "cover:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage",
67
71
  "cover:all": "yarn cover:base --coverage",
68
72
  "cover:unit": "yarn cover:base --testMatch \"<rootDir>/test/*.unittest.js\" --coverage",
69
73
  "cover:basic": "yarn cover:base --testMatch \"<rootDir>/test/*.basictest.js\" --coverage",
70
74
  "cover:integration": "yarn cover:base --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\" --coverage",
71
75
  "cover:integration:a": "yarn cover:base --testMatch \"<rootDir>/test/*.{basictest,test}.js\" --coverage",
72
- "cover:integration:b": "yarn cover:base --testMatch \"<rootDir>/test/*.longtest.js\" --coverage",
73
- "cover:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules node_modules/jest-cli/bin/jest --logHeapUsage",
74
- "cover:types": "node node_modules/tooling/type-coverage",
75
- "cover:merge": "yarn mkdirp .nyc_output && nyc merge .nyc_output coverage/coverage-nyc.json && rimraf .nyc_output",
76
- "cover:report": "nyc report --reporter=lcov --reporter=text -t coverage"
76
+ "cover:integration:b": "yarn cover:base --testMatch \"<rootDir>/test/*.longtest.js\" --coverage"
77
77
  },
78
78
  "lint-staged": {
79
79
  "*.{js,cjs,mjs}": [
@@ -95,7 +95,7 @@
95
95
  "acorn-import-phases": "^1.0.3",
96
96
  "browserslist": "^4.28.1",
97
97
  "chrome-trace-event": "^1.0.2",
98
- "enhanced-resolve": "^5.17.4",
98
+ "enhanced-resolve": "^5.19.0",
99
99
  "es-module-lexer": "^2.0.0",
100
100
  "eslint-scope": "5.1.1",
101
101
  "events": "^3.2.0",
@@ -108,22 +108,21 @@
108
108
  "schema-utils": "^4.3.3",
109
109
  "tapable": "^2.3.0",
110
110
  "terser-webpack-plugin": "^5.3.16",
111
- "watchpack": "^2.4.4",
111
+ "watchpack": "^2.5.1",
112
112
  "webpack-sources": "^3.3.3"
113
113
  },
114
114
  "devDependencies": {
115
115
  "@babel/core": "^7.27.1",
116
116
  "@babel/preset-react": "^7.27.1",
117
117
  "@changesets/cli": "^2.29.8",
118
+ "@changesets/get-github-info": "^0.7.0",
118
119
  "@codspeed/core": "^5.0.1",
119
- "@eslint/js": "^9.39.0",
120
- "@eslint/markdown": "^7.4.0",
121
- "@stylistic/eslint-plugin": "^5.6.0",
122
120
  "@types/glob-to-regexp": "^0.4.4",
123
121
  "@types/graceful-fs": "^4.1.9",
124
122
  "@types/jest": "^30.0.0",
125
123
  "@types/mime-types": "^2.1.4",
126
- "@types/node": "^24.10.1",
124
+ "@types/neo-async": "^2.6.7",
125
+ "@types/node": "^25.1.0",
127
126
  "@types/xxhashjs": "^0.2.4",
128
127
  "assemblyscript": "^0.28.9",
129
128
  "babel-loader": "^10.0.0",
@@ -137,17 +136,10 @@
137
136
  "es5-ext": "^0.10.53",
138
137
  "es6-promise-polyfill": "^1.2.0",
139
138
  "eslint": "^9.39.2",
140
- "eslint-config-prettier": "^10.1.1",
141
- "eslint-config-webpack": "^4.7.3",
142
- "eslint-plugin-import": "^2.32.0",
143
- "eslint-plugin-jest": "^29.5.0",
144
- "eslint-plugin-jsdoc": "^61.5.0",
145
- "eslint-plugin-n": "^17.23.1",
146
- "eslint-plugin-prettier": "^5.5.0",
147
- "eslint-plugin-unicorn": "^62.0.0",
139
+ "eslint-config-webpack": "^4.9.1",
148
140
  "file-loader": "^6.0.0",
149
141
  "fork-ts-checker-webpack-plugin": "^9.0.2",
150
- "globals": "^16.0.0",
142
+ "globals": "^17.0.0",
151
143
  "hash-wasm": "^4.9.0",
152
144
  "husky": "^9.0.11",
153
145
  "istanbul": "^0.4.5",
@@ -187,9 +179,9 @@
187
179
  "style-loader": "^4.0.0",
188
180
  "terser": "^5.43.1",
189
181
  "three": "^0.182.0",
190
- "tinybench": "^5.0.0",
182
+ "tinybench": "^6.0.0",
191
183
  "toml": "^3.0.0",
192
- "tooling": "webpack/tooling#v1.24.3",
184
+ "tooling": "webpack/tooling#v1.24.4",
193
185
  "ts-loader": "^9.5.4",
194
186
  "typescript": "^5.9.3",
195
187
  "url-loader": "^4.1.0",