webpack 5.99.8 → 5.100.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 (314) hide show
  1. package/README.md +0 -3
  2. package/bin/webpack.js +8 -2
  3. package/hot/log.js +15 -15
  4. package/hot/poll.js +1 -0
  5. package/lib/APIPlugin.js +3 -3
  6. package/lib/AbstractMethodError.js +1 -0
  7. package/lib/AutomaticPrefetchPlugin.js +1 -0
  8. package/lib/BannerPlugin.js +1 -1
  9. package/lib/CacheFacade.js +2 -1
  10. package/lib/CaseSensitiveModulesWarning.js +4 -4
  11. package/lib/Chunk.js +6 -6
  12. package/lib/ChunkGraph.js +37 -32
  13. package/lib/ChunkGroup.js +17 -10
  14. package/lib/ChunkTemplate.js +1 -1
  15. package/lib/CleanPlugin.js +94 -17
  16. package/lib/CodeGenerationResults.js +1 -1
  17. package/lib/CompatibilityPlugin.js +5 -2
  18. package/lib/Compilation.js +77 -71
  19. package/lib/Compiler.js +46 -16
  20. package/lib/ConcatenationScope.js +15 -6
  21. package/lib/ConstPlugin.js +65 -45
  22. package/lib/ContextModule.js +16 -12
  23. package/lib/ContextModuleFactory.js +4 -3
  24. package/lib/ContextReplacementPlugin.js +4 -2
  25. package/lib/CssModule.js +2 -3
  26. package/lib/DefinePlugin.js +111 -3
  27. package/lib/DelegatedModuleFactoryPlugin.js +18 -18
  28. package/lib/Dependency.js +16 -12
  29. package/lib/DependencyTemplate.js +1 -0
  30. package/lib/DllEntryPlugin.js +3 -1
  31. package/lib/DllPlugin.js +4 -3
  32. package/lib/DllReferencePlugin.js +2 -2
  33. package/lib/DynamicEntryPlugin.js +1 -1
  34. package/lib/EntryOptionPlugin.js +5 -0
  35. package/lib/ErrorHelpers.js +4 -4
  36. package/lib/EvalDevToolModulePlugin.js +3 -3
  37. package/lib/EvalSourceMapDevToolPlugin.js +7 -7
  38. package/lib/ExportsInfo.js +48 -39
  39. package/lib/ExternalModule.js +15 -11
  40. package/lib/ExternalModuleFactoryPlugin.js +5 -2
  41. package/lib/FileSystemInfo.js +51 -38
  42. package/lib/FlagDependencyExportsPlugin.js +14 -7
  43. package/lib/FlagDependencyUsagePlugin.js +1 -1
  44. package/lib/Generator.js +14 -1
  45. package/lib/HookWebpackError.js +1 -0
  46. package/lib/HotModuleReplacementPlugin.js +77 -50
  47. package/lib/IgnorePlugin.js +1 -1
  48. package/lib/InvalidDependenciesModuleWarning.js +1 -1
  49. package/lib/JavascriptMetaInfoPlugin.js +0 -1
  50. package/lib/LibManifestPlugin.js +4 -2
  51. package/lib/LoaderOptionsPlugin.js +6 -4
  52. package/lib/MainTemplate.js +2 -2
  53. package/lib/Module.js +21 -6
  54. package/lib/ModuleFactory.js +1 -0
  55. package/lib/ModuleGraph.js +24 -2
  56. package/lib/ModuleGraphConnection.js +5 -5
  57. package/lib/ModuleInfoHeaderPlugin.js +2 -1
  58. package/lib/ModuleParseError.js +1 -0
  59. package/lib/ModuleSourceTypesConstants.js +12 -12
  60. package/lib/ModuleTemplate.js +1 -1
  61. package/lib/ModuleTypeConstants.js +21 -21
  62. package/lib/MultiCompiler.js +6 -6
  63. package/lib/NormalModule.js +61 -56
  64. package/lib/NormalModuleFactory.js +52 -37
  65. package/lib/NormalModuleReplacementPlugin.js +1 -1
  66. package/lib/NullFactory.js +1 -0
  67. package/lib/OptimizationStages.js +1 -1
  68. package/lib/Parser.js +1 -0
  69. package/lib/ProgressPlugin.js +12 -5
  70. package/lib/ProvidePlugin.js +5 -1
  71. package/lib/RecordIdsPlugin.js +3 -3
  72. package/lib/RuntimeGlobals.js +175 -155
  73. package/lib/RuntimeModule.js +1 -0
  74. package/lib/RuntimePlugin.js +34 -8
  75. package/lib/RuntimeTemplate.js +111 -11
  76. package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
  77. package/lib/SourceMapDevToolPlugin.js +19 -17
  78. package/lib/Template.js +2 -2
  79. package/lib/TemplatedPathPlugin.js +1 -1
  80. package/lib/WarnDeprecatedOptionPlugin.js +7 -8
  81. package/lib/WatchIgnorePlugin.js +4 -3
  82. package/lib/WebpackIsIncludedPlugin.js +2 -1
  83. package/lib/WebpackOptionsApply.js +115 -27
  84. package/lib/asset/AssetGenerator.js +26 -21
  85. package/lib/asset/AssetModulesPlugin.js +19 -17
  86. package/lib/asset/AssetSourceGenerator.js +11 -9
  87. package/lib/asset/RawDataUrlModule.js +4 -2
  88. package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
  89. package/lib/buildChunkGraph.js +6 -3
  90. package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
  91. package/lib/cache/IdleFileCachePlugin.js +7 -4
  92. package/lib/cache/MemoryCachePlugin.js +1 -0
  93. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  94. package/lib/cache/PackFileCacheStrategy.js +26 -20
  95. package/lib/cache/ResolverCachePlugin.js +16 -8
  96. package/lib/cli.js +15 -10
  97. package/lib/config/browserslistTargetHandler.js +3 -3
  98. package/lib/config/defaults.js +25 -17
  99. package/lib/config/normalization.js +2 -1
  100. package/lib/config/target.js +6 -5
  101. package/lib/container/ContainerPlugin.js +1 -1
  102. package/lib/container/ContainerReferencePlugin.js +1 -1
  103. package/lib/container/FallbackModule.js +2 -1
  104. package/lib/container/HoistContainerReferencesPlugin.js +1 -1
  105. package/lib/container/ModuleFederationPlugin.js +2 -2
  106. package/lib/container/RemoteModule.js +1 -1
  107. package/lib/css/CssGenerator.js +9 -6
  108. package/lib/css/CssModulesPlugin.js +44 -31
  109. package/lib/css/CssParser.js +6 -4
  110. package/lib/css/walkCssTokens.js +33 -37
  111. package/lib/debug/ProfilingPlugin.js +6 -6
  112. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
  113. package/lib/dependencies/AMDPlugin.js +12 -8
  114. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
  115. package/lib/dependencies/CachedConstDependency.js +1 -5
  116. package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
  117. package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
  118. package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
  119. package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
  120. package/lib/dependencies/CommonJsPlugin.js +15 -16
  121. package/lib/dependencies/ContextDependencyHelpers.js +2 -1
  122. package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
  123. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
  124. package/lib/dependencies/CssIcssExportDependency.js +1 -1
  125. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
  126. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
  127. package/lib/dependencies/CssUrlDependency.js +1 -1
  128. package/lib/dependencies/DynamicExports.js +9 -9
  129. package/lib/dependencies/ExportsInfoDependency.js +1 -1
  130. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
  131. package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
  132. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
  133. package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
  134. package/lib/dependencies/HarmonyImportDependency.js +11 -5
  135. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
  136. package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
  137. package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
  138. package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
  139. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  140. package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
  141. package/lib/dependencies/ImportMetaPlugin.js +2 -2
  142. package/lib/dependencies/ImportParserPlugin.js +40 -9
  143. package/lib/dependencies/ImportPlugin.js +3 -1
  144. package/lib/dependencies/LoaderPlugin.js +1 -0
  145. package/lib/dependencies/ModuleDependency.js +1 -1
  146. package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
  147. package/lib/dependencies/RequireContextPlugin.js +3 -1
  148. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +3 -0
  149. package/lib/dependencies/RequireEnsurePlugin.js +6 -6
  150. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
  151. package/lib/dependencies/RequireIncludePlugin.js +1 -0
  152. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
  153. package/lib/dependencies/SystemPlugin.js +1 -1
  154. package/lib/dependencies/URLContextDependency.js +65 -0
  155. package/lib/dependencies/URLDependency.js +1 -1
  156. package/lib/dependencies/URLPlugin.js +17 -157
  157. package/lib/dependencies/WorkerPlugin.js +23 -10
  158. package/lib/dependencies/processExportInfo.js +2 -1
  159. package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
  160. package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
  161. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +73 -6
  162. package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
  163. package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
  164. package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
  165. package/lib/hmr/LazyCompilationPlugin.js +4 -2
  166. package/lib/hmr/lazyCompilationBackend.js +4 -2
  167. package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
  168. package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
  169. package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
  170. package/lib/ids/HashedModuleIdsPlugin.js +5 -4
  171. package/lib/ids/IdHelpers.js +21 -17
  172. package/lib/ids/NamedChunkIdsPlugin.js +5 -5
  173. package/lib/ids/NamedModuleIdsPlugin.js +4 -4
  174. package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
  175. package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
  176. package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
  177. package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
  178. package/lib/ids/SyncModuleIdsPlugin.js +1 -1
  179. package/lib/index.js +13 -3
  180. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
  181. package/lib/javascript/BasicEvaluatedExpression.js +2 -1
  182. package/lib/javascript/ChunkHelpers.js +1 -0
  183. package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
  184. package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
  185. package/lib/javascript/JavascriptGenerator.js +14 -2
  186. package/lib/javascript/JavascriptModulesPlugin.js +68 -27
  187. package/lib/javascript/JavascriptParser.js +136 -81
  188. package/lib/javascript/JavascriptParserHelpers.js +41 -41
  189. package/lib/javascript/StartupHelpers.js +17 -17
  190. package/lib/json/JsonGenerator.js +4 -2
  191. package/lib/json/JsonModulesPlugin.js +2 -2
  192. package/lib/json/JsonParser.js +1 -1
  193. package/lib/library/AbstractLibraryPlugin.js +6 -2
  194. package/lib/library/AssignLibraryPlugin.js +21 -6
  195. package/lib/library/EnableLibraryPlugin.js +23 -3
  196. package/lib/library/ModuleLibraryPlugin.js +4 -1
  197. package/lib/library/UmdLibraryPlugin.js +15 -6
  198. package/lib/logging/createConsoleLogger.js +3 -3
  199. package/lib/logging/runtime.js +9 -9
  200. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
  201. package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
  202. package/lib/node/nodeConsole.js +4 -2
  203. package/lib/optimize/AggressiveMergingPlugin.js +45 -46
  204. package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
  205. package/lib/optimize/ConcatenatedModule.js +227 -57
  206. package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
  207. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
  208. package/lib/optimize/InnerGraph.js +115 -112
  209. package/lib/optimize/InnerGraphPlugin.js +2 -2
  210. package/lib/optimize/LimitChunkCountPlugin.js +4 -2
  211. package/lib/optimize/MangleExportsPlugin.js +4 -3
  212. package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
  213. package/lib/optimize/MinChunkSizePlugin.js +6 -3
  214. package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
  215. package/lib/optimize/RealContentHashPlugin.js +26 -20
  216. package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
  217. package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
  218. package/lib/optimize/SideEffectsFlagPlugin.js +6 -3
  219. package/lib/optimize/SplitChunksPlugin.js +16 -13
  220. package/lib/rules/BasicEffectRulePlugin.js +4 -2
  221. package/lib/rules/BasicMatcherRulePlugin.js +3 -1
  222. package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
  223. package/lib/rules/RuleSetCompiler.js +7 -4
  224. package/lib/rules/UseEffectRulePlugin.js +3 -1
  225. package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
  226. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
  227. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
  228. package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
  229. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
  230. package/lib/schemes/DataUriPlugin.js +3 -1
  231. package/lib/schemes/FileUriPlugin.js +1 -1
  232. package/lib/schemes/HttpUriPlugin.js +27 -19
  233. package/lib/schemes/VirtualUrlPlugin.js +222 -0
  234. package/lib/serialization/AggregateErrorSerializer.js +1 -1
  235. package/lib/serialization/BinaryMiddleware.js +5 -4
  236. package/lib/serialization/FileMiddleware.js +7 -4
  237. package/lib/serialization/ObjectMiddleware.js +14 -8
  238. package/lib/serialization/Serializer.js +5 -3
  239. package/lib/serialization/SerializerMiddleware.js +2 -0
  240. package/lib/sharing/ConsumeSharedModule.js +1 -1
  241. package/lib/sharing/ConsumeSharedPlugin.js +3 -3
  242. package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
  243. package/lib/sharing/ProvideSharedModule.js +1 -1
  244. package/lib/sharing/ProvideSharedPlugin.js +6 -3
  245. package/lib/sharing/SharePlugin.js +2 -1
  246. package/lib/sharing/ShareRuntimeModule.js +3 -5
  247. package/lib/sharing/utils.js +34 -34
  248. package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
  249. package/lib/stats/DefaultStatsPresetPlugin.js +4 -2
  250. package/lib/stats/DefaultStatsPrinterPlugin.js +28 -22
  251. package/lib/stats/StatsFactory.js +4 -2
  252. package/lib/stats/StatsPrinter.js +3 -2
  253. package/lib/url/URLParserPlugin.js +266 -0
  254. package/lib/util/ArrayQueue.js +1 -1
  255. package/lib/util/AsyncQueue.js +1 -1
  256. package/lib/util/Hash.js +2 -0
  257. package/lib/util/IterableHelpers.js +1 -1
  258. package/lib/util/LazyBucketSortedSet.js +2 -1
  259. package/lib/util/LazySet.js +11 -6
  260. package/lib/util/ParallelismFactorCalculator.js +1 -1
  261. package/lib/util/SetHelpers.js +3 -3
  262. package/lib/util/SortableSet.js +2 -2
  263. package/lib/util/StackedCacheMap.js +3 -1
  264. package/lib/util/StackedMap.js +2 -2
  265. package/lib/util/StringXor.js +1 -0
  266. package/lib/util/TupleSet.js +1 -0
  267. package/lib/util/URLAbsoluteSpecifier.js +1 -1
  268. package/lib/util/cleverMerge.js +12 -8
  269. package/lib/util/comparators.js +154 -127
  270. package/lib/util/compileBooleanMatcher.js +8 -3
  271. package/lib/util/concatenate.js +8 -7
  272. package/lib/util/conventions.js +72 -73
  273. package/lib/util/create-schema-validation.js +2 -1
  274. package/lib/util/createHash.js +10 -4
  275. package/lib/util/deprecation.js +69 -66
  276. package/lib/util/deterministicGrouping.js +4 -2
  277. package/lib/util/extractUrlAndGlobal.js +1 -1
  278. package/lib/util/findGraphRoots.js +2 -2
  279. package/lib/util/fs.js +30 -23
  280. package/lib/util/hash/md4.js +2 -2
  281. package/lib/util/hash/wasm-hash.js +4 -2
  282. package/lib/util/identifier.js +13 -12
  283. package/lib/util/internalSerializables.js +2 -0
  284. package/lib/util/magicComment.js +5 -5
  285. package/lib/util/processAsyncTree.js +1 -1
  286. package/lib/util/propertyAccess.js +1 -1
  287. package/lib/util/propertyName.js +1 -1
  288. package/lib/util/registerExternalSerializer.js +1 -2
  289. package/lib/util/removeBOM.js +1 -1
  290. package/lib/util/runtime.js +29 -21
  291. package/lib/util/semver.js +1 -1
  292. package/lib/util/serialization.js +3 -0
  293. package/lib/util/source.js +3 -2
  294. package/lib/validateSchema.js +1 -0
  295. package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
  296. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
  297. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
  298. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
  299. package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
  300. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
  301. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
  302. package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
  303. package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
  304. package/lib/webpack.js +4 -5
  305. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  306. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
  307. package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
  308. package/package.json +121 -114
  309. package/schemas/WebpackOptions.check.js +1 -1
  310. package/schemas/WebpackOptions.json +17 -0
  311. package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
  312. package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
  313. package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
  314. package/types.d.ts +1261 -366
