webpack 5.104.1 → 5.105.1

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 (323) hide show
  1. package/README.md +2 -2
  2. package/bin/webpack.js +6 -3
  3. package/lib/APIPlugin.js +85 -15
  4. package/lib/AbstractMethodError.js +1 -0
  5. package/lib/AsyncDependenciesBlock.js +17 -2
  6. package/lib/AsyncDependencyToInitialChunkError.js +3 -0
  7. package/lib/AutomaticPrefetchPlugin.js +1 -1
  8. package/lib/BannerPlugin.js +5 -1
  9. package/lib/CacheFacade.js +2 -2
  10. package/lib/CaseSensitiveModulesWarning.js +1 -0
  11. package/lib/Chunk.js +9 -5
  12. package/lib/ChunkGraph.js +30 -9
  13. package/lib/ChunkGroup.js +6 -3
  14. package/lib/ChunkRenderError.js +9 -2
  15. package/lib/CleanPlugin.js +4 -1
  16. package/lib/CodeGenerationError.js +7 -1
  17. package/lib/CodeGenerationResults.js +10 -3
  18. package/lib/CommentCompilationWarning.js +2 -1
  19. package/lib/Compilation.js +284 -236
  20. package/lib/Compiler.js +4 -3
  21. package/lib/ConcatenationScope.js +2 -1
  22. package/lib/ConcurrentCompilationError.js +3 -3
  23. package/lib/ContextModule.js +248 -111
  24. package/lib/ContextModuleFactory.js +14 -2
  25. package/lib/DefinePlugin.js +15 -8
  26. package/lib/DelegatedModule.js +6 -0
  27. package/lib/DelegatedModuleFactoryPlugin.js +2 -0
  28. package/lib/Dependency.js +6 -1
  29. package/lib/DependencyTemplates.js +3 -2
  30. package/lib/DllModule.js +2 -0
  31. package/lib/DllReferencePlugin.js +1 -0
  32. package/lib/DotenvPlugin.js +11 -5
  33. package/lib/DynamicEntryPlugin.js +8 -1
  34. package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
  35. package/lib/EvalSourceMapDevToolPlugin.js +17 -13
  36. package/lib/ExportsInfo.js +8 -4
  37. package/lib/ExternalModule.js +16 -0
  38. package/lib/ExternalModuleFactoryPlugin.js +9 -2
  39. package/lib/ExternalsPlugin.js +2 -1
  40. package/lib/FalseIIFEUmdWarning.js +1 -0
  41. package/lib/FileSystemInfo.js +49 -25
  42. package/lib/FlagDependencyExportsPlugin.js +8 -1
  43. package/lib/FlagDependencyUsagePlugin.js +9 -7
  44. package/lib/HarmonyLinkingError.js +1 -0
  45. package/lib/HookWebpackError.js +2 -0
  46. package/lib/HotModuleReplacementPlugin.js +16 -2
  47. package/lib/IgnoreWarningsPlugin.js +5 -2
  48. package/lib/InitFragment.js +1 -0
  49. package/lib/InvalidDependenciesModuleWarning.js +1 -0
  50. package/lib/LibManifestPlugin.js +1 -0
  51. package/lib/ManifestPlugin.js +8 -1
  52. package/lib/Module.js +7 -4
  53. package/lib/ModuleBuildError.js +3 -1
  54. package/lib/ModuleDependencyError.js +1 -0
  55. package/lib/ModuleDependencyWarning.js +1 -0
  56. package/lib/ModuleError.js +4 -1
  57. package/lib/ModuleFilenameHelpers.js +4 -2
  58. package/lib/ModuleGraph.js +3 -0
  59. package/lib/ModuleGraphConnection.js +10 -1
  60. package/lib/ModuleHashingError.js +2 -0
  61. package/lib/ModuleInfoHeaderPlugin.js +6 -1
  62. package/lib/ModuleNotFoundError.js +1 -0
  63. package/lib/ModuleParseError.js +5 -1
  64. package/lib/ModuleProfile.js +1 -1
  65. package/lib/ModuleRestoreError.js +2 -0
  66. package/lib/ModuleSourceTypeConstants.js +1 -11
  67. package/lib/ModuleStoreError.js +2 -0
  68. package/lib/ModuleWarning.js +3 -1
  69. package/lib/MultiCompiler.js +11 -7
  70. package/lib/MultiWatching.js +2 -2
  71. package/lib/NoModeWarning.js +1 -0
  72. package/lib/NodeStuffInWebError.js +1 -0
  73. package/lib/NormalModule.js +28 -5
  74. package/lib/NormalModuleFactory.js +20 -4
  75. package/lib/OptionsApply.js +3 -1
  76. package/lib/ProgressPlugin.js +4 -0
  77. package/lib/RawModule.js +2 -0
  78. package/lib/RuntimeModule.js +10 -0
  79. package/lib/RuntimePlugin.js +7 -9
  80. package/lib/RuntimeTemplate.js +14 -7
  81. package/lib/SourceMapDevToolPlugin.js +30 -23
  82. package/lib/Template.js +10 -5
  83. package/lib/TemplatedPathPlugin.js +4 -2
  84. package/lib/UnhandledSchemeError.js +1 -0
  85. package/lib/UnsupportedFeatureWarning.js +3 -0
  86. package/lib/WarnDeprecatedOptionPlugin.js +1 -0
  87. package/lib/WatchIgnorePlugin.js +1 -1
  88. package/lib/Watching.js +5 -0
  89. package/lib/WebpackError.js +4 -0
  90. package/lib/WebpackOptionsApply.js +61 -41
  91. package/lib/asset/AssetBytesGenerator.js +1 -0
  92. package/lib/asset/AssetGenerator.js +18 -3
  93. package/lib/asset/AssetModulesPlugin.js +33 -2
  94. package/lib/asset/AssetParser.js +4 -0
  95. package/lib/asset/AssetSourceGenerator.js +1 -0
  96. package/lib/asset/RawDataUrlModule.js +4 -0
  97. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
  98. package/lib/buildChunkGraph.js +31 -2
  99. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  100. package/lib/cache/PackFileCacheStrategy.js +41 -8
  101. package/lib/cache/getLazyHashedEtag.js +13 -4
  102. package/lib/cache/mergeEtags.js +3 -1
  103. package/lib/cli.js +3 -1
  104. package/lib/config/defaults.js +65 -44
  105. package/lib/config/normalization.js +96 -0
  106. package/lib/container/ContainerEntryDependency.js +3 -0
  107. package/lib/container/ContainerEntryModule.js +7 -0
  108. package/lib/container/ContainerExposedDependency.js +1 -0
  109. package/lib/container/FallbackDependency.js +1 -0
  110. package/lib/container/FallbackItemDependency.js +1 -0
  111. package/lib/container/FallbackModule.js +4 -0
  112. package/lib/container/HoistContainerReferencesPlugin.js +6 -0
  113. package/lib/container/ModuleFederationPlugin.js +1 -1
  114. package/lib/container/RemoteModule.js +24 -0
  115. package/lib/css/CssGenerator.js +31 -4
  116. package/lib/css/CssModulesPlugin.js +26 -30
  117. package/lib/css/CssParser.js +12 -9
  118. package/lib/debug/ProfilingPlugin.js +1 -0
  119. package/lib/dependencies/AMDDefineDependency.js +3 -1
  120. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -0
  121. package/lib/dependencies/AMDPlugin.js +1 -1
  122. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +7 -1
  123. package/lib/dependencies/CachedConstDependency.js +1 -0
  124. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -0
  125. package/lib/dependencies/CommonJsExportRequireDependency.js +1 -0
  126. package/lib/dependencies/CommonJsFullRequireDependency.js +2 -0
  127. package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -0
  128. package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
  129. package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -0
  130. package/lib/dependencies/ConstDependency.js +1 -0
  131. package/lib/dependencies/ContextDependencyHelpers.js +11 -4
  132. package/lib/dependencies/ContextElementDependency.js +1 -0
  133. package/lib/dependencies/CriticalDependencyWarning.js +1 -0
  134. package/lib/dependencies/CssIcssExportDependency.js +7 -4
  135. package/lib/dependencies/CssIcssSymbolDependency.js +1 -0
  136. package/lib/dependencies/CssUrlDependency.js +2 -3
  137. package/lib/dependencies/ExternalModuleInitFragment.js +4 -1
  138. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +0 -9
  139. package/lib/dependencies/HarmonyAcceptDependency.js +3 -0
  140. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -1
  141. package/lib/dependencies/HarmonyExportExpressionDependency.js +4 -0
  142. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +8 -1
  143. package/lib/dependencies/HarmonyExportInitFragment.js +17 -3
  144. package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
  145. package/lib/dependencies/HarmonyImportDependency.js +1 -1
  146. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +269 -5
  147. package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -3
  148. package/lib/dependencies/ImportDependency.js +1 -0
  149. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  150. package/lib/dependencies/ImportMetaPlugin.js +53 -11
  151. package/lib/dependencies/ImportParserPlugin.js +7 -12
  152. package/lib/dependencies/LoaderPlugin.js +3 -0
  153. package/lib/dependencies/ModuleDecoratorDependency.js +1 -0
  154. package/lib/dependencies/ModuleDependency.js +1 -0
  155. package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
  156. package/lib/dependencies/ProvidedDependency.js +1 -0
  157. package/lib/dependencies/RequireContextPlugin.js +1 -0
  158. package/lib/dependencies/RequireEnsureDependenciesBlock.js +1 -1
  159. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +7 -2
  160. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -0
  161. package/lib/dependencies/WorkerDependency.js +9 -3
  162. package/lib/dependencies/WorkerPlugin.js +1 -0
  163. package/lib/dependencies/getFunctionExpression.js +3 -1
  164. package/lib/electron/ElectronTargetPlugin.js +3 -1
  165. package/lib/errors/BuildCycleError.js +4 -1
  166. package/lib/esm/ModuleChunkFormatPlugin.js +6 -4
  167. package/lib/esm/ModuleChunkLoadingPlugin.js +1 -0
  168. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -0
  169. package/lib/hmr/LazyCompilationPlugin.js +5 -0
  170. package/lib/hmr/lazyCompilationBackend.js +3 -2
  171. package/lib/ids/ChunkModuleIdRangePlugin.js +9 -7
  172. package/lib/ids/DeterministicChunkIdsPlugin.js +1 -0
  173. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -0
  174. package/lib/ids/HashedModuleIdsPlugin.js +3 -8
  175. package/lib/ids/IdHelpers.js +10 -8
  176. package/lib/ids/NamedChunkIdsPlugin.js +7 -5
  177. package/lib/ids/NamedModuleIdsPlugin.js +1 -0
  178. package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
  179. package/lib/ids/OccurrenceModuleIdsPlugin.js +18 -10
  180. package/lib/ids/SyncModuleIdsPlugin.js +30 -20
  181. package/lib/index.js +2 -2
  182. package/lib/javascript/BasicEvaluatedExpression.js +1 -0
  183. package/lib/javascript/EnableChunkLoadingPlugin.js +5 -2
  184. package/lib/javascript/JavascriptModulesPlugin.js +29 -8
  185. package/lib/javascript/JavascriptParser.js +47 -14
  186. package/lib/json/JsonGenerator.js +1 -0
  187. package/lib/json/JsonParser.js +9 -2
  188. package/lib/library/AbstractLibraryPlugin.js +4 -1
  189. package/lib/library/AmdLibraryPlugin.js +2 -1
  190. package/lib/library/AssignLibraryPlugin.js +6 -2
  191. package/lib/library/EnableLibraryPlugin.js +1 -0
  192. package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
  193. package/lib/library/JsonpLibraryPlugin.js +1 -1
  194. package/lib/library/ModuleLibraryPlugin.js +130 -13
  195. package/lib/library/SystemLibraryPlugin.js +4 -1
  196. package/lib/library/UmdLibraryPlugin.js +4 -3
  197. package/lib/logging/Logger.js +9 -5
  198. package/lib/logging/createConsoleLogger.js +4 -0
  199. package/lib/logging/truncateArgs.js +1 -1
  200. package/lib/node/CommonJsChunkLoadingPlugin.js +6 -4
  201. package/lib/node/NodeEnvironmentPlugin.js +1 -0
  202. package/lib/node/NodeTargetPlugin.js +10 -1
  203. package/lib/node/NodeTemplatePlugin.js +1 -0
  204. package/lib/node/NodeWatchFileSystem.js +6 -0
  205. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -0
  206. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
  207. package/lib/node/ReadFileCompileWasmPlugin.js +1 -0
  208. package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -0
  209. package/lib/node/nodeConsole.js +18 -1
  210. package/lib/optimize/AggressiveMergingPlugin.js +2 -1
  211. package/lib/optimize/AggressiveSplittingPlugin.js +15 -6
  212. package/lib/optimize/ConcatenatedModule.js +33 -19
  213. package/lib/optimize/FlagIncludedChunksPlugin.js +11 -1
  214. package/lib/optimize/InnerGraph.js +5 -3
  215. package/lib/optimize/InnerGraphPlugin.js +25 -25
  216. package/lib/optimize/LimitChunkCountPlugin.js +3 -2
  217. package/lib/optimize/MangleExportsPlugin.js +14 -2
  218. package/lib/optimize/MergeDuplicateChunksPlugin.js +5 -1
  219. package/lib/optimize/MinChunkSizePlugin.js +5 -2
  220. package/lib/optimize/ModuleConcatenationPlugin.js +19 -4
  221. package/lib/optimize/RealContentHashPlugin.js +37 -27
  222. package/lib/optimize/RemoveParentModulesPlugin.js +12 -3
  223. package/lib/optimize/RuntimeChunkPlugin.js +3 -5
  224. package/lib/optimize/SideEffectsFlagPlugin.js +3 -0
  225. package/lib/optimize/SplitChunksPlugin.js +23 -5
  226. package/lib/performance/AssetsOverSizeLimitWarning.js +6 -2
  227. package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -2
  228. package/lib/performance/NoAsyncChunksWarning.js +1 -0
  229. package/lib/performance/SizeLimitsPlugin.js +6 -6
  230. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +2 -0
  231. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -1
  232. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -0
  233. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -0
  234. package/lib/rules/BasicEffectRulePlugin.js +2 -0
  235. package/lib/rules/BasicMatcherRulePlugin.js +3 -0
  236. package/lib/rules/ObjectMatcherRulePlugin.js +5 -1
  237. package/lib/rules/RuleSetCompiler.js +6 -0
  238. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
  239. package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
  240. package/lib/runtime/CompatRuntimeModule.js +1 -0
  241. package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
  242. package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -0
  243. package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
  244. package/lib/runtime/GetMainFilenameRuntimeModule.js +2 -0
  245. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
  246. package/lib/runtime/LoadScriptRuntimeModule.js +2 -0
  247. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +16 -32
  248. package/lib/runtime/PublicPathRuntimeModule.js +1 -0
  249. package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -0
  250. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
  251. package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
  252. package/lib/schemes/HttpUriPlugin.js +39 -20
  253. package/lib/schemes/VirtualUrlPlugin.js +28 -2
  254. package/lib/serialization/BinaryMiddleware.js +4 -0
  255. package/lib/serialization/FileMiddleware.js +9 -4
  256. package/lib/serialization/ObjectMiddleware.js +34 -11
  257. package/lib/serialization/PlainObjectSerializer.js +2 -0
  258. package/lib/sharing/ConsumeSharedModule.js +60 -0
  259. package/lib/sharing/ConsumeSharedPlugin.js +5 -4
  260. package/lib/sharing/ProvideSharedModule.js +4 -0
  261. package/lib/sharing/ProvideSharedPlugin.js +24 -25
  262. package/lib/sharing/resolveMatchedConfigs.js +2 -2
  263. package/lib/sharing/utils.js +8 -6
  264. package/lib/stats/DefaultStatsFactoryPlugin.js +20 -12
  265. package/lib/stats/DefaultStatsPrinterPlugin.js +6 -5
  266. package/lib/stats/StatsFactory.js +2 -2
  267. package/lib/url/URLParserPlugin.js +5 -3
  268. package/lib/util/AppendOnlyStackedSet.js +57 -0
  269. package/lib/util/Hash.js +1 -0
  270. package/lib/util/IterableHelpers.js +1 -0
  271. package/lib/util/LazyBucketSortedSet.js +1 -0
  272. package/lib/util/LazySet.js +1 -0
  273. package/lib/util/ParallelismFactorCalculator.js +1 -0
  274. package/lib/util/SortableSet.js +1 -0
  275. package/lib/util/StringXor.js +1 -0
  276. package/lib/util/binarySearchBounds.js +15 -8
  277. package/lib/util/chainedImports.js +1 -1
  278. package/lib/util/cleverMerge.js +6 -1
  279. package/lib/util/comparators.js +21 -1
  280. package/lib/util/compileBooleanMatcher.js +3 -3
  281. package/lib/util/concatenate.js +3 -2
  282. package/lib/util/conventions.js +3 -2
  283. package/lib/util/deterministicGrouping.js +13 -1
  284. package/lib/util/extractSourceMap.js +12 -13
  285. package/lib/util/fs.js +15 -19
  286. package/lib/util/hash/BatchedHash.js +4 -0
  287. package/lib/util/hash/BulkUpdateHash.js +8 -1
  288. package/lib/util/hash/hash-digest.js +1 -0
  289. package/lib/util/hash/wasm-hash.js +18 -2
  290. package/lib/util/identifier.js +7 -2
  291. package/lib/util/magicComment.js +1 -1
  292. package/lib/util/propertyName.js +1 -1
  293. package/lib/util/registerExternalSerializer.js +1 -0
  294. package/lib/util/runtime.js +15 -1
  295. package/lib/util/semver.js +1 -0
  296. package/lib/util/serialization.js +2 -2
  297. package/lib/wasm/EnableWasmLoadingPlugin.js +2 -0
  298. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +11 -3
  299. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -0
  300. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -2
  301. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -1
  302. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +3 -0
  303. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
  304. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +7 -3
  305. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -2
  306. package/lib/wasm-sync/WebAssemblyParser.js +3 -1
  307. package/lib/web/FetchCompileWasmPlugin.js +1 -0
  308. package/lib/web/JsonpChunkLoadingPlugin.js +1 -0
  309. package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
  310. package/lib/webpack.js +16 -4
  311. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  312. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -0
  313. package/package.json +33 -36
  314. package/schemas/WebpackOptions.check.js +1 -1
  315. package/schemas/WebpackOptions.json +121 -55
  316. package/schemas/plugins/BannerPlugin.json +2 -2
  317. package/schemas/plugins/IgnorePlugin.json +1 -1
  318. package/schemas/plugins/ManifestPlugin.json +3 -3
  319. package/schemas/plugins/ProgressPlugin.json +1 -1
  320. package/schemas/plugins/SourceMapDevToolPlugin.json +2 -2
  321. package/schemas/plugins/schemes/HttpUriPlugin.json +1 -1
  322. package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
  323. package/types.d.ts +440 -137
