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
@@ -46,19 +46,19 @@ const RBDT_FILE_DEPENDENCIES = 9;
46
46
  const INVALID = Symbol("invalid");
47
47
 
48
48
  /**
49
- * @typedef {Object} FileSystemInfoEntry
49
+ * @typedef {object} FileSystemInfoEntry
50
50
  * @property {number} safeTime
51
51
  * @property {number=} timestamp
52
52
  */
53
53
 
54
54
  /**
55
- * @typedef {Object} ResolvedContextFileSystemInfoEntry
55
+ * @typedef {object} ResolvedContextFileSystemInfoEntry
56
56
  * @property {number} safeTime
57
57
  * @property {string=} timestampHash
58
58
  */
59
59
 
60
60
  /**
61
- * @typedef {Object} ContextFileSystemInfoEntry
61
+ * @typedef {object} ContextFileSystemInfoEntry
62
62
  * @property {number} safeTime
63
63
  * @property {string=} timestampHash
64
64
  * @property {ResolvedContextFileSystemInfoEntry=} resolved
@@ -66,21 +66,21 @@ const INVALID = Symbol("invalid");
66
66
  */
67
67
 
68
68
  /**
69
- * @typedef {Object} TimestampAndHash
69
+ * @typedef {object} TimestampAndHash
70
70
  * @property {number} safeTime
71
71
  * @property {number=} timestamp
72
72
  * @property {string} hash
73
73
  */
74
74
 
75
75
  /**
76
- * @typedef {Object} ResolvedContextTimestampAndHash
76
+ * @typedef {object} ResolvedContextTimestampAndHash
77
77
  * @property {number} safeTime
78
78
  * @property {string=} timestampHash
79
79
  * @property {string} hash
80
80
  */
81
81
 
82
82
  /**
83
- * @typedef {Object} ContextTimestampAndHash
83
+ * @typedef {object} ContextTimestampAndHash
84
84
  * @property {number} safeTime
85
85
  * @property {string=} timestampHash
86
86
  * @property {string} hash
@@ -89,14 +89,14 @@ const INVALID = Symbol("invalid");
89
89
  */
90
90
 
91
91
  /**
92
- * @typedef {Object} ContextHash
92
+ * @typedef {object} ContextHash
93
93
  * @property {string} hash
94
94
  * @property {string=} resolved
95
95
  * @property {Set<string>=} symlinks
96
96
  */
97
97
 
98
98
  /**
99
- * @typedef {Object} SnapshotOptimizationEntry
99
+ * @typedef {object} SnapshotOptimizationEntry
100
100
  * @property {Snapshot} snapshot
101
101
  * @property {number} shared
102
102
  * @property {Set<string> | undefined} snapshotContent
@@ -104,19 +104,19 @@ const INVALID = Symbol("invalid");
104
104
  */
105
105
 
106
106
  /**
107
- * @typedef {Object} ResolveBuildDependenciesResult
107
+ * @typedef {object} ResolveBuildDependenciesResult
108
108
  * @property {Set<string>} files list of files
109
109
  * @property {Set<string>} directories list of directories
110
110
  * @property {Set<string>} missing list of missing entries
111
111
  * @property {Map<string, string | false>} resolveResults stored resolve results
112
- * @property {Object} resolveDependencies dependencies of the resolving
112
+ * @property {object} resolveDependencies dependencies of the resolving
113
113
  * @property {Set<string>} resolveDependencies.files list of files
114
114
  * @property {Set<string>} resolveDependencies.directories list of directories
115
115
  * @property {Set<string>} resolveDependencies.missing list of missing entries
116
116
  */
117
117
 
118
118
  /**
119
- * @typedef {Object} SnapshotOptions
119
+ * @typedef {object} SnapshotOptions
120
120
  * @property {boolean=} hash should use hash to snapshot
121
121
  * @property {boolean=} timestamp should use timestamp to snapshot
122
122
  */