@@ -44,8 +44,9 @@ class CompatibilityPlugin {
44
44
  if (
45
45
  parserOptions.browserify !== undefined &&
46
46
  !parserOptions.browserify
47
- )
47
+ ) {
48
48
  return;
49
+ }
49
50
 
50
51
  parser.hooks.call.for("require").tap(
51
52
  PLUGIN_NAME,
@@ -75,8 +76,9 @@ class CompatibilityPlugin {
75
76
  last.options.request === "." &&
76
77
  last.userRequest === "." &&
77
78
  last.options.recursive
78
- )
79
+ ) {
79
80
  parser.state.current.dependencies.pop();
81
+ }
80
82
  }
81
83
  parser.state.module.addPresentationalDependency(dep);
82
84
  return true;
@@ -191,4 +193,5 @@ class CompatibilityPlugin {
191
193
  );
192
194
  }
193
195
  }
196
+
194
197
  module.exports = CompatibilityPlugin;
@@ -5,17 +5,17 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const util = require("util");
8
9
  const asyncLib = require("neo-async");
9
10
  const {
11
+ AsyncParallelHook,
12
+ AsyncSeriesBailHook,
13
+ AsyncSeriesHook,
10
14
  HookMap,
11
- SyncHook,
12
15
  SyncBailHook,
13
- SyncWaterfallHook,
14
- AsyncSeriesHook,
15
- AsyncSeriesBailHook,
16
- AsyncParallelHook
16
+ SyncHook,
17
+ SyncWaterfallHook
17
18
  } = require("tapable");
