webpack 5.98.0 → 5.99.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 (251) hide show
  1. package/README.md +7 -3
  2. package/lib/AsyncDependenciesBlock.js +3 -1
  3. package/lib/BannerPlugin.js +1 -1
  4. package/lib/Cache.js +9 -7
  5. package/lib/CacheFacade.js +5 -5
  6. package/lib/Chunk.js +2 -2
  7. package/lib/ChunkGraph.js +21 -16
  8. package/lib/ChunkTemplate.js +6 -6
  9. package/lib/CleanPlugin.js +10 -10
  10. package/lib/CodeGenerationResults.js +4 -3
  11. package/lib/CompatibilityPlugin.js +4 -1
  12. package/lib/Compilation.js +326 -152
  13. package/lib/Compiler.js +13 -18
  14. package/lib/ConditionalInitFragment.js +1 -1
  15. package/lib/ConstPlugin.js +5 -3
  16. package/lib/ContextModule.js +4 -2
  17. package/lib/ContextModuleFactory.js +3 -3
  18. package/lib/ContextReplacementPlugin.js +43 -16
  19. package/lib/DefinePlugin.js +25 -24
  20. package/lib/DelegatedModule.js +4 -2
  21. package/lib/DelegatedModuleFactoryPlugin.js +2 -1
  22. package/lib/Dependency.js +19 -13
  23. package/lib/DependencyTemplates.js +4 -3
  24. package/lib/DllModule.js +4 -2
  25. package/lib/DllModuleFactory.js +2 -2
  26. package/lib/DllReferencePlugin.js +2 -1
  27. package/lib/DynamicEntryPlugin.js +1 -1
  28. package/lib/EnvironmentPlugin.js +4 -2
  29. package/lib/ExportsInfo.js +72 -40
  30. package/lib/ExternalModule.js +14 -5
  31. package/lib/ExternalModuleFactoryPlugin.js +24 -12
  32. package/lib/FileSystemInfo.js +129 -94
  33. package/lib/FlagDependencyExportsPlugin.js +6 -4
  34. package/lib/FlagDependencyUsagePlugin.js +1 -1
  35. package/lib/Generator.js +29 -1
  36. package/lib/HookWebpackError.js +2 -2
  37. package/lib/HotModuleReplacementPlugin.js +3 -9
  38. package/lib/IgnoreErrorModuleFactory.js +2 -2
  39. package/lib/IgnorePlugin.js +0 -5
  40. package/lib/InitFragment.js +1 -1
  41. package/lib/LoaderOptionsPlugin.js +8 -5
  42. package/lib/MainTemplate.js +7 -7
  43. package/lib/Module.js +40 -17
  44. package/lib/ModuleBuildError.js +3 -1
  45. package/lib/ModuleDependencyError.js +4 -3
  46. package/lib/ModuleDependencyWarning.js +4 -3
  47. package/lib/ModuleFactory.js +9 -3
  48. package/lib/ModuleFilenameHelpers.js +13 -13
  49. package/lib/ModuleGraph.js +20 -14
  50. package/lib/ModuleGraphConnection.js +7 -13
  51. package/lib/ModuleNotFoundError.js +1 -1
  52. package/lib/ModuleParseError.js +2 -1
  53. package/lib/ModuleSourceTypesConstants.js +11 -0
  54. package/lib/ModuleTemplate.js +5 -5
  55. package/lib/ModuleTypeConstants.js +15 -0
  56. package/lib/MultiCompiler.js +4 -4
  57. package/lib/MultiStats.js +1 -1
  58. package/lib/NormalModule.js +101 -54
  59. package/lib/NormalModuleFactory.js +38 -33
  60. package/lib/NormalModuleReplacementPlugin.js +3 -2
  61. package/lib/NullFactory.js +2 -2
  62. package/lib/Parser.js +4 -3
  63. package/lib/ProgressPlugin.js +1 -2
  64. package/lib/RawModule.js +4 -2
  65. package/lib/RecordIdsPlugin.js +6 -2
  66. package/lib/RequestShortener.js +3 -1
  67. package/lib/ResolverFactory.js +12 -9
  68. package/lib/RuntimeModule.js +4 -2
  69. package/lib/RuntimeTemplate.js +2 -1
  70. package/lib/SelfModuleFactory.js +2 -2
  71. package/lib/SourceMapDevToolPlugin.js +0 -8
  72. package/lib/Template.js +6 -5
  73. package/lib/TemplatedPathPlugin.js +15 -12
  74. package/lib/WebpackOptionsApply.js +1 -1
  75. package/lib/asset/AssetGenerator.js +237 -170
  76. package/lib/asset/AssetModulesPlugin.js +50 -8
  77. package/lib/asset/AssetSourceGenerator.js +18 -0
  78. package/lib/asset/RawDataUrlModule.js +4 -2
  79. package/lib/buildChunkGraph.js +14 -4
  80. package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
  81. package/lib/cache/PackFileCacheStrategy.js +137 -121
  82. package/lib/cache/ResolverCachePlugin.js +15 -7
  83. package/lib/cache/getLazyHashedEtag.js +4 -3
  84. package/lib/cli.js +23 -15
  85. package/lib/config/defaults.js +93 -26
  86. package/lib/config/normalization.js +14 -13
  87. package/lib/config/target.js +8 -8
  88. package/lib/container/ContainerEntryModule.js +4 -2
  89. package/lib/container/ContainerEntryModuleFactory.js +2 -2
  90. package/lib/container/FallbackModule.js +4 -2
  91. package/lib/container/FallbackModuleFactory.js +2 -2
  92. package/lib/container/RemoteModule.js +4 -2
  93. package/lib/container/options.js +5 -5
  94. package/lib/css/CssGenerator.js +71 -9
  95. package/lib/css/CssModulesPlugin.js +30 -5
  96. package/lib/css/CssParser.js +37 -17
  97. package/lib/css/walkCssTokens.js +17 -17
  98. package/lib/debug/ProfilingPlugin.js +98 -38
  99. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +10 -4
  100. package/lib/dependencies/AMDPlugin.js +5 -2
  101. package/lib/dependencies/AMDRequireArrayDependency.js +4 -3
  102. package/lib/dependencies/AMDRequireContextDependency.js +2 -1
  103. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +15 -7
  104. package/lib/dependencies/AMDRuntimeModules.js +3 -1
  105. package/lib/dependencies/CommonJsExportRequireDependency.js +4 -5
  106. package/lib/dependencies/CommonJsExportsParserPlugin.js +3 -3
  107. package/lib/dependencies/CommonJsImportsParserPlugin.js +8 -7
  108. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -1
  109. package/lib/dependencies/ContextDependencyHelpers.js +13 -6
  110. package/lib/dependencies/CssIcssExportDependency.js +15 -12
  111. package/lib/dependencies/CssIcssImportDependency.js +4 -1
  112. package/lib/dependencies/CssLocalIdentifierDependency.js +17 -14
  113. package/lib/dependencies/ExportsInfoDependency.js +6 -1
  114. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +5 -5
  115. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +22 -15
  116. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +23 -8
  117. package/lib/dependencies/HarmonyExportSpecifierDependency.js +2 -2
  118. package/lib/dependencies/HarmonyImportDependency.js +8 -6
  119. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -14
  120. package/lib/dependencies/HarmonyImportSpecifierDependency.js +5 -5
  121. package/lib/dependencies/ImportContextDependency.js +2 -1
  122. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -4
  123. package/lib/dependencies/JsonExportsDependency.js +24 -8
  124. package/lib/dependencies/LoaderPlugin.js +4 -14
  125. package/lib/dependencies/RequireContextDependency.js +2 -1
  126. package/lib/dependencies/RequireContextDependencyParserPlugin.js +6 -3
  127. package/lib/dependencies/RequireEnsureDependenciesBlock.js +3 -2
  128. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +11 -5
  129. package/lib/dependencies/RequireResolveContextDependency.js +1 -1
  130. package/lib/dependencies/WebAssemblyExportImportedDependency.js +1 -1
  131. package/lib/dependencies/WorkerDependency.js +6 -3
  132. package/lib/dependencies/WorkerPlugin.js +100 -41
  133. package/lib/esm/ModuleChunkFormatPlugin.js +5 -0
  134. package/lib/hmr/HotModuleReplacement.runtime.js +1 -0
  135. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +1 -0
  136. package/lib/hmr/LazyCompilationPlugin.js +32 -24
  137. package/lib/hmr/lazyCompilationBackend.js +1 -1
  138. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  139. package/lib/ids/HashedModuleIdsPlugin.js +2 -1
  140. package/lib/ids/IdHelpers.js +15 -14
  141. package/lib/ids/SyncModuleIdsPlugin.js +9 -5
  142. package/lib/index.js +5 -5
  143. package/lib/javascript/BasicEvaluatedExpression.js +6 -6
  144. package/lib/javascript/JavascriptGenerator.js +11 -1
  145. package/lib/javascript/JavascriptModulesPlugin.js +51 -31
  146. package/lib/javascript/JavascriptParser.js +272 -188
  147. package/lib/javascript/JavascriptParserHelpers.js +10 -9
  148. package/lib/javascript/StartupHelpers.js +4 -1
  149. package/lib/json/JsonData.js +4 -4
  150. package/lib/json/JsonGenerator.js +54 -22
  151. package/lib/json/JsonModulesPlugin.js +16 -2
  152. package/lib/json/JsonParser.js +8 -4
  153. package/lib/library/AbstractLibraryPlugin.js +7 -3
  154. package/lib/library/AssignLibraryPlugin.js +29 -1
  155. package/lib/library/EnableLibraryPlugin.js +7 -10
  156. package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
  157. package/lib/library/ModuleLibraryPlugin.js +121 -15
  158. package/lib/logging/Logger.js +2 -2
  159. package/lib/logging/createConsoleLogger.js +4 -4
  160. package/lib/node/NodeEnvironmentPlugin.js +6 -2
  161. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -2
  162. package/lib/node/ReadFileCompileWasmPlugin.js +1 -2
  163. package/lib/node/nodeConsole.js +3 -1
  164. package/lib/optimize/AggressiveSplittingPlugin.js +1 -1
  165. package/lib/optimize/ConcatenatedModule.js +19 -12
  166. package/lib/optimize/InnerGraph.js +3 -2
  167. package/lib/optimize/InnerGraphPlugin.js +13 -7
  168. package/lib/optimize/LimitChunkCountPlugin.js +20 -0
  169. package/lib/optimize/ModuleConcatenationPlugin.js +10 -7
  170. package/lib/optimize/RealContentHashPlugin.js +8 -4
  171. package/lib/optimize/SideEffectsFlagPlugin.js +4 -2
  172. package/lib/optimize/SplitChunksPlugin.js +87 -65
  173. package/lib/rules/BasicEffectRulePlugin.js +9 -1
  174. package/lib/rules/BasicMatcherRulePlugin.js +15 -4
  175. package/lib/rules/ObjectMatcherRulePlugin.js +12 -3
  176. package/lib/rules/RuleSetCompiler.js +25 -14
  177. package/lib/rules/UseEffectRulePlugin.js +47 -17
  178. package/lib/runtime/GetChunkFilenameRuntimeModule.js +6 -6
  179. package/lib/schemes/HttpUriPlugin.js +38 -17
  180. package/lib/serialization/BinaryMiddleware.js +52 -19
  181. package/lib/serialization/FileMiddleware.js +78 -48
  182. package/lib/serialization/ObjectMiddleware.js +78 -29
  183. package/lib/serialization/PlainObjectSerializer.js +1 -1
  184. package/lib/serialization/Serializer.js +15 -10
  185. package/lib/serialization/SerializerMiddleware.js +80 -41
  186. package/lib/serialization/SingleItemMiddleware.js +10 -7
  187. package/lib/serialization/types.js +1 -1
  188. package/lib/sharing/ConsumeSharedModule.js +4 -2
  189. package/lib/sharing/ProvideSharedModule.js +4 -2
  190. package/lib/sharing/ProvideSharedModuleFactory.js +5 -3
  191. package/lib/sharing/utils.js +2 -2
  192. package/lib/stats/DefaultStatsFactoryPlugin.js +80 -78
  193. package/lib/stats/DefaultStatsPresetPlugin.js +43 -23
  194. package/lib/stats/DefaultStatsPrinterPlugin.js +85 -43
  195. package/lib/stats/StatsFactory.js +11 -11
  196. package/lib/stats/StatsPrinter.js +7 -7
  197. package/lib/util/ArrayHelpers.js +2 -4
  198. package/lib/util/ArrayQueue.js +1 -1
  199. package/lib/util/AsyncQueue.js +4 -4
  200. package/lib/util/IterableHelpers.js +1 -1
  201. package/lib/util/LazyBucketSortedSet.js +41 -23
  202. package/lib/util/LazySet.js +3 -2
  203. package/lib/util/MapHelpers.js +1 -1
  204. package/lib/util/ParallelismFactorCalculator.js +1 -1
  205. package/lib/util/Semaphore.js +3 -3
  206. package/lib/util/SetHelpers.js +1 -1
  207. package/lib/util/SortableSet.js +9 -7
  208. package/lib/util/TupleQueue.js +9 -8
  209. package/lib/util/TupleSet.js +2 -2
  210. package/lib/util/WeakTupleMap.js +12 -11
  211. package/lib/util/binarySearchBounds.js +2 -1
  212. package/lib/util/cleverMerge.js +84 -54
  213. package/lib/util/comparators.js +22 -21
  214. package/lib/util/compileBooleanMatcher.js +3 -3
  215. package/lib/util/concatenate.js +6 -4
  216. package/lib/util/create-schema-validation.js +4 -4
  217. package/lib/util/createHash.js +2 -2
  218. package/lib/util/deprecation.js +35 -33
  219. package/lib/util/deterministicGrouping.js +6 -6
  220. package/lib/util/findGraphRoots.js +1 -1
  221. package/lib/util/fs.js +39 -39
  222. package/lib/util/hash/wasm-hash.js +2 -2
  223. package/lib/util/identifier.js +15 -18
  224. package/lib/util/makeSerializable.js +1 -1
  225. package/lib/util/memoize.js +4 -1
  226. package/lib/util/objectToMap.js +3 -2
  227. package/lib/util/processAsyncTree.js +2 -2
  228. package/lib/util/propertyName.js +0 -1
  229. package/lib/util/registerExternalSerializer.js +15 -18
  230. package/lib/util/removeBOM.js +25 -0
  231. package/lib/util/runtime.js +34 -27
  232. package/lib/util/serialization.js +5 -16
  233. package/lib/util/smartGrouping.js +3 -3
  234. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
  235. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +11 -0
  236. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +10 -0
  237. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -0
  238. package/lib/wasm-sync/WebAssemblyGenerator.js +28 -12
  239. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +10 -0
  240. package/lib/wasm-sync/WebAssemblyParser.js +9 -4
  241. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -0
  242. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +30 -25
  243. package/package.json +19 -17
  244. package/schemas/WebpackOptions.check.js +1 -1
  245. package/schemas/WebpackOptions.json +48 -13
  246. package/schemas/plugins/JsonModulesPluginGenerator.check.d.ts +7 -0
  247. package/schemas/plugins/JsonModulesPluginGenerator.check.js +6 -0
  248. package/schemas/plugins/JsonModulesPluginGenerator.json +11 -0
  249. package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
  250. package/types.d.ts +918 -615
  251. package/lib/library/ModernModuleLibraryPlugin.js +0 -144