@@ -286,7 +286,7 @@ const { isSourceEqual } = require("./util/source");
286
286
 
287
287
  /**
288
288
  * @typedef {object} LogEntry
289
- * @property {string} type
289
+ * @property {keyof LogType} type
290
290
  * @property {EXPECTED_ANY[]=} args
291
291
  * @property {number} time
292
292
  * @property {string[]=} trace
@@ -403,11 +403,11 @@ const { isSourceEqual } = require("./util/source");
403
403
 
404
404
  /** @typedef {KnownCreateStatsOptionsContext & Record<string, EXPECTED_ANY>} CreateStatsOptionsContext */
405
405
 
406
- /** @typedef {{ module: Module, hash: string, runtime: RuntimeSpec, runtimes: RuntimeSpec[]}} CodeGenerationJob */
406
+ /** @typedef {{ module: Module, hash: string, runtime: RuntimeSpec, runtimes: RuntimeSpec[] }} CodeGenerationJob */
407
407
 
408
408
  /** @typedef {CodeGenerationJob[]} CodeGenerationJobs */
409
409
 
410
- /** @typedef {{javascript: ModuleTemplate}} ModuleTemplates */
410
+ /** @typedef {{ javascript: ModuleTemplate }} ModuleTemplates */
411
411
 
412
412
  /** @typedef {Set<Module>} NotCodeGeneratedModules */
