webpack 5.90.3 → 5.92.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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

Files changed (257) hide show
  1. package/README.md +5 -5
  2. package/bin/webpack.js +6 -3
  3. package/lib/APIPlugin.js +14 -6
  4. package/lib/AutomaticPrefetchPlugin.js +1 -1
  5. package/lib/BannerPlugin.js +3 -1
  6. package/lib/Cache.js +8 -2
  7. package/lib/CacheFacade.js +3 -3
  8. package/lib/Chunk.js +7 -4
  9. package/lib/ChunkGraph.js +52 -25
  10. package/lib/ChunkGroup.js +23 -17
  11. package/lib/CleanPlugin.js +8 -6
  12. package/lib/Compilation.js +295 -120
  13. package/lib/Compiler.js +223 -87
  14. package/lib/ConcatenationScope.js +3 -3
  15. package/lib/ConditionalInitFragment.js +4 -5
  16. package/lib/ContextModule.js +95 -41
  17. package/lib/ContextModuleFactory.js +4 -2
  18. package/lib/ContextReplacementPlugin.js +3 -2
  19. package/lib/DefinePlugin.js +18 -6
  20. package/lib/Dependency.js +12 -10
  21. package/lib/DependencyTemplate.js +17 -7
  22. package/lib/DllModule.js +1 -0
  23. package/lib/DllReferencePlugin.js +7 -3
  24. package/lib/EntryOptionPlugin.js +4 -1
  25. package/lib/EntryPlugin.js +6 -1
  26. package/lib/Entrypoint.js +1 -1
  27. package/lib/EvalDevToolModulePlugin.js +11 -0
  28. package/lib/ExportsInfo.js +23 -8
  29. package/lib/ExternalModule.js +160 -35
  30. package/lib/ExternalModuleFactoryPlugin.js +37 -2
  31. package/lib/FileSystemInfo.js +69 -42
  32. package/lib/FlagDependencyExportsPlugin.js +21 -7
  33. package/lib/Generator.js +4 -4
  34. package/lib/HookWebpackError.js +2 -2
  35. package/lib/HotModuleReplacementPlugin.js +108 -45
  36. package/lib/IgnorePlugin.js +4 -1
  37. package/lib/InitFragment.js +5 -3
  38. package/lib/LibManifestPlugin.js +17 -9
  39. package/lib/Module.js +41 -14
  40. package/lib/ModuleFactory.js +3 -3
  41. package/lib/ModuleFilenameHelpers.js +30 -17
  42. package/lib/ModuleGraph.js +60 -31
  43. package/lib/ModuleGraphConnection.js +2 -1
  44. package/lib/MultiCompiler.js +62 -9
  45. package/lib/NodeStuffPlugin.js +14 -3
  46. package/lib/NormalModule.js +13 -13
  47. package/lib/NormalModuleFactory.js +18 -9
  48. package/lib/NormalModuleReplacementPlugin.js +5 -1
  49. package/lib/Parser.js +1 -1
  50. package/lib/PlatformPlugin.js +39 -0
  51. package/lib/ProgressPlugin.js +1 -1
  52. package/lib/ProvidePlugin.js +3 -1
  53. package/lib/RawModule.js +2 -1
  54. package/lib/RecordIdsPlugin.js +4 -4
  55. package/lib/ResolverFactory.js +6 -4
  56. package/lib/RuntimeModule.js +4 -4
  57. package/lib/RuntimePlugin.js +1 -0
  58. package/lib/RuntimeTemplate.js +124 -52
  59. package/lib/SourceMapDevToolPlugin.js +4 -1
  60. package/lib/Stats.js +11 -4
  61. package/lib/Template.js +5 -5
  62. package/lib/TemplatedPathPlugin.js +48 -7
  63. package/lib/Watching.js +67 -60
  64. package/lib/WebpackError.js +6 -6
  65. package/lib/WebpackOptionsApply.js +18 -5
  66. package/lib/asset/AssetGenerator.js +15 -0
  67. package/lib/asset/RawDataUrlModule.js +3 -1
  68. package/lib/async-modules/AwaitDependenciesInitFragment.js +2 -2
  69. package/lib/buildChunkGraph.js +120 -67
  70. package/lib/cache/IdleFileCachePlugin.js +8 -3
  71. package/lib/cache/MemoryCachePlugin.js +1 -1
  72. package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
  73. package/lib/cache/PackFileCacheStrategy.js +51 -18
  74. package/lib/cache/ResolverCachePlugin.js +22 -14
  75. package/lib/cache/getLazyHashedEtag.js +2 -2
  76. package/lib/cli.js +5 -5
  77. package/lib/config/browserslistTargetHandler.js +7 -1
  78. package/lib/config/defaults.js +108 -34
  79. package/lib/config/normalization.js +3 -1
  80. package/lib/config/target.js +18 -11
  81. package/lib/container/ContainerEntryDependency.js +2 -1
  82. package/lib/container/ContainerEntryModule.js +4 -2
  83. package/lib/container/ContainerPlugin.js +14 -10
  84. package/lib/container/FallbackModule.js +1 -1
  85. package/lib/container/RemoteRuntimeModule.js +12 -3
  86. package/lib/css/CssExportsGenerator.js +68 -25
  87. package/lib/css/CssGenerator.js +34 -6
  88. package/lib/css/CssLoadingRuntimeModule.js +217 -98
  89. package/lib/css/CssModulesPlugin.js +238 -107
  90. package/lib/css/CssParser.js +24 -15
  91. package/lib/css/walkCssTokens.js +1 -1
  92. package/lib/debug/ProfilingPlugin.js +28 -3
  93. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +9 -5
  94. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -1
  95. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -1
  96. package/lib/dependencies/CommonJsExportRequireDependency.js +33 -18
  97. package/lib/dependencies/CommonJsExportsDependency.js +13 -5
  98. package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -15
  99. package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -2
  100. package/lib/dependencies/ContextDependencyHelpers.js +49 -29
  101. package/lib/dependencies/ContextElementDependency.js +8 -1
  102. package/lib/dependencies/CssExportDependency.js +2 -2
  103. package/lib/dependencies/CssLocalIdentifierDependency.js +71 -9
  104. package/lib/dependencies/CssUrlDependency.js +10 -7
  105. package/lib/dependencies/ExportsInfoDependency.js +5 -4
  106. package/lib/dependencies/ExternalModuleDependency.js +4 -2
  107. package/lib/dependencies/ExternalModuleInitFragment.js +5 -3
  108. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -4
  109. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +43 -23
  110. package/lib/dependencies/HarmonyExportHeaderDependency.js +1 -1
  111. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +73 -32
  112. package/lib/dependencies/HarmonyExportInitFragment.js +10 -2
  113. package/lib/dependencies/HarmonyImportDependency.js +28 -12
  114. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +70 -19
  115. package/lib/dependencies/HarmonyImportSideEffectDependency.js +7 -6
  116. package/lib/dependencies/HarmonyImportSpecifierDependency.js +47 -35
  117. package/lib/dependencies/ImportDependency.js +9 -2
  118. package/lib/dependencies/ImportEagerDependency.js +4 -2
  119. package/lib/dependencies/ImportMetaContextDependency.js +7 -0
  120. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +25 -14
  121. package/lib/dependencies/ImportMetaPlugin.js +1 -1
  122. package/lib/dependencies/ImportParserPlugin.js +15 -5
  123. package/lib/dependencies/ImportWeakDependency.js +4 -2
  124. package/lib/dependencies/LoaderDependency.js +2 -1
  125. package/lib/dependencies/LoaderImportDependency.js +2 -1
  126. package/lib/dependencies/LoaderPlugin.js +2 -2
  127. package/lib/dependencies/ModuleDependency.js +4 -5
  128. package/lib/dependencies/PureExpressionDependency.js +64 -47
  129. package/lib/dependencies/RequireContextPlugin.js +1 -1
  130. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +26 -14
  131. package/lib/dependencies/RequireEnsureDependency.js +1 -1
  132. package/lib/dependencies/URLDependency.js +7 -4
  133. package/lib/dependencies/WorkerDependency.js +1 -1
  134. package/lib/dependencies/WorkerPlugin.js +2 -1
  135. package/lib/dependencies/getFunctionExpression.js +3 -1
  136. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -3
  137. package/lib/hmr/LazyCompilationPlugin.js +2 -2
  138. package/lib/ids/ChunkModuleIdRangePlugin.js +1 -1
  139. package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
  140. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  141. package/lib/ids/IdHelpers.js +6 -6
  142. package/lib/ids/NamedChunkIdsPlugin.js +1 -1
  143. package/lib/ids/NamedModuleIdsPlugin.js +1 -1
  144. package/lib/ids/SyncModuleIdsPlugin.js +2 -2
  145. package/lib/index.js +11 -0
  146. package/lib/javascript/BasicEvaluatedExpression.js +2 -2
  147. package/lib/javascript/ChunkHelpers.js +2 -2
  148. package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
  149. package/lib/javascript/JavascriptGenerator.js +0 -1
  150. package/lib/javascript/JavascriptModulesPlugin.js +174 -17
  151. package/lib/javascript/JavascriptParser.js +204 -71
  152. package/lib/javascript/JavascriptParserHelpers.js +1 -1
  153. package/lib/javascript/StartupHelpers.js +22 -5
  154. package/lib/library/AbstractLibraryPlugin.js +2 -2
  155. package/lib/library/AmdLibraryPlugin.js +2 -2
  156. package/lib/library/AssignLibraryPlugin.js +3 -3
  157. package/lib/library/ExportPropertyLibraryPlugin.js +2 -2
  158. package/lib/library/JsonpLibraryPlugin.js +2 -2
  159. package/lib/library/ModuleLibraryPlugin.js +2 -2
  160. package/lib/library/SystemLibraryPlugin.js +2 -2
  161. package/lib/library/UmdLibraryPlugin.js +33 -12
  162. package/lib/logging/Logger.js +27 -2
  163. package/lib/logging/createConsoleLogger.js +13 -9
  164. package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
  165. package/lib/node/NodeEnvironmentPlugin.js +14 -8
  166. package/lib/node/NodeTemplatePlugin.js +1 -1
  167. package/lib/node/NodeWatchFileSystem.js +37 -26
  168. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -1
  169. package/lib/node/ReadFileCompileWasmPlugin.js +1 -1
  170. package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -1
  171. package/lib/node/nodeConsole.js +24 -1
  172. package/lib/optimize/AggressiveMergingPlugin.js +1 -1
  173. package/lib/optimize/AggressiveSplittingPlugin.js +1 -0
  174. package/lib/optimize/ConcatenatedModule.js +140 -121
  175. package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
  176. package/lib/optimize/InnerGraph.js +8 -3
  177. package/lib/optimize/InnerGraphPlugin.js +36 -13
  178. package/lib/optimize/LimitChunkCountPlugin.js +1 -2
  179. package/lib/optimize/ModuleConcatenationPlugin.js +13 -3
  180. package/lib/optimize/RealContentHashPlugin.js +3 -3
  181. package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
  182. package/lib/optimize/RuntimeChunkPlugin.js +6 -1
  183. package/lib/optimize/SideEffectsFlagPlugin.js +48 -17
  184. package/lib/optimize/SplitChunksPlugin.js +10 -10
  185. package/lib/performance/SizeLimitsPlugin.js +13 -2
  186. package/lib/rules/ObjectMatcherRulePlugin.js +15 -1
  187. package/lib/rules/RuleSetCompiler.js +9 -7
  188. package/lib/runtime/EnsureChunkRuntimeModule.js +2 -1
  189. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +2 -1
  190. package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
  191. package/lib/runtime/StartupChunkDependenciesPlugin.js +1 -1
  192. package/lib/schemes/HttpUriPlugin.js +1 -1
  193. package/lib/serialization/BinaryMiddleware.js +4 -4
  194. package/lib/serialization/FileMiddleware.js +4 -3
  195. package/lib/serialization/NullPrototypeObjectSerializer.js +2 -2
  196. package/lib/serialization/ObjectMiddleware.js +8 -5
  197. package/lib/serialization/PlainObjectSerializer.js +2 -2
  198. package/lib/serialization/Serializer.js +19 -0
  199. package/lib/serialization/SerializerMiddleware.js +2 -2
  200. package/lib/serialization/SingleItemMiddleware.js +2 -2
  201. package/lib/serialization/types.js +1 -1
  202. package/lib/sharing/ConsumeSharedModule.js +2 -2
  203. package/lib/sharing/ConsumeSharedPlugin.js +17 -3
  204. package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -2
  205. package/lib/sharing/ProvideSharedPlugin.js +13 -6
  206. package/lib/sharing/resolveMatchedConfigs.js +3 -3
  207. package/lib/sharing/utils.js +13 -6
  208. package/lib/stats/DefaultStatsFactoryPlugin.js +20 -20
  209. package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
  210. package/lib/stats/StatsFactory.js +2 -2
  211. package/lib/stats/StatsPrinter.js +6 -6
  212. package/lib/util/ArrayQueue.js +14 -21
  213. package/lib/util/AsyncQueue.js +1 -1
  214. package/lib/util/Queue.js +8 -2
  215. package/lib/util/SortableSet.js +16 -4
  216. package/lib/util/StackedCacheMap.js +26 -0
  217. package/lib/util/TupleQueue.js +8 -2
  218. package/lib/util/WeakTupleMap.js +57 -13
  219. package/lib/util/binarySearchBounds.js +1 -1
  220. package/lib/util/cleverMerge.js +26 -13
  221. package/lib/util/comparators.js +37 -15
  222. package/lib/util/conventions.js +129 -0
  223. package/lib/util/createHash.js +3 -5
  224. package/lib/util/deprecation.js +3 -3
  225. package/lib/util/deterministicGrouping.js +2 -2
  226. package/lib/util/findGraphRoots.js +1 -1
  227. package/lib/util/fs.js +383 -69
  228. package/lib/util/hash/BatchedHash.js +3 -0
  229. package/lib/util/hash/xxhash64.js +2 -2
  230. package/lib/util/identifier.js +5 -5
  231. package/lib/util/mergeScope.js +79 -0
  232. package/lib/util/runtime.js +2 -17
  233. package/lib/util/semver.js +3 -0
  234. package/lib/util/smartGrouping.js +3 -3
  235. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +4 -2
  236. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
  237. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -2
  238. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
  239. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +16 -7
  240. package/lib/wasm-sync/WebAssemblyGenerator.js +40 -19
  241. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
  242. package/lib/wasm-sync/WebAssemblyParser.js +7 -4
  243. package/lib/wasm-sync/WebAssemblyUtils.js +2 -1
  244. package/lib/web/FetchCompileWasmPlugin.js +1 -1
  245. package/lib/web/JsonpChunkLoadingRuntimeModule.js +3 -2
  246. package/lib/webpack.js +19 -6
  247. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -1
  248. package/package.json +40 -39
  249. package/schemas/WebpackOptions.check.js +1 -1
  250. package/schemas/WebpackOptions.json +97 -8
  251. package/schemas/plugins/BannerPlugin.check.js +1 -1
  252. package/schemas/plugins/BannerPlugin.json +5 -1
  253. package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
  254. package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
  255. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
  256. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  257. package/types.d.ts +1826 -639