@@ -7,7 +7,7 @@
7
7
 
8
8
  const util = require("util");
9
9
 
10
- /** @type {Map<string, Function>} */
10
+ /** @type {Map<string, () => void>} */
11
11
  const deprecationCache = new Map();
12
12
 
13
13
  /**
@@ -23,7 +23,7 @@ const deprecationCache = new Map();
23
23
  /**
24
24
  * @param {string} message deprecation message
25
25
  * @param {string} code deprecation code
26
- * @returns {Function} function to trigger deprecation
26
+ * @returns {() => void} function to trigger deprecation
27
27
  */
28
28
  const createDeprecation = (message, code) => {
29
29
  const cached = deprecationCache.get(message);
@@ -37,6 +37,9 @@ const createDeprecation = (message, code) => {
37
37
  return fn;
38
38
  };
39
39
 
40
+ /** @typedef {"concat" | "entry" | "filter" | "find" | "findIndex" | "includes" | "indexOf" | "join" | "lastIndexOf" | "map" | "reduce" | "reduceRight" | "slice" | "some"} COPY_METHODS_NAMES */
41
+
42
+ /** @type {COPY_METHODS_NAMES[]} */
40
43
  const COPY_METHODS = [
41
44
  "concat",
42
45
  "entry",
@@ -54,6 +57,9 @@ const COPY_METHODS = [
54
57
  "some"
55
58
  ];
56
59
 
60
+ /** @typedef {"copyWithin" | "entries" | "fill" | "keys" | "pop" | "reverse" | "shift" | "splice" | "sort" | "unshift"} DISABLED_METHODS_NAMES */
61
+
62
+ /** @type {DISABLED_METHODS_NAMES[]} */
57
63
  const DISABLED_METHODS = [
58
64
  "copyWithin",
59
65
  "entries",
@@ -68,7 +74,13 @@ const DISABLED_METHODS = [
68
74
  ];
69
75
 
70
76
  /**
71
- * @param {any} set new set
77
+ * @template T
78
+ * @typedef {Set<T> & {[Symbol.isConcatSpreadable]?: boolean} & { push?: (...items: T[]) => void } & { [P in DISABLED_METHODS_NAMES]?: () => void } & { [P in COPY_METHODS_NAMES]?: () => TODO }} SetWithDeprecatedArrayMethods
79
+ */
80
+
81
+ /**
82
+ * @template T
83
+ * @param {SetWithDeprecatedArrayMethods<T>} set new set
72
84
  * @param {string} name property name
73
85
  * @returns {void}
74
86
  */
@@ -81,7 +93,7 @@ module.exports.arrayToSetDeprecation = (set, name) => {
81
93
  );
82
94
  /**
83
95
  * @deprecated
84
- * @this {Set<any>}
96
+ * @this {Set<T>}
85
97
  * @returns {number} count
86
98
  */
87
99
  set[method] = function () {
@@ -108,7 +120,7 @@ module.exports.arrayToSetDeprecation = (set, name) => {
108
120
  );
109
121
  /**
110
122
  * @deprecated
111
- * @this {Set<any>}
123
+ * @this {Set<T>}
112
124
  * @returns {number} count
113
125
  */
114
126
  set.push = function () {
@@ -121,6 +133,7 @@ module.exports.arrayToSetDeprecation = (set, name) => {
121
133
  };
122
134
  for (const method of DISABLED_METHODS) {
123
135
  if (set[method]) continue;
136
+
124
137
  set[method] = () => {
125
138
  throw new Error(
126
139
  `${name} was changed from Array to Set (using Array method '${method}' is not possible)`
@@ -129,12 +142,12 @@ module.exports.arrayToSetDeprecation = (set, name) => {
129
142
  }
130
143
  /**
131
144
  * @param {number} index index
132
- * @returns {any} value
145
+ * @returns {() => T | undefined} value
133
146
  */
134
147
  const createIndexGetter = index => {
135
148
  /**
136
- * @this {Set<any>} a Set
137
- * @returns {any} the value at this location
149
+ * @this {Set<T>} a Set
150
+ * @returns {T | undefined} the value at this location
138
151
  */
139
152
  // eslint-disable-next-line func-style
140
153
  const fn = function () {
@@ -214,67 +227,56 @@ module.exports.createArrayToSetDeprecationSet = name => {
214
227
  * @param {string} name property name
215
228
  * @param {string} code deprecation code
216
229
  * @param {string} note additional note
217
- * @returns {Proxy<T>} frozen object with deprecation when modifying
230
+ * @returns {T} frozen object with deprecation when modifying
218
231
  */
219
232
  module.exports.soonFrozenObjectDeprecation = (obj, name, code, note = "") => {
220
233
  const message = `${name} will be frozen in future, all modifications are deprecated.${
221
234
  note && `\n${note}`
222
235
  }`;
223
- return /** @type {Proxy<T>} */ (
224
- new Proxy(/** @type {object} */ (obj), {
236
+ return /** @type {T} */ (
237
+ new Proxy(obj, {
225
238
  set: util.deprecate(
226
239
  /**
227
- * @param {T} target target
240
+ * @param {object} target target
228
241
  * @param {string | symbol} property property
229
- * @param {any} value value
230
- * @param {any} receiver receiver
242
+ * @param {EXPECTED_ANY} value value
243
+ * @param {EXPECTED_ANY} receiver receiver
231
244
  * @returns {boolean} result
232
245
  */
233
246
  (target, property, value, receiver) =>
234
- Reflect.set(
235
- /** @type {object} */ (target),
236
- property,
237
- value,
238
- receiver
239
- ),
247
+ Reflect.set(target, property, value, receiver),
240
248
  message,
241
249
  code
242
250
  ),
243
251
  defineProperty: util.deprecate(
244
252
  /**
245
- * @param {T} target target
253
+ * @param {object} target target
246
254
  * @param {string | symbol} property property
247
255
  * @param {PropertyDescriptor} descriptor descriptor
248
256
  * @returns {boolean} result
249
257
  */
250
258
  (target, property, descriptor) =>
251
- Reflect.defineProperty(
252
- /** @type {object} */ (target),
253
- property,
254
- descriptor
255
- ),
259
+ Reflect.defineProperty(target, property, descriptor),
256
260
  message,
257
261
  code
258
262
  ),
259
263
  deleteProperty: util.deprecate(
260
264
  /**
261
- * @param {T} target target
265
+ * @param {object} target target
262
266
  * @param {string | symbol} property property
263
267
  * @returns {boolean} result
264
268
  */
265
- (target, property) =>
266
- Reflect.deleteProperty(/** @type {object} */ (target), property),
269
+ (target, property) => Reflect.deleteProperty(target, property),
267
270
  message,
268
271
  code
269
272
  ),
270
273
  setPrototypeOf: util.deprecate(
271
274
  /**
272
- * @param {T} target target
273
- * @param {object | null} proto proto
275
+ * @param {object} target target
276
+ * @param {EXPECTED_OBJECT | null} proto proto
274
277
  * @returns {boolean} result
275
278
  */
276
- (target, proto) =>
277
- Reflect.setPrototypeOf(/** @type {object} */ (target), proto),
279
+ (target, proto) => Reflect.setPrototypeOf(target, proto),
278
280
  message,
279
281
  code
280
282
  )
@@ -152,15 +152,15 @@ const getTooSmallTypes = (size, minSize) => {
152
152
  };
153
153
 
154
154
  /**
155
- * @template T
156
- * @param {TODO} size size
155
+ * @template {object} T
156
+ * @param {T} size size
157
157
  * @param {Set<string>} types types
158
158
  * @returns {number} number of matching size types
159
159
  */
160
160
  const getNumberOfMatchingSizeTypes = (size, types) => {
161
161
  let i = 0;
162
162
  for (const key of Object.keys(size)) {
163
- if (size[key] !== 0 && types.has(key)) i++;
163
+ if (size[/** @type {keyof T} */ (key)] !== 0 && types.has(key)) i++;
164
164
  }
165
165
  return i;
166
166
  };
@@ -212,7 +212,7 @@ class Group {
212
212
  }
213
213
 
214
214
  /**
215
- * @param {function(Node<T>): boolean} filter filter function
215
+ * @param {(node: Node<T>) => boolean} filter filter function
216
216
  * @returns {Node<T>[] | undefined} removed nodes
217
217
  */
218
218
  popNodes(filter) {
@@ -277,8 +277,8 @@ const getSimilarities = nodes => {
277
277
  * @property {Record<string, number>} maxSize maximum size of a group
278
278
  * @property {Record<string, number>} minSize minimum size of a group (preferred over maximum size)
279
279
  * @property {Iterable<T>} items a list of items
280
- * @property {function(T): Record<string, number>} getSize function to get size of an item
281
- * @property {function(T): string} getKey function to get the key of an item
280
+ * @property {(item: T) => Record<string, number>} getSize function to get size of an item
281
+ * @property {(item: T) => string} getKey function to get the key of an item
282
282
  */
283
283
 
284
284
  /**
@@ -49,7 +49,7 @@ class Cycle {
49
49
  /**
50
50
  * @template T
51
51
  * @param {Iterable<T>} items list of items
52
- * @param {function(T): Iterable<T>} getDependencies function to get dependencies of an item (items that are not in list are ignored)
52
+ * @param {(item: T) => Iterable<T>} getDependencies function to get dependencies of an item (items that are not in list are ignored)
53
53
  * @returns {Iterable<T>} graph roots of the items
54
54
  */
55
55
  module.exports = (items, getDependencies) => {
package/lib/util/fs.js CHANGED
@@ -63,22 +63,22 @@ const path = require("path");
63
63
 
64
64
  /** @typedef {string | number | boolean | null} JsonPrimitive */
65
65
  /** @typedef {JsonValue[]} JsonArray */
66
- /** @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue */
67
66
  /** @typedef {{[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined}} JsonObject */
67
+ /** @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue */
68
68
 
69
- /** @typedef {function(NodeJS.ErrnoException | null): void} NoParamCallback */
70
- /** @typedef {function(NodeJS.ErrnoException | null, string=): void} StringCallback */
71
- /** @typedef {function(NodeJS.ErrnoException | null, Buffer=): void} BufferCallback */
72
- /** @typedef {function(NodeJS.ErrnoException | null, (string | Buffer)=): void} StringOrBufferCallback */
73
- /** @typedef {function(NodeJS.ErrnoException | null, (string[])=): void} ReaddirStringCallback */
74
- /** @typedef {function(NodeJS.ErrnoException | null, (Buffer[])=): void} ReaddirBufferCallback */
75
- /** @typedef {function(NodeJS.ErrnoException | null, (string[] | Buffer[])=): void} ReaddirStringOrBufferCallback */
76
- /** @typedef {function(NodeJS.ErrnoException | null, (Dirent[])=): void} ReaddirDirentCallback */
77
- /** @typedef {function(NodeJS.ErrnoException | null, IStats=): void} StatsCallback */
78
- /** @typedef {function(NodeJS.ErrnoException | null, IBigIntStats=): void} BigIntStatsCallback */
79
- /** @typedef {function(NodeJS.ErrnoException | null, (IStats | IBigIntStats)=): void} StatsOrBigIntStatsCallback */
80
- /** @typedef {function(NodeJS.ErrnoException | null, number=): void} NumberCallback */
81
- /** @typedef {function(NodeJS.ErrnoException | Error | null, JsonObject=): void} ReadJsonCallback */
69
+ /** @typedef {(err: NodeJS.ErrnoException | null) => void} NoParamCallback */
70
+ /** @typedef {(err: NodeJS.ErrnoException | null, result?: string) => void} StringCallback */
71
+ /** @typedef {(err: NodeJS.ErrnoException | null, result?: Buffer) => void} BufferCallback */
72
+ /** @typedef {(err: NodeJS.ErrnoException | null, result?: string | Buffer) => void} StringOrBufferCallback */
73
+ /** @typedef {(err: NodeJS.ErrnoException | null, result?: string[]) => void} ReaddirStringCallback */
74
+ /** @typedef {(err: NodeJS.ErrnoException | null, result?: Buffer[]) => void} ReaddirBufferCallback */
75
+ /** @typedef {(err: NodeJS.ErrnoException | null, result?: string[] | Buffer[]) => void} ReaddirStringOrBufferCallback */
76
+ /** @typedef {(err: NodeJS.ErrnoException | null, result?: Dirent[]) => void} ReaddirDirentCallback */
77
+ /** @typedef {(err: NodeJS.ErrnoException | null, result?: IStats) => void} StatsCallback */
78
+ /** @typedef {(err: NodeJS.ErrnoException | null, result?: IBigIntStats) => void} BigIntStatsCallback */
79
+ /** @typedef {(err: NodeJS.ErrnoException | null, result?: IStats | IBigIntStats) => void} StatsOrBigIntStatsCallback */
80
+ /** @typedef {(err: NodeJS.ErrnoException | null, result?: number) => void} NumberCallback */
81
+ /** @typedef {(err: NodeJS.ErrnoException | Error | null, result?: JsonObject) => void} ReadJsonCallback */
82
82
 
83
83
  /** @typedef {Map<string, FileSystemInfoEntry | "ignore">} TimeInfoEntries */
84
84
 
@@ -96,13 +96,13 @@ const path = require("path");
96
96
  // TODO webpack 6 deprecate missing getInfo
97
97
  /**
98
98
  * @typedef {object} Watcher
99
- * @property {function(): void} close closes the watcher and all underlying file watchers
100
- * @property {function(): void} pause closes the watcher, but keeps underlying file watchers alive until the next watch call
101
- * @property {(function(): Changes | null)=} getAggregatedChanges get current aggregated changes that have not yet send to callback
102
- * @property {(function(): Removals | null)=} getAggregatedRemovals get current aggregated removals that have not yet send to callback
103
- * @property {function(): TimeInfoEntries} getFileTimeInfoEntries get info about files
104
- * @property {function(): TimeInfoEntries} getContextTimeInfoEntries get info about directories
105
- * @property {function(): WatcherInfo=} getInfo get info about timestamps and changes
99
+ * @property {() => void} close closes the watcher and all underlying file watchers
100
+ * @property {() => void} pause closes the watcher, but keeps underlying file watchers alive until the next watch call
101
+ * @property {(() => Changes | null)=} getAggregatedChanges get current aggregated changes that have not yet send to callback
102
+ * @property {(() => Removals | null)=} getAggregatedRemovals get current aggregated removals that have not yet send to callback
103
+ * @property {() => TimeInfoEntries} getFileTimeInfoEntries get info about files
104
+ * @property {() => TimeInfoEntries} getContextTimeInfoEntries get info about directories
105
+ * @property {() => WatcherInfo=} getInfo get info about timestamps and changes
106
106
  */
107
107
 
108
108
  /**
@@ -112,8 +112,8 @@ const path = require("path");
112
112
  * @param {Iterable<string>} missing watched existence entries
113
113
  * @param {number} startTime timestamp of start time
114
114
  * @param {WatchOptions} options options object
115
- * @param {function(Error | null, TimeInfoEntries=, TimeInfoEntries=, Changes=, Removals=): void} callback aggregated callback
116
- * @param {function(string, number): void} callbackUndelayed callback when the first change was detected
115
+ * @param {(err: Error | null, timeInfoEntries1?: TimeInfoEntries, timeInfoEntries2?: TimeInfoEntries, changes?: Changes, removals?: Removals) => void} callback aggregated callback
116
+ * @param {(value: string, num: number) => void} callbackUndelayed callback when the first change was detected
117
117
  * @returns {Watcher} a watcher
118
118
  */
119
119
 
@@ -264,15 +264,15 @@ const path = require("path");
264
264
  */
265
265
 
266
266
  /**
267
- * @typedef {function(PathOrFileDescriptor, ReadJsonCallback): void} ReadJson
267
+ * @typedef {(pathOrFileDescriptor: PathOrFileDescriptor, callback: ReadJsonCallback) => void} ReadJson
268
268
  */
269
269
 
270
270
  /**
271
- * @typedef {function(PathOrFileDescriptor): JsonObject} ReadJsonSync
271
+ * @typedef {(pathOrFileDescriptor: PathOrFileDescriptor) => JsonObject} ReadJsonSync
272
272
  */
273
273
 
274
274
  /**
275
- * @typedef {function((string | string[] | Set<string>)=): void} Purge
275
+ * @typedef {(value?: string | string[] | Set<string>) => void} Purge
276
276
  */
277
277
 
278
278
  /**
@@ -292,9 +292,9 @@ const path = require("path");
292
292
  * @property {ReadJson=} readJson
293
293
  * @property {ReadJsonSync=} readJsonSync
294
294
  * @property {Purge=} purge
295
- * @property {(function(string, string): string)=} join
296
- * @property {(function(string, string): string)=} relative
297
- * @property {(function(string): string)=} dirname
295
+ * @property {((path1: string, path2: string) => string)=} join
296
+ * @property {((from: string, to: string) => string)=} relative
297
+ * @property {((dirname: string) => string)=} dirname
298
298
  */
299
299
 
300
300
  /**
@@ -337,7 +337,7 @@ const path = require("path");
337
337
  */
338
338
 
339
339
  /**
340
- * @typedef {function(PathLike, NoParamCallback): void} Unlink
340
+ * @typedef {(pathLike: PathLike, callback: NoParamCallback) => void} Unlink
341
341
  */
342
342
 
343
343
  /**
@@ -350,9 +350,9 @@ const path = require("path");
350
350
  * @property {Stat} stat
351
351
  * @property {LStat=} lstat
352
352
  * @property {ReadFile} readFile
353
- * @property {(function(string, string): string)=} join
354
- * @property {(function(string, string): string)=} relative
355
- * @property {(function(string): string)=} dirname
353
+ * @property {((path1: string, path2: string) => string)=} join
354
+ * @property {((from: string, to: string) => string)=} relative
355
+ * @property {((dirname: string) => string)=} dirname
356
356
  */
357
357
 
358
358
  /**
@@ -395,7 +395,7 @@ const path = require("path");
395
395
  */
396
396
 
397
397
  /**
398
- * @typedef {function(PathLike, (BufferEncoding | WriteStreamOptions)=): NodeJS.WritableStream} CreateWriteStream
398
+ * @typedef {(pathLike: PathLike, result?: BufferEncoding | WriteStreamOptions) => NodeJS.WritableStream} CreateWriteStream
399
399
  */
400
400
 
401
401
  /**
@@ -431,7 +431,7 @@ const path = require("path");
431
431
  */
432
432
 
433
433
  /**
434
- * @template {NodeJS.ArrayBufferView} [TBuffer=Buffer]
434
+ * @template {NodeJS.ArrayBufferView} [TBuffer=NodeJS.ArrayBufferView]
435
435
  * @typedef {{
436
436
  * (fd: number, buffer: TBuffer, offset: number, length: number, position: ReadPosition | null, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void): void;
437
437
  * (fd: number, options: ReadAsyncOptions<TBuffer>, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void): void;
@@ -439,9 +439,9 @@ const path = require("path");
439
439
  * }} Read
440
440
  */
441
441
 
442
- /** @typedef {function(number, NoParamCallback): void} Close */
442
+ /** @typedef {(df: number, callback: NoParamCallback) => void} Close */
443
443
 
444
- /** @typedef {function(PathLike, PathLike, NoParamCallback): void} Rename */
444
+ /** @typedef {(a: PathLike, b: PathLike, callback: NoParamCallback) => void} Rename */
445
445
 
446
446
  /**
447
447
  * @typedef {object} IntermediateFileSystemExtras
@@ -517,7 +517,7 @@ module.exports.dirname = dirname;
517
517
  /**
518
518
  * @param {OutputFileSystem} fs a file system
519
519
  * @param {string} p an absolute path
520
- * @param {function(Error=): void} callback callback function for the error
520
+ * @param {(err?: Error) => void} callback callback function for the error
521
521
  * @returns {void}
522
522
  */
523
523
  const mkdirp = (fs, p, callback) => {
@@ -613,7 +613,7 @@ module.exports.readJson = readJson;
613
613
  /**
614
614
  * @param {InputFileSystem} fs a file system
615
615
  * @param {string} p an absolute path
616
- * @param {function(NodeJS.ErrnoException | Error | null, (IStats | string)=): void} callback callback
616
+ * @param {(err: NodeJS.ErrnoException | Error | null, stats?: IStats | string) => void} callback callback
617
617
  * @returns {void}
618
618
  */
619
619
  const lstatReadlinkAbsolute = (fs, p, callback) => {
@@ -19,7 +19,7 @@ class WasmHash {
19
19
  * @param {number} digestSize size of digest returned by wasm
20
20
  */
21
21
  constructor(instance, instancesPool, chunkSize, digestSize) {
22
- const exports = /** @type {any} */ (instance.exports);
22
+ const exports = /** @type {EXPECTED_ANY} */ (instance.exports);
23
23
  exports.init();
24
24
  this.exports = exports;
25
25
  this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
@@ -149,7 +149,7 @@ class WasmHash {
149
149
  }
150
150
 
151
151
  /**
152
- * @param {TODO} wasmModule wasm module
152
+ * @param {WebAssembly.Module} wasmModule wasm module
153
153
  * @param {WasmHash[]} instancesPool pool of instances
154
154
  * @param {number} chunkSize size of data chunks passed to wasm
155
155
  * @param {number} digestSize size of digest returned by wasm
@@ -10,11 +10,6 @@ const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/;
10
10
  const SEGMENTS_SPLIT_REGEXP = /([|!])/;
11
11
  const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
12
12
 
13
- /**
14
- * @typedef {object} MakeRelativePathsCache
15
- * @property {Map<string, Map<string, string>>=} relativePaths
16
- */
17
-
18
13
  /**
19
14
  * @param {string} relativePath relative path
20
15
  * @returns {string} request
@@ -85,24 +80,26 @@ const requestToAbsolute = (context, relativePath) => {
85
80
  return relativePath;
86
81
  };
87
82
 
83
+ /** @typedef {EXPECTED_OBJECT} AssociatedObjectForCache */
84
+
88
85
  /**
89
86
  * @template T
90
- * @typedef {function(string, object=): T} MakeCacheableResult
87
+ * @typedef {(value: string, cache?: AssociatedObjectForCache) => T} MakeCacheableResult
91
88
  */
92
89
 
93
90
  /**
94
91
  * @template T
95
- * @typedef {function(string): T} BindCacheResultFn
92
+ * @typedef {(value: string) => T} BindCacheResultFn
96
93
  */
97
94
 
98
95
  /**
99
96
  * @template T
100
- * @typedef {function(object): BindCacheResultFn<T>} BindCache
97
+ * @typedef {(cache: AssociatedObjectForCache) => BindCacheResultFn<T>} BindCache
101
98
  */
102
99
 
103
100
  /**
104
101
  * @template T
105
- * @param {(function(string): T)} realFn real function
102
+ * @param {((value: string) => T)} realFn real function
106
103
  * @returns {MakeCacheableResult<T> & { bindCache: BindCache<T> }} cacheable function
107
104
  */
108
105
  const makeCacheable = realFn => {
@@ -110,11 +107,11 @@ const makeCacheable = realFn => {
110
107
  * @template T
111
108
  * @typedef {Map<string, T>} CacheItem
112
109
  */
113
- /** @type {WeakMap<object, CacheItem<T>>} */
110
+ /** @type {WeakMap<AssociatedObjectForCache, CacheItem<T>>} */
114
111
  const cache = new WeakMap();
115
112
 
116
113
  /**
117
- * @param {object} associatedObjectForCache an object to which the cache will be attached
114
+ * @param {AssociatedObjectForCache} associatedObjectForCache an object to which the cache will be attached
118
115
  * @returns {CacheItem<T>} cache item
119
116
  */
120
117
  const getCache = associatedObjectForCache => {
@@ -156,18 +153,18 @@ const makeCacheable = realFn => {
156
153
  return fn;
157
154
  };
158
155
 
159
- /** @typedef {function(string, string, object=): string} MakeCacheableWithContextResult */
160
- /** @typedef {function(string, string): string} BindCacheForContextResultFn */
161
- /** @typedef {function(string): string} BindContextCacheForContextResultFn */
162
- /** @typedef {function(object=): BindCacheForContextResultFn} BindCacheForContext */
163
- /** @typedef {function(string, object=): BindContextCacheForContextResultFn} BindContextCacheForContext */
156
+ /** @typedef {(context: string, value: string, associatedObjectForCache?: AssociatedObjectForCache) => string} MakeCacheableWithContextResult */
157
+ /** @typedef {(context: string, value: string) => string} BindCacheForContextResultFn */
158
+ /** @typedef {(value: string) => string} BindContextCacheForContextResultFn */
159
+ /** @typedef {(associatedObjectForCache?: AssociatedObjectForCache) => BindCacheForContextResultFn} BindCacheForContext */
160
+ /** @typedef {(value: string, associatedObjectForCache?: AssociatedObjectForCache) => BindContextCacheForContextResultFn} BindContextCacheForContext */
164
161
 
165
162
  /**
166
- * @param {function(string, string): string} fn function
163
+ * @param {(context: string, identifier: string) => string} fn function
167
164
  * @returns {MakeCacheableWithContextResult & { bindCache: BindCacheForContext, bindContextCache: BindContextCacheForContext }} cacheable function with context
168
165
  */
169
166
  const makeCacheableWithContext = fn => {
170
- /** @type {WeakMap<object, Map<string, Map<string, string>>>} */
167
+ /** @type {WeakMap<AssociatedObjectForCache, Map<string, Map<string, string>>>} */
171
168
  const cache = new WeakMap();
172
169
 
173
170
  /** @type {MakeCacheableWithContextResult & { bindCache: BindCacheForContext, bindContextCache: BindContextCacheForContext }} */
@@ -13,7 +13,7 @@ const { register } = require("./serialization");
13
13
  /** @typedef {{ serialize: (context: ObjectSerializerContext) => void, deserialize: (context: ObjectDeserializerContext) => void }} SerializableClass */
14
14
  /**
15
15
  * @template {SerializableClass} T
16
- * @typedef {(new (...params: any[]) => T) & { deserialize?: (context: ObjectDeserializerContext) => T }} SerializableClassConstructor
16
+ * @typedef {(new (...params: EXPECTED_ANY[]) => T) & { deserialize?: (context: ObjectDeserializerContext) => T }} SerializableClassConstructor
17
17
  */
18
18
 
19
19
  /**
@@ -4,7 +4,10 @@
4
4
 
5
5
  "use strict";
6
6
 
7
- /** @template T @typedef {function(): T} FunctionReturning */
7
+ /**
8
+ * @template T
9
+ * @typedef {() => T} FunctionReturning
10
+ */
8
11
 
9
12
  /**
10
13
  * @template T
@@ -6,8 +6,9 @@
6
6
 
7
7
  /**
8
8
  * Convert an object into an ES6 map
9
- * @param {object} obj any object type that works with Object.entries()
10
- * @returns {Map<string, any>} an ES6 Map of KV pairs
9
+ * @template {object} T
10
+ * @param {T} obj any object type that works with Object.entries()
11
+ * @returns {Map<string, T[keyof T]>} an ES6 Map of KV pairs
11
12
  */
12
13
  module.exports = function objectToMap(obj) {
13
14
  return new Map(Object.entries(obj));
@@ -10,8 +10,8 @@
10
10
  * @template {Error} E
11
11
  * @param {Iterable<T>} items initial items
12
12
  * @param {number} concurrency number of items running in parallel
13
- * @param {function(T, function(T): void, function(E=): void): void} processor worker which pushes more items
14
- * @param {function(E=): void} callback all items processed
13
+ * @param {(item: T, push: (item: T) => void, callback: (err?: E) => void) => void} processor worker which pushes more items
14
+ * @param {(err?: E) => void} callback all items processed
15
15
  * @returns {void}
16
16
  */
17
17
  const processAsyncTree = (items, concurrency, processor, callback) => {
@@ -50,7 +50,6 @@ const RESERVED_IDENTIFIER = new Set([
50
50
  "public",
51
51
  "static",
52
52
  "yield",
53
- "yield",
54
53
  // module code
55
54
  "await",
56
55
  // skip future reserved keywords defined under ES1 till ES3