413
413
 
@@ -491,6 +491,8 @@ const compareErrors = concatComparators(byModule, byLocation, byMessage);
491
491
  * @typedef {Module & { restoreFromUnsafeCache?: (unsafeCacheData: UnsafeCacheData, moduleFactory: ModuleFactory, compilationParams: CompilationParams) => void }} ModuleWithRestoreFromUnsafeCache
492
492
  */
493
493
 
494
+ /** @typedef {(module: Module) => boolean} UnsafeCachePredicate */
495
+
494
496
  /** @type {WeakMap<Dependency, ModuleWithRestoreFromUnsafeCache | null>} */
495
497
  const unsafeCacheDependencies = new WeakMap();
496
498
 
@@ -514,22 +516,25 @@ class Compilation {
514
516
  /** @type {AsyncSeriesHook<[CompilationAssets], ProcessAssetsAdditionalOptions>} */
515
517
  const processAssetsHook = new AsyncSeriesHook(["assets"]);
516
518
 
519
+ /** @type {Set<string>} */
517
520
  let savedAssets = new Set();
518
521
  /**
519
522
  * @param {CompilationAssets} assets assets
520
523
  * @returns {CompilationAssets} new assets
521
524
  */
522
525
  const popNewAssets = (assets) => {
526
+ /** @type {undefined | CompilationAssets} */
523
527
  let newAssets;
524
528
  for (const file of Object.keys(assets)) {
525
529
  if (savedAssets.has(file)) continue;
526
530
  if (newAssets === undefined) {
527
531
  newAssets = Object.create(null);
528
532
  }
529
- newAssets[file] = assets[file];
533
+ /** @type {CompilationAssets} */
534
+ (newAssets)[file] = assets[file];
530
535
  savedAssets.add(file);
531
536
  }
532
- return newAssets;
537
+ return /** @type {CompilationAssets} */ (newAssets);
533
538
  };
534
539
  processAssetsHook.intercept({
535
540
  name: "Compilation",
@@ -1257,7 +1262,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1257
1262
  this._codeGenerationCache = this.getCache("Compilation/codeGeneration");
1258
1263
 
1259
1264
  const unsafeCache = options.module.unsafeCache;
1265
+ /** @type {boolean} */
1260
1266
  this._unsafeCache = Boolean(unsafeCache);
1267
+ /** @type {UnsafeCachePredicate} */
1261
1268
  this._unsafeCachePredicate =
1262
1269
  typeof unsafeCache === "function" ? unsafeCache : () => true;
1263
1270
  }
@@ -1347,6 +1354,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1347
1354
  );
1348
1355
  }