@@ -48,7 +48,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
48
48
 
49
49
  /** @typedef {KnownStatsCompilation & Record<string, any>} StatsCompilation */
50
50
  /**
51
- * @typedef {Object} KnownStatsCompilation
51
+ * @typedef {object} KnownStatsCompilation
52
52
  * @property {any=} env
53
53
  * @property {string=} name
54
54
  * @property {string=} hash
@@ -76,7 +76,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
76
76
 
77
77
  /** @typedef {KnownStatsLogging & Record<string, any>} StatsLogging */
78
78
  /**
79
- * @typedef {Object} KnownStatsLogging
79
+ * @typedef {object} KnownStatsLogging
80
80
  * @property {StatsLoggingEntry[]} entries
81
81
  * @property {number} filteredEntries
82
82
  * @property {boolean} debug
@@ -84,7 +84,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
84
84
 
85
85
  /** @typedef {KnownStatsLoggingEntry & Record<string, any>} StatsLoggingEntry */
86
86
  /**
87
- * @typedef {Object} KnownStatsLoggingEntry
87
+ * @typedef {object} KnownStatsLoggingEntry
88
88
  * @property {string} type
89
89
  * @property {string} message
90
90
  * @property {string[]=} trace
@@ -95,7 +95,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
95
95
 
96
96
  /** @typedef {KnownStatsAsset & Record<string, any>} StatsAsset */
