@depup/webpack 5.110.3-depup.0 → 5.111.1-depup.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 (283) hide show
  1. package/README.md +7 -8
  2. package/changes.json +7 -11
  3. package/lib/APIPlugin.js +26 -11
  4. package/lib/AutomaticPrefetchPlugin.js +1 -1
  5. package/lib/Cache.js +8 -3
  6. package/lib/CacheFacade.js +1 -1
  7. package/lib/CircularModulesPlugin.js +157 -55
  8. package/lib/CleanPlugin.js +2 -2
  9. package/lib/CompatibilityPlugin.js +3 -4
  10. package/lib/Compilation.js +336 -337
  11. package/lib/Compiler.js +213 -51
  12. package/lib/ConstPlugin.js +16 -132
  13. package/lib/CopyPlugin.js +1054 -0
  14. package/lib/DefinePlugin.js +24 -8
  15. package/lib/DependencyTemplate.js +2 -1
  16. package/lib/DotenvPlugin.js +24 -28
  17. package/lib/ErrorHelpers.js +113 -0
  18. package/lib/ExportsInfo.js +20 -16
  19. package/lib/ExternalModule.js +47 -22
  20. package/lib/FileSystemInfo.js +17 -14
  21. package/lib/FlagDependencyExportsPlugin.js +53 -34
  22. package/lib/FlagDependencyUsagePlugin.js +9 -13
  23. package/lib/Generator.js +24 -2
  24. package/lib/HotModuleReplacementPlugin.js +55 -7
  25. package/lib/IgnorePlugin.js +1 -1
  26. package/lib/JavascriptMetaInfoPlugin.js +5 -3
  27. package/lib/LoaderOptionsPlugin.js +1 -1
  28. package/lib/MainTemplate.js +5 -1
  29. package/lib/Module.js +19 -10
  30. package/lib/ModuleGraph.js +6 -9
  31. package/lib/MultiCompiler.js +7 -17
  32. package/lib/MultiWatching.js +1 -1
  33. package/lib/NormalModule.js +135 -50
  34. package/lib/NormalModuleFactory.js +1 -1
  35. package/lib/RuntimeGlobals.js +21 -7
  36. package/lib/RuntimeModule.js +28 -12
  37. package/lib/RuntimePlugin.js +30 -3
  38. package/lib/RuntimeTemplate.js +813 -518
  39. package/lib/SourceMapDevToolPlugin.js +54 -104
  40. package/lib/TemplatedPathPlugin.js +16 -59
  41. package/lib/Watching.js +9 -0
  42. package/lib/WebpackOptionsApply.js +84 -91
  43. package/lib/asset/AssetBytesGenerator.js +7 -1
  44. package/lib/asset/AssetGenerator.js +50 -24
  45. package/lib/asset/AssetModule.js +3 -0
  46. package/lib/asset/AssetSourceGenerator.js +7 -1
  47. package/lib/asset/WebManifestParser.js +7 -5
  48. package/lib/buildChunkGraph.js +11 -15
  49. package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
  50. package/lib/cache/IdleFileCachePlugin.js +2 -2
  51. package/lib/cache/MemoryCachePlugin.js +4 -4
  52. package/lib/cache/MemoryWithGcCachePlugin.js +7 -8
  53. package/lib/cache/PackFileCacheStrategy.js +17 -19
  54. package/lib/cache/getLazyHashedEtag.js +3 -5
  55. package/lib/config/browserslistTargetHandler.js +17 -4
  56. package/lib/config/defaults.js +138 -128
  57. package/lib/config/getClaimedAssetTypes.js +10 -11
  58. package/lib/config/normalization.js +82 -12
  59. package/lib/config/target.js +13 -4
  60. package/lib/container/ContainerReferencePlugin.js +6 -0
  61. package/lib/container/RemoteRuntimeModule.js +9 -0
  62. package/lib/container/declaredRemotes.js +39 -0
  63. package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
  64. package/lib/{ContextModule.js → context/ContextModule.js} +54 -115
  65. package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +19 -21
  66. package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
  67. package/lib/css/CssGenerator.js +27 -11
  68. package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
  69. package/lib/css/CssLoadingRuntimeModule.js +94 -36
  70. package/lib/css/CssModule.js +1 -1
  71. package/lib/css/CssModulesPlugin.js +7 -6
  72. package/lib/css/CssParser.js +162 -31
  73. package/lib/css/CssServerStylesRuntimeModule.js +9 -0
  74. package/lib/css/cssMinify.js +43 -32
  75. package/lib/css/data.js +3514 -869
  76. package/lib/css/syntax.js +6370 -1220
  77. package/lib/debug/ProfilingPlugin.js +7 -4
  78. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
  79. package/lib/dependencies/AMDRuntimeModules.js +18 -0
  80. package/lib/dependencies/CommonJsExportRequireDependency.js +13 -12
  81. package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
  82. package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -5
  83. package/lib/dependencies/CommonJsPlugin.js +19 -3
  84. package/lib/dependencies/CommonJsRequireDependency.js +14 -5
  85. package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
  86. package/lib/dependencies/ContextDependency.js +1 -1
  87. package/lib/dependencies/ContextDependencyHelpers.js +3 -9
  88. package/lib/dependencies/ContextElementDependency.js +1 -1
  89. package/lib/dependencies/CssIcssExportDependency.js +13 -9
  90. package/lib/dependencies/CssIcssImportDependency.js +3 -6
  91. package/lib/dependencies/CssUrlDependency.js +3 -5
  92. package/lib/dependencies/HarmonyCompatibilityDependency.js +67 -22
  93. package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -4
  94. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +10 -7
  95. package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
  96. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +74 -17
  97. package/lib/dependencies/HarmonyExportInitFragment.js +110 -23
  98. package/lib/dependencies/HarmonyExportSpecifierDependency.js +25 -58
  99. package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
  100. package/lib/dependencies/HarmonyImportDependency.js +6 -1
  101. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +111 -17
  102. package/lib/dependencies/HarmonyImportSideEffectDependency.js +3 -4
  103. package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
  104. package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
  105. package/lib/dependencies/HtmlEntryDependency.js +124 -102
  106. package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
  107. package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
  108. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
  109. package/lib/dependencies/ImportMetaGlobHelpers.js +1 -1
  110. package/lib/dependencies/ImportMetaMainDependency.js +104 -0
  111. package/lib/dependencies/ImportMetaPlugin.js +67 -25
  112. package/lib/dependencies/ImportParserPlugin.js +1 -1
  113. package/lib/dependencies/LoaderPlugin.js +26 -1
  114. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  115. package/lib/dependencies/SystemRuntimeModule.js +9 -0
  116. package/lib/dependencies/URLContextDependency.js +1 -1
  117. package/lib/dependencies/URLDependency.js +6 -5
  118. package/lib/dependencies/WorkerAndWorkletPlugin.js +15 -21
  119. package/lib/dependencies/WorkerDependency.js +7 -7
  120. package/lib/dependencies/WorkletDependency.js +7 -11
  121. package/lib/dll/DelegatedModule.js +18 -1
  122. package/lib/dll/DllReferencePlugin.js +11 -8
  123. package/lib/dll/LibManifestPlugin.js +1 -1
  124. package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
  125. package/lib/errors/DuplicateModulesWarning.js +12 -7
  126. package/lib/errors/EmptyCopyPatternWarning.js +26 -0
  127. package/lib/errors/ExternalStarReexportError.js +44 -0
  128. package/lib/errors/HookWebpackError.js +3 -2
  129. package/lib/errors/MissingSourceMapsWarning.js +36 -0
  130. package/lib/errors/ModuleParseError.js +2 -1
  131. package/lib/errors/UnusedAssetsWarning.js +36 -0
  132. package/lib/errors/UnusedFederationWarning.js +35 -0
  133. package/lib/errors/UnusedModulesWarning.js +38 -0
  134. package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
  135. package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
  136. package/lib/esm/ModuleChunkLoadingPlugin.js +30 -11
  137. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -60
  138. package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
  139. package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
  140. package/lib/hmr/LazyCompilationPlugin.js +3 -5
  141. package/lib/html/HtmlGenerator.js +72 -87
  142. package/lib/html/HtmlModulesPlugin.js +418 -200
  143. package/lib/html/HtmlParser.js +110 -147
  144. package/lib/html/builtinEmbeddedRenderer.js +107 -0
  145. package/lib/html/data.js +142 -7
  146. package/lib/html/htmlMinify.js +92 -122
  147. package/lib/html/syntax.js +1618 -1391
  148. package/lib/ids/HashedModuleIdsPlugin.js +2 -1
  149. package/lib/index.js +49 -3
  150. package/lib/javascript/ChunkFormatHelpers.js +4 -3
  151. package/lib/javascript/JavascriptGenerator.js +8 -1
  152. package/lib/javascript/JavascriptModule.js +1 -0
  153. package/lib/javascript/JavascriptModulesPlugin.js +73 -72
  154. package/lib/javascript/JavascriptParser.js +1970 -900
  155. package/lib/javascript/StartupHelpers.js +27 -3
  156. package/lib/javascript/data.js +172 -0
  157. package/lib/javascript/grammar.js +5546 -0
  158. package/lib/javascript/parser.js +1500 -0
  159. package/lib/javascript/regexp.js +1762 -0
  160. package/lib/javascript/regexpData.js +51 -0
  161. package/lib/javascript/syntax.js +9061 -5262
  162. package/lib/json/JsonGenerator.js +7 -1
  163. package/lib/library/ModuleLibraryPlugin.js +171 -132
  164. package/lib/loaders/LoaderRunner.js +137 -9
  165. package/lib/node/NodeWatchFileSystem.js +3 -9
  166. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
  167. package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
  168. package/lib/optimize/AggressiveMergingPlugin.js +3 -5
  169. package/lib/optimize/ConcatenatedModule.js +178 -120
  170. package/lib/optimize/ConstExportsPlugin.js +50 -39
  171. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
  172. package/lib/optimize/InlineExports.js +20 -123
  173. package/lib/optimize/InnerGraphPlugin.js +7 -13
  174. package/lib/optimize/LimitChunkCountPlugin.js +5 -8
  175. package/lib/optimize/MangleExportsPlugin.js +13 -4
  176. package/lib/optimize/ModuleConcatenationPlugin.js +27 -5
  177. package/lib/optimize/RealContentHashPlugin.js +68 -9
  178. package/lib/optimize/SideEffectsFlagPlugin.js +24 -28
  179. package/lib/optimize/SplitChunksPlugin.js +2 -4
  180. package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
  181. package/lib/performance/BroadContextsPlugin.js +1 -1
  182. package/lib/performance/CacheEffectivenessPlugin.js +7 -7
  183. package/lib/performance/DuplicateModulesPlugin.js +57 -13
  184. package/lib/performance/EvalUsagePlugin.js +5 -2
  185. package/lib/performance/MissingSourceMapsPlugin.js +115 -0
  186. package/lib/performance/PureAnnotationsPlugin.js +6 -3
  187. package/lib/performance/SizeLimitsPlugin.js +2 -4
  188. package/lib/performance/TopLevelThisPlugin.js +5 -4
  189. package/lib/performance/UnusedAssetsPlugin.js +109 -0
  190. package/lib/performance/UnusedFederationPlugin.js +147 -0
  191. package/lib/performance/UnusedModulesPlugin.js +141 -0
  192. package/lib/performance/UnusedReexportsPlugin.js +1 -55
  193. package/lib/performance/isOnlyReexported.js +65 -0
  194. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
  195. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +8 -8
  196. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
  197. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
  198. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
  199. package/lib/prefetch/ResourceHintPlugin.js +18 -23
  200. package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
  201. package/lib/prefetch/StartupAssetHintRuntimeModule.js +16 -10
  202. package/lib/rules/RuleSetCompiler.js +211 -4
  203. package/lib/runtime/AsyncModuleRuntimeModule.js +98 -66
  204. package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
  205. package/lib/runtime/BaseUriRuntimeModule.js +9 -0
  206. package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
  207. package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
  208. package/lib/runtime/GetChunkFilenameRuntimeModule.js +12 -4
  209. package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
  210. package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
  211. package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
  212. package/lib/runtime/GlobalRuntimeModule.js +11 -4
  213. package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
  214. package/lib/runtime/HelperRuntimeModule.js +10 -0
  215. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +305 -224
  216. package/lib/runtime/NonceRuntimeModule.js +9 -0
  217. package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
  218. package/lib/runtime/PublicPathRuntimeModule.js +9 -0
  219. package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
  220. package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
  221. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
  222. package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
  223. package/lib/runtime/SystemContextRuntimeModule.js +9 -0
  224. package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
  225. package/lib/schemes/DataUriPlugin.js +3 -6
  226. package/lib/schemes/VirtualUrlPlugin.js +1 -1
  227. package/lib/serialization/BinaryMiddleware.js +9 -9
  228. package/lib/serialization/FileMiddleware.js +16 -16
  229. package/lib/serialization/ObjectMiddleware.js +168 -139
  230. package/lib/sharing/ConsumeSharedPlugin.js +12 -0
  231. package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
  232. package/lib/sharing/ShareRuntimeModule.js +9 -0
  233. package/lib/sharing/declaredShared.js +47 -0
  234. package/lib/stats/DefaultStatsFactoryPlugin.js +6 -5
  235. package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
  236. package/lib/typescript/TypeScriptPlugin.js +2 -3
  237. package/lib/url/URLParserPlugin.js +6 -8
  238. package/lib/util/LocConverter.js +4 -7
  239. package/lib/util/SourceProcessor.js +91 -91
  240. package/lib/util/async.js +292 -0
  241. package/lib/util/buildDiagnostics.js +69 -0
  242. package/lib/util/chainedImports.js +3 -4
  243. package/lib/util/concatenate.js +4 -4
  244. package/lib/util/createHooksRegistry.js +1 -2
  245. package/lib/util/dataURL.js +2 -3
  246. package/lib/util/deterministicGrouping.js +8 -13
  247. package/lib/util/findGraphRoots.js +6 -13
  248. package/lib/util/fs.js +27 -1
  249. package/lib/util/globUtils.js +1 -1
  250. package/lib/util/handlerKeys.js +40 -0
  251. package/lib/util/hash/wasm-hash.js +3 -4
  252. package/lib/util/identifier.js +20 -0
  253. package/lib/util/internalSerializables.js +5 -1
  254. package/lib/util/registerExternalSerializer.js +6 -45
  255. package/lib/util/semver.js +5 -3
  256. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +9 -0
  257. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
  258. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
  259. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
  260. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +12 -4
  261. package/lib/wasm-sync/WebAssemblyGenerator.js +6 -1
  262. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -1
  263. package/lib/wasm-sync/WebAssemblyUtils.js +2 -4
  264. package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
  265. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
  266. package/package.json +55 -46
  267. package/schemas/WebpackOptions.check.js +1 -1
  268. package/schemas/WebpackOptions.json +379 -66
  269. package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
  270. package/schemas/plugins/ManifestPlugin.check.js +1 -1
  271. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  272. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  273. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  274. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  275. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  276. package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
  277. package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
  278. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
  279. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  280. package/types.d.ts +1723 -604
  281. package/lib/dependencies/ExportBindingInitFragment.js +0 -191
  282. package/lib/errors/EntrypointOverlapWarning.js +0 -45
  283. package/lib/performance/EntrypointOverlapPlugin.js +0 -122