1349
1356
  }
1357
+ /** @type {LogEntry["trace"]} */
1350
1358
  let trace;
1351
1359
  switch (type) {
1352
1360
  case LogType.warn:
@@ -1519,7 +1527,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1519
1527
  /**
1520
1528
  * Attempts to search for a module by its identifier
1521
1529
  * @param {string} identifier identifier (usually path) for module
1522
- * @returns {Module|undefined} attempt to search for module and return it, else undefined
1530
+ * @returns {Module | undefined} attempt to search for module and return it, else undefined
1523
1531
  */
1524
1532
  findModule(identifier) {
1525
1533
  return this._modules.get(identifier);
@@ -2292,6 +2300,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2292
2300
  (originModule)
2293
2301
  );
2294
2302
  if (creatingModuleDuringBuildSet === undefined) {
2303
+ /** @type {Set<Module>} */
2295
2304
  creatingModuleDuringBuildSet = new Set();
2296
2305
  this.creatingModuleDuringBuild.set(
2297
2306
  /** @type {Module} */
@@ -2598,7 +2607,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2598
2607
  this.moduleGraph.setModuleMemCaches(this.moduleMemCaches);
2599
2608
  }
2600
2609
  const { moduleGraph, moduleMemCaches } = this;
2610
+ /** @type {Set<Module>} */
2601
2611
  const affectedModules = new Set();
2612
+ /** @type {Set<Module>} */
2602
2613
  const infectedModules = new Set();
2603
2614
  let statNew = 0;
2604
2615
  let statChanged = 0;
@@ -2714,6 +2725,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2714
2725
  }
2715
2726
  return affected;
2716
2727
  };