97
97
  /**
98
- * @typedef {Object} KnownStatsAsset
98
+ * @typedef {object} KnownStatsAsset
99
99
  * @property {string} type
100
100
  * @property {string} name
101
101
  * @property {AssetInfo} info
@@ -116,7 +116,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
116
116
 
117
117
  /** @typedef {KnownStatsChunkGroup & Record<string, any>} StatsChunkGroup */
118
118
  /**
119
- * @typedef {Object} KnownStatsChunkGroup
119
+ * @typedef {object} KnownStatsChunkGroup
120
120
  * @property {string=} name
121
121
  * @property {(string|number)[]=} chunks
122
122
  * @property {({ name: string, size?: number })[]=} assets
@@ -132,7 +132,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
132
132
 
133
133
  /** @typedef {KnownStatsModule & Record<string, any>} StatsModule */
134
134
  /**
135
- * @typedef {Object} KnownStatsModule
135
+ * @typedef {object} KnownStatsModule
136
136
  * @property {string=} type
137
137
  * @property {string=} moduleType
138
138
  * @property {string=} layer
@@ -176,7 +176,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
176
176
 
177
177
  /** @typedef {KnownStatsProfile & Record<string, any>} StatsProfile */
178
178
  /**
179
- * @typedef {Object} KnownStatsProfile
179
+ * @typedef {object} KnownStatsProfile
180
180
  * @property {number} total
181
181
  * @property {number} resolving
182
182
  * @property {number} restoring
@@ -191,7 +191,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
191
191
 
192
192
  /** @typedef {KnownStatsModuleIssuer & Record<string, any>} StatsModuleIssuer */