@@ -6,7 +6,6 @@
6
6
  "use strict";
7
7
 
8
8
  const util = require("util");
9
- const asyncLib = require("neo-async");
10
9
  const {
11
10
  AsyncParallelHook,
12
11
  AsyncSeriesBailHook,
@@ -28,6 +27,9 @@ const Dependency = require("./Dependency");
28
27
  const DependencyTemplates = require("./DependencyTemplates");
29
28
  const Entrypoint = require("./Entrypoint");
30
29
  const ErrorHelpers = require("./ErrorHelpers");
30
+
31
+ const { toError } = ErrorHelpers;
32
+
31
33
  const FileSystemInfo = require("./FileSystemInfo");
32
34
  const LazyBarrelController = require("./LazyBarrel");
33
35
  const MainTemplate = require("./MainTemplate");
@@ -53,6 +55,8 @@ const AsyncQueue = require("./util/AsyncQueue");
53
55
  const LazySet = require("./util/LazySet");
54
56
  const { getOrInsert } = require("./util/MapHelpers");
55
57
  const WeakTupleMap = require("./util/WeakTupleMap");
58
+ const asyncLib = require("./util/async");
59
+ const { replayOptimizationBailouts } = require("./util/buildDiagnostics");
56
60
  const { cachedCleverMerge } = require("./util/cleverMerge");
57
61
  const {
58
62
  compareErrors,
@@ -367,6 +371,20 @@ const getBuildCycleError = memoize(() => require("./errors/BuildCycleError"));
367
371
  * @property {string[]=} trace
368
372
  */
369
373
 
374
+ /**
375
+ * Where an asset which is a symbolic link points, as the link itself spells it.
376
+ * @typedef {object} AssetSymlink
377
+ * @property {string} target what the link points at, left as it is written
378
+ * @property {boolean} isDirectory whether it points at a directory, which is what Windows needs in order to create one
379
+ */
380
+
381
+ /**
382
+ * Access and modification times an asset carries onto the file it is written to.
383
+ * @typedef {object} AssetTimestamps
384
+ * @property {number} atime last access time, in milliseconds
385
+ * @property {number} mtime last modification time, in milliseconds
386
+ */
387
+
370
388
  /**
371
389
  * Defines the known asset info type used by this module.
372
390
  * @typedef {object} KnownAssetInfo
@@ -378,6 +396,10 @@ const getBuildCycleError = memoize(() => require("./errors/BuildCycleError"));
378
396
  * @property {string | string[]=} contenthash the value(s) of the content hash used for this asset
379
397
  * @property {Record<string, string>=} contenthashDigest maps a `[contenthash:<digest>]` value to its digest, so `RealContentHashPlugin` re-encodes the recomputed hash in it
380
398
  * @property {string=} sourceFilename when asset was created from a source file (potentially transformed), the original filename relative to compilation context
399
+ * @property {boolean=} copied true, when the asset was copied from a file by `output.copy`
400
+ * @property {AssetSymlink=} symlink when set, the asset is emitted as a symbolic link rather than as its content
401
+ * @property {number=} mode when set, the file the asset is written to is given these permissions
402
+ * @property {AssetTimestamps=} timestamps when set, the file the asset is written to is stamped with these times
381
403
  * @property {number=} size size in bytes, only set after asset has been emitted
382
404
  * @property {boolean=} development true, when asset is only used for development and doesn't count towards user-facing assets
383
405
  * @property {boolean=} hotModuleReplacement true, when asset ships data for updating an existing application (HMR)
@@ -1458,6 +1480,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1458
1480
  this.missingDependencies = new LazySet();
1459
1481
  /** @type {FileSystemDependencies} */
1460
1482
  this.buildDependencies = new LazySet();
1483
+ /** @type {FileSystemDependencies} */
1484
+ this.optionalBuildDependencies = new LazySet();
1461
1485
  // TODO webpack 6 remove
1462
1486
  /**
1463
1487
  * @deprecated
@@ -1806,6 +1830,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1806
1830
  if (currentProfile !== undefined) {
1807
1831
  currentProfile.markBuildingEnd();
1808
1832
  }
1833
+ replayOptimizationBailouts(this.moduleGraph, module);
1809
1834
  this.hooks.stillValidModule.call(module);
1810
1835
  return callback();
1811
1836
  }
@@ -1826,6 +1851,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1826
1851
  this.hooks.failedModule.call(module, err);
1827
1852
  return callback(err);
1828
1853
  }
1854
+ replayOptimizationBailouts(this.moduleGraph, module);
1829
1855
  if (currentProfile !== undefined) {
1830
1856
  currentProfile.markStoringStart();
1831
1857
  }
@@ -2348,7 +2374,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2348
2374
  if (err) {
2349
2375
  const notFoundError = new (getModuleNotFoundError())(
2350
2376
  originModule,
2351
- err,
2377
+ toError(err),
2352
2378
  /** @type {DependencyLocation} */
2353
2379
  (dependencies.map((d) => d.loc).find(Boolean))
2354
2380
  );
@@ -2633,12 +2659,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2633
2659
  return;
2634
2660
  }