2728
+ /** @type {Set<Module>} */
2717
2729
  const directOnlyInfectedModules = new Set();
2718
2730
  for (const module of infectedModules) {
2719
2731
  for (const [
@@ -2732,6 +2744,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2732
2744
  }
2733
2745
  }
2734
2746
  for (const module of directOnlyInfectedModules) infectedModules.add(module);
2747
+ /** @type {Set<Module>} */
2735
2748
  const directOnlyAffectModules = new Set();
2736
2749
  for (const module of affectedModules) {
2737
2750
  for (const [
@@ -2994,6 +3007,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2994
3007
  * @param {(profile: ModuleProfile) => number} getParallelism get parallelism callback
2995
3008
  */
2996
3009
  const logByLoadersSummary = (category, getDuration, getParallelism) => {
3010
+ /** @type {Map<string, { module: Module, profile: ModuleProfile }[]>} */
2997
3011
  const map = new Map();
2998
3012
  for (const [module, profile] of modulesWithProfiles) {
2999
3013
  const list = getOrInsert(
@@ -3205,6 +3219,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
3205
3219
  this.chunkGroups.push(entrypoint);
3206
3220
  connectChunkGroupAndChunk(entrypoint, chunk);
3207
3221
 
3222
+ /** @type {Set<Module>} */
3208
3223
  const entryModules = new Set();
3209
3224
  for (const dep of [...this.globalEntry.dependencies, ...dependencies]) {
3210
3225
  entrypoint.addOrigin(
@@ -3252,6 +3267,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
3252
3267
  modulesList.push(module);
3253
3268
  }
3254
3269
  }
3270
+ /** @type {Set<Chunk>} */
3255
3271
  const runtimeChunks = new Set();
3256
3272
  outer: for (const [
3257
3273
  name,
@@ -3625,6 +3641,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3625
3641
  const runIteration = () => {
3626
3642
  /** @type {CodeGenerationJobs} */
3627
3643
  let delayedJobs = [];
3644
+ /** @type {Set<Module>} */
3628
3645
  let delayedModules = new Set();
3629
3646
  asyncLib.eachLimit(
3630
3647
  jobs,
@@ -3668,7 +3685,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3668
3685
  );
3669
3686
  },
3670
3687
  (err) => {
3671
- if (err) return callback(err);
3688
+ if (err) return callback(/** @type {WebpackError} */ (err));
3672
3689
  if (delayedJobs.length > 0) {
3673
3690
  if (delayedJobs.length === jobs.length) {
3674
3691
  return callback(
@@ -3746,6 +3763,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3746
3763
  );
3747
3764
  cache.get((err, cachedResult) => {
3748
3765
  if (err) return callback(/** @type {WebpackError} */ (err));
3766
+ /** @type {CodeGenerationResult} */
3749
3767
  let result;
3750
3768
  if (!cachedResult) {
3751
3769
  try {
@@ -3845,6 +3863,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3845
3863
  continue;
3846
3864
  }
3847
3865
  }
3866
+ /** @type {RuntimeRequirements} */
3848
3867
  let set;
3849
3868
  const runtimeRequirements =
3850
3869
  codeGenerationResults.getRuntimeRequirements(module, runtime);
@@ -4407,6 +4426,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4407
4426
  hashDigestLength,
4408
4427
  errors
4409
4428
  ) {
4429
+ /** @type {string} */
4410
4430
  let moduleHashDigest;
4411
4431
  try {
4412
4432
  const moduleHash = createHash(hashFunction);
@@ -4529,6 +4549,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4529
4549
  // If there are any references between chunks
4530
4550
  // make sure to follow these chains
4531
4551
  if (remaining > 0) {
4552
+ /** @type {Chunk[]} */
4532
4553
  const readyChunks = [];
4533
4554
  for (const chunk of runtimeChunks) {
4534
4555
  const hasFullHashModules =
@@ -4555,6 +4576,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4555
4576
  }
4556
4577
  // If there are still remaining references we have cycles and want to create a warning
4557
4578
  if (remaining > 0) {
4579
+ /** @type {RuntimeChunkInfo[]} */
4558
4580
  const circularRuntimeChunkInfo = [];
4559
4581
  for (const info of runtimeChunksMap.values()) {
4560
4582
  if (info.remaining !== 0) {
@@ -4574,6 +4596,7 @@ This prevents using hashes of each other and should be avoided.`);
4574
4596
  }
4575
4597
  this.logger.timeEnd("hashing: sort chunks");
4576
4598
 
4599
+ /** @type {Set<Chunk>} */
4577
4600
  const fullHashChunks = new Set();
4578
4601
  /** @type {CodeGenerationJobs} */
4579
4602
  const codeGenerationJobs = [];
@@ -4702,7 +4725,7 @@ This prevents using hashes of each other and should be avoided.`);
4702
4725
  ).hash = moduleHashDigest;
4703
4726
  }
4704
4727
  const chunkHash = createHash(hashFunction);
4705
- chunkHash.update(chunk.hash);
4728
+ chunkHash.update(/** @type {string} */ (chunk.hash));
4706
4729
  chunkHash.update(this.hash);
4707
4730
  const chunkHashDigest = chunkHash.digest(hashDigest);
4708
4731
  chunk.hash = chunkHashDigest;
@@ -4873,6 +4896,7 @@ This prevents using hashes of each other and should be avoided.`);
4873
4896
  const related = info.related;
4874
4897
  if (!related) continue;
4875
4898
  const entry = related[key];
4899
+ /** @type {string | string[]} */
4876
4900
  let newEntry;
4877
4901
  if (Array.isArray(entry)) {
4878
4902
  newEntry = entry.map((x) => (x === file ? newFile : x));
@@ -5026,8 +5050,9 @@ This prevents using hashes of each other and should be avoided.`);
5026
5050
  */
5027
5051
  createChunkAssets(callback) {
5028
5052
  const outputOptions = this.outputOptions;
5053
+ /** @type {WeakMap<Source, CachedSource>} */
5029
5054
  const cachedSourceMap = new WeakMap();
5030
- /** @type {Map<string, {hash: string, source: Source, chunk: Chunk}>} */
5055
+ /** @type {Map<string, { hash: string, source: Source, chunk: Chunk }>} */
5031
5056
  const alreadyWrittenFiles = new Map();
5032
5057
 
5033
5058
  asyncLib.forEachLimit(
@@ -5392,254 +5417,277 @@ This prevents using hashes of each other and should be avoided.`);
5392
5417
  };
5393
5418
 
5394
5419
  // Generate code for all aggregated modules
5395
- asyncLib.eachLimit(modules, 10, codeGen, (err) => {
5396
- if (err) return callback(err);
5397
- reportErrors();
5398
-
5399
- // for backward-compat temporary set the chunk graph
5400
- // TODO webpack 6
5401
- const old = this.chunkGraph;
5402
- this.chunkGraph = chunkGraph;
5403
- this.processRuntimeRequirements({
5404
- chunkGraph,
5405
- modules,
5406
- chunks,
5407
- codeGenerationResults,
5408
- chunkGraphEntries: chunks
5409
- });
5410
- this.chunkGraph = old;
5411
-
5412
- const runtimeModules =
5413
- chunkGraph.getChunkRuntimeModulesIterable(chunk);
5420
+ asyncLib.eachLimit(
5421
+ /** @type {import("neo-async").IterableCollection<Module>} */ (
5422
+ /** @type {unknown} */ (modules)
5423
+ ),
5424
+ 10,
5425
+ codeGen,
5426
+ (err) => {
5427
+ if (err) return callback(err);
5428
+ reportErrors();
5414
5429
 
5415
- // Hash runtime modules
5416
- for (const module of runtimeModules) {
5417
- modules.add(module);
5418
- this._createModuleHash(
5419
- module,
5430
+ // for backward-compat temporary set the chunk graph
5431
+ // TODO webpack 6
5432
+ const old = this.chunkGraph;
5433
+ this.chunkGraph = chunkGraph;
5434
+ this.processRuntimeRequirements({
5420
5435
  chunkGraph,
5421
- runtime,
5422
- hashFunction,
5423
- runtimeTemplate,
5424
- hashDigest,
5425
- hashDigestLength,
5426
- errors
5427
- );
5428
- }
5436
+ modules,
5437
+ chunks,
5438
+ codeGenerationResults,
5439
+ chunkGraphEntries: chunks
5440
+ });
5441
+ this.chunkGraph = old;
5429
5442
 
5430
- // Generate code for all runtime modules
5431
- asyncLib.eachLimit(runtimeModules, 10, codeGen, (err) => {
5432
- if (err) return callback(err);
5433
- reportErrors();
5443
+ const runtimeModules =
5444
+ chunkGraph.getChunkRuntimeModulesIterable(chunk);
5434
5445
 
5435
- /** @type {Map<Module, ExecuteModuleArgument>} */
5436
- const moduleArgumentsMap = new Map();
5437
- /** @type {Map<string, ExecuteModuleArgument>} */
5438
- const moduleArgumentsById = new Map();
5439
-
5440
- /** @type {ExecuteModuleResult["fileDependencies"]} */
5441
- const fileDependencies = new LazySet();
5442
- /** @type {ExecuteModuleResult["contextDependencies"]} */
5443
- const contextDependencies = new LazySet();
5444
- /** @type {ExecuteModuleResult["missingDependencies"]} */
5445
- const missingDependencies = new LazySet();
5446
- /** @type {ExecuteModuleResult["buildDependencies"]} */
5447
- const buildDependencies = new LazySet();
5448
-
5449
- /** @type {ExecuteModuleResult["assets"]} */
5450
- const assets = new Map();
5451
-
5452
- let cacheable = true;
5453
-
5454
- /** @type {ExecuteModuleContext} */
5455
- const context = {
5456
- assets,
5457
- __webpack_require__: undefined,
5458
- chunk,
5459
- chunkGraph
5460
- };
5446
+ // Hash runtime modules
5447
+ for (const module of runtimeModules) {
5448
+ modules.add(module);
5449
+ this._createModuleHash(
5450
+ module,
5451
+ chunkGraph,
5452
+ runtime,
5453
+ hashFunction,
5454
+ runtimeTemplate,
5455
+ hashDigest,
5456
+ hashDigestLength,
5457
+ errors
5458
+ );
5459
+ }
5461
5460
 
5462
- // Prepare execution
5461
+ // Generate code for all runtime modules
5463
5462
  asyncLib.eachLimit(
5464
- modules,
5463
+ /** @type {import("neo-async").IterableCollection<RuntimeModule>} */ (
5464
+ runtimeModules
5465
+ ),
5465
5466
  10,
5466
- (module, callback) => {
5467
- const codeGenerationResult = codeGenerationResults.get(
5468
- module,
5469
- runtime
5470
- );
5471
- /** @type {ExecuteModuleArgument} */
5472
- const moduleArgument = {
5473
- module,
5474
- codeGenerationResult,
5475
- moduleObject: undefined
5476
- };
5477
- moduleArgumentsMap.set(module, moduleArgument);
5478
- moduleArgumentsById.set(module.identifier(), moduleArgument);
5479
- module.addCacheDependencies(
5480
- fileDependencies,
5481
- contextDependencies,
5482
- missingDependencies,
5483
- buildDependencies
5484
- );
5485
- if (
5486
- /** @type {BuildInfo} */ (module.buildInfo).cacheable ===
5487
- false
5488
- ) {
5489
- cacheable = false;
5490
- }
5491
- if (module.buildInfo && module.buildInfo.assets) {
5492
- const { assets: moduleAssets, assetsInfo } = module.buildInfo;
5493
- for (const assetName of Object.keys(moduleAssets)) {
5494
- assets.set(assetName, {
5495
- source: moduleAssets[assetName],
5496
- info: assetsInfo ? assetsInfo.get(assetName) : undefined
5497
- });
5498
- }
5499
- }
5500
- this.hooks.prepareModuleExecution.callAsync(
5501
- moduleArgument,
5502
- context,
5503
- callback
5504
- );
5505
- },
5467
+ codeGen,
5506
5468
  (err) => {
5507
5469
  if (err) return callback(err);
5470
+ reportErrors();
5508
5471
 
5509
- /** @type {ExecuteModuleExports | undefined} */
5510
- let exports;
5511
- try {
5512
- const {
5513
- strictModuleErrorHandling,
5514
- strictModuleExceptionHandling
5515
- } = this.outputOptions;
5516
-
5517
- /** @type {WebpackRequire} */
5518
- const __webpack_require__ = (id) => {
5519
- const cached = moduleCache[id];
5520
- if (cached !== undefined) {
5521
- if (cached.error) throw cached.error;
5522
- return cached.exports;
5523
- }
5524
- const moduleArgument = moduleArgumentsById.get(id);
5525
- return __webpack_require_module__(
5526
- /** @type {ExecuteModuleArgument} */
5527
- (moduleArgument),
5528
- id
5529
- );
5530
- };
5531
- const interceptModuleExecution = (__webpack_require__[
5532
- /** @type {"i"} */
5533
- (
5534
- RuntimeGlobals.interceptModuleExecution.replace(
5535
- `${RuntimeGlobals.require}.`,
5536
- ""
5537
- )
5538
- )
5539
- ] = /** @type {NonNullable<WebpackRequire["i"]>} */ ([]));
5540
- const moduleCache = (__webpack_require__[
5541
- /** @type {"c"} */ (
5542
- RuntimeGlobals.moduleCache.replace(
5543
- `${RuntimeGlobals.require}.`,
5544
- ""
5545
- )
5546
- )
5547
- ] = /** @type {NonNullable<WebpackRequire["c"]>} */ ({}));
5472
+ /** @type {Map<Module, ExecuteModuleArgument>} */
5473
+ const moduleArgumentsMap = new Map();
5474
+ /** @type {Map<string, ExecuteModuleArgument>} */
5475
+ const moduleArgumentsById = new Map();
5548
5476
 
5549
- context.__webpack_require__ = __webpack_require__;
5477
+ /** @type {ExecuteModuleResult["fileDependencies"]} */
5478
+ const fileDependencies = new LazySet();
5479
+ /** @type {ExecuteModuleResult["contextDependencies"]} */
5480
+ const contextDependencies = new LazySet();
5481
+ /** @type {ExecuteModuleResult["missingDependencies"]} */
5482
+ const missingDependencies = new LazySet();
5483
+ /** @type {ExecuteModuleResult["buildDependencies"]} */
5484
+ const buildDependencies = new LazySet();
5550
5485
 
5551
- /**
5552
- * @param {ExecuteModuleArgument} moduleArgument the module argument
5553
- * @param {string=} id id
5554
- * @returns {ExecuteModuleExports} exports
5555
- */
5556
- const __webpack_require_module__ = (moduleArgument, id) => {
5557
- /** @type {ExecuteOptions} */
5558
- const execOptions = {
5559
- id,
5560
- module: {
5561
- id,
5562
- exports: {},
5563
- loaded: false,
5564
- error: undefined
5565
- },
5566
- require: __webpack_require__
5486
+ /** @type {ExecuteModuleResult["assets"]} */
5487
+ const assets = new Map();
5488
+
5489
+ let cacheable = true;
5490
+
5491
+ /** @type {ExecuteModuleContext} */
5492
+ const context = {
5493
+ assets,
5494
+ __webpack_require__: undefined,
5495
+ chunk,
5496
+ chunkGraph
5497
+ };
5498
+
5499
+ // Prepare execution
5500
+ asyncLib.eachLimit(
5501
+ modules,
5502
+ 10,
5503
+ (module, callback) => {
5504
+ const codeGenerationResult = codeGenerationResults.get(
5505
+ module,
5506
+ runtime
5507
+ );
5508
+ /** @type {ExecuteModuleArgument} */
5509
+ const moduleArgument = {
5510
+ module,
5511
+ codeGenerationResult,
5512
+ moduleObject: undefined
5567
5513
  };
5568
- for (const handler of interceptModuleExecution) {
5569
- handler(execOptions);
5514
+ moduleArgumentsMap.set(module, moduleArgument);
5515
+ moduleArgumentsById.set(
5516
+ module.identifier(),
5517
+ moduleArgument
5518
+ );
5519
+ module.addCacheDependencies(
5520
+ fileDependencies,
5521
+ contextDependencies,
5522
+ missingDependencies,
5523
+ buildDependencies
5524
+ );
5525
+ if (
5526
+ /** @type {BuildInfo} */ (module.buildInfo).cacheable ===
5527
+ false
5528
+ ) {
5529
+ cacheable = false;
5570
5530
  }
5571
- const module = moduleArgument.module;
5572
- this.buildTimeExecutedModules.add(module);
5573
- const moduleObject = execOptions.module;
5574
- moduleArgument.moduleObject = moduleObject;
5575
- try {
5576
- if (id) moduleCache[id] = moduleObject;
5577
-
5578
- tryRunOrWebpackError(
5579
- () =>
5580
- this.hooks.executeModule.call(
5581
- moduleArgument,
5582
- context
5583
- ),
5584
- "Compilation.hooks.executeModule"
5585
- );
5586
- moduleObject.loaded = true;
5587
- return moduleObject.exports;
5588
- } catch (execErr) {
5589
- if (strictModuleExceptionHandling) {
5590
- if (id) delete moduleCache[id];
5591
- } else if (strictModuleErrorHandling) {
5592
- moduleObject.error =
5593
- /** @type {WebpackError} */
5594
- (execErr);
5595
- }
5596
- if (!(/** @type {WebpackError} */ (execErr).module)) {
5597
- /** @type {WebpackError} */
5598
- (execErr).module = module;
5531
+ if (module.buildInfo && module.buildInfo.assets) {
5532
+ const { assets: moduleAssets, assetsInfo } =
5533
+ module.buildInfo;
5534
+ for (const assetName of Object.keys(moduleAssets)) {
5535
+ assets.set(assetName, {
5536
+ source: moduleAssets[assetName],
5537
+ info: assetsInfo
5538
+ ? assetsInfo.get(assetName)
5539
+ : undefined
5540
+ });
5599
5541
  }
5600
- throw execErr;
5601
5542
  }
5602
- };
5603
-
5604
- for (const runtimeModule of chunkGraph.getChunkRuntimeModulesInOrder(
5605
- chunk
5606
- )) {
5607
- __webpack_require_module__(
5608
- /** @type {ExecuteModuleArgument} */
5609
- (moduleArgumentsMap.get(runtimeModule))
5543
+ this.hooks.prepareModuleExecution.callAsync(
5544
+ moduleArgument,
5545
+ context,
5546
+ callback
5610
5547
  );
5611
- }
5548
+ },
5549
+ (err) => {
5550
+ if (err) return callback(/** @type {WebpackError} */ (err));
5612
5551
 
5613
- exports = __webpack_require__(module.identifier());
5614
- } catch (execErr) {
5615
- const { message, stack, module } =
5616
- /** @type {WebpackError} */
5617
- (execErr);
5618
- const err = new WebpackError(
5619
- `Execution of module code from module graph (${
5620
- /** @type {Module} */
5621
- (module).readableIdentifier(this.requestShortener)
5622
- }) failed: ${message}`,
5623
- { cause: execErr }
5624
- );
5625
- err.stack = stack;
5626
- err.module = module;
5627
- return callback(err);
5628
- }
5552
+ /** @type {ExecuteModuleExports | undefined} */
5553
+ let exports;
5554
+ try {
5555
+ const {
5556
+ strictModuleErrorHandling,
5557
+ strictModuleExceptionHandling
5558
+ } = this.outputOptions;
5559
+
5560
+ /** @type {WebpackRequire} */
5561
+ const __webpack_require__ = (id) => {
5562
+ const cached = moduleCache[id];
5563
+ if (cached !== undefined) {
5564
+ if (cached.error) throw cached.error;
5565
+ return cached.exports;
5566
+ }
5567
+ const moduleArgument = moduleArgumentsById.get(id);
5568
+ return __webpack_require_module__(
5569
+ /** @type {ExecuteModuleArgument} */
5570
+ (moduleArgument),
5571
+ id
5572
+ );
5573
+ };
5574
+ const interceptModuleExecution = (__webpack_require__[
5575
+ /** @type {"i"} */
5576
+ (
5577
+ RuntimeGlobals.interceptModuleExecution.replace(
5578
+ `${RuntimeGlobals.require}.`,
5579
+ ""
5580
+ )
5581
+ )
5582
+ ] = /** @type {NonNullable<WebpackRequire["i"]>} */ ([]));
5583
+ const moduleCache = (__webpack_require__[
5584
+ /** @type {"c"} */ (
5585
+ RuntimeGlobals.moduleCache.replace(
5586
+ `${RuntimeGlobals.require}.`,
5587
+ ""
5588
+ )
5589
+ )
5590
+ ] = /** @type {NonNullable<WebpackRequire["c"]>} */ ({}));
5591
+
5592
+ context.__webpack_require__ = __webpack_require__;
5593
+
5594
+ /**
5595
+ * @param {ExecuteModuleArgument} moduleArgument the module argument
5596
+ * @param {string=} id id
5597
+ * @returns {ExecuteModuleExports} exports
5598
+ */
5599
+ const __webpack_require_module__ = (
5600
+ moduleArgument,
5601
+ id
5602
+ ) => {
5603
+ /** @type {ExecuteOptions} */
5604
+ const execOptions = {
5605
+ id,
5606
+ module: {
5607
+ id,
5608
+ exports: {},
5609
+ loaded: false,
5610
+ error: undefined
5611
+ },
5612
+ require: __webpack_require__
5613
+ };
5614
+ for (const handler of interceptModuleExecution) {
5615
+ handler(execOptions);
5616
+ }
5617
+ const module = moduleArgument.module;
5618
+ this.buildTimeExecutedModules.add(module);
5619
+ const moduleObject = execOptions.module;
5620
+ moduleArgument.moduleObject = moduleObject;
5621
+ try {
5622
+ if (id) moduleCache[id] = moduleObject;
5623
+
5624
+ tryRunOrWebpackError(
5625
+ () =>
5626
+ this.hooks.executeModule.call(
5627
+ moduleArgument,
5628
+ context
5629
+ ),
5630
+ "Compilation.hooks.executeModule"
5631
+ );
5632
+ moduleObject.loaded = true;
5633
+ return moduleObject.exports;
5634
+ } catch (execErr) {
5635
+ if (strictModuleExceptionHandling) {
5636
+ if (id) delete moduleCache[id];
5637
+ } else if (strictModuleErrorHandling) {
5638
+ moduleObject.error =
5639
+ /** @type {WebpackError} */
5640
+ (execErr);
5641
+ }
5642
+ if (!(/** @type {WebpackError} */ (execErr).module)) {
5643
+ /** @type {WebpackError} */
5644
+ (execErr).module = module;
5645
+ }
5646
+ throw execErr;
5647
+ }
5648
+ };
5649
+
5650
+ for (const runtimeModule of chunkGraph.getChunkRuntimeModulesInOrder(
5651
+ chunk
5652
+ )) {
5653
+ __webpack_require_module__(
5654
+ /** @type {ExecuteModuleArgument} */
5655
+ (moduleArgumentsMap.get(runtimeModule))
5656
+ );
5657
+ }
5629
5658
 
5630
- callback(null, {
5631
- exports,
5632
- assets,
5633
- cacheable,
5634
- fileDependencies,
5635
- contextDependencies,
5636
- missingDependencies,
5637
- buildDependencies
5638
- });
5659
+ exports = __webpack_require__(module.identifier());
5660
+ } catch (execErr) {
5661
+ const { message, stack, module } =
5662
+ /** @type {WebpackError} */
5663
+ (execErr);
5664
+ const err = new WebpackError(
5665
+ `Execution of module code from module graph (${
5666
+ /** @type {Module} */
5667
+ (module).readableIdentifier(this.requestShortener)
5668
+ }) failed: ${message}`,
5669
+ { cause: execErr }
5670
+ );
5671
+ err.stack = stack;
5672
+ err.module = module;
5673
+ return callback(err);
5674
+ }
5675
+
5676
+ callback(null, {
5677
+ exports,
5678
+ assets,
5679
+ cacheable,
5680
+ fileDependencies,
5681
+ contextDependencies,
5682
+ missingDependencies,
5683
+ buildDependencies
5684
+ });
5685
+ }
5686
+ );
5639
5687
  }
5640
5688
  );
5641
- });
5642
- });
5689
+ }
5690
+ );
5643
5691
  }
5644
5692
  );
5645
5693
  }