webpack 5.104.1 → 5.105.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/bin/webpack.js +6 -3
  2. package/lib/APIPlugin.js +85 -15
  3. package/lib/AbstractMethodError.js +1 -0
  4. package/lib/AsyncDependenciesBlock.js +13 -1
  5. package/lib/AsyncDependencyToInitialChunkError.js +1 -0
  6. package/lib/AutomaticPrefetchPlugin.js +1 -1
  7. package/lib/BannerPlugin.js +2 -0
  8. package/lib/CacheFacade.js +2 -2
  9. package/lib/CaseSensitiveModulesWarning.js +1 -0
  10. package/lib/Chunk.js +8 -4
  11. package/lib/ChunkGraph.js +30 -9
  12. package/lib/ChunkGroup.js +6 -3
  13. package/lib/ChunkRenderError.js +2 -0
  14. package/lib/CleanPlugin.js +4 -1
  15. package/lib/CodeGenerationError.js +7 -1
  16. package/lib/CodeGenerationResults.js +10 -3
  17. package/lib/CommentCompilationWarning.js +2 -1
  18. package/lib/Compilation.js +280 -236
  19. package/lib/Compiler.js +3 -2
  20. package/lib/ConcatenationScope.js +2 -1
  21. package/lib/ConcurrentCompilationError.js +3 -3
  22. package/lib/ContextModule.js +248 -111
  23. package/lib/ContextModuleFactory.js +14 -2
  24. package/lib/DefinePlugin.js +3 -1
  25. package/lib/DelegatedModule.js +6 -0
  26. package/lib/DelegatedModuleFactoryPlugin.js +2 -0
  27. package/lib/Dependency.js +6 -1
  28. package/lib/DependencyTemplates.js +3 -2
  29. package/lib/DllModule.js +2 -0
  30. package/lib/DllReferencePlugin.js +1 -0
  31. package/lib/DotenvPlugin.js +11 -5
  32. package/lib/DynamicEntryPlugin.js +1 -0
  33. package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
  34. package/lib/EvalSourceMapDevToolPlugin.js +17 -13
  35. package/lib/ExportsInfo.js +8 -4
  36. package/lib/ExternalModule.js +16 -0
  37. package/lib/FalseIIFEUmdWarning.js +1 -0
  38. package/lib/FileSystemInfo.js +49 -25
  39. package/lib/FlagDependencyExportsPlugin.js +8 -1
  40. package/lib/FlagDependencyUsagePlugin.js +9 -7
  41. package/lib/HarmonyLinkingError.js +1 -0
  42. package/lib/HookWebpackError.js +2 -0
  43. package/lib/HotModuleReplacementPlugin.js +16 -2
  44. package/lib/InitFragment.js +1 -0
  45. package/lib/InvalidDependenciesModuleWarning.js +1 -0
  46. package/lib/LibManifestPlugin.js +1 -0
  47. package/lib/ManifestPlugin.js +4 -1
  48. package/lib/Module.js +7 -4
  49. package/lib/ModuleBuildError.js +3 -1
  50. package/lib/ModuleDependencyError.js +1 -0
  51. package/lib/ModuleDependencyWarning.js +1 -0
  52. package/lib/ModuleError.js +2 -1
  53. package/lib/ModuleFilenameHelpers.js +2 -1
  54. package/lib/ModuleGraph.js +3 -0
  55. package/lib/ModuleGraphConnection.js +10 -1
  56. package/lib/ModuleHashingError.js +2 -0
  57. package/lib/ModuleInfoHeaderPlugin.js +6 -1
  58. package/lib/ModuleNotFoundError.js +1 -0
  59. package/lib/ModuleParseError.js +5 -1
  60. package/lib/ModuleProfile.js +1 -1
  61. package/lib/ModuleRestoreError.js +2 -0
  62. package/lib/ModuleSourceTypeConstants.js +1 -11
  63. package/lib/ModuleStoreError.js +2 -0
  64. package/lib/ModuleWarning.js +3 -1
  65. package/lib/MultiCompiler.js +11 -7
  66. package/lib/MultiWatching.js +2 -2
  67. package/lib/NoModeWarning.js +1 -0
  68. package/lib/NodeStuffInWebError.js +1 -0
  69. package/lib/NormalModule.js +26 -5
  70. package/lib/NormalModuleFactory.js +20 -4
  71. package/lib/OptionsApply.js +3 -1
  72. package/lib/ProgressPlugin.js +4 -0
  73. package/lib/RawModule.js +2 -0
  74. package/lib/RuntimeModule.js +10 -0
  75. package/lib/RuntimePlugin.js +7 -9
  76. package/lib/RuntimeTemplate.js +14 -7
  77. package/lib/SourceMapDevToolPlugin.js +30 -23
  78. package/lib/Template.js +10 -5
  79. package/lib/TemplatedPathPlugin.js +4 -2
  80. package/lib/UnhandledSchemeError.js +1 -0
  81. package/lib/UnsupportedFeatureWarning.js +1 -0
  82. package/lib/WarnDeprecatedOptionPlugin.js +1 -0
  83. package/lib/WatchIgnorePlugin.js +1 -1
  84. package/lib/Watching.js +5 -0
  85. package/lib/WebpackError.js +4 -0
  86. package/lib/WebpackOptionsApply.js +60 -40
  87. package/lib/asset/AssetBytesGenerator.js +1 -0
  88. package/lib/asset/AssetGenerator.js +9 -3
  89. package/lib/asset/AssetModulesPlugin.js +33 -2
  90. package/lib/asset/AssetSourceGenerator.js +1 -0
  91. package/lib/asset/RawDataUrlModule.js +4 -0
  92. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
  93. package/lib/buildChunkGraph.js +31 -2
  94. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  95. package/lib/cache/PackFileCacheStrategy.js +41 -8
  96. package/lib/cache/getLazyHashedEtag.js +13 -4
  97. package/lib/cache/mergeEtags.js +3 -1
  98. package/lib/cli.js +3 -1
  99. package/lib/config/defaults.js +65 -44
  100. package/lib/config/normalization.js +96 -0
  101. package/lib/container/ContainerEntryModule.js +4 -0
  102. package/lib/container/FallbackModule.js +2 -0
  103. package/lib/container/HoistContainerReferencesPlugin.js +6 -0
  104. package/lib/container/RemoteModule.js +19 -0
  105. package/lib/css/CssGenerator.js +31 -4
  106. package/lib/css/CssModulesPlugin.js +26 -30
  107. package/lib/css/CssParser.js +12 -9
  108. package/lib/debug/ProfilingPlugin.js +1 -0
  109. package/lib/dependencies/AMDDefineDependency.js +3 -1
  110. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
  111. package/lib/dependencies/AMDPlugin.js +1 -1
  112. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
  113. package/lib/dependencies/CachedConstDependency.js +1 -0
  114. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
  115. package/lib/dependencies/CommonJsExportRequireDependency.js +1 -0
  116. package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
  117. package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -0
  118. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
  119. package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
  120. package/lib/dependencies/ConstDependency.js +1 -0
  121. package/lib/dependencies/ContextDependencyHelpers.js +11 -4
  122. package/lib/dependencies/ContextElementDependency.js +1 -0
  123. package/lib/dependencies/CriticalDependencyWarning.js +1 -0
  124. package/lib/dependencies/CssIcssExportDependency.js +5 -4
  125. package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
  126. package/lib/dependencies/CssUrlDependency.js +2 -3
  127. package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
  128. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
  129. package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
  130. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +1 -0
  131. package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
  132. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
  133. package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
  134. package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
  135. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +266 -5
  136. package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
  137. package/lib/dependencies/ImportDependency.js +1 -0
  138. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  139. package/lib/dependencies/ImportMetaPlugin.js +53 -11
  140. package/lib/dependencies/ImportParserPlugin.js +7 -12
  141. package/lib/dependencies/LoaderPlugin.js +3 -0
  142. package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
  143. package/lib/dependencies/ModuleDependency.js +1 -0
  144. package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
  145. package/lib/dependencies/ProvidedDependency.js +1 -0
  146. package/lib/dependencies/RequireContextPlugin.js +1 -0
  147. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
  148. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
  149. package/lib/dependencies/WorkerDependency.js +9 -3
  150. package/lib/dependencies/WorkerPlugin.js +1 -0
  151. package/lib/dependencies/getFunctionExpression.js +3 -1
  152. package/lib/errors/BuildCycleError.js +4 -1
  153. package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
  154. package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
  155. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
  156. package/lib/hmr/LazyCompilationPlugin.js +5 -0
  157. package/lib/hmr/lazyCompilationBackend.js +3 -2
  158. package/lib/ids/ChunkModuleIdRangePlugin.js +2 -0
  159. package/lib/ids/IdHelpers.js +10 -8
  160. package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -7
  161. package/lib/ids/SyncModuleIdsPlugin.js +5 -1
  162. package/lib/javascript/BasicEvaluatedExpression.js +1 -0
  163. package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
  164. package/lib/javascript/JavascriptModulesPlugin.js +29 -8
  165. package/lib/javascript/JavascriptParser.js +47 -14
  166. package/lib/json/JsonParser.js +6 -0
  167. package/lib/library/AbstractLibraryPlugin.js +4 -1
  168. package/lib/library/AmdLibraryPlugin.js +2 -1
  169. package/lib/library/AssignLibraryPlugin.js +6 -2
  170. package/lib/library/EnableLibraryPlugin.js +1 -0
  171. package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
  172. package/lib/library/JsonpLibraryPlugin.js +1 -1
  173. package/lib/library/ModuleLibraryPlugin.js +130 -13
  174. package/lib/library/SystemLibraryPlugin.js +4 -1
  175. package/lib/library/UmdLibraryPlugin.js +4 -3
  176. package/lib/logging/createConsoleLogger.js +3 -0
  177. package/lib/logging/truncateArgs.js +1 -1
  178. package/lib/node/CommonJsChunkLoadingPlugin.js +1 -0
  179. package/lib/node/NodeTargetPlugin.js +1 -0
  180. package/lib/node/NodeWatchFileSystem.js +3 -0
  181. package/lib/node/nodeConsole.js +18 -1
  182. package/lib/optimize/AggressiveMergingPlugin.js +2 -1
  183. package/lib/optimize/AggressiveSplittingPlugin.js +10 -6
  184. package/lib/optimize/ConcatenatedModule.js +33 -19
  185. package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
  186. package/lib/optimize/InnerGraph.js +5 -3
  187. package/lib/optimize/InnerGraphPlugin.js +25 -25
  188. package/lib/optimize/MangleExportsPlugin.js +14 -2
  189. package/lib/optimize/MergeDuplicateChunksPlugin.js +3 -0
  190. package/lib/optimize/MinChunkSizePlugin.js +5 -2
  191. package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
  192. package/lib/optimize/RealContentHashPlugin.js +35 -27
  193. package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
  194. package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
  195. package/lib/optimize/SplitChunksPlugin.js +14 -3
  196. package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
  197. package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
  198. package/lib/performance/NoAsyncChunksWarning.js +1 -0
  199. package/lib/rules/BasicEffectRulePlugin.js +2 -0
  200. package/lib/rules/BasicMatcherRulePlugin.js +3 -0
  201. package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
  202. package/lib/rules/RuleSetCompiler.js +2 -0
  203. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
  204. package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
  205. package/lib/runtime/CompatRuntimeModule.js +1 -0
  206. package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
  207. package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -0
  208. package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
  209. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
  210. package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
  211. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +15 -32
  212. package/lib/runtime/PublicPathRuntimeModule.js +1 -0
  213. package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
  214. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
  215. package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
  216. package/lib/schemes/HttpUriPlugin.js +27 -7
  217. package/lib/schemes/VirtualUrlPlugin.js +7 -2
  218. package/lib/serialization/BinaryMiddleware.js +4 -0
  219. package/lib/serialization/FileMiddleware.js +9 -4
  220. package/lib/serialization/ObjectMiddleware.js +34 -11
  221. package/lib/serialization/PlainObjectSerializer.js +2 -0
  222. package/lib/sharing/ConsumeSharedModule.js +60 -0
  223. package/lib/sharing/ConsumeSharedPlugin.js +5 -4
  224. package/lib/sharing/ProvideSharedModule.js +4 -0
  225. package/lib/sharing/ProvideSharedPlugin.js +24 -25
  226. package/lib/sharing/resolveMatchedConfigs.js +2 -2
  227. package/lib/sharing/utils.js +8 -6
  228. package/lib/stats/DefaultStatsFactoryPlugin.js +14 -12
  229. package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
  230. package/lib/stats/StatsFactory.js +2 -2
  231. package/lib/url/URLParserPlugin.js +4 -3
  232. package/lib/util/AppendOnlyStackedSet.js +57 -0
  233. package/lib/util/Hash.js +1 -0
  234. package/lib/util/IterableHelpers.js +1 -0
  235. package/lib/util/LazyBucketSortedSet.js +1 -0
  236. package/lib/util/LazySet.js +1 -0
  237. package/lib/util/ParallelismFactorCalculator.js +1 -0
  238. package/lib/util/SortableSet.js +1 -0
  239. package/lib/util/StringXor.js +1 -0
  240. package/lib/util/binarySearchBounds.js +15 -8
  241. package/lib/util/chainedImports.js +1 -1
  242. package/lib/util/cleverMerge.js +6 -1
  243. package/lib/util/comparators.js +21 -1
  244. package/lib/util/compileBooleanMatcher.js +3 -3
  245. package/lib/util/concatenate.js +3 -2
  246. package/lib/util/conventions.js +3 -2
  247. package/lib/util/deterministicGrouping.js +13 -1
  248. package/lib/util/extractSourceMap.js +12 -13
  249. package/lib/util/fs.js +15 -19
  250. package/lib/util/hash/BatchedHash.js +3 -0
  251. package/lib/util/hash/BulkUpdateHash.js +7 -1
  252. package/lib/util/hash/hash-digest.js +1 -0
  253. package/lib/util/hash/wasm-hash.js +16 -1
  254. package/lib/util/identifier.js +7 -2
  255. package/lib/util/magicComment.js +1 -1
  256. package/lib/util/propertyName.js +1 -1
  257. package/lib/util/registerExternalSerializer.js +1 -0
  258. package/lib/util/runtime.js +15 -1
  259. package/lib/util/semver.js +1 -0
  260. package/lib/util/serialization.js +2 -2
  261. package/lib/wasm/EnableWasmLoadingPlugin.js +1 -0
  262. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
  263. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
  264. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
  265. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
  266. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
  267. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
  268. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
  269. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
  270. package/lib/wasm-sync/WebAssemblyParser.js +3 -1
  271. package/lib/web/FetchCompileWasmPlugin.js +1 -0
  272. package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
  273. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
  274. package/lib/webpack.js +13 -3
  275. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  276. package/package.json +20 -28
  277. package/schemas/WebpackOptions.check.js +1 -1
  278. package/schemas/WebpackOptions.json +71 -5
  279. package/types.d.ts +339 -93