2635
2661
 
2636
- // lazy barrel:
2637
- // 1. first call: barrel module is not classified yet, so this records the requested
2638
- // ids and returns undefined; the targets get built below when
2639
- // `processModuleDependencies` runs `_lazyBarrelController.classify` and replays them.
2640
- // 2. later call: barrel module is already built, so `processModuleDependencies` won't
2641
- // re-walk it; the newly requested targets must be built here.
2662
+ // lazy barrel: on the first call the module is unclassified, so this only
2663
+ // records the ids and `processModuleDependencies` replays them. Later the
2664
+ // module is built and never re-walked, so the targets are built here.
2642
2665
  const unlazyItems = this._lazyBarrelController.request(
2643
2666
  module,
2644
2667
  dependencies
@@ -4164,7 +4187,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4164
4187
  // Reported and carried on with, as the first pass does: a throw
4165
4188
  // here would leave the build with no error to show for it.
4166
4189
  this.errors.push(
4167
- new (getCodeGenerationError())(module, /** @type {Error} */ (err))
4190
+ new (getCodeGenerationError())(module, toError(err))
4168
4191
  );
4169
4192
  result = {
4170
4193
  sources: new Map(),
@@ -4221,15 +4244,17 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4221
4244
  const { codeGenerationDependencies } = module;
4222
4245
  if (
4223
4246
  codeGenerationDependencies !== undefined &&
4224
- (notCodeGeneratedModules === undefined ||
4225
- codeGenerationDependencies.some((dep) => {
4226
- const referencedModule = /** @type {Module} */ (
4227
- moduleGraph.getModule(dep)
4228
- );
4229
- return /** @type {NotCodeGeneratedModules} */ (
4230
- notCodeGeneratedModules
4231
- ).has(referencedModule);
4232
- }))
4247
+ codeGenerationDependencies.some((dep) => {
4248
+ const referencedModule = moduleGraph.getModule(dep);
4249
+ // Nothing resolved it, so it is never code-generated and
4250
+ // waiting on it would stall instead of ordering anything.
4251
+ if (!referencedModule) return false;
4252
+ return (
4253
+ notCodeGeneratedModules === undefined ||
4254
+ /** @type {NotCodeGeneratedModules} */
4255
+ (notCodeGeneratedModules).has(referencedModule)
4256
+ );
4257
+ })
4233
4258
  ) {
4234
4259
  delayedJobs.push(job);
4235
4260
  delayedModules.add(module);
@@ -4338,6 +4363,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4338
4363
  codeGenerated = true;
4339
4364
  this.codeGeneratedModules.add(module);
4340
4365
  this._generatingModule = module;
4366
+ // Not stored, since nothing is restored here: named so a reason lands on
4367
+ // the same module as it does in a cached build.
4368
+ runtimeTemplate.beginAnalyzableBailouts(module);
4341
4369
  result = module.codeGeneration({
4342
4370
  chunkGraph,
4343
4371
  moduleGraph,
@@ -4349,9 +4377,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4349
4377
  compilation: this
4350
4378
  });
4351
4379
  } catch (err) {
4352
- errors.push(
4353
- new (getCodeGenerationError())(module, /** @type {Error} */ (err))
4354
- );
4380
+ errors.push(new (getCodeGenerationError())(module, toError(err)));
4355
4381
  result = {
4356
4382
  sources: new Map(),
4357
4383
  runtimeRequirements: null,
@@ -4359,6 +4385,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4359
4385
  };
4360
4386
  } finally {
4361
4387
  this._generatingModule = undefined;
4388
+ runtimeTemplate.finishAnalyzableBailouts();
4362
4389
  }
4363
4390
  for (const runtime of runtimes) {
4364
4391
  results.add(module, runtime, result);
@@ -4382,6 +4409,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4382
4409
  codeGenerated = true;
4383
4410
  this.codeGeneratedModules.add(module);
4384
4411
  this._generatingModule = module;
4412
+ runtimeTemplate.beginAnalyzableBailouts(module);
4385
4413
  result = module.codeGeneration({
4386
4414
  chunkGraph,
4387
4415
  moduleGraph,
@@ -4392,10 +4420,15 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4392
4420
  codeGenerationResults: results,
4393
4421
  compilation: this
4394
4422
  });
4423
+ // The bailouts travel with the result: a restored module never runs
4424
+ // the code generation that would record them again.
4425
+ const bailouts = runtimeTemplate.finishAnalyzableBailouts();
4426
+ if (bailouts !== undefined) {
4427
+ if (result.data === undefined) result.data = new Map();
4428
+ result.data.set("analyzableBailouts", bailouts);
4429
+ }
4395
4430
  } catch (err) {
4396
- errors.push(
4397
- new (getCodeGenerationError())(module, /** @type {Error} */ (err))
4398
- );
4431
+ errors.push(new (getCodeGenerationError())(module, toError(err)));
4399
4432
  result = cachedResult = {
4400
4433
  sources: new Map(),
4401
4434
  runtimeRequirements: null,
@@ -4403,9 +4436,14 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
4403
4436
  };
4404
4437
  } finally {
4405
4438
  this._generatingModule = undefined;
4439
+ runtimeTemplate.finishAnalyzableBailouts();
4406
4440
  }
4407
4441
  } else {
4408
4442
  result = cachedResult;
4443
+ const bailouts = result.data && result.data.get("analyzableBailouts");
4444
+ if (bailouts) {
4445
+ runtimeTemplate.restoreAnalyzableBailouts(module, bailouts);
4446
+ }
4409
4447
  }
4410
4448
  for (const runtime of runtimes) {
4411
4449
  results.add(module, runtime, result);
@@ -5008,6 +5046,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
5008
5046
  this.contextDependencies.addAll(child.contextDependencies);
5009
5047
  this.missingDependencies.addAll(child.missingDependencies);
5010
5048
  this.buildDependencies.addAll(child.buildDependencies);
5049
+ this.optionalBuildDependencies.addAll(child.optionalBuildDependencies);
5011
5050
  }
5012
5051
 
5013
5052
  for (const module of this.modules) {
@@ -5165,22 +5204,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
5165
5204
  }
5166
5205
 
5167
5206
  this.logger.time("hashing: sort chunks");
5168
- /*
5169
- * Chunks are hashed in 4 categories, in this order:
5170
- * 1. Async chunks - no hash dependencies on other chunks
5171
- * 2. Non-entry initial chunks (e.g. shared split chunks) - no hash
5172
- * dependencies on other chunks, but runtime chunks may read their
5173
- * hashes via GetChunkFilenameRuntimeModule (dependentHash)
5174
- * 3. Runtime chunks - may use hashes of async and non-entry initial
5175
- * chunks (via GetChunkFilenameRuntimeModule). Ordered by references
5176
- * between each other (for async entrypoints)
5177
- * 4. Entry chunks - may depend on runtimeChunk.hash (via
5178
- * createChunkHashHandler for ESM/CJS entry importing runtime)
5179
- *
5180
- * This ordering ensures all hash dependencies flow in one direction:
5181
- * async/initial → runtime → entry, with no circular dependencies.
5182
- * Chunks within each category are sorted by id for determinism.
5183
- */
5207
+ // Hashed as async, then non-entry initial, then runtime, then entry chunks,
5208
+ // so hash dependencies flow one way between those groups. A cycle among the
5209
+ // runtime chunks is still possible, and is warned about below.
5184
5210
  /** @type {Chunk[]} */
5185
5211
  const unorderedRuntimeChunks = [];
5186
5212
  /** @type {Chunk[]} */
@@ -5367,9 +5393,7 @@ This prevents using hashes of each other and should be avoided.`);
5367
5393
  this.hooks.contentHash.call(chunk);
5368
5394
  }
5369
5395
  } catch (err) {
5370
- this.errors.push(
5371
- new (getChunkRenderError())(chunk, "", /** @type {Error} */ (err))
5372
- );
5396
+ this.errors.push(new (getChunkRenderError())(chunk, "", toError(err)));
5373
5397
  }
5374
5398
  this.logger.timeAggregate("hashing: hash chunks");
5375
5399
  };
@@ -5377,14 +5401,6 @@ This prevents using hashes of each other and should be avoided.`);
5377
5401
  for (const chunk of initialChunks) processChunk(chunk);