193
193
  /**
194
- * @typedef {Object} KnownStatsModuleIssuer
194
+ * @typedef {object} KnownStatsModuleIssuer
195
195
  * @property {string=} identifier
196
196
  * @property {string=} name
197
197
  * @property {(string|number)=} id
@@ -200,7 +200,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
200
200
 
201
201
  /** @typedef {KnownStatsModuleReason & Record<string, any>} StatsModuleReason */
202
202
  /**
203
- * @typedef {Object} KnownStatsModuleReason
203
+ * @typedef {object} KnownStatsModuleReason
204
204
  * @property {string=} moduleIdentifier
205
205
  * @property {string=} module
206
206
  * @property {string=} moduleName
@@ -217,7 +217,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
217
217
 
218
218
  /** @typedef {KnownStatsChunk & Record<string, any>} StatsChunk */
219
219
  /**
220
- * @typedef {Object} KnownStatsChunk
220
+ * @typedef {object} KnownStatsChunk
221
221
  * @property {boolean} rendered
222
222
  * @property {boolean} initial
223
223
  * @property {boolean} entry
@@ -243,7 +243,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
243
243
 
244
244
  /** @typedef {KnownStatsChunkOrigin & Record<string, any>} StatsChunkOrigin */
245
245
  /**
246
- * @typedef {Object} KnownStatsChunkOrigin
246
+ * @typedef {object} KnownStatsChunkOrigin
247
247
  * @property {string=} module
248
248
  * @property {string=} moduleIdentifier
249
249
  * @property {string=} moduleName
@@ -254,7 +254,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
254
254
 
255
255
  /** @typedef {KnownStatsModuleTraceItem & Record<string, any>} StatsModuleTraceItem */
256
256
  /**
257
- * @typedef {Object} KnownStatsModuleTraceItem
257
+ * @typedef {object} KnownStatsModuleTraceItem
258
258
  * @property {string=} originIdentifier
259
259
  * @property {string=} originName
260
260
  * @property {string=} moduleIdentifier
@@ -266,13 +266,13 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
266
266
 
267
267
  /** @typedef {KnownStatsModuleTraceDependency & Record<string, any>} StatsModuleTraceDependency */
268
268
  /**
269
- * @typedef {Object} KnownStatsModuleTraceDependency
269
+ * @typedef {object} KnownStatsModuleTraceDependency
270
270
  * @property {string=} loc
271
271
  */
272
272
 
273
273
  /** @typedef {KnownStatsError & Record<string, any>} StatsError */
274
274
  /**
275
- * @typedef {Object} KnownStatsError
275
+ * @typedef {object} KnownStatsError
276
276
  * @property {string} message
277
277
  * @property {string=} chunkName
278
278
  * @property {boolean=} chunkEntry
@@ -297,7 +297,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
297
297
  */
298
298
 