18
- const util = require("util");
19
19
  const { CachedSource } = require("webpack-sources");
20
20
  const { MultiItemCache } = require("./CacheFacade");
21
21
  const Chunk = require("./Chunk");
@@ -56,7 +56,7 @@ const Stats = require("./Stats");
56
56
  const WebpackError = require("./WebpackError");
57
57
  const buildChunkGraph = require("./buildChunkGraph");
58
58
  const BuildCycleError = require("./errors/BuildCycleError");
59
- const { Logger, LogType } = require("./logging/Logger");
59
+ const { LogType, Logger } = require("./logging/Logger");
60
60
  const StatsFactory = require("./stats/StatsFactory");
61
61
  const StatsPrinter = require("./stats/StatsPrinter");
62
62
  const { equals: arrayEquals } = require("./util/ArrayHelpers");
@@ -66,18 +66,18 @@ const { getOrInsert } = require("./util/MapHelpers");
66
66
  const WeakTupleMap = require("./util/WeakTupleMap");
67
67
  const { cachedCleverMerge } = require("./util/cleverMerge");
68
68
  const {
69
+ compareIds,
69
70
  compareLocations,
70
- concatComparators,
71
+ compareModulesByIdentifier,
71
72
  compareSelect,
72
- compareIds,
73
73
  compareStringsNumeric,
74
- compareModulesByIdentifier
74
+ concatComparators
75
75
  } = require("./util/comparators");