5378
5402
  for (const chunk of runtimeChunks) processChunk(chunk);
5379
5403
  for (const chunk of entryChunks) processChunk(chunk);
5380
- if (errors.length > 0) {
5381
- errors.sort(
5382
- compareSelect((err) => err.module, compareModulesByIdentifier)
5383
- );
5384
- for (const error of errors) {
5385
- this.errors.push(error);
5386
- }
5387
- }
5388
5404
 
5389
5405
  this.logger.timeAggregateEnd("hashing: hash runtime modules");
5390
5406
  this.logger.timeAggregateEnd("hashing: hash chunks");
@@ -5399,19 +5415,16 @@ This prevents using hashes of each other and should be avoided.`);
5399
5415
  for (const module of /** @type {Iterable<RuntimeModule>} */ (
5400
5416
  chunkGraph.getChunkFullHashModulesIterable(chunk)
5401
5417
  )) {
5402
- const moduleHash = createHash(hashFunction);
5403
- module.updateHash(moduleHash, {
5404
- chunkGraph,
5405
- runtime: chunk.runtime,
5406
- runtimeTemplate
5407
- });
5408
- const moduleHashDigest = moduleHash.digest(hashDigest);
5409
5418
  const oldHash = chunkGraph.getModuleHash(module, chunk.runtime);
5410
- chunkGraph.setModuleHashes(
5419
+ const moduleHashDigest = this._createModuleHash(
5411
5420
  module,
5421
+ chunkGraph,
5412
5422
  chunk.runtime,
5413
- moduleHashDigest,
5414
- moduleHashDigest.slice(0, hashDigestLength)
5423
+ hashFunction,
5424
+ runtimeTemplate,
5425
+ hashDigest,
5426
+ hashDigestLength,
5427
+ errors
5415
5428
  );
5416
5429
  /** @type {CodeGenerationJob} */
5417
5430
  (
@@ -5428,6 +5441,16 @@ This prevents using hashes of each other and should be avoided.`);
5428
5441
  this.hooks.contentHash.call(chunk);