@@ -133,7 +133,13 @@ class SnapshotIterator {
133
133
  }
134
134
  }
135
135
 
136
+ /** @typedef {(snapshot: Snapshot) => (Map<string, any> | Set<string>)[]} GetMapsFunction */
137
+
136
138
  class SnapshotIterable {
139
+ /**
140
+ * @param {Snapshot} snapshot snapshot
141
+ * @param {GetMapsFunction} getMaps get maps function
142
+ */
137
143
  constructor(snapshot, getMaps) {
138
144
  this.snapshot = snapshot;
139
145
  this.getMaps = getMaps;
@@ -213,6 +219,13 @@ class SnapshotIterable {
213
219
  }
214
220
  }
215
221
 
222
+ /** @typedef {Map<string, FileSystemInfoEntry | null>} FileTimestamps */
223
+ /** @typedef {Map<string, string | null>} FileHashes */
224
+ /** @typedef {Map<string, TimestampAndHash | string | null>} FileTshs */
225
+ /** @typedef {Map<string, ResolvedContextFileSystemInfoEntry | null>} ContextTimestamps */
226
+ /** @typedef {Map<string, string | null>} ContextHashes */
227
+ /** @typedef {Map<string, ResolvedContextTimestampAndHash | null>} ContextTshs */
228
+
216
229
  class Snapshot {
217
230
  constructor() {
218
231
  this._flags = 0;
@@ -224,17 +237,17 @@ class Snapshot {
224
237
  this._cachedMissingIterable = undefined;
225
238
  /** @type {number | undefined} */
226
239
  this.startTime = undefined;
227
- /** @type {Map<string, FileSystemInfoEntry | null> | undefined} */
240
+ /** @type {FileTimestamps | undefined} */
228
241
  this.fileTimestamps = undefined;
229
- /** @type {Map<string, string | null> | undefined} */
242
+ /** @type {FileHashes | undefined} */
230
243
  this.fileHashes = undefined;
231
- /** @type {Map<string, TimestampAndHash | string | null> | undefined} */
244
+ /** @type {FileTshs | undefined} */
232
245
  this.fileTshs = undefined;
233
- /** @type {Map<string, ResolvedContextFileSystemInfoEntry | null> | undefined} */
246
+ /** @type {ContextTimestamps | undefined} */
234
247
  this.contextTimestamps = undefined;
235
- /** @type {Map<string, string | null> | undefined} */
248
+ /** @type {ContextHashes | undefined} */
236
249
  this.contextHashes = undefined;
237
- /** @type {Map<string, ResolvedContextTimestampAndHash | null> | undefined} */
250
+ /** @type {ContextTshs | undefined} */
238
251
  this.contextTshs = undefined;
239
252
  /** @type {Map<string, boolean> | undefined} */
240
253
  this.missingExistence = undefined;
@@ -254,6 +267,9 @@ class Snapshot {
254
267
  return (this._flags & 1) !== 0;
255
268
  }
256
269
 
270
+ /**
271
+ * @param {number} value start value
272
+ */
257
273
  setStartTime(value) {
258
274
  this._flags = this._flags | 1;
259
275
  this.startTime = value;
@@ -427,7 +443,7 @@ class Snapshot {
427
443
  }
428
444
 
429
445
  /**
430
- * @param {function(Snapshot): (ReadonlyMap<string, any> | ReadonlySet<string>)[]} getMaps first
446
+ * @param {GetMapsFunction} getMaps first
431
447
  * @returns {Iterable<string>} iterable
432
448
  */
433
449
  _createIterable(getMaps) {
@@ -728,6 +744,10 @@ class SnapshotOptimization {
728
744
  }
729
745
  }
730
746
 
747
+ /**
748
+ * @param {string} str input
749
+ * @returns {TODO} result
750
+ */
731
751
  const parseString = str => {
732
752
  if (str[0] === "'" || str[0] === "`")
733
753
  str = `"${str.slice(1, -1).replace(/"/g, '\\"')}"`;
@@ -898,7 +918,7 @@ const addAll = (source, target) => {
898
918
  class FileSystemInfo {
899
919
  /**
900
920
  * @param {InputFileSystem} fs file system
901
- * @param {Object} options options
921
+ * @param {object} options options
902
922
  * @param {Iterable<string | RegExp>=} options.unmanagedPaths paths that are not managed by a package manager and the contents are subject to change
903
923
  * @param {Iterable<string | RegExp>=} options.managedPaths paths that are only managed by a package manager
904
924
  * @param {Iterable<string | RegExp>=} options.immutablePaths paths that are immutable
@@ -989,7 +1009,7 @@ class FileSystemInfo {
989
1009
  );
990
1010
  /** @type {StackedCacheMap<string, FileSystemInfoEntry | "ignore" | null>} */
991
1011
  this._fileTimestamps = new StackedCacheMap();
992
- /** @type {Map<string, string>} */
1012
+ /** @type {Map<string, string | null>} */
993
1013
  this._fileHashes = new Map();
994
1014
  /** @type {Map<string, TimestampAndHash | string>} */
995
1015
  this._fileTshs = new Map();
@@ -1081,13 +1101,18 @@ class FileSystemInfo {
1081
1101
  }
1082
1102
 
1083
1103
  logStatistics() {
1104
+ const logger = /** @type {Logger} */ (this.logger);
1105
+ /**
1106
+ * @param {string} header header
1107
+ * @param {string | undefined} message message
1108
+ */
1084
1109
  const logWhenMessage = (header, message) => {
1085
1110
  if (message) {
1086
- this.logger.log(`${header}: ${message}`);
1111
+ logger.log(`${header}: ${message}`);
1087
1112
  }
1088
1113
  };
1089
- this.logger.log(`${this._statCreatedSnapshots} new snapshots created`);
1090
- this.logger.log(
1114
+ logger.log(`${this._statCreatedSnapshots} new snapshots created`);
1115
+ logger.log(
1091
1116
  `${
1092
1117
  this._statTestedSnapshotsNotCached &&
1093
1118
  Math.round(
@@ -1099,7 +1124,7 @@ class FileSystemInfo {
1099
1124
  this._statTestedSnapshotsCached + this._statTestedSnapshotsNotCached
1100
1125
  })`
1101
1126
  );
1102
- this.logger.log(
1127
+ logger.log(
1103
1128
  `${
1104
1129
  this._statTestedChildrenNotCached &&
1105
1130
  Math.round(
@@ -1110,8 +1135,8 @@ class FileSystemInfo {
1110
1135
  this._statTestedChildrenCached + this._statTestedChildrenNotCached
1111
1136
  })`
1112
1137
  );
1113
- this.logger.log(`${this._statTestedEntries} entries tested`);
1114
- this.logger.log(
1138
+ logger.log(`${this._statTestedEntries} entries tested`);
1139
+ logger.log(
1115
1140
  `File info in cache: ${this._fileTimestamps.size} timestamps ${this._fileHashes.size} hashes ${this._fileTshs.size} timestamp hash combinations`
1116
1141
  );
1117
1142
  logWhenMessage(
@@ -1126,7 +1151,7 @@ class FileSystemInfo {
1126
1151
  `File timestamp hash combination snapshot optimization`,
1127
1152
  this._fileTshsOptimization.getStatisticMessage()
1128
1153
  );
1129
- this.logger.log(
1154
+ logger.log(
1130
1155
  `Directory info in cache: ${this._contextTimestamps.size} timestamps ${this._contextHashes.size} hashes ${this._contextTshs.size} timestamp hash combinations`
1131
1156
  );
1132
1157
  logWhenMessage(
@@ -1145,9 +1170,7 @@ class FileSystemInfo {
1145
1170
  `Missing items snapshot optimization`,
1146
1171
  this._missingExistenceOptimization.getStatisticMessage()
1147
1172
  );
1148
- this.logger.log(
1149
- `Managed items info in cache: ${this._managedItems.size} items`
1150
- );
1173
+ logger.log(`Managed items info in cache: ${this._managedItems.size} items`);
1151
1174
  logWhenMessage(
1152
1175
  `Managed items snapshot optimization`,
1153
1176
  this._managedItemInfoOptimization.getStatisticMessage()
@@ -1302,13 +1325,15 @@ class FileSystemInfo {
1302
1325
  const cache = this._contextHashes.get(path);
1303
1326
  if (cache !== undefined) {
1304
1327
  const resolved = getResolvedHash(cache);
1305
- if (resolved !== undefined) return callback(null, resolved);
1328
+ if (resolved !== undefined)
1329
+ return callback(null, /** @type {string} */ (resolved));
1306
1330
  return this._resolveContextHash(cache, callback);
1307
1331
  }
1308
1332
  this.contextHashQueue.add(path, (err, entry) => {
1309
1333
  if (err) return callback(err);
1310
1334
  const resolved = getResolvedHash(entry);
1311
- if (resolved !== undefined) return callback(null, resolved);
1335
+ if (resolved !== undefined)
1336
+ return callback(null, /** @type {string} */ (resolved));
1312
1337
  this._resolveContextHash(entry, callback);
1313
1338
  });
1314
1339
  }
@@ -1513,7 +1538,8 @@ class FileSystemInfo {
1513
1538
  resolveResults.set(key, result.path);
1514
1539
  } else {
1515
1540
  invalidResolveResults.add(key);
1516
- this.logger.warn(
1541
+ /** @type {Logger} */
1542
+ (this.logger).warn(
1517
1543
  `Resolving '${path}' in ${context} for build dependencies doesn't lead to expected result '${expected}', but to '${
1518
1544
  err || (result && result.path)
1519
1545
  }' instead. Resolving dependencies are ignored for this path.\n${pathToString(
@@ -1941,9 +1967,9 @@ class FileSystemInfo {
1941
1967
  /**
1942
1968
  *
1943
1969
  * @param {number | null | undefined} startTime when processing the files has started
1944
- * @param {Iterable<string>} files all files
1945
- * @param {Iterable<string>} directories all directories
1946
- * @param {Iterable<string>} missing all missing files or directories
1970
+ * @param {Iterable<string> | null} files all files
1971
+ * @param {Iterable<string> | null} directories all directories
1972
+ * @param {Iterable<string> | null} missing all missing files or directories
1947
1973
  * @param {SnapshotOptions | null | undefined} options options object (for future extensions)
1948
1974
  * @param {function((WebpackError | null)=, (Snapshot | null)=): void} callback callback function
1949
1975
  * @returns {void}
@@ -3018,7 +3044,7 @@ class FileSystemInfo {
3018
3044
  /**
3019
3045
  * @template T
3020
3046
  * @template ItemType
3021
- * @param {Object} options options
3047
+ * @param {object} options options
3022
3048
  * @param {string} options.path path
3023
3049
  * @param {function(string): ItemType} options.fromImmutablePath called when context item is an immutable path
3024
3050
  * @param {function(string): ItemType} options.fromManagedItem called when context item is a managed path
@@ -3318,7 +3344,7 @@ class FileSystemInfo {
3318
3344
 
3319
3345
  /**
3320
3346
  * @param {ContextHash} entry context hash
3321
- * @param {function((Error | null)=, string=): void} callback callback
3347
+ * @param {function((WebpackError | null)=, string=): void} callback callback
3322
3348
  * @returns {void}
3323
3349
  */
3324
3350
  _resolveContextHash(entry, callback) {
@@ -3340,7 +3366,7 @@ class FileSystemInfo {
3340
3366
  });
3341
3367
  },
3342
3368
  err => {
3343
- if (err) return callback(err);
3369
+ if (err) return callback(/** @type {WebpackError} */ (err));
3344
3370
  const hash = createHash(this._hashFunction);
3345
3371
  hash.update(entry.hash);
3346
3372
  hashes.sort();
@@ -3394,7 +3420,7 @@ class FileSystemInfo {
3394
3420
  timestampHash: info,
3395
3421
  hash: info || ""
3396
3422
  }),
3397
- fromSymlink: (fle, target, callback) => {
3423
+ fromSymlink: (file, target, callback) => {
3398
3424
  callback(null, {
3399
3425
  timestampHash: target,
3400
3426
  hash: target,
@@ -3583,7 +3609,7 @@ class FileSystemInfo {
3583
3609
  elements.length === 1 &&
3584
3610
  elements[0] === "node_modules"
3585
3611
  ) {
3586
- // This is only a grouping folder e. g. used by yarn
3612
+ // This is only a grouping folder e.g. used by yarn
3587
3613
  // we are only interested in existence of this special directory
3588
3614
  this._managedItems.set(path, "*nested");
3589
3615
  return callback(null, "*nested");
@@ -3604,7 +3630,8 @@ class FileSystemInfo {
3604
3630
  return callback(e);
3605
3631
  }
3606
3632
  if (!data.name) {
3607
- this.logger.warn(
3633
+ /** @type {Logger} */
3634
+ (this.logger).warn(
3608
3635
  `${packageJsonPath} doesn't contain a "name" property (see snapshot.managedPaths option)`
3609
3636
  );
3610
3637
  return callback();
@@ -15,6 +15,7 @@ const Queue = require("./util/Queue");
15
15
  /** @typedef {import("./Dependency").ExportsSpec} ExportsSpec */
16
16
  /** @typedef {import("./ExportsInfo")} ExportsInfo */
17
17
  /** @typedef {import("./Module")} Module */
18
+ /** @typedef {import("./Module").BuildInfo} BuildInfo */
18
19
 
19
20
  const PLUGIN_NAME = "FlagDependencyExportsPlugin";
20
21
  const PLUGIN_LOGGER_NAME = `webpack.${PLUGIN_NAME}`;
@@ -63,7 +64,10 @@ class FlagDependencyExportsPlugin {
63
64
  }
64
65
  }
65
66
  // If the module has no hash, it's uncacheable
66
- if (typeof module.buildInfo.hash !== "string") {
67
+ if (
68
+ typeof (/** @type {BuildInfo} */ (module.buildInfo).hash) !==
69
+ "string"
70
+ ) {
67
71
  statFlaggedUncached++;
68
72
  // Enqueue uncacheable module for determining the exports
69
73
  queue.enqueue(module);
@@ -79,7 +83,8 @@ class FlagDependencyExportsPlugin {
79
83
  }
80
84
  cache.get(
81
85
  module.identifier(),
82
- module.buildInfo.hash,
86
+ /** @type {BuildInfo} */
87
+ (module.buildInfo).hash,
83
88
  (err, result) => {
84
89
  if (err) return callback(err);
85
90
 
@@ -234,7 +239,10 @@ class FlagDependencyExportsPlugin {
234
239
  if (exports) {
235
240
  const nestedExportsInfo =
236
241
  exportInfo.createNestedExportsInfo();
237
- mergeExports(nestedExportsInfo, exports);
242
+ mergeExports(
243
+ /** @type {ExportsInfo} */ (nestedExportsInfo),
244
+ exports
245
+ );
238
246
  }
239
247
 
240
248
  if (
@@ -272,7 +280,8 @@ class FlagDependencyExportsPlugin {
272
280
 
273
281
  if (exportInfo.exportsInfoOwned) {
274
282
  if (
275
- exportInfo.exportsInfo.setRedirectNamedTo(
283
+ /** @type {ExportsInfo} */
284
+ (exportInfo.exportsInfo).setRedirectNamedTo(
276
285
  targetExportsInfo
277
286
  )
278
287
  ) {
@@ -312,7 +321,7 @@ class FlagDependencyExportsPlugin {
312
321
 
313
322
  logger.time("figure out provided exports");
314
323
  while (queue.length > 0) {
315
- module = queue.dequeue();
324
+ module = /** @type {Module} */ (queue.dequeue());
316
325
 
317
326
  statQueueItemsProcessed++;
318
327
 
@@ -356,7 +365,11 @@ class FlagDependencyExportsPlugin {
356
365
  asyncLib.each(
357
366
  modulesToStore,
358
367
  (module, callback) => {
359
- if (typeof module.buildInfo.hash !== "string") {
368
+ if (
369
+ typeof (
370
+ /** @type {BuildInfo} */ (module.buildInfo).hash
371
+ ) !== "string"
372
+ ) {
360
373
  // not cacheable
361
374
  return callback();
362
375
  }
@@ -370,7 +383,8 @@ class FlagDependencyExportsPlugin {
370
383
  }
371
384
  cache.store(
372
385
  module.identifier(),
373
- module.buildInfo.hash,
386
+ /** @type {BuildInfo} */
387
+ (module.buildInfo).hash,
374
388
  cachedData,
375
389
  callback
376
390
  );
package/lib/Generator.js CHANGED
@@ -13,6 +13,7 @@
13
13
  /** @typedef {import("./DependencyTemplate")} DependencyTemplate */
14
14
  /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
15
15
  /** @typedef {import("./Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
16
+ /** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
16
17
  /** @typedef {import("./ModuleGraph")} ModuleGraph */
17
18
  /** @typedef {import("./NormalModule")} NormalModule */
18
19
  /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
@@ -20,14 +21,13 @@
20
21
  /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
21
22
 
22
23
  /**
23
- * @typedef {Object} GenerateContext
24
+ * @typedef {object} GenerateContext
24
25
  * @property {DependencyTemplates} dependencyTemplates mapping from dependencies to templates
25
26
  * @property {RuntimeTemplate} runtimeTemplate the runtime template
26
27
  * @property {ModuleGraph} moduleGraph the module graph
27
28
  * @property {ChunkGraph} chunkGraph the chunk graph
28
- * @property {Set<string>} runtimeRequirements the requirements for runtime
29
+ * @property {RuntimeRequirements} runtimeRequirements the requirements for runtime
29
30
  * @property {RuntimeSpec} runtime the runtime
30
- * @property {RuntimeSpec[]} [runtimes] the runtimes
31
31
  * @property {ConcatenationScope=} concatenationScope when in concatenated module, information about other concatenated modules
32
32
  * @property {CodeGenerationResults=} codeGenerationResults code generation results of other modules (need to have a codeGenerationDependency to use that)
33
33
  * @property {string} type which kind of code should be generated
@@ -35,7 +35,7 @@
35
35
  */
36
36
 
37
37
  /**
38
- * @typedef {Object} UpdateHashContext
38
+ * @typedef {object} UpdateHashContext
39
39
  * @property {NormalModule} module the module
40
40
  * @property {ChunkGraph} chunkGraph
41
41
  * @property {RuntimeSpec} runtime
@@ -12,7 +12,7 @@ const WebpackError = require("./WebpackError");
12
12
  /**
13
13
  * @template T
14
14
  * @callback Callback
15
- * @param {Error=} err
15
+ * @param {Error | null} err
16
16
  * @param {T=} stats
17
17
  * @returns {void}
18
18
  */
@@ -51,7 +51,7 @@ module.exports.makeWebpackError = makeWebpackError;
51
51
 
52
52
  /**
53
53
  * @template T
54
- * @param {function((WebpackError | null)=, T=): void} callback webpack error callback
54
+ * @param {function(WebpackError | null, T=): void} callback webpack error callback
55
55
  * @param {string} hook name of hook
56
56
  * @returns {Callback<T>} generic callback
57
57
  */