299
299
  /**
300
- * @typedef {Object} SimpleExtractors
300
+ * @typedef {object} SimpleExtractors
301
301
  * @property {ExtractorsByOption<Compilation, StatsCompilation>} compilation
302
302
  * @property {ExtractorsByOption<PreprocessedAsset, StatsAsset>} asset
303
303
  * @property {ExtractorsByOption<PreprocessedAsset, StatsAsset>} asset$visible
@@ -1526,7 +1526,7 @@ const FILTER = {
1526
1526
  }
1527
1527
  };
1528
1528
 
1529
- /** @type {Record<string, Record<string, (thing: Object, context: StatsFactoryContext, options: NormalizedStatsOptions) => boolean | undefined>>} */
1529
+ /** @type {Record<string, Record<string, (thing: object, context: StatsFactoryContext, options: NormalizedStatsOptions) => boolean | undefined>>} */
1530
1530
  const FILTER_RESULTS = {
1531
1531
  "compilation.warnings": {
1532
1532
  warningsFilter: util.deprecate(
@@ -2246,7 +2246,7 @@ const sortOrderRegular = field => {
2246
2246
 
2247
2247
  /**
2248
2248
  * @param {string} field field name
2249
- * @returns {function(Object, Object): number} comparators
2249
+ * @returns {function(object, object): number} comparators
2250
2250
  */
2251
2251
  const sortByField = field => {
2252
2252
  if (!field) {
@@ -2361,8 +2361,8 @@ const ITEM_NAMES = {
2361
2361
  };
2362
2362
 
2363
2363
  /**
2364
- * @param {Object[]} items items to be merged
2365
- * @returns {Object} an object
2364
+ * @param {object[]} items items to be merged
2365
+ * @returns {object} an object
2366
2366
  */
2367
2367
  const mergeToObject = items => {
2368
2368
  const obj = Object.create(null);
@@ -2372,7 +2372,7 @@ const mergeToObject = items => {
2372
2372
  return obj;
2373
2373
  };
2374
2374
 
2375
- /** @type {Record<string, (items: Object[]) => any>} */
2375
+ /** @type {Record<string, (items: object[]) => any>} */
2376
2376
  const MERGER = {
2377
2377
  "compilation.entrypoints": mergeToObject,
2378
2378
  "compilation.namedChunkGroups": mergeToObject
@@ -22,7 +22,7 @@ const plural = (n, singular, plural) => (n === 1 ? singular : plural);
22
22
 
23
23
  /**
24
24
  * @param {Record<string, number>} sizes sizes by source type
25
- * @param {Object} options options
25
+ * @param {object} options options
26
26
  * @param {(number) => string=} options.formatSize size formatter
27
27
  * @returns {string} text
28
28
  */
@@ -18,7 +18,7 @@ const smartGrouping = require("../util/smartGrouping");
18
18
  /** @typedef {import("../util/smartGrouping").GroupConfig<any, object>} GroupConfig */
19
19
 
20
20
  /**
21
- * @typedef {Object} KnownStatsFactoryContext
21
+ * @typedef {object} KnownStatsFactoryContext
22
22
  * @property {string} type
23
23
  * @property {function(string): string=} makePathsRelative
24
24
  * @property {Compilation=} compilation
@@ -35,7 +35,7 @@ const smartGrouping = require("../util/smartGrouping");
35
35
  class StatsFactory {
36
36
  constructor() {
37
37
  this.hooks = Object.freeze({
38
- /** @type {HookMap<SyncBailHook<[Object, any, StatsFactoryContext]>>} */
38
+ /** @type {HookMap<SyncBailHook<[object, any, StatsFactoryContext]>>} */
39
39
  extract: new HookMap(
40
40
  () => new SyncBailHook(["object", "data", "context"])
41
41
  ),
@@ -17,13 +17,13 @@ const { HookMap, SyncWaterfallHook, SyncBailHook } = require("tapable");
17
17
  /** @typedef {import("./DefaultStatsFactoryPlugin").StatsModuleReason} StatsModuleReason */
18
18
 
19
19
  /**
20
- * @typedef {Object} PrintedElement
20
+ * @typedef {object} PrintedElement
21
21
  * @property {string} element
22
22
  * @property {string} content
23
23
  */
24
24
 
25
25
  /**
26
- * @typedef {Object} KnownStatsPrinterContext
26
+ * @typedef {object} KnownStatsPrinterContext
27
27
  * @property {string=} type
28
28
  * @property {StatsCompilation=} compilation
29
29
  * @property {StatsChunkGroup=} chunkGroup
@@ -147,8 +147,8 @@ class StatsPrinter {
147
147
 
148
148
  /**
149
149
  * @param {string} type The type
150
- * @param {Object} object Object to print
151
- * @param {Object=} baseContext The base context
150
+ * @param {object} object Object to print
151
+ * @param {object=} baseContext The base context
152
152
  * @returns {string} printed result
153
153
  */
154
154
  print(type, object, baseContext) {
@@ -168,8 +168,8 @@ class StatsPrinter {
168
168
  /**
169
169
  * @private
170
170
  * @param {string} type type
171
- * @param {Object} object object
172
- * @param {Object=} baseContext context
171
+ * @param {object} object object
172
+ * @param {object=} baseContext context
173
173
  * @returns {string} printed result
174
174
  */
175
175
  _print(type, object, baseContext) {
@@ -13,9 +13,15 @@ class ArrayQueue {
13
13
  * @param {Iterable<T>=} items The initial elements.
14
14
  */
15
15
  constructor(items) {
16
- /** @private @type {T[]} */
16
+ /**
17
+ * @private
18
+ * @type {T[]}
19
+ */
17
20
  this._list = items ? Array.from(items) : [];
18
- /** @private @type {T[]} */
21
+ /**
22
+ * @private
23
+ * @type {T[]}
24
+ */
19
25
  this._listReversed = [];
20
26
  }
21
27
 
@@ -77,31 +83,18 @@ class ArrayQueue {
77
83
  }
78
84
 
79
85
  [Symbol.iterator]() {
80
- let i = -1;
81
- let reversed = false;
82
86
  return {
83
87
  next: () => {
84
- if (!reversed) {
85
- i++;
86
- if (i < this._list.length) {
87
- return {
88
- done: false,
89
- value: this._list[i]
90
- };
91
- }
92
- reversed = true;
93
- i = this._listReversed.length;
94
- }
95
- i--;
96
- if (i < 0) {
88
+ const item = this.dequeue();
89
+ if (item) {
97
90
  return {
98
- done: true,
99
- value: undefined
91
+ done: false,
92
+ value: item
100
93
  };
101
94
  }
102
95
  return {
103
- done: false,
104
- value: this._listReversed[i]
96
+ done: true,
97
+ value: undefined
105
98
  };
106
99
  }
107
100
  };
@@ -53,7 +53,7 @@ class AsyncQueueEntry {
53
53
  */
54
54
  class AsyncQueue {
55
55
  /**
56
- * @param {Object} options options object
56
+ * @param {object} options options object
57
57
  * @param {string=} options.name name of the queue
58
58
  * @param {number=} options.parallelism how many items should be processed at once
59
59
  * @param {AsyncQueue<any, any, any>=} options.parent parent queue, which will have priority over this queue and with shared parallelism
package/lib/util/Queue.js CHANGED
@@ -13,9 +13,15 @@ class Queue {
13
13
  * @param {Iterable<T>=} items The initial elements.
14
14
  */
15
15
  constructor(items) {
16
- /** @private @type {Set<T>} */
16
+ /**
17
+ * @private
18
+ * @type {Set<T>}
19
+ */
17
20
  this._set = new Set(items);
18
- /** @private @type {Iterator<T>} */
21
+ /**
22
+ * @private
23
+ * @type {Iterator<T>}
24
+ */
19
25
  this._iterator = this._set[Symbol.iterator]();
20
26
  }
21
27
 
@@ -21,13 +21,25 @@ class SortableSet extends Set {
21
21
  */
22
22
  constructor(initialIterable, defaultSort) {
23
23
  super(initialIterable);
24
- /** @private @type {undefined | function(T, T): number}} */
24
+ /**
25
+ * @private
26
+ * @type {undefined | function(T, T): number}}
27
+ */
25
28
  this._sortFn = defaultSort;
26
- /** @private @type {typeof NONE | undefined | function(T, T): number}} */
29
+ /**
30
+ * @private
31
+ * @type {typeof NONE | undefined | function(T, T): number}}
32
+ */
27
33
  this._lastActiveSortFn = NONE;
28
- /** @private @type {Map<Function, any> | undefined} */
34
+ /**
35
+ * @private
36
+ * @type {Map<Function, any> | undefined}
37
+ */
29
38
  this._cache = undefined;
30
- /** @private @type {Map<Function, any> | undefined} */
39
+ /**
40
+ * @private
41
+ * @type {Map<Function, any> | undefined}
42
+ */
31
43
  this._cacheOrderIndependent = undefined;
32
44
  }
33
45
 
@@ -8,6 +8,29 @@
8
8
  /**
9
9
  * @template K
10
10
  * @template V
11
+ *
12
+ * The StackedCacheMap is a data structure designed as an alternative to a Map
13
+ * in situations where you need to handle multiple item additions and
14
+ * frequently access the largest map.
15
+ *
16
+ * It is particularly optimized for efficiently adding multiple items
17
+ * at once, which can be achieved using the `addAll` method.
18
+ *
19
+ * It has a fallback Map that is used when the map to be added is mutable.
20
+ *
21
+ * Note: `delete` and `has` are not supported for performance reasons.
22
+ *
23
+ * @example
24
+ * ```js
25
+ * const map = new StackedCacheMap();
26
+ * map.addAll(new Map([["a", 1], ["b", 2]]), true);
27
+ * map.addAll(new Map([["c", 3], ["d", 4]]), true);
28
+ * map.get("a"); // 1
29
+ * map.get("d"); // 4
30
+ * for (const [key, value] of map) {
31
+ * console.log(key, value);
32
+ * }
33
+ * ```
11
34
  */
12
35
  class StackedCacheMap {
13
36
  constructor() {
@@ -18,6 +41,9 @@ class StackedCacheMap {
18
41
  }
19
42
 
20
43
  /**
44
+ * If `immutable` is true, the map can be referenced by the StackedCacheMap
45
+ * and should not be changed afterwards. If the map is mutable, all items
46
+ * are copied into a fallback Map.
21
47
  * @param {ReadonlyMap<K, V>} map map to add
22
48
  * @param {boolean=} immutable if 'map' is immutable and StackedCacheMap can keep referencing it
23
49
  */
@@ -15,9 +15,15 @@ class TupleQueue {
15
15
  * @param {Iterable<T>=} items The initial elements.
16
16
  */
17
17
  constructor(items) {
18
- /** @private @type {TupleSet<T>} */
18
+ /**
19
+ * @private
20
+ * @type {TupleSet<T>}
21
+ */
19
22
  this._set = new TupleSet(items);
20
- /** @private @type {Iterator<T>} */
23
+ /**
24
+ * @private
25
+ * @type {Iterator<T>}
26
+ */
21
27
  this._iterator = this._set[Symbol.iterator]();
22
28
  }
23
29
 
@@ -5,6 +5,21 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ /**
9
+ * @template {any[]} T
10
+ * @template V
11
+ * @typedef {Map<object, WeakTupleMap<T, V>>} M
12
+ */
13
+ /**
14
+ * @template {any[]} T
15
+ * @template V
16
+ * @typedef {WeakMap<object, WeakTupleMap<T, V>>} W
17
+ */
18
+
19
+ /**
20
+ * @param {any} thing thing
21
+ * @returns {boolean} true if is weak
22
+ */
8
23
  const isWeakKey = thing => typeof thing === "object" && thing !== null;
9
24
 
10
25
  /**
@@ -15,11 +30,20 @@ class WeakTupleMap {
15
30
  constructor() {
16
31
  /** @private */
17
32
  this.f = 0;
18
- /** @private @type {any} */
33
+ /**
34
+ * @private
35
+ * @type {any}
36
+ */
19
37
  this.v = undefined;
20
- /** @private @type {Map<object, WeakTupleMap<T, V>> | undefined} */
38
+ /**
39
+ * @private
40
+ * @type {M<T, V> | undefined}
41
+ */
21
42
  this.m = undefined;
22
- /** @private @type {WeakMap<object, WeakTupleMap<T, V>> | undefined} */
43
+ /**
44
+ * @private
45
+ * @type {W<T, V> | undefined}
46
+ */
23
47
  this.w = undefined;
24
48
  }
25
49
 
@@ -41,7 +65,7 @@ class WeakTupleMap {
41
65
  * @returns {boolean} true, if the tuple is in the Set
42
66
  */
43
67
  has(...args) {
44
- /** @type {WeakTupleMap<T, V>} */
68
+ /** @type {WeakTupleMap<T, V> | undefined} */
45
69
  let node = this;
46
70
  for (let i = 0; i < args.length; i++) {
47
71
  node = node._peek(args[i]);
@@ -52,10 +76,10 @@ class WeakTupleMap {
52
76
 
53
77
  /**
54
78
  * @param {T} args tuple
55
- * @returns {V} the value
79
+ * @returns {V | undefined} the value
56
80
  */
57
81
  get(...args) {
58
- /** @type {WeakTupleMap<T, V>} */
82
+ /** @type {WeakTupleMap<T, V> | undefined} */
59
83
  let node = this;
60
84
  for (let i = 0; i < args.length; i++) {
61
85
  node = node._peek(args[i]);
@@ -86,7 +110,7 @@ class WeakTupleMap {
86
110
  * @returns {void}
87
111
  */
88
112
  delete(...args) {
89
- /** @type {WeakTupleMap<T, V>} */
113
+ /** @type {WeakTupleMap<T, V> | undefined} */
90
114
  let node = this;
91
115
  for (let i = 0; i < args.length; i++) {
92
116
  node = node._peek(args[i]);
@@ -113,6 +137,10 @@ class WeakTupleMap {
113
137
  return (this.f & 1) === 1;
114
138
  }
115
139
 
140
+ /**
141
+ * @param {any} v value
142
+ * @private
143
+ */
116
144
  _setValue(v) {
117
145
  this.f |= 1;
118
146
  this.v = v;
@@ -123,16 +151,26 @@ class WeakTupleMap {
123
151
  this.v = undefined;
124
152
  }
125
153
 
154
+ /**
155
+ * @param {any} thing thing
156
+ * @returns {WeakTupleMap<T, V> | undefined} thing
157
+ * @private
158
+ */
126
159
  _peek(thing) {
127
160
  if (isWeakKey(thing)) {
128
161
  if ((this.f & 4) !== 4) return undefined;
129
- return this.w.get(thing);
162
+ return /** @type {W<T, V>} */ (this.w).get(thing);
130
163
  } else {
131
164
  if ((this.f & 2) !== 2) return undefined;
132
- return this.m.get(thing);
165
+ return /** @type {M<T, V>} */ (this.m).get(thing);
133
166
  }
134
167
  }
135
168
 
169
+ /**
170
+ * @private
171
+ * @param {any} thing thing
172
+ * @returns {WeakTupleMap<T, V>} value
173
+ */
136
174
  _get(thing) {
137
175
  if (isWeakKey(thing)) {
138
176
  if ((this.f & 4) !== 4) {
@@ -142,12 +180,15 @@ class WeakTupleMap {
142
180
  (this.w = newMap).set(thing, newNode);
143
181
  return newNode;
144
182
  }
145
- const entry = this.w.get(thing);
183
+ const entry =
184
+ /** @type {W<T, V>} */
185
+ (this.w).get(thing);
146
186
  if (entry !== undefined) {
147
187
  return entry;
148
188
  }
149
189
  const newNode = new WeakTupleMap();
150
- this.w.set(thing, newNode);
190
+ /** @type {W<T, V>} */
191
+ (this.w).set(thing, newNode);
151
192
  return newNode;
152
193
  } else {
153
194
  if ((this.f & 2) !== 2) {
@@ -157,12 +198,15 @@ class WeakTupleMap {
157
198
  (this.m = newMap).set(thing, newNode);
158
199
  return newNode;
159
200
  }
160
- const entry = this.m.get(thing);
201
+ const entry =
202
+ /** @type {M<T, V>} */
203
+ (this.m).get(thing);
161
204
  if (entry !== undefined) {
162
205
  return entry;
163
206
  }
164
207
  const newNode = new WeakTupleMap();
165
- this.m.set(thing, newNode);
208
+ /** @type {M<T, V>} */
209
+ (this.m).set(thing, newNode);
166
210
  return newNode;
167
211
  }
168
212
  }
@@ -75,7 +75,7 @@ const compileSearch = (funcName, predicate, reversed, extraArgs, earlyOut) => {
75
75
  * @param {boolean} reversed Whether the search should be reversed.
76
76
  * @param {SearchPredicateSuffix} suffix The suffix to be used in the function name.
77
77
  * @param {boolean=} earlyOut Whether the search should return as soon as a match is found.
78
- * @returns {function} The compiled binary search function.
78
+ * @returns {Function} The compiled binary search function.
79
79
  */
80
80
  const compileBoundsSearch = (predicate, reversed, suffix, earlyOut) => {
81
81
  const arg1 = compileSearch(
@@ -38,11 +38,11 @@ const cachedCleverMerge = (first, second) => {
38
38
  innerCache = new WeakMap();
39
39
  mergeCache.set(first, innerCache);
40
40
  }
41
- const prevMerge = innerCache.get(second);
41
+ const prevMerge = /** @type {T & O} */ (innerCache.get(second));
42
42
  if (prevMerge !== undefined) return prevMerge;
43
43
  const newMerge = _cleverMerge(first, second, true);
44
44
  innerCache.set(second, newMerge);
45
- return newMerge;
45
+ return /** @type {T & O} */ (newMerge);
46
46
  };
47
47
 
48
48
  /**
@@ -69,7 +69,7 @@ const cachedSetProperty = (obj, property, value) => {
69
69
 
70
70
  let result = mapByValue.get(value);
71
71
 
72
- if (result) return result;
72
+ if (result) return /** @type {T} */ (result);
73
73
 
74
74
  result = {
75
75
  ...obj,
@@ -77,18 +77,18 @@ const cachedSetProperty = (obj, property, value) => {
77
77
  };
78
78
  mapByValue.set(value, result);
79
79
 
80
- return result;
80
+ return /** @type {T} */ (result);
81
81
  };
82
82
 
83
83
  /**
84
- * @typedef {Object} ObjectParsedPropertyEntry
84
+ * @typedef {object} ObjectParsedPropertyEntry
85
85
  * @property {any | undefined} base base value
86
86
  * @property {string | undefined} byProperty the name of the selector property
87
87
  * @property {Map<string, any>} byValues value depending on selector property, merged with base
88
88
  */
89
89
 
90
90
  /**
91
- * @typedef {Object} ParsedObject
91
+ * @typedef {object} ParsedObject
92
92
  * @property {Map<string, ObjectParsedPropertyEntry>} static static properties (key is property name)
93
93
  * @property {{ byProperty: string, fn: Function } | undefined} dynamic dynamic part
94
94
  */
@@ -257,7 +257,7 @@ const cleverMerge = (first, second) => {
257
257
  if (typeof second !== "object" || second === null) return second;
258
258
  if (typeof first !== "object" || first === null) return first;
259
259
 
260
- return _cleverMerge(first, second, false);
260
+ return /** @type {T & O} */ (_cleverMerge(first, second, false));
261
261
  };
262
262
 
263
263
  /**
@@ -498,27 +498,40 @@ const mergeSingleValue = (a, b, internalCaching) => {
498
498
  };
499
499
 
500
500
  /**
501
- * @template T
501
+ * @template {object} T
502
502
  * @param {T} obj the object
503
+ * @param {(keyof T)[]=} keysToKeepOriginalValue keys to keep original value
503
504
  * @returns {T} the object without operations like "..." or DELETE
504
505
  */
505
- const removeOperations = obj => {
506
+ const removeOperations = (obj, keysToKeepOriginalValue = []) => {
506
507
  const newObj = /** @type {T} */ ({});
507
508
  for (const key of Object.keys(obj)) {
508
- const value = obj[key];
509
+ const value = obj[/** @type {keyof T} */ (key)];
509
510
  const type = getValueType(value);
511
+ if (
512
+ type === VALUE_TYPE_OBJECT &&
513
+ keysToKeepOriginalValue.includes(/** @type {keyof T} */ (key))
514
+ ) {
515
+ newObj[/** @type {keyof T} */ (key)] = value;
516
+ continue;
517
+ }
510
518
  switch (type) {
511
519
  case VALUE_TYPE_UNDEFINED:
512
520
  case VALUE_TYPE_DELETE:
513
521
  break;
514
522
  case VALUE_TYPE_OBJECT:
515
- newObj[key] = removeOperations(value);
523
+ newObj[key] = removeOperations(
524
+ /** @type {TODO} */ (value),
525
+ keysToKeepOriginalValue
526
+ );
516
527
  break;
517
528
  case VALUE_TYPE_ARRAY_EXTEND:
518
- newObj[key] = value.filter(i => i !== "...");
529
+ newObj[key] =
530
+ /** @type {any[]} */
531
+ (value).filter(i => i !== "...");
519
532
  break;
520
533
  default:
521
- newObj[key] = value;
534
+ newObj[/** @type {keyof T} */ (key)] = value;
522
535
  break;
523
536
  }
524
537
  }