5429
5442
  }
5430
5443
  this.logger.timeEnd("hashing: process full hash modules");
5444
+
5445
+ if (errors.length > 0) {
5446
+ errors.sort(
5447
+ compareSelect((err) => err.module, compareModulesByIdentifier)
5448
+ );
5449
+ for (const error of errors) {
5450
+ this.errors.push(error);
5451
+ }
5452
+ }
5453
+
5431
5454
  return codeGenerationJobs;
5432
5455
  }
5433
5456
 
@@ -5861,7 +5884,7 @@ This prevents using hashes of each other and should be avoided.`);
5861
5884
  /** @type {Map<string, { hash: string, source: Source, chunk: Chunk }>} */
5862
5885
  const alreadyWrittenFiles = new Map();
5863
5886
 
5864
- asyncLib.forEachLimit(
5887
+ asyncLib.eachLimit(
5865
5888
  this.chunks,
5866
5889
  15,
5867
5890
  (chunk, callback) => {
@@ -5884,7 +5907,7 @@ This prevents using hashes of each other and should be avoided.`);
5884
5907
  });
5885
5908
  } catch (err) {
5886
5909
  this.errors.push(
5887
- new (getChunkRenderError())(chunk, "", /** @type {Error} */ (err))
5910
+ new (getChunkRenderError())(chunk, "", toError(err))
5888
5911
  );
5889
5912
  return callback();
5890
5913
  }
@@ -5923,7 +5946,7 @@ This prevents using hashes of each other and should be avoided.`);
5923
5946
  : "");
5924
5947
 
5925
5948
  this.errors.push(
5926
- new (getChunkRenderError())(chunk, filename, err)
5949
+ new (getChunkRenderError())(chunk, filename, toError(err))
5927
5950
  );
5928
5951
  inTry = false;
5929
5952
  return callback();
@@ -6239,299 +6262,275 @@ This prevents using hashes of each other and should be avoided.`);
6239
6262
  };
6240
6263
 
6241
6264
  // Generate code for all aggregated modules