76
76
  const createHash = require("./util/createHash");
77
77
  const {
78
78
  arrayToSetDeprecation,
79
- soonFrozenObjectDeprecation,
80
- createFakeHook
79
+ createFakeHook,
80
+ soonFrozenObjectDeprecation
81
81
  } = require("./util/deprecation");
82
82
  const processAsyncTree = require("./util/processAsyncTree");
83
83
  const { getRuntimeKey } = require("./util/runtime");
@@ -102,6 +102,7 @@ const { isSourceEqual } = require("./util/source");
102
102
  /** @typedef {import("./Compiler").MemCache} MemCache */
103
103
  /** @typedef {import("./Compiler").WeakReferences} WeakReferences */
104
104
  /** @typedef {import("./Compiler").ModuleMemCachesItem} ModuleMemCachesItem */
105
+ /** @typedef {import("./Compiler").Records} Records */
105
106
  /** @typedef {import("./DependenciesBlock")} DependenciesBlock */
106
107
  /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
107
108
  /** @typedef {import("./Dependency").ReferencedExport} ReferencedExport */
@@ -391,8 +392,6 @@ const { isSourceEqual } = require("./util/source");
391
392
 
392
393
  /** @typedef {Set<Module>} NotCodeGeneratedModules */
393
394
 
394
- /** @typedef {Record<string, TODO>} Records */
395
-
396
395
  /** @type {AssetInfo} */
397
396
  const EMPTY_ASSET_INFO = Object.freeze({});
398
397
 
@@ -531,8 +530,9 @@ class Compilation {
531
530
  if (
532
531
  /** @type {ProcessedAssets} */
533
532
  (processedAssets).has(this.assets)
534
- )
533
+ ) {
535
534
  additionalAssetsFn(assets);
535
+ }
536
536
  });
537
537
  }