@@ -26,6 +26,7 @@ const {
26
26
  /** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */
27
27
  /** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumeSharedPluginOptions} ConsumeSharedPluginOptions */
28
28
  /** @typedef {import("../Compiler")} Compiler */
29
+ /** @typedef {import("../Compilation").FileSystemDependencies} FileSystemDependencies */
29
30
  /** @typedef {import("../ResolverFactory").ResolveOptionsWithDependencyType} ResolveOptionsWithDependencyType */
30
31
  /** @typedef {import("../util/semver").SemVerRange} SemVerRange */
31
32
  /** @typedef {import("./ConsumeSharedModule").ConsumeOptions} ConsumeOptions */
@@ -159,7 +160,7 @@ class ConsumeSharedPlugin {
159
160
  };
160
161
  const directFallback =
161
162
  config.import &&
162
- /^(\.\.?(\/|$)|\/|[A-Za-z]:|\\\\)/.test(config.import);
163
+ /^(?:\.\.?(?:\/|$)|\/|[A-Z]:|\\\\)/i.test(config.import);
163
164
  return Promise.all([
164
165
  new Promise(
165
166
  /**
@@ -170,7 +171,7 @@ class ConsumeSharedPlugin {
170
171
  resolve();
171
172
  return;
172
173
  }
173
- /** @typedef {ResolveContext} */
174
+ /** @type {ResolveContext & { fileDependencies: FileSystemDependencies, contextDependencies: FileSystemDependencies, missingDependencies: FileSystemDependencies }} */
174
175
  const resolveContext = {
175
176
  fileDependencies: new LazySet(),
176
177
  contextDependencies: new LazySet(),
@@ -215,13 +216,13 @@ class ConsumeSharedPlugin {
215
216
  }
216
217
  let packageName = config.packageName;
217
218
  if (packageName === undefined) {
218
- if (/^(\/|[A-Za-z]:|\\\\)/.test(request)) {
219
+ if (/^(?:\/|[A-Z]:|\\\\)/i.test(request)) {
219
220
  // For relative or absolute requests we don't automatically use a packageName.
220
221
  // If wished one can specify one with the packageName option.
221
222
  resolve();
222
223
  return;
223
224
  }
224
- const match = /^((?:@[^\\/]+[\\/])?[^\\/]+)/.exec(request);
225
+ const match = /^(?:@[^\\/]+[\\/])?[^\\/]+/.exec(request);
225
226
  if (!match) {
226
227
  requiredVersionWarning(
227
228
  "Unable to extract the package name from request."
@@ -22,7 +22,9 @@ const ProvideForSharedDependency = require("./ProvideForSharedDependency");
22
22
  /** @typedef {import("../Module").LibIdent} LibIdent */
23
23
  /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
24
24
  /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
25
+ /** @typedef {import("../Module").Sources} Sources */
25
26
  /** @typedef {import("../Module").SourceTypes} SourceTypes */
27
+ /** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
26
28
  /** @typedef {import("../RequestShortener")} RequestShortener */
27
29
  /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
28
30
  /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
@@ -147,7 +149,9 @@ class ProvideSharedModule extends Module {
147
149
  runtimeRequirements
148
150
  })
149
151
  }${this._eager ? ", 1" : ""});`;
152
+ /** @type {Sources} */
150
153
  const sources = new Map();
154
+ /** @type {CodeGenerationResultData} */
151
155
  const data = new Map();
152
156
  data.set("share-init", [
153
157
  {
@@ -45,29 +45,28 @@ class ProvideSharedPlugin {
45
45
  constructor(options) {
46
46
  validate(options);
47
47
 
48
- this._provides = /** @type {[string, ProvideOptions][]} */ (
49
- parseOptions(
50
- options.provides,
51
- (item) => {
52
- if (Array.isArray(item)) {
53
- throw new Error("Unexpected array of provides");
54
- }
55
- /** @type {ProvideOptions} */
56
- const result = {
57
- shareKey: item,
58
- version: undefined,
59
- shareScope: options.shareScope || "default",
60
- eager: false
61
- };
62
- return result;
63
- },
64
- (item) => ({
65
- shareKey: item.shareKey,
66
- version: item.version,
67
- shareScope: item.shareScope || options.shareScope || "default",
68
- eager: Boolean(item.eager)
69
- })
70
- )
48
+ /** @type {[string, ProvideOptions][]} */
49
+ this._provides = parseOptions(
50
+ options.provides,
51
+ (item) => {
52
+ if (Array.isArray(item)) {
53
+ throw new Error("Unexpected array of provides");
54
+ }
55
+ /** @type {ProvideOptions} */
56
+ const result = {
57
+ shareKey: item,
58
+ version: undefined,
59
+ shareScope: options.shareScope || "default",
60
+ eager: false
61
+ };
62
+ return result;
63
+ },
64
+ (item) => ({
65
+ shareKey: /** @type {string} */ (item.shareKey),
66
+ version: item.version,
67
+ shareScope: item.shareScope || options.shareScope || "default",
68
+ eager: Boolean(item.eager)
69
+ })
71
70
  );
72
71
  this._provides.sort(([a], [b]) => {
73
72
  if (a < b) return -1;
@@ -95,13 +94,13 @@ class ProvideSharedPlugin {
95
94
  /** @type {Map<string, ProvideOptions>} */
96
95
  const prefixMatchProvides = new Map();
97
96
  for (const [request, config] of this._provides) {
98
- if (/^(\/|[A-Za-z]:\\|\\\\|\.\.?(\/|$))/.test(request)) {
97
+ if (/^(?:\/|[A-Z]:\\|\\\\|\.\.?(?:\/|$))/i.test(request)) {
99
98
  // relative request
100
99
  resolvedProvideMap.set(request, {
101
100
  config,
102
101
  version: config.version
103
102
  });
104
- } else if (/^(\/|[A-Za-z]:\\|\\\\)/.test(request)) {
103
+ } else if (/^(?:\/|[A-Z]:\\|\\\\)/i.test(request)) {
105
104
  // absolute path
106
105
  resolvedProvideMap.set(request, {
107
106
  config,
@@ -54,7 +54,7 @@ module.exports.resolveMatchedConfigs = (compilation, configs) => {
54
54
  return Promise.all(
55
55
  // eslint-disable-next-line array-callback-return
56
56
  configs.map(([request, config]) => {
57
- if (/^\.\.?(\/|$)/.test(request)) {
57
+ if (/^\.\.?(?:\/|$)/.test(request)) {
58
58
  // relative request
59
59
  return new Promise((resolve) => {
60
60
  resolver.resolve(
@@ -77,7 +77,7 @@ module.exports.resolveMatchedConfigs = (compilation, configs) => {
77
77
  }
78
78
  );
79
79
  });
80
- } else if (/^(\/|[A-Za-z]:\\|\\\\)/.test(request)) {
80
+ } else if (/^(?:\/|[a-z]:\\|\\\\)/i.test(request)) {
81
81
  // absolute path
82
82
  resolved.set(request, config);
83
83
  } else if (request.endsWith("/")) {
@@ -15,30 +15,30 @@ const { dirname, join, readJson } = require("../util/fs");
15
15
  const RE_URL_GITHUB_EXTREME_SHORT = /^[^/@:.\s][^/@:\s]*\/[^@:\s]*[^/@:\s]#\S+/;
16
16
 
17
17
  // Short url with specific protocol. eg: github:foo/bar
18
- const RE_GIT_URL_SHORT = /^(github|gitlab|bitbucket|gist):\/?[^/.]+\/?/i;
18
+ const RE_GIT_URL_SHORT = /^(?:github|gitlab|bitbucket|gist):\/?[^/.]+\/?/i;
19
19
 
20
20
  // Currently supported protocols
21
21
  const RE_PROTOCOL =
22
- /^((git\+)?(ssh|https?|file)|git|github|gitlab|bitbucket|gist):$/i;
22
+ /^(?:(?:git\+)?(?:ssh|https?|file)|git|github|gitlab|bitbucket|gist):$/i;
23
23
 
24
24
  // Has custom protocol
25
- const RE_CUSTOM_PROTOCOL = /^((git\+)?(ssh|https?|file)|git):\/\//i;
25
+ const RE_CUSTOM_PROTOCOL = /^(?:(?:git\+)?(?:ssh|https?|file)|git):\/\//i;
26
26
 
27
27
  // Valid hash format for npm / yarn ...
28
28
  const RE_URL_HASH_VERSION = /#(?:semver:)?(.+)/;
29
29
 
30
30
  // Simple hostname validate
31
- const RE_HOSTNAME = /^(?:[^/.]+(\.[^/]+)+|localhost)$/;
31
+ const RE_HOSTNAME = /^(?:[^/.]+(?:\.[^/]+)+|localhost)$/;
32
32
 
33
33
  // For hostname with colon. eg: ssh://user@github.com:foo/bar
34
34
  const RE_HOSTNAME_WITH_COLON =
35
35
  /([^/@#:.]+(?:\.[^/@#:.]+)+|localhost):([^#/0-9]+)/;
36
36
 
37
37
  // Reg for url without protocol
38
- const RE_NO_PROTOCOL = /^([^/@#:.]+(?:\.[^/@#:.]+)+)/;
38
+ const RE_NO_PROTOCOL = /^[^/@#:.]+(?:\.[^/@#:.]+)+/;
39
39
 
40
40
  // RegExp for version string
41
- const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
41
+ const VERSION_PATTERN_REGEXP = /^(?:[\d^=v<>~]|[*xX]$)/;
42
42
 
43
43
  // Specific protocol for short url without normal hostname
44
44
  const PROTOCOLS_FOR_SHORT = [
@@ -248,7 +248,9 @@ function getGitUrlVersion(gitUrl) {
248
248
 
249
249
  gitUrl = correctUrl(gitUrl);
250
250
 
251
+ /** @type {undefined | URL} */
251
252
  let parsed;
253
+
252
254
  try {
253
255
  parsed = new URL(gitUrl);
254
256
  // eslint-disable-next-line no-empty
@@ -386,12 +386,10 @@ const uniqueOrderedArray = (items, selector, comparator) =>
386
386
  * @returns {MappedValues<T, R>} mapped object
387
387
  */
388
388
  const mapObject = (obj, fn) => {
389
+ /** @type {MappedValues<T, R>} */
389
390
  const newObj = Object.create(null);
390
- for (const key of Object.keys(obj)) {
391
- newObj[key] = fn(
392
- obj[/** @type {keyof T} */ (key)],
393
- /** @type {keyof T} */ (key)
394
- );
391
+ for (const key of /** @type {(keyof T)[]} */ (Object.keys(obj))) {
392
+ newObj[key] = fn(obj[key], key);
395
393
  }
396
394
  return newObj;
397
395
  };
@@ -507,8 +505,8 @@ const EXTRACT_ERROR = {
507
505
  object.details = /** @type {WebpackError} */ (error).details;
508
506
  }
509
507
  },
510
- errorStack: (object, error) => {
511
- if (typeof error !== "string") {
508
+ errorStack: (object, error, _context, { errorStack }) => {
509
+ if (typeof error !== "string" && errorStack) {
512
510
  object.stack = error.stack;
513
511
  }
514
512
  },
@@ -587,6 +585,7 @@ const SIMPLE_EXTRACTORS = {
587
585
  const util = require("util");
588
586
 
589
587
  object.logging = {};
588
+ /** @type {Set<keyof LogType>} */
590
589
  let acceptedTypes;
591
590
  let collapsedGroups = false;
592
591
  switch (logging) {
@@ -677,6 +676,7 @@ const SIMPLE_EXTRACTORS = {
677
676
  if (depthInCollapsedGroup > 0) depthInCollapsedGroup--;
678
677
  continue;
679
678
  }
679
+ /** @type {undefined | string} */
680
680
  let message;
681
681
  if (entry.type === LogType.time) {
682
682
  const [label, first, second] =
@@ -1229,7 +1229,7 @@ const SIMPLE_EXTRACTORS = {
1229
1229
  const codeGenerated = compilation.codeGeneratedModules.has(module);
1230
1230
  const buildTimeExecuted =
1231
1231
  compilation.buildTimeExecutedModules.has(module);
1232
- /** @type {{[x: string]: number}} */
1232
+ /** @type {{ [x: string]: number }} */
1233
1233
  const sizes = {};
1234
1234
  for (const sourceType of module.getSourceTypes()) {
1235
1235
  sizes[sourceType] = module.size(sourceType);
@@ -1826,6 +1826,7 @@ const getTotalItems = (children) => {
1826
1826
  */
1827
1827
  const collapse = (children) => {
1828
1828
  // After collapse each child must take exactly one line
1829
+ /** @type {Children<T>[]} */
1829
1830
  const newChildren = [];
1830
1831
  for (const child of children) {
1831
1832
  if (child.children) {
@@ -1872,6 +1873,7 @@ const spaceLimited = (
1872
1873
  /** @type {number[]} */
1873
1874
  const groupSizes = [];
1874
1875
  // This are the items, which take 1 line each
1876
+ /** @type {Children<T>[]} */
1875
1877
  const items = [];
1876
1878
  // The total of group sizes
1877
1879
  let groupsSize = 0;
@@ -1907,6 +1909,7 @@ const spaceLimited = (
1907
1909
  if (limit < max) {
1908
1910
  // calculate how much we are over the size limit
1909
1911
  // this allows to approach the limit faster
1912
+ /** @type {number} */
1910
1913
  let oversize;
1911
1914
  // If each group would take 1 line the total would be below the maximum
1912
1915
  // collapse some groups, keep items
@@ -2377,6 +2380,7 @@ const MODULES_GROUPERS = (type) => ({
2377
2380
  const pathMatch =
2378
2381
  groupModulesByPath && GROUP_PATH_REGEXP.exec(resource);
2379
2382
  const path = pathMatch ? pathMatch[1].split(/[/\\]/) : [];
2383
+ /** @type {string[]} */
2380
2384
  const keys = [];
2381
2385
  if (groupModulesByPath) {
2382
2386
  if (extension) {
@@ -2442,9 +2446,7 @@ const MODULES_GROUPERS = (type) => ({
2442
2446
  });
2443
2447
 
2444
2448
  /**
2445
- * @typedef {{
2446
- * groupReasonsByOrigin: (groupConfigs: GroupConfig<KnownStatsModuleReason, BaseGroup & { module: string, children: KnownStatsModuleReason[], active: boolean }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void
2447
- * }} ModuleReasonsGroupers
2449
+ * @typedef {{ groupReasonsByOrigin: (groupConfigs: GroupConfig<KnownStatsModuleReason, BaseGroup & { module: string, children: KnownStatsModuleReason[], active: boolean }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void }} ModuleReasonsGroupers
2448
2450
  */
2449
2451
 
2450
2452
  /** @type {ModuleReasonsGroupers} */
@@ -2541,7 +2543,7 @@ const sortByField = (field) => {
2541
2543
  /**
2542
2544
  * @typedef {{
2543
2545
  * assetsSort: (comparators: Comparator<Asset>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
2544
- * _: (comparators: Comparator<Asset>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void
2546
+ * _: (comparators: Comparator<Asset>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
2545
2547
  * }} AssetSorters
2546
2548
  */
2547
2549
 
@@ -245,6 +245,7 @@ const COMPILATION_SIMPLE_PRINTERS = {
245
245
  nameMessage && versionMessage
246
246
  ? `${nameMessage} (${versionMessage})`
247
247
  : versionMessage || nameMessage || "webpack";
248
+ /** @type {string} */
248
249
  let statusMessage;
249
250
  if (errorsMessage && warningsMessage) {
250
251
  statusMessage = `compiled with ${errorsMessage} and ${warningsMessage}`;
@@ -587,8 +588,7 @@ const MODULE_SIMPLE_PRINTERS = {
587
588
  };
588
589
 
589
590
  /**
590
- * @typedef {Printers<KnownStatsModuleIssuer, "moduleIssuer"> &
591
- * Printers<KnownStatsModuleIssuer["profile"], "moduleIssuer.profile", "moduleIssuer">} ModuleIssuerPrinters
591
+ * @typedef {Printers<KnownStatsModuleIssuer, "moduleIssuer"> & Printers<KnownStatsModuleIssuer["profile"], "moduleIssuer.profile", "moduleIssuer">} ModuleIssuerPrinters
592
592
  */
593
593
 
594
594
  /** @type {ModuleIssuerPrinters} */
@@ -598,8 +598,7 @@ const MODULE_ISSUER_PRINTERS = {
598
598
  };
599
599
 
600
600
  /**
601
- * @typedef {Printers<KnownStatsModuleReason, "moduleReason"> &
602
- * { ["moduleReason.filteredChildren"]?: SimplePrinter<number, "moduleReason"> }} ModuleReasonsPrinters
601
+ * @typedef {Printers<KnownStatsModuleReason, "moduleReason"> & { ["moduleReason.filteredChildren"]?: SimplePrinter<number, "moduleReason"> }} ModuleReasonsPrinters
603
602
  */
604
603
 
605
604
  /** @type {ModuleReasonsPrinters} */
@@ -799,7 +798,7 @@ const ERROR_PRINTERS = {
799
798
  "error.file": (file, { bold }) => bold(file),
800
799
  "error.moduleName": (moduleName, { bold }) =>
801
800
  moduleName.includes("!")
802
- ? `${bold(moduleName.replace(/^(\s|\S)*!/, ""))} (${moduleName})`
801
+ ? `${bold(moduleName.replace(/^([\s\S])*!/, ""))} (${moduleName})`
803
802
  : `${bold(moduleName)}`,
804
803
  "error.loc": (loc, { green }) => green(loc),
805
804
  "error.message": (message, { bold, formatError }) =>
@@ -1193,6 +1192,7 @@ const joinOneLine = (items) =>
1193
1192
  * @returns {string} result
1194
1193
  */
1195
1194
  const joinInBrackets = (items) => {
1195
+ /** @type {string[]} */
1196
1196
  const res = [];
1197
1197
  let mode = 0;
1198
1198
  for (const item of items) {
@@ -1296,6 +1296,7 @@ const joinError =
1296
1296
  /** @type {Record<string, SimpleElementJoiner>} */
1297
1297
  const SIMPLE_ELEMENT_JOINERS = {
1298
1298
  compilation: (items) => {
1299
+ /** @type {string[]} */
1299
1300
  const result = [];
1300
1301
  let lastNeedMore = false;
1301
1302
  for (const item of items) {
@@ -161,7 +161,7 @@ class StatsFactory {
161
161
  /**
162
162
  * @template {StatsFactoryHooks[keyof StatsFactoryHooks]} HM
163
163
  * @template {HM extends HookMap<infer H> ? H : never} H
164
- * @template {H extends import("tapable").Hook<any, infer R> ? R : never} R
164
+ * @template {H extends import("tapable").Hook<EXPECTED_ANY, infer R> ? R : never} R
165
165
  * @param {HM} hookMap hook map
166
166
  * @param {Caches<H>} cache cache
167
167
  * @param {string} type type
@@ -197,7 +197,7 @@ class StatsFactory {
197
197
  /**
198
198
  * @template {StatsFactoryHooks[keyof StatsFactoryHooks]} T
199
199
  * @template {T extends HookMap<infer H> ? H : never} H
200
- * @template {H extends import("tapable").Hook<any, infer R> ? R : never} R
200
+ * @template {H extends import("tapable").Hook<EXPECTED_ANY, infer R> ? R : never} R
201
201
  * @param {T} hookMap hook map
202
202
  * @param {Caches<H>} cache cache
203
203
  * @param {string} type type
@@ -54,9 +54,7 @@ const isMetaUrl = (parser, arg) => {
54
54
  return true;
55
55
  };
56
56
 
57
- /**
58
- * @type {WeakMap<NewExpressionNode, BasicEvaluatedExpression | undefined>}
59
- */
57
+ /** @type {WeakMap<NewExpressionNode, BasicEvaluatedExpression | undefined>} */
60
58
  const getEvaluatedExprCache = new WeakMap();
61
59
 
62
60
  /**
@@ -167,6 +165,7 @@ class URLParserPlugin {
167
165
  const evaluatedExpr = getEvaluatedExpr(expr, parser);
168
166
  if (!evaluatedExpr) return;
169
167
 
168
+ /** @type {string | undefined} */
170
169
  let request;
171
170
 
172
171
  // static URL
@@ -190,7 +189,9 @@ class URLParserPlugin {
190
189
  if (this.options.dynamicUrl === false) return;
191
190
 
192
191
  // context URL
192
+ /** @type {undefined | RegExp} */
193
193
  let include;
194
+ /** @type {undefined | RegExp} */
194
195
  let exclude;
195
196
 
196
197
  if (importOptions) {
@@ -0,0 +1,57 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Ivan Kopeykin @vankop
4
+ */
5
+
6
+ "use strict";
7
+
8
+ /**
9
+ * @template T
10
+ */
11
+ class AppendOnlyStackedSet {
12
+ /**
13
+ * @param {Set<T>[]} sets an optional array of sets
14
+ */
15
+ constructor(sets = []) {
16
+ /** @type {Set<T>[]} */
17
+ this._sets = sets;
18
+ /** @type {Set<T> | undefined} */
19
+ this._current = undefined;
20
+ }
21
+
22
+ /**
23
+ * @param {T} el element
24
+ */
25
+ add(el) {
26
+ if (!this._current) {
27
+ this._current = new Set();
28
+ this._sets.push(this._current);
29
+ }
30
+ this._current.add(el);
31
+ }
32
+
33
+ /**
34
+ * @param {T} el element
35
+ * @returns {boolean} result
36
+ */
37
+ has(el) {
38
+ for (const set of this._sets) {
39
+ if (set.has(el)) return true;
40
+ }
41
+ return false;
42
+ }
43
+
44
+ clear() {
45
+ this._sets = [];
46
+ if (this._current) this._current.clear();
47
+ }
48
+
49
+ /**
50
+ * @returns {AppendOnlyStackedSet<T>} child
51
+ */
52
+ createChild() {
53
+ return new AppendOnlyStackedSet(this._sets.length ? [...this._sets] : []);
54
+ }
55
+ }
56
+
57
+ module.exports = AppendOnlyStackedSet;
package/lib/util/Hash.js CHANGED
@@ -6,6 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  /** @typedef {import("../../declarations/WebpackOptions").HashDigest} Encoding */
9
+ /** @typedef {string | typeof Hash} HashFunction */
9
10
 
10
11
  class Hash {
11
12
  /* istanbul ignore next */
@@ -11,6 +11,7 @@
11
11
  * @returns {T | undefined} last item
12
12
  */
13
13
  const last = (set) => {
14
+ /** @type {T | undefined} */
14
15
  let last;
15
16
  for (const item of set) last = item;
16
17
  return last;
@@ -56,6 +56,7 @@ class LazyBucketSortedSet {
56
56
  this._keys = new SortableSet(undefined, comparator);
57
57
  /** @type {Map<K, Entry<T, K>>} */
58
58
  this._map = new Map();
59
+ /** @type {Set<T>} */
59
60
  this._unsortedItems = new Set();
60
61
  this.size = 0;
61
62
  }
@@ -222,6 +222,7 @@ class LazySet {
222
222
  */
223
223
  static deserialize({ read }) {
224
224
  const count = read();
225
+ /** @type {T[]} */
225
226
  const items = [];
226
227
  for (let i = 0; i < count; i++) {
227
228
  items.push(read());
@@ -35,6 +35,7 @@ class ParallelismFactorCalculator {
35
35
  a < b ? -1 : 1
36
36
  );
37
37
  const parallelism = segments.map(() => 0);
38
+ /** @type {number[]} */
38
39
  const rangeStartIndices = [];
39
40
  for (let i = 0; i < this._rangePoints.length; i += 2) {
40
41
  const start = this._rangePoints[i];
@@ -88,6 +88,7 @@ class SortableSet extends Set {
88
88
  return;
89
89
  }
90
90
 
91
+ /** @type {T[]} */
91
92
  const sortedArray = [...this].sort(sortFn);
92
93
  super.clear();
93
94
  for (let i = 0; i < sortedArray.length; i += 1) {
@@ -62,6 +62,7 @@ class StringXor {
62
62
  const valueLen = value.length;
63
63
  if (valueLen < len) {
64
64
  const newValue = (this._value = Buffer.allocUnsafe(len));
65
+ /** @type {number} */
65
66
  let i;
66
67
  for (i = 0; i < valueLen; i++) {
67
68
  newValue[i] = value[i] ^ str.charCodeAt(i);
@@ -64,6 +64,11 @@ const compileSearch = (funcName, predicate, reversed, extraArgs, earlyOut) => {
64
64
  return code.join("");
65
65
  };
66
66
 
67
+ /**
68
+ * @template T
69
+ * @typedef {(items: T[], start: number, compareFn?: number | ((item: T, needle: number) => number), l?: number, h?: number) => number} Search
70
+ */
71
+
67
72
  /**
68
73
  * This helper functions generate code for two binary search functions:
69
74
  * A(): Performs a binary search on an array using the comparison operator specified.
@@ -74,7 +79,7 @@ const compileSearch = (funcName, predicate, reversed, extraArgs, earlyOut) => {
74
79
  * @param {boolean} reversed Whether the search should be reversed.
75
80
  * @param {SearchPredicateSuffix} suffix The suffix to be used in the function name.
76
81
  * @param {boolean=} earlyOut Whether the search should return as soon as a match is found.
77
- * @returns {(items: T[], start: number, compareFn?: number | ((item: T, needle: number) => number), l?: number, h?: number) => number} The compiled binary search function.
82
+ * @returns {Search<T>} The compiled binary search function.
78
83
  */
79
84
  const compileBoundsSearch = (predicate, reversed, suffix, earlyOut) => {
80
85
  const arg1 = compileSearch("A", `x${predicate}y`, reversed, ["y"], earlyOut);
@@ -106,6 +111,14 @@ return dispatchBinarySearch";
106
111
  return result();
107
112
  };
108
113
 
114
+ const fns = {
115
+ ge: compileBoundsSearch(">=", false, "GE"),
116
+ gt: compileBoundsSearch(">", false, "GT"),
117
+ lt: compileBoundsSearch("<", true, "LT"),
118
+ le: compileBoundsSearch("<=", true, "LE"),
119
+ eq: compileBoundsSearch("-", true, "EQ", true)
120
+ };
121
+
109
122
  /**
110
123
  * These functions are used to perform binary searches on arrays.
111
124
  * @example
@@ -120,10 +133,4 @@ return dispatchBinarySearch";
120
133
  * const index2 = le(arr, 5); // index2 === 4
121
134
  * ```
122
135
  */
123
- module.exports = {
124
- ge: compileBoundsSearch(">=", false, "GE"),
125
- gt: compileBoundsSearch(">", false, "GT"),
126
- lt: compileBoundsSearch("<", true, "LT"),
127
- le: compileBoundsSearch("<=", true, "LE"),
128
- eq: compileBoundsSearch("-", true, "EQ", true)
129
- };
136
+ module.exports = fns;
@@ -23,7 +23,7 @@
23
23
  * @param {IdRanges | undefined} ranges cumulative range of ids for each of allIds
24
24
  * @param {ModuleGraph} moduleGraph moduleGraph
25
25
  * @param {Dependency} dependency dependency
26
- * @returns {{trimmedIds: string[], trimmedRange: Range}} computed trimmed ids and cumulative range of those ids
26
+ * @returns {{ trimmedIds: string[], trimmedRange: Range }} computed trimmed ids and cumulative range of those ids
27
27
  */
28
28
  module.exports.getTrimmedIdsAndRange = (
29
29
  untrimmedIds,
@@ -7,7 +7,8 @@
7
7
 
8
8
  /** @type {WeakMap<EXPECTED_OBJECT, WeakMap<EXPECTED_OBJECT, EXPECTED_OBJECT>>} */
9
9
  const mergeCache = new WeakMap();
10
- /** @type {WeakMap<EXPECTED_OBJECT, Map<string, Map<string | number | boolean, EXPECTED_OBJECT>>>} */
10
+ /** @typedef {Map<string, Map<string | number | boolean, EXPECTED_OBJECT>>} InnerPropertyCache */
11
+ /** @type {WeakMap<EXPECTED_OBJECT, InnerPropertyCache>} */
11
12
  const setPropertyCache = new WeakMap();
12
13
  const DELETE = Symbol("DELETE");
13
14
  const DYNAMIC_INFO = Symbol("cleverMerge dynamic info");
@@ -406,6 +407,7 @@ const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
406
407
  } else {
407
408
  // = first.base + (first.byProperty + second.byProperty)
408
409
  // need to merge first and second byValues
410
+ /** @type {Map<string, T & O>} */
409
411
  const newByValues = new Map(firstEntry.byValues);
410
412
  for (const [key, value] of /** @type {ByValues} */ (
411
413
  secondEntry.byValues
@@ -444,7 +446,9 @@ const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
444
446
  byValues: secondEntry.byValues
445
447
  };
446
448
  }
449
+ /** @type {O[keyof O] | T[keyof T] | (T[keyof T] & O[keyof O]) | (T[keyof T] | undefined)[] | (O[keyof O] | undefined)[] | (O[keyof O] | T[keyof T] | undefined)[] | undefined} */
447
450
  let newBase;
451
+ /** @type {Map<string, (T & O) | O[keyof O] | (O[keyof O] | undefined)[] | ((T & O) | undefined)[] | (T & O & O[keyof O]) | ((T & O) | O[keyof O] | undefined)[] | undefined>} */
448
452
  const intermediateByValues = new Map(firstEntry.byValues);
449
453
  for (const [key, value] of intermediateByValues) {
450
454
  intermediateByValues.set(
@@ -485,6 +489,7 @@ const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
485
489
  `${firstEntry.byProperty} and ${secondEntry.byProperty} for a single property is not supported`
486
490
  );
487
491
  }
492
+ /** @type {Map<string, (T & O) | O[keyof O] | (O[keyof O] | undefined)[] | (T & O & O[keyof O]) | ((T & O) | undefined)[] | ((T & O) | O[keyof O] | undefined)[] | undefined>} */
488
493
  const newByValues = new Map(intermediateByValues);
489
494
  for (const [key, value] of /** @type {ByValues} */ (
490
495
  secondEntry.byValues