6242
- asyncLib.eachLimit(
6243
- /** @type {import("neo-async").IterableCollection<Module>} */ (
6244
- /** @type {unknown} */ (modules)
6245
- ),
6246
- 10,
6247
- codeGen,
6248
- (err) => {
6265
+ asyncLib.eachLimit(modules, 10, codeGen, (err) => {
6266
+ if (err) return callback(err);
6267
+ reportErrors();
6268
+
6269
+ // for backward-compat temporary set the chunk graph
6270
+ // TODO webpack 6
6271
+ const old = this.chunkGraph;
6272
+ this.chunkGraph = chunkGraph;
6273
+ this.processRuntimeRequirements({
6274
+ chunkGraph,
6275
+ modules,
6276
+ chunks,
6277
+ codeGenerationResults,
6278
+ chunkGraphEntries: chunks
6279
+ });
6280
+ // restored before the deferred attach so no concurrent `make`
6281
+ // task observes the build-time graph
6282
+ this.chunkGraph = old;
6283
+ this._attachPendingRuntimeModules((err) => {
6249
6284
  if (err) return callback(err);
6250
- reportErrors();
6251
-
6252
- // for backward-compat temporary set the chunk graph
6253
- // TODO webpack 6
6254
- const old = this.chunkGraph;
6255
- this.chunkGraph = chunkGraph;
6256
- this.processRuntimeRequirements({
6257
- chunkGraph,
6258
- modules,
6259
- chunks,
6260
- codeGenerationResults,
6261
- chunkGraphEntries: chunks
6262
- });
6263
- // restored before the deferred attach so no concurrent `make`
6264
- // task observes the build-time graph
6265
- this.chunkGraph = old;
6266
- this._attachPendingRuntimeModules((err) => {
6267
- if (err) return callback(err);
6268
6285
 
6269
- const runtimeModules =
6270
- chunkGraph.getChunkRuntimeModulesIterable(chunk);
6286
+ const runtimeModules =
6287
+ chunkGraph.getChunkRuntimeModulesIterable(chunk);
6271
6288
 
6272
- // Hash runtime modules
6273
- for (const module of runtimeModules) {
6274
- modules.add(module);
6275
- this._createModuleHash(
6276
- module,
6277
- chunkGraph,
6278
- runtime,
6279
- hashFunction,
6280
- runtimeTemplate,
6281
- hashDigest,
6282
- hashDigestLength,
6283
- errors
6284
- );
6285
- }
6289
+ // Hash runtime modules
6290
+ for (const module of runtimeModules) {
6291
+ modules.add(module);
6292
+ this._createModuleHash(
6293
+ module,
6294
+ chunkGraph,
6295
+ runtime,
6296
+ hashFunction,
6297
+ runtimeTemplate,
6298
+ hashDigest,
6299
+ hashDigestLength,
6300
+ errors
6301
+ );
6302
+ }
6303
+
6304
+ // Generate code for all runtime modules
6305
+ asyncLib.eachLimit(runtimeModules, 10, codeGen, (err) => {
6306
+ if (err) return callback(err);
6307
+ reportErrors();
6308
+
6309
+ /** @type {Map<Module, ExecuteModuleArgument>} */
6310
+ const moduleArgumentsMap = new Map();
6311
+ /** @type {Map<string, ExecuteModuleArgument>} */
6312
+ const moduleArgumentsById = new Map();
6313
+
6314
+ /** @type {ExecuteModuleResult["fileDependencies"]} */
6315
+ const fileDependencies = new LazySet();
6316
+ /** @type {ExecuteModuleResult["contextDependencies"]} */
6317
+ const contextDependencies = new LazySet();
6318
+ /** @type {ExecuteModuleResult["missingDependencies"]} */
6319
+ const missingDependencies = new LazySet();
6320
+ /** @type {ExecuteModuleResult["buildDependencies"]} */
6321
+ const buildDependencies = new LazySet();
6322
+
6323
+ /** @type {ExecuteModuleResult["assets"]} */
6324
+ const assets = new Map();
6325
+
6326
+ let cacheable = true;
6327
+ /** @type {ExecuteModuleResult["notCacheableReasons"]} */
6328
+ const notCacheableReasons = [];
6329
+
6330
+ /** @type {ExecuteModuleContext} */
6331
+ const context = {
6332
+ assets,
6333
+ __webpack_require__: undefined,
6334
+ chunk,
6335
+ chunkGraph
6336
+ };
6286
6337
 
6287
- // Generate code for all runtime modules
6338
+ // Prepare execution
6288
6339
  asyncLib.eachLimit(
6289
- /** @type {import("neo-async").IterableCollection<RuntimeModule>} */ (
6290
- runtimeModules
6291
- ),
6340
+ modules,
6292
6341
  10,
6293
- codeGen,
6294
- (err) => {
6295
- if (err) return callback(err);
6296
- reportErrors();
6297
-
6298
- /** @type {Map<Module, ExecuteModuleArgument>} */
6299
- const moduleArgumentsMap = new Map();
6300
- /** @type {Map<string, ExecuteModuleArgument>} */
6301
- const moduleArgumentsById = new Map();
6302
-
6303
- /** @type {ExecuteModuleResult["fileDependencies"]} */
6304
- const fileDependencies = new LazySet();
6305
- /** @type {ExecuteModuleResult["contextDependencies"]} */
6306
- const contextDependencies = new LazySet();
6307
- /** @type {ExecuteModuleResult["missingDependencies"]} */
6308
- const missingDependencies = new LazySet();
6309
- /** @type {ExecuteModuleResult["buildDependencies"]} */
6310
- const buildDependencies = new LazySet();
6311
-
6312
- /** @type {ExecuteModuleResult["assets"]} */
6313
- const assets = new Map();
6314
-
6315
- let cacheable = true;
6316
- /** @type {ExecuteModuleResult["notCacheableReasons"]} */
6317
- const notCacheableReasons = [];
6318
-
6319
- /** @type {ExecuteModuleContext} */
6320
- const context = {
6321
- assets,
6322
- __webpack_require__: undefined,
6323
- chunk,
6324
- chunkGraph
6342
+ (module, callback) => {
6343
+ const codeGenerationResult = codeGenerationResults.get(
6344
+ module,
6345
+ runtime
6346
+ );
6347
+ /** @type {ExecuteModuleArgument} */
6348
+ const moduleArgument = {
6349
+ module,
6350
+ codeGenerationResult,
6351
+ moduleObject: undefined
6325
6352
  };
6326
-
6327
- // Prepare execution
6328
- asyncLib.eachLimit(
6329
- modules,
6330
- 10,
6331
- (module, callback) => {
6332
- const codeGenerationResult = codeGenerationResults.get(
6333
- module,
6334
- runtime
6335
- );
6336
- /** @type {ExecuteModuleArgument} */
6337
- const moduleArgument = {
6338
- module,
6339
- codeGenerationResult,
6340
- moduleObject: undefined
6341
- };
6342
- moduleArgumentsMap.set(module, moduleArgument);
6343
- moduleArgumentsById.set(
6344
- module.identifier(),
6345
- moduleArgument
6346
- );
6347
- module.addCacheDependencies(
6348
- fileDependencies,
6349
- contextDependencies,
6350
- missingDependencies,
6351
- buildDependencies
6352
- );
6353
- const buildInfo = /** @type {BuildInfo} */ (
6354
- module.buildInfo
6355
- );
6356
- if (buildInfo.cacheable === false) {
6357
- cacheable = false;
6358
- if (buildInfo.notCacheableReasons) {
6359
- for (const reason of buildInfo.notCacheableReasons) {
6360
- if (!notCacheableReasons.includes(reason)) {
6361
- notCacheableReasons.push(reason);
6362
- }
6363
- }
6353
+ moduleArgumentsMap.set(module, moduleArgument);
6354
+ moduleArgumentsById.set(module.identifier(), moduleArgument);
6355
+ module.addCacheDependencies(
6356
+ fileDependencies,
6357
+ contextDependencies,
6358
+ missingDependencies,
6359
+ buildDependencies
6360
+ );
6361
+ const buildInfo = /** @type {BuildInfo} */ (module.buildInfo);
6362
+ if (buildInfo.cacheable === false) {
6363
+ cacheable = false;
6364
+ const moduleDiagnostics = buildInfo.diagnostics;
6365
+ if (
6366
+ moduleDiagnostics !== undefined &&
6367
+ moduleDiagnostics.notCacheableReasons
6368
+ ) {
6369
+ for (const reason of moduleDiagnostics.notCacheableReasons) {
6370
+ if (!notCacheableReasons.includes(reason)) {
6371
+ notCacheableReasons.push(reason);
6364
6372
  }
6365
6373
  }
6366
- if (module.buildInfo && module.buildInfo.assets) {
6367
- const { assets: moduleAssets, assetsInfo } =
6368
- module.buildInfo;
6369
- for (const assetName of Object.keys(moduleAssets)) {
6370
- assets.set(assetName, {
6371
- source: moduleAssets[assetName],
6372
- info: assetsInfo
6373
- ? assetsInfo.get(assetName)
6374
- : undefined
6375
- });
6376
- }
6374
+ }
6375
+ }
6376
+ if (module.buildInfo && module.buildInfo.assets) {
6377
+ const { assets: moduleAssets, assetsInfo } =
6378
+ module.buildInfo;
6379
+ for (const assetName of Object.keys(moduleAssets)) {
6380
+ assets.set(assetName, {
6381
+ source: moduleAssets[assetName],
6382
+ info: assetsInfo ? assetsInfo.get(assetName) : undefined
6383
+ });
6384
+ }
6385
+ }
6386
+ this.hooks.prepareModuleExecution.callAsync(
6387
+ moduleArgument,
6388
+ context,
6389
+ callback
6390
+ );
6391
+ },
6392
+ (err) => {
6393
+ if (err) {
6394
+ return callback(/** @type {WebpackError} */ (err));
6395
+ }
6396
+
6397
+ /** @type {ExecuteModuleExports | undefined} */
6398
+ let exports;
6399
+ try {
6400
+ const {
6401
+ strictModuleErrorHandling,
6402
+ strictModuleExceptionHandling
6403
+ } = this.outputOptions;
6404
+
6405
+ /** @type {WebpackRequire} */
6406
+ const __webpack_require__ = (id) => {
6407
+ const cached = moduleCache[id];
6408
+ if (cached !== undefined) {
6409
+ if (cached.error) throw cached.error;
6410
+ return cached.exports;
6377
6411
  }
6378
- this.hooks.prepareModuleExecution.callAsync(
6379
- moduleArgument,
6380
- context,
6381
- callback
6412
+ const moduleArgument = moduleArgumentsById.get(id);
6413
+ return __webpack_require_module__(
6414
+ /** @type {ExecuteModuleArgument} */
6415
+ (moduleArgument),
6416
+ id
6382
6417
  );
6383
- },
6384
- (err) => {
6385
- if (err) {
6386
- return callback(/** @type {WebpackError} */ (err));
6418
+ };
6419
+ const interceptModuleExecution = (__webpack_require__[
6420
+ /** @type {"i"} */
6421
+ (
6422
+ RuntimeGlobals.interceptModuleExecution.replace(
6423
+ `${RuntimeGlobals.require}.`,
6424
+ ""
6425
+ )
6426
+ )
6427
+ ] = /** @type {NonNullable<WebpackRequire["i"]>} */ ([]));
6428
+ const moduleCache = (__webpack_require__[
6429
+ /** @type {"c"} */ (
6430
+ RuntimeGlobals.moduleCache.replace(
6431
+ `${RuntimeGlobals.require}.`,
6432
+ ""
6433
+ )
6434
+ )
6435
+ ] = /** @type {NonNullable<WebpackRequire["c"]>} */ ({}));
6436
+
6437
+ context.__webpack_require__ = __webpack_require__;
6438
+
6439
+ /**
6440
+ * Webpack require module.
6441
+ * @param {ExecuteModuleArgument} moduleArgument the module argument
6442
+ * @param {string=} id id
6443
+ * @returns {ExecuteModuleExports} exports
6444
+ */
6445
+ const __webpack_require_module__ = (moduleArgument, id) => {
6446
+ /** @type {ExecuteOptions} */
6447
+ const execOptions = {
6448
+ id,
6449
+ module: {
6450
+ id,
6451
+ exports: {},
6452
+ loaded: false,
6453
+ error: undefined
6454
+ },
6455
+ require: __webpack_require__
6456
+ };
6457
+ for (const handler of interceptModuleExecution) {
6458
+ handler(execOptions);
6387
6459
  }
6388
-
6389
- /** @type {ExecuteModuleExports | undefined} */
6390
- let exports;
6460
+ const module = moduleArgument.module;
6461
+ this.buildTimeExecutedModules.add(module);
6462
+ const moduleObject = execOptions.module;
6463
+ moduleArgument.moduleObject = moduleObject;
6391
6464
  try {
6392
- const {
6393
- strictModuleErrorHandling,
6394
- strictModuleExceptionHandling
6395
- } = this.outputOptions;
6396
-
6397
- /** @type {WebpackRequire} */
6398
- const __webpack_require__ = (id) => {
6399
- const cached = moduleCache[id];
6400
- if (cached !== undefined) {
6401
- if (cached.error) throw cached.error;
6402
- return cached.exports;
6403
- }
6404
- const moduleArgument = moduleArgumentsById.get(id);
6405
- return __webpack_require_module__(
6406
- /** @type {ExecuteModuleArgument} */
6407
- (moduleArgument),
6408
- id
6409
- );
6410
- };
6411
- const interceptModuleExecution = (__webpack_require__[
6412
- /** @type {"i"} */
6413
- (
6414
- RuntimeGlobals.interceptModuleExecution.replace(
6415
- `${RuntimeGlobals.require}.`,
6416
- ""
6417
- )
6418
- )
6419
- ] =
6420
- /** @type {NonNullable<WebpackRequire["i"]>} */ ([]));
6421
- const moduleCache = (__webpack_require__[
6422
- /** @type {"c"} */ (
6423
- RuntimeGlobals.moduleCache.replace(
6424
- `${RuntimeGlobals.require}.`,
6425
- ""
6426
- )
6427
- )
6428
- ] =
6429
- /** @type {NonNullable<WebpackRequire["c"]>} */ ({}));
6430
-
6431
- context.__webpack_require__ = __webpack_require__;
6432
-
6433
- /**
6434
- * Webpack require module.
6435
- * @param {ExecuteModuleArgument} moduleArgument the module argument
6436
- * @param {string=} id id
6437
- * @returns {ExecuteModuleExports} exports
6438
- */
6439
- const __webpack_require_module__ = (
6440
- moduleArgument,
6441
- id
6442
- ) => {
6443
- /** @type {ExecuteOptions} */
6444
- const execOptions = {
6445
- id,
6446
- module: {
6447
- id,
6448
- exports: {},
6449
- loaded: false,
6450
- error: undefined
6451
- },
6452
- require: __webpack_require__
6453
- };
6454
- for (const handler of interceptModuleExecution) {
6455
- handler(execOptions);
6456
- }
6457
- const module = moduleArgument.module;
6458
- this.buildTimeExecutedModules.add(module);
6459
- const moduleObject = execOptions.module;
6460
- moduleArgument.moduleObject = moduleObject;
6461
- try {
6462
- if (id) moduleCache[id] = moduleObject;
6463
-
6464
- tryRunOrWebpackError(
6465
- () =>
6466
- this.hooks.executeModule.call(
6467
- moduleArgument,
6468
- context
6469
- ),
6470
- "Compilation.hooks.executeModule"
6471
- );
6472
- moduleObject.loaded = true;
6473
- return moduleObject.exports;
6474
- } catch (execErr) {
6475
- if (strictModuleExceptionHandling) {
6476
- if (id) delete moduleCache[id];
6477
- } else if (strictModuleErrorHandling) {
6478
- moduleObject.error =
6479
- /** @type {WebpackError} */
6480
- (execErr);
6481
- }
6482
- if (
6483
- !(/** @type {WebpackError} */ (execErr).module)
6484
- ) {
6485
- /** @type {WebpackError} */
6486
- (execErr).module = module;
6487
- }
6488
- throw execErr;
6489
- }
6490
- };
6491
-
6492
- for (const runtimeModule of chunkGraph.getChunkRuntimeModulesInOrder(
6493
- chunk
6494
- )) {
6495
- __webpack_require_module__(
6496
- /** @type {ExecuteModuleArgument} */
6497
- (moduleArgumentsMap.get(runtimeModule))
6498
- );
6499
- }
6500
-
6501
- exports = __webpack_require__(module.identifier());
6465
+ if (id) moduleCache[id] = moduleObject;
6466
+
6467
+ tryRunOrWebpackError(
6468
+ () =>
6469
+ this.hooks.executeModule.call(
6470
+ moduleArgument,
6471
+ context
6472
+ ),
6473
+ "Compilation.hooks.executeModule"
6474
+ );
6475
+ moduleObject.loaded = true;
6476
+ return moduleObject.exports;
6502
6477
  } catch (execErr) {
6503
- const { message, stack, module } =
6478
+ if (strictModuleExceptionHandling) {
6479
+ if (id) delete moduleCache[id];
6480
+ } else if (strictModuleErrorHandling) {
6481
+ moduleObject.error =
6482
+ /** @type {WebpackError} */
6483
+ (execErr);
6484
+ }
6485
+ if (!(/** @type {WebpackError} */ (execErr).module)) {
6504
6486
  /** @type {WebpackError} */
6505
- (execErr);
6506
- const err = new WebpackError(
6507
- `Execution of module code from module graph (${
6508
- /** @type {Module} */
6509
- (module).readableIdentifier(this.requestShortener)
6510
- }) failed: ${message}`,
6511
- { cause: execErr }
6512
- );
6513
- err.stack = stack;
6514
- err.module = module;
6515
- return callback(err);
6487
+ (execErr).module = module;
6488
+ }
6489
+ throw execErr;
6516
6490
  }
6517
-
6518
- callback(null, {
6519
- exports,
6520
- assets,
6521
- cacheable,
6522
- notCacheableReasons,
6523
- fileDependencies,
6524
- contextDependencies,
6525
- missingDependencies,
6526
- buildDependencies
6527
- });
6491
+ };
6492
+
6493
+ for (const runtimeModule of chunkGraph.getChunkRuntimeModulesInOrder(
6494
+ chunk
6495
+ )) {
6496
+ __webpack_require_module__(
6497
+ /** @type {ExecuteModuleArgument} */
6498
+ (moduleArgumentsMap.get(runtimeModule))
6499
+ );
6528
6500
  }
6529
- );
6501
+
6502
+ exports = __webpack_require__(module.identifier());
6503
+ } catch (execErr) {
6504
+ const { message, stack, module } =
6505
+ /** @type {WebpackError} */
6506
+ (execErr);
6507
+ const err = new WebpackError(
6508
+ `Execution of module code from module graph (${
6509
+ /** @type {Module} */
6510
+ (module).readableIdentifier(this.requestShortener)
6511
+ }) failed: ${message}`,
6512
+ { cause: execErr }
6513
+ );
6514
+ err.stack = stack;
6515
+ err.module = module;
6516
+ return callback(err);
6517
+ }
6518
+
6519
+ callback(null, {
6520
+ exports,
6521
+ assets,
6522
+ cacheable,
6523
+ notCacheableReasons,
6524
+ fileDependencies,
6525
+ contextDependencies,
6526
+ missingDependencies,
6527
+ buildDependencies
6528
+ });
6530
6529
  }
6531
6530
  );
6532
6531
  });
6533
- }
6534
- );
6532
+ });
6533
+ });
6535
6534
  }
6536
6535
  );
6537
6536
  }