538
538
  return {
@@ -549,8 +549,9 @@ class Compilation {
549
549
  } catch (err) {
550
550
  return callback(/** @type {Error} */ (err));
551
551
  }
552
- if (processedAssets !== undefined)
552
+ if (processedAssets !== undefined) {
553
553
  processedAssets.add(this.assets);
554
+ }
554
555
  const newAssets = popNewAssets(assets);
555
556
  if (newAssets !== undefined) {
556
557
  this.hooks.processAdditionalAssets.callAsync(
@@ -570,8 +571,9 @@ class Compilation {
570
571
  if (
571
572
  /** @type {ProcessedAssets} */
572
573
  (processedAssets).has(this.assets)
573
- )
574
+ ) {
574
575
  return additionalAssetsFn(assets, callback);
576
+ }
575
577
  callback();
576
578
  }
577
579
  );
@@ -592,8 +594,9 @@ class Compilation {
592
594
  */
593
595
  err => {
594
596
  if (err) return callback(err);
595
- if (processedAssets !== undefined)
597
+ if (processedAssets !== undefined) {
596
598
  processedAssets.add(this.assets);
599
+ }
597
600
  const newAssets = popNewAssets(assets);
598
601
  if (newAssets !== undefined) {
599
602
  this.hooks.processAdditionalAssets.callAsync(
@@ -613,8 +616,9 @@ class Compilation {
613
616
  if (
614
617
  /** @type {ProcessedAssets} */
615
618
  (processedAssets).has(this.assets)
616
- )
619
+ ) {
617
620
  return additionalAssetsFn(assets);
621
+ }
618
622
  return Promise.resolve();
619
623
  });
620
624
  }
@@ -628,8 +632,9 @@ class Compilation {
628
632
  const p = fn(assets);
629
633
  if (!p || !p.then) return p;
630
634
  return p.then(() => {
631
- if (processedAssets !== undefined)
635
+ if (processedAssets !== undefined) {
632
636
  processedAssets.add(this.assets);
637
+ }
633
638
  const newAssets = popNewAssets(assets);
634
639
  if (newAssets !== undefined) {
635
640
  return this.hooks.processAdditionalAssets.promise(
@@ -678,7 +683,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
678
683
  {
679
684
  name,
680
685
  /** @type {AsyncSeriesHook<T>["intercept"]} */
681
- intercept(interceptor) {
686
+ intercept(_interceptor) {
682
687
  throw new Error(errorMessage("it's using 'intercept'"));
683
688
  },
684
689
  /** @type {AsyncSeriesHook<T>["tap"]} */
@@ -1232,7 +1237,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1232
1237
  // properties in the prototype chain
1233
1238
  /** @type {Partial<NormalizedStatsOptions>} */
1234
1239
  const options = {};
1235
- // eslint-disable-next-line guard-for-in
1236
1240
  for (const key in optionsOrPreset) {
1237
1241
  options[key] = optionsOrPreset[/** @type {keyof StatsOptions} */ (key)];
1238
1242
  }
@@ -1445,8 +1449,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1445
1449
  }
1446
1450
  this._modules.set(identifier, module);
1447
1451
  this.modules.add(module);
1448
- if (this._backCompat)
1452
+ if (this._backCompat) {
1449
1453
  ModuleGraph.setModuleGraphForModule(module, this.moduleGraph);
1454
+ }
1450
1455
  if (currentProfile !== undefined) {
1451
1456
  currentProfile.markIntegrationEnd();
1452
1457
  }
@@ -1739,8 +1744,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1739
1744
  inProgressTransitive = -1;
1740
1745
  onTransitiveTasksFinished(err);
1741
1746
  }
1742
- if (--inProgressTransitive === 0)
1747
+ if (--inProgressTransitive === 0) {
1743
1748
  return onTransitiveTasksFinished();
1749
+ }
1744
1750
  }
1745
1751
  );
1746
1752
  if (--inProgressSorting === 0) onDependenciesSorted();
@@ -1891,8 +1897,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1891
1897
 
1892
1898
  this._modules.set(module.identifier(), module);
1893
1899
  this.modules.add(module);
1894
- if (this._backCompat)
1900
+ if (this._backCompat) {
1895
1901
  ModuleGraph.setModuleGraphForModule(module, this.moduleGraph);
1902
+ }
1896
1903
 
1897
1904
  this._handleModuleBuildAndDependencies(
1898
1905
  originModule,
@@ -2021,8 +2028,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2021
2028
  const unsafeCacheableModule =
2022
2029
  /** @type {ModuleWithRestoreFromUnsafeCache} */
2023
2030
  (module);
2024
- for (let i = 0; i < dependencies.length; i++) {
2025
- const dependency = dependencies[i];
2031
+ for (const dependency of dependencies) {
2026
2032
  moduleGraph.setResolvedModule(
2027
2033
  connectOrigin ? originModule : null,
2028
2034
  dependency,
@@ -2038,8 +2044,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2038
2044
  }
2039
2045
  } else {
2040
2046
  applyFactoryResultDependencies();
2041
- for (let i = 0; i < dependencies.length; i++) {
2042
- const dependency = dependencies[i];
2047
+ for (const dependency of dependencies) {
2043
2048
  moduleGraph.setResolvedModule(
2044
2049
  connectOrigin ? originModule : null,
2045
2050
  dependency,
@@ -2356,6 +2361,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2356
2361
  */
2357
2362
  _addEntryItem(context, entry, target, options, callback) {
2358
2363
  const { name } = options;
2364
+ /** @type {EntryData | undefined} */
2359
2365
  let entryData =
2360
2366
  name !== undefined ? this.entries.get(name) : this.globalEntry;
2361
2367
  if (entryData === undefined) {
@@ -2443,8 +2449,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2443
2449
  */
2444
2450
  _rebuildModule(module, callback) {
2445
2451
  this.hooks.rebuildModule.call(module);
2446
- const oldDependencies = module.dependencies.slice();
2447
- const oldBlocks = module.blocks.slice();
2452
+ const oldDependencies = [...module.dependencies];
2453
+ const oldBlocks = [...module.blocks];
2448
2454
  module.invalidateBuild();
2449
2455
  this.buildQueue.invalidate(module);
2450
2456
  this.buildModule(module, err => {
@@ -2694,7 +2700,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2694
2700
  }
2695
2701
  if (module.blocks.length > 0) {
2696
2702
  blocks = [];
2697
- const queue = Array.from(module.blocks);
2703
+ const queue = [...module.blocks];
2698
2704
  for (const block of queue) {
2699
2705
  const chunkGroup = chunkGraph.getBlockChunkGroup(block);
2700
2706
  if (chunkGroup) {
@@ -2726,7 +2732,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2726
2732
  }
2727
2733
  }
2728
2734
  if (blocks !== undefined) {
2729
- const queue = Array.from(module.blocks);
2735
+ const queue = [...module.blocks];
2730
2736
  let i = 0;
2731
2737
  for (const block of queue) {
2732
2738
  const chunkGroup = chunkGraph.getBlockChunkGroup(block);
@@ -2784,7 +2790,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2784
2790
  this.factorizeQueue.clear();
2785
2791
  if (this.profile) {
2786
2792
  this.logger.time("finish module profiles");
2793
+
2787
2794
  const ParallelismFactorCalculator = require("./util/ParallelismFactorCalculator");
2795
+
2788
2796
  const p = new ParallelismFactorCalculator();
2789
2797
  const moduleGraph = this.moduleGraph;
2790
2798
  /** @type {Map<Module, ModuleProfile>} */
@@ -3435,18 +3443,13 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3435
3443
  */
3436
3444
  reportDependencyErrorsAndWarnings(module, blocks) {
3437
3445
  let hasProblems = false;
3438
- for (let indexBlock = 0; indexBlock < blocks.length; indexBlock++) {
3439
- const block = blocks[indexBlock];
3446
+ for (const block of blocks) {
3440
3447
  const dependencies = block.dependencies;
3441
3448
 
3442
- for (let indexDep = 0; indexDep < dependencies.length; indexDep++) {
3443
- const d = dependencies[indexDep];
3444
-
3449
+ for (const d of dependencies) {
3445
3450
  const warnings = d.getWarnings(this.moduleGraph);
3446
3451
  if (warnings) {
3447
- for (let indexWar = 0; indexWar < warnings.length; indexWar++) {
3448
- const w = warnings[indexWar];
3449
-
3452
+ for (const w of warnings) {
3450
3453
  const warning = new ModuleDependencyWarning(module, w, d.loc);
3451
3454
  this.warnings.push(warning);
3452
3455
  hasProblems = true;
@@ -3454,9 +3457,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3454
3457
  }
3455
3458
  const errors = d.getErrors(this.moduleGraph);
3456
3459
  if (errors) {
3457
- for (let indexErr = 0; indexErr < errors.length; indexErr++) {
3458
- const e = errors[indexErr];
3459
-
3460
+ for (const e of errors) {
3460
3461
  const error = new ModuleDependencyError(module, e, d.loc);
3461
3462
  this.errors.push(error);
3462
3463
  hasProblems = true;
@@ -3464,8 +3465,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3464
3465
  }
3465
3466
  }
3466
3467
 
3467
- if (this.reportDependencyErrorsAndWarnings(module, block.blocks))
3468
+ if (this.reportDependencyErrorsAndWarnings(module, block.blocks)) {
3468
3469
  hasProblems = true;
3470
+ }
3469
3471
  }
3470
3472
  return hasProblems;
3471
3473
  }
@@ -3850,8 +3852,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3850
3852
  */
3851
3853
  addRuntimeModule(chunk, module, chunkGraph = this.chunkGraph) {
3852
3854
  // Deprecated ModuleGraph association
3853
- if (this._backCompat)
3855
+ if (this._backCompat) {
3854
3856
  ModuleGraph.setModuleGraphForModule(module, this.moduleGraph);
3857
+ }
3855
3858
 
3856
3859
  // add it to the list
3857
3860
  this.modules.add(module);
@@ -3923,7 +3926,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3923
3926
  }
3924
3927
  }
3925
3928
  const chunkGroup = new ChunkGroup(groupOptions);
3926
- if (module)
3929
+ if (module) {
3927
3930
  chunkGroup.addOrigin(
3928
3931
  module,
3929
3932
  /** @type {DependencyLocation} */
@@ -3931,6 +3934,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3931
3934
  /** @type {string} */
3932
3935
  (request)
3933
3936
  );
3937
+ }
3934
3938
  const chunk = this.addChunk(name);
3935
3939
 
3936
3940
  connectChunkGroupAndChunk(chunkGroup, chunk);
@@ -4000,8 +4004,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4000
4004
  }
4001
4005
  const chunk = new Chunk(name, this._backCompat);
4002
4006
  this.chunks.add(chunk);
4003
- if (this._backCompat)
4007
+ if (this._backCompat) {
4004
4008
  ChunkGraph.setChunkGraphForChunk(chunk, this.chunkGraph);
4009
+ }
4005
4010
  if (name) {
4006
4011
  this.namedChunks.set(name, chunk);
4007
4012
  }
@@ -4097,7 +4102,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4097
4102
 
4098
4103
  /**
4099
4104
  * @param {Module} module module relationship for removal
4100
- * @param {DependenciesBlockLike} block //TODO: good description
4105
+ * @param {DependenciesBlockLike} block dependencies block
4101
4106
  * @returns {void}
4102
4107
  */
4103
4108
  removeReasonsOfDependencyBlock(module, block) {
@@ -4161,16 +4166,14 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4161
4166
  };
4162
4167
 
4163
4168
  const blocks = block.blocks;
4164
- for (let indexBlock = 0; indexBlock < blocks.length; indexBlock++) {
4165
- const asyncBlock = blocks[indexBlock];
4169
+ for (const asyncBlock of blocks) {
4166
4170
  const chunkGroup =
4167
4171
  /** @type {ChunkGroup} */
4168
4172
  (this.chunkGraph.getBlockChunkGroup(asyncBlock));
4169
4173
  // Grab all chunks from the first Block's AsyncDepBlock
4170
4174
  const chunks = chunkGroup.chunks;
4171
4175
  // For each chunk in chunkGroup
4172
- for (let indexChunk = 0; indexChunk < chunks.length; indexChunk++) {
4173
- const iteratedChunk = chunks[indexChunk];
4176
+ for (const iteratedChunk of chunks) {
4174
4177
  chunkGroup.removeChunk(iteratedChunk);
4175
4178
  // Recurse
4176
4179
  this.removeChunkFromDependencies(block, iteratedChunk);
@@ -4211,13 +4214,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4211
4214
  }
4212
4215
 
4213
4216
  summarizeDependencies() {
4214
- for (
4215
- let indexChildren = 0;
4216
- indexChildren < this.children.length;
4217
- indexChildren++
4218
- ) {
4219
- const child = this.children[indexChildren];
4220
-
4217
+ for (const child of this.children) {
4221
4218
  this.fileDependencies.addAll(child.fileDependencies);
4222
4219
  this.contextDependencies.addAll(child.contextDependencies);
4223
4220
  this.missingDependencies.addAll(child.missingDependencies);
@@ -4383,16 +4380,21 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4383
4380
  /** @type {Chunk[]} */
4384
4381
  const unorderedRuntimeChunks = [];
4385
4382
  /** @type {Chunk[]} */
4386
- const otherChunks = [];
4383
+ const initialChunks = [];
4384
+ /** @type {Chunk[]} */
4385
+ const asyncChunks = [];
4387
4386
  for (const c of this.chunks) {
4388
4387
  if (c.hasRuntime()) {
4389
4388
  unorderedRuntimeChunks.push(c);
4389
+ } else if (c.canBeInitial()) {
4390
+ initialChunks.push(c);
4390
4391
  } else {
4391
- otherChunks.push(c);
4392
+ asyncChunks.push(c);
4392
4393
  }
4393
4394
  }
4394
4395
  unorderedRuntimeChunks.sort(byId);
4395
- otherChunks.sort(byId);
4396
+ initialChunks.sort(byId);
4397
+ asyncChunks.sort(byId);
4396
4398
 
4397
4399
  /** @typedef {{ chunk: Chunk, referencedBy: RuntimeChunkInfo[], remaining: number }} RuntimeChunkInfo */
4398
4400
  /** @type {Map<Chunk, RuntimeChunkInfo>} */
@@ -4407,7 +4409,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4407
4409
  let remaining = 0;
4408
4410
  for (const info of runtimeChunksMap.values()) {
4409
4411
  for (const other of new Set(
4410
- Array.from(info.chunk.getAllReferencedAsyncEntrypoints()).map(
4412
+ [...info.chunk.getAllReferencedAsyncEntrypoints()].map(
4411
4413
  e => e.chunks[e.chunks.length - 1]
4412
4414
  )
4413
4415
  )) {
@@ -4558,8 +4560,9 @@ This prevents using hashes of each other and should be avoided.`);
4558
4560
  }
4559
4561
  this.logger.timeAggregate("hashing: hash chunks");
4560
4562
  };
4561
- for (const chunk of otherChunks) processChunk(chunk);
4563
+ for (const chunk of asyncChunks) processChunk(chunk);
4562
4564
  for (const chunk of runtimeChunks) processChunk(chunk);
4565
+ for (const chunk of initialChunks) processChunk(chunk);
4563
4566
  if (errors.length > 0) {
4564
4567
  errors.sort(compareSelect(err => err.module, compareModulesByIdentifier));
4565
4568
  for (const error of errors) {
@@ -4783,7 +4786,9 @@ This prevents using hashes of each other and should be avoided.`);
4783
4786
  newEntry = entry.map(x => (x === file ? newFile : x));
4784
4787
  } else if (entry === file) {
4785
4788
  newEntry = newFile;
4786
- } else continue;
4789
+ } else {
4790
+ continue;
4791
+ }
4787
4792
  this.assetsInfo.set(name, {
4788
4793
  ...info,
4789
4794
  related: {
@@ -5274,7 +5279,7 @@ This prevents using hashes of each other and should be avoided.`);
5274
5279
  runtimeTemplate,
5275
5280
  errors,
5276
5281
  codeGenerationResults,
5277
- (err, codeGenerated) => {
5282
+ (err, _codeGenerated) => {
5278
5283
  callback(err);
5279
5284
  }
5280
5285
  );
@@ -5511,6 +5516,7 @@ This prevents using hashes of each other and should be avoided.`);
5511
5516
  (moduleArgumentsMap.get(runtimeModule))
5512
5517
  );
5513
5518
  }
5519
+
5514
5520
  exports = __webpack_require__(module.identifier());
5515
5521
  } catch (execErr) {
5516
5522
  const { message, stack, module } =
@@ -5610,7 +5616,7 @@ Compilation.prototype.factorizeModule = /**
5610
5616
  (options: FactorizeModuleOptions & { factoryResult?: false }, callback: ModuleCallback): void;
5611
5617
  (options: FactorizeModuleOptions & { factoryResult: true }, callback: ModuleFactoryResultCallback): void;
5612
5618
  }} */ (
5613
- function (options, callback) {
5619
+ function factorizeModule(options, callback) {
5614
5620
  this.factorizeQueue.add(options, /** @type {TODO} */ (callback));
5615
5621
  }
5616
5622
  );
@@ -5640,7 +5646,7 @@ Object.defineProperty(compilationPrototype, "cache", {
5640
5646
  * @this {Compilation} the compilation
5641
5647
  * @returns {Cache} the cache
5642
5648
  */
5643
- function () {
5649
+ function cache() {
5644
5650
  return this.compiler.cache;
5645
5651
  },
5646
5652
  "Compilation.cache was removed in favor of Compilation.getCache()",
@@ -5648,9 +5654,9 @@ Object.defineProperty(compilationPrototype, "cache", {
5648
5654
  ),
5649
5655
  set: util.deprecate(
5650
5656
  /**
5651
- * @param {EXPECTED_ANY} v value
5657
+ * @param {EXPECTED_ANY} _v value
5652
5658
  */
5653
- v => {},
5659
+ _v => {},
5654
5660
  "Compilation.cache was removed in favor of Compilation.getCache()",
5655
5661
  "DEP_WEBPACK_COMPILATION_CACHE"
5656
5662
  )
package/lib/Compiler.js CHANGED
@@ -8,13 +8,12 @@
8
8
  const parseJson = require("json-parse-even-better-errors");
9
9
  const asyncLib = require("neo-async");
10
10
  const {
11
- SyncHook,
12
- SyncBailHook,
13
11
  AsyncParallelHook,
14
- AsyncSeriesHook
12
+ AsyncSeriesHook,
13
+ SyncBailHook,
14
+ SyncHook
15
15
  } = require("tapable");
16
16
  const { SizeOnlySource } = require("webpack-sources");
17
- const webpack = require(".");
18
17
  const Cache = require("./Cache");
19
18
  const CacheFacade = require("./CacheFacade");
20
19
  const ChunkGraph = require("./ChunkGraph");
@@ -29,9 +28,10 @@ const Stats = require("./Stats");
29
28
  const Watching = require("./Watching");
30
29
  const WebpackError = require("./WebpackError");
31
30
  const { Logger } = require("./logging/Logger");
32
- const { join, dirname, mkdirp } = require("./util/fs");
31
+ const { dirname, join, mkdirp } = require("./util/fs");
33
32
  const { makePathsRelative } = require("./util/identifier");
34
33
  const { isSourceEqual } = require("./util/source");
34
+ const webpack = require(".");
35
35
 
36
36
  /** @typedef {import("webpack-sources").Source} Source */
37
37
  /** @typedef {import("../declarations/WebpackOptions").EntryNormalized} Entry */
@@ -42,10 +42,19 @@ const { isSourceEqual } = require("./util/source");
42
42
  /** @typedef {import("./Chunk")} Chunk */
43
43
  /** @typedef {import("./ChunkGraph").ModuleId} ModuleId */
44
44
  /** @typedef {import("./Dependency")} Dependency */
45
+ /** @typedef {import("./HotModuleReplacementPlugin").ChunkHashes} ChunkHashes */
46
+ /** @typedef {import("./HotModuleReplacementPlugin").ChunkModuleHashes} ChunkModuleHashes */
47
+ /** @typedef {import("./HotModuleReplacementPlugin").ChunkModuleIds} ChunkModuleIds */
48
+ /** @typedef {import("./HotModuleReplacementPlugin").ChunkRuntime} ChunkRuntime */
49
+ /** @typedef {import("./HotModuleReplacementPlugin").FullHashChunkModuleHashes} FullHashChunkModuleHashes */
50
+ /** @typedef {import("./HotModuleReplacementPlugin").HotIndex} HotIndex */
45
51
  /** @typedef {import("./Module")} Module */
46
52
  /** @typedef {import("./Module").BuildInfo} BuildInfo */
53
+ /** @typedef {import("./RecordIdsPlugin").RecordsChunks} RecordsChunks */
54
+ /** @typedef {import("./RecordIdsPlugin").RecordsModules} RecordsModules */
47
55
  /** @typedef {import("./config/target").PlatformTargetProperties} PlatformTargetProperties */
48
56
  /** @typedef {import("./logging/createConsoleLogger").LoggingFunction} LoggingFunction */
57
+ /** @typedef {import("./optimize/AggressiveSplittingPlugin").SplitData} SplitData */
49
58
  /** @typedef {import("./util/fs").IStats} IStats */
50
59
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
51
60
  /** @typedef {import("./util/fs").IntermediateFileSystem} IntermediateFileSystem */
@@ -80,6 +89,22 @@ const { isSourceEqual } = require("./util/source");
80
89
  * @param {Compilation=} compilation
81
90
  */
82
91
 
92
+ /**
93
+ * @typedef {object} KnownRecords
94
+ * @property {SplitData[]=} aggressiveSplits
95
+ * @property {RecordsChunks=} chunks
96
+ * @property {RecordsModules=} modules
97
+ * @property {string=} hash
98
+ * @property {HotIndex=} hotIndex
99
+ * @property {FullHashChunkModuleHashes=} fullHashChunkModuleHashes
100
+ * @property {ChunkModuleHashes=} chunkModuleHashes
101
+ * @property {ChunkHashes=} chunkHashes
102
+ * @property {ChunkRuntime=} chunkRuntime
103
+ * @property {ChunkModuleIds=} chunkModuleIds
104
+ */
105
+
106
+ /** @typedef {KnownRecords & Record<string, KnownRecords[]> & Record<string, EXPECTED_ANY>} Records */
107
+
83
108
  /**
84
109
  * @typedef {object} AssetEmittedInfo
85
110
  * @property {Buffer} content
@@ -238,11 +263,11 @@ class Compiler {
238
263
  /** @type {WatchFileSystem | null} */
239
264
  this.watchFileSystem = null;
240
265
 
241
- /** @type {string|null} */
266
+ /** @type {string | null} */
242
267
  this.recordsInputPath = null;
243
- /** @type {string|null} */
268
+ /** @type {string | null} */
244
269
  this.recordsOutputPath = null;
245
- /** @type {Record<string, TODO>} */
270
+ /** @type {Records} */
246
271
  this.records = {};
247
272
  /** @type {Set<string | RegExp>} */
248
273
  this.managedPaths = new Set();
@@ -1075,8 +1100,10 @@ ${other}`);
1075
1100
  };
1076
1101
 
1077
1102
  const recordsOutputPathDirectory = dirname(
1078
- /** @type {OutputFileSystem} */ (this.outputFileSystem),
1079
- /** @type {string} */ (this.recordsOutputPath)
1103
+ /** @type {OutputFileSystem} */
1104
+ (this.outputFileSystem),
1105
+ /** @type {string} */
1106
+ (this.recordsOutputPath)
1080
1107
  );
1081
1108
  if (!recordsOutputPathDirectory) {
1082
1109
  return writeFile();
@@ -1140,7 +1167,7 @@ ${other}`);
1140
1167
 
1141
1168
  try {
1142
1169
  this.records = parseJson(
1143
- /** @type {Buffer} */ (content).toString("utf-8")
1170
+ /** @type {Buffer} */ (content).toString("utf8")
1144
1171
  );
1145
1172
  } catch (parseErr) {
1146
1173
  return callback(
@@ -1201,7 +1228,9 @@ ${other}`);
1201
1228
  this.records[relativeCompilerName] = [];
1202
1229
  }
1203
1230
  if (this.records[relativeCompilerName][compilerIndex]) {
1204
- childCompiler.records = this.records[relativeCompilerName][compilerIndex];
1231
+ childCompiler.records =
1232
+ /** @type {Records} */
1233
+ (this.records[relativeCompilerName][compilerIndex]);
1205
1234
  } else {
1206
1235
  this.records[relativeCompilerName].push((childCompiler.records = {}));
1207
1236
  }
@@ -1231,11 +1260,12 @@ ${other}`);
1231
1260
  childCompiler.hooks[
1232
1261
  /** @type {keyof Compiler["hooks"]} */
1233
1262
  (name)
1234
- ].taps =
1235
- this.hooks[
1263
+ ].taps = [
1264
+ ...this.hooks[
1236
1265
  /** @type {keyof Compiler["hooks"]} */
1237
1266
  (name)
1238
- ].taps.slice();
1267
+ ].taps
1268
+ ];
1239
1269
  }
1240
1270
  }
1241
1271
 
@@ -1361,7 +1391,7 @@ ${other}`);
1361
1391
  close(callback) {
1362
1392
  if (this.watching) {
1363
1393
  // When there is still an active watching, close this first
1364
- this.watching.close(err => {
1394
+ this.watching.close(_err => {
1365
1395
  this.close(callback);
1366
1396
  });
1367
1397
  return;