@depup/webpack 5.110.1-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 (304) 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/ChunkGraph.js +20 -18
  8. package/lib/CircularModulesPlugin.js +157 -55
  9. package/lib/CleanPlugin.js +2 -2
  10. package/lib/CompatibilityPlugin.js +3 -4
  11. package/lib/Compilation.js +337 -338
  12. package/lib/Compiler.js +213 -51
  13. package/lib/ConcatenationScope.js +25 -35
  14. package/lib/ConstPlugin.js +16 -132
  15. package/lib/CopyPlugin.js +1054 -0
  16. package/lib/DefinePlugin.js +24 -8
  17. package/lib/DependencyTemplate.js +2 -1
  18. package/lib/DotenvPlugin.js +64 -40
  19. package/lib/ErrorHelpers.js +113 -0
  20. package/lib/ExportsInfo.js +30 -16
  21. package/lib/ExternalModule.js +47 -22
  22. package/lib/FileSystemInfo.js +17 -14
  23. package/lib/FlagDependencyExportsPlugin.js +53 -34
  24. package/lib/FlagDependencyUsagePlugin.js +17 -15
  25. package/lib/Generator.js +24 -2
  26. package/lib/HotModuleReplacementPlugin.js +55 -7
  27. package/lib/IgnorePlugin.js +1 -1
  28. package/lib/JavascriptMetaInfoPlugin.js +5 -3
  29. package/lib/LoaderOptionsPlugin.js +1 -1
  30. package/lib/MainTemplate.js +5 -1
  31. package/lib/Module.js +19 -10
  32. package/lib/ModuleGraph.js +6 -9
  33. package/lib/MultiCompiler.js +7 -17
  34. package/lib/MultiWatching.js +1 -1
  35. package/lib/NormalModule.js +148 -70
  36. package/lib/NormalModuleFactory.js +1 -1
  37. package/lib/RuntimeGlobals.js +21 -7
  38. package/lib/RuntimeModule.js +28 -12
  39. package/lib/RuntimePlugin.js +33 -3
  40. package/lib/RuntimeTemplate.js +1147 -847
  41. package/lib/SourceMapDevToolPlugin.js +54 -104
  42. package/lib/TemplatedPathPlugin.js +16 -59
  43. package/lib/Watching.js +9 -0
  44. package/lib/WebpackOptionsApply.js +84 -91
  45. package/lib/asset/AssetBytesGenerator.js +7 -1
  46. package/lib/asset/AssetGenerator.js +50 -24
  47. package/lib/asset/AssetModule.js +3 -0
  48. package/lib/asset/AssetSourceGenerator.js +7 -1
  49. package/lib/asset/WebManifestParser.js +7 -5
  50. package/lib/async-modules/AsyncModuleHelpers.js +10 -4
  51. package/lib/buildChunkGraph.js +11 -15
  52. package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
  53. package/lib/cache/IdleFileCachePlugin.js +2 -2
  54. package/lib/cache/MemoryCachePlugin.js +4 -4
  55. package/lib/cache/MemoryWithGcCachePlugin.js +7 -8
  56. package/lib/cache/PackFileCacheStrategy.js +17 -19
  57. package/lib/cache/getLazyHashedEtag.js +3 -5
  58. package/lib/config/browserslistTargetHandler.js +17 -4
  59. package/lib/config/defaults.js +162 -142
  60. package/lib/config/getClaimedAssetTypes.js +10 -11
  61. package/lib/config/normalization.js +100 -20
  62. package/lib/config/target.js +13 -4
  63. package/lib/container/ContainerReferencePlugin.js +6 -0
  64. package/lib/container/RemoteRuntimeModule.js +9 -0
  65. package/lib/container/declaredRemotes.js +39 -0
  66. package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
  67. package/lib/{ContextModule.js → context/ContextModule.js} +54 -115
  68. package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +19 -21
  69. package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
  70. package/lib/css/CssGenerator.js +27 -11
  71. package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
  72. package/lib/css/CssLoadingRuntimeModule.js +92 -15
  73. package/lib/css/CssModule.js +1 -1
  74. package/lib/css/CssModulesPlugin.js +3 -10
  75. package/lib/css/CssParser.js +162 -31
  76. package/lib/css/CssServerStylesRuntimeModule.js +9 -0
  77. package/lib/css/cssMinify.js +43 -32
  78. package/lib/css/data.js +3526 -871
  79. package/lib/css/syntax.js +6455 -1237
  80. package/lib/debug/ProfilingPlugin.js +7 -4
  81. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
  82. package/lib/dependencies/AMDRuntimeModules.js +18 -0
  83. package/lib/dependencies/CommonJsExportRequireDependency.js +13 -12
  84. package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
  85. package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -5
  86. package/lib/dependencies/CommonJsPlugin.js +19 -3
  87. package/lib/dependencies/CommonJsRequireDependency.js +32 -9
  88. package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
  89. package/lib/dependencies/ContextDependency.js +1 -1
  90. package/lib/dependencies/ContextDependencyHelpers.js +3 -9
  91. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +20 -7
  92. package/lib/dependencies/ContextElementDependency.js +1 -1
  93. package/lib/dependencies/CssIcssExportDependency.js +13 -9
  94. package/lib/dependencies/CssIcssImportDependency.js +3 -6
  95. package/lib/dependencies/CssUrlDependency.js +3 -5
  96. package/lib/dependencies/HarmonyCompatibilityDependency.js +67 -22
  97. package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -4
  98. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +10 -4
  99. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +12 -7
  100. package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
  101. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +217 -34
  102. package/lib/dependencies/HarmonyExportInitFragment.js +110 -23
  103. package/lib/dependencies/HarmonyExportSpecifierDependency.js +25 -58
  104. package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
  105. package/lib/dependencies/HarmonyImportDependency.js +99 -41
  106. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +198 -25
  107. package/lib/dependencies/HarmonyImportSideEffectDependency.js +117 -4
  108. package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
  109. package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
  110. package/lib/dependencies/HtmlEntryDependency.js +136 -104
  111. package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
  112. package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
  113. package/lib/dependencies/ImportContextDependency.js +43 -3
  114. package/lib/dependencies/ImportDependency.js +8 -29
  115. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
  116. package/lib/dependencies/ImportMetaGlobHelpers.js +1 -1
  117. package/lib/dependencies/ImportMetaMainDependency.js +104 -0
  118. package/lib/dependencies/ImportMetaPlugin.js +67 -25
  119. package/lib/dependencies/ImportParserPlugin.js +25 -15
  120. package/lib/dependencies/LoaderPlugin.js +26 -1
  121. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  122. package/lib/dependencies/RequireHeaderDependency.js +20 -21
  123. package/lib/dependencies/SystemRuntimeModule.js +9 -0
  124. package/lib/dependencies/URLContextDependency.js +1 -1
  125. package/lib/dependencies/URLDependency.js +6 -5
  126. package/lib/dependencies/WorkerAndWorkletPlugin.js +16 -21
  127. package/lib/dependencies/WorkerDependency.js +12 -18
  128. package/lib/dependencies/WorkletDependency.js +12 -20
  129. package/lib/dependencies/importOptionsCheck.js +47 -0
  130. package/lib/dll/DelegatedModule.js +18 -1
  131. package/lib/dll/DllReferencePlugin.js +11 -8
  132. package/lib/dll/LibManifestPlugin.js +1 -1
  133. package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
  134. package/lib/errors/DotenvFileError.js +29 -0
  135. package/lib/errors/DuplicateModulesWarning.js +12 -7
  136. package/lib/errors/EmptyCopyPatternWarning.js +26 -0
  137. package/lib/errors/ExternalStarReexportError.js +44 -0
  138. package/lib/errors/HookWebpackError.js +3 -2
  139. package/lib/errors/ImportedBindingAssignmentError.js +30 -0
  140. package/lib/errors/MissingSourceMapsWarning.js +36 -0
  141. package/lib/errors/ModuleParseError.js +2 -1
  142. package/lib/errors/UnusedAssetsWarning.js +36 -0
  143. package/lib/errors/UnusedFederationWarning.js +35 -0
  144. package/lib/errors/UnusedModulesWarning.js +38 -0
  145. package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
  146. package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
  147. package/lib/esm/ModuleChunkLoadingPlugin.js +21 -5
  148. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +91 -53
  149. package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
  150. package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
  151. package/lib/hmr/LazyCompilationPlugin.js +3 -5
  152. package/lib/html/HtmlGenerator.js +72 -87
  153. package/lib/html/HtmlModulesPlugin.js +479 -215
  154. package/lib/html/HtmlParser.js +110 -147
  155. package/lib/html/builtinEmbeddedRenderer.js +107 -0
  156. package/lib/html/data.js +142 -7
  157. package/lib/html/htmlMinify.js +92 -122
  158. package/lib/html/syntax.js +2031 -1556
  159. package/lib/ids/HashedModuleIdsPlugin.js +2 -1
  160. package/lib/index.js +49 -3
  161. package/lib/javascript/ChunkFormatHelpers.js +4 -3
  162. package/lib/javascript/JavascriptGenerator.js +8 -1
  163. package/lib/javascript/JavascriptModule.js +1 -0
  164. package/lib/javascript/JavascriptModulesPlugin.js +76 -80
  165. package/lib/javascript/JavascriptParser.js +1970 -900
  166. package/lib/javascript/StartupHelpers.js +27 -3
  167. package/lib/javascript/data.js +172 -0
  168. package/lib/javascript/grammar.js +5546 -0
  169. package/lib/javascript/parser.js +1500 -0
  170. package/lib/javascript/regexp.js +1762 -0
  171. package/lib/javascript/regexpData.js +51 -0
  172. package/lib/javascript/syntax.js +9061 -5262
  173. package/lib/json/JsonGenerator.js +7 -1
  174. package/lib/library/ModuleLibraryPlugin.js +171 -132
  175. package/lib/loaders/LoaderRunner.js +170 -14
  176. package/lib/node/NodeWatchFileSystem.js +3 -9
  177. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
  178. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +8 -15
  179. package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
  180. package/lib/optimize/AggressiveMergingPlugin.js +3 -5
  181. package/lib/optimize/ConcatenatedModule.js +222 -125
  182. package/lib/optimize/ConstExportsPlugin.js +50 -34
  183. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
  184. package/lib/optimize/InlineExports.js +20 -2
  185. package/lib/optimize/InnerGraphPlugin.js +7 -13
  186. package/lib/optimize/LimitChunkCountPlugin.js +5 -8
  187. package/lib/optimize/MangleExportsPlugin.js +13 -4
  188. package/lib/optimize/ModuleConcatenationPlugin.js +27 -5
  189. package/lib/optimize/RealContentHashPlugin.js +179 -44
  190. package/lib/optimize/SideEffectsFlagPlugin.js +24 -28
  191. package/lib/optimize/SplitChunksPlugin.js +2 -4
  192. package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
  193. package/lib/performance/BroadContextsPlugin.js +1 -1
  194. package/lib/performance/CacheEffectivenessPlugin.js +7 -7
  195. package/lib/performance/DuplicateModulesPlugin.js +57 -13
  196. package/lib/performance/EvalUsagePlugin.js +5 -2
  197. package/lib/performance/MissingSourceMapsPlugin.js +115 -0
  198. package/lib/performance/PureAnnotationsPlugin.js +6 -3
  199. package/lib/performance/SizeLimitsPlugin.js +2 -4
  200. package/lib/performance/TopLevelThisPlugin.js +5 -4
  201. package/lib/performance/UnusedAssetsPlugin.js +109 -0
  202. package/lib/performance/UnusedFederationPlugin.js +147 -0
  203. package/lib/performance/UnusedModulesPlugin.js +141 -0
  204. package/lib/performance/UnusedReexportsPlugin.js +1 -55
  205. package/lib/performance/isOnlyReexported.js +65 -0
  206. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
  207. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +8 -8
  208. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
  209. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
  210. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
  211. package/lib/prefetch/ResourceHintPlugin.js +29 -35
  212. package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
  213. package/lib/prefetch/StartupAssetHintRuntimeModule.js +16 -10
  214. package/lib/rules/RuleSetCompiler.js +211 -4
  215. package/lib/runtime/AsyncModuleRuntimeModule.js +103 -67
  216. package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
  217. package/lib/runtime/BaseUriRuntimeModule.js +9 -0
  218. package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
  219. package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
  220. package/lib/runtime/GetChunkFilenameRuntimeModule.js +12 -4
  221. package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
  222. package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
  223. package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
  224. package/lib/runtime/GlobalRuntimeModule.js +11 -4
  225. package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
  226. package/lib/runtime/HelperRuntimeModule.js +10 -0
  227. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +313 -222
  228. package/lib/runtime/NonceRuntimeModule.js +9 -0
  229. package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
  230. package/lib/runtime/PublicPathRuntimeModule.js +9 -0
  231. package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
  232. package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
  233. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
  234. package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
  235. package/lib/runtime/SystemContextRuntimeModule.js +9 -0
  236. package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
  237. package/lib/schemes/DataUriPlugin.js +3 -6
  238. package/lib/schemes/HttpUriPlugin.js +22 -5
  239. package/lib/schemes/VirtualUrlPlugin.js +1 -1
  240. package/lib/serialization/BinaryMiddleware.js +9 -9
  241. package/lib/serialization/FileMiddleware.js +31 -18
  242. package/lib/serialization/ObjectMiddleware.js +168 -139
  243. package/lib/sharing/ConsumeSharedPlugin.js +12 -0
  244. package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
  245. package/lib/sharing/ShareRuntimeModule.js +9 -0
  246. package/lib/sharing/declaredShared.js +47 -0
  247. package/lib/stats/DefaultStatsFactoryPlugin.js +6 -5
  248. package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
  249. package/lib/typescript/TypeScriptPlugin.js +10 -13
  250. package/lib/url/URLParserPlugin.js +6 -8
  251. package/lib/util/ArrayQueue.js +3 -3
  252. package/lib/util/LocConverter.js +4 -7
  253. package/lib/util/SourceProcessor.js +115 -99
  254. package/lib/util/URLAbsoluteSpecifier.js +3 -1
  255. package/lib/util/async.js +292 -0
  256. package/lib/util/buildDiagnostics.js +69 -0
  257. package/lib/util/chainedImports.js +3 -4
  258. package/lib/util/concatenate.js +4 -4
  259. package/lib/util/conventions.js +5 -1
  260. package/lib/util/createHooksRegistry.js +1 -2
  261. package/lib/util/createMappings.js +25 -3
  262. package/lib/util/dataURL.js +2 -3
  263. package/lib/util/deterministicGrouping.js +8 -13
  264. package/lib/util/findGraphRoots.js +6 -13
  265. package/lib/util/fs.js +27 -1
  266. package/lib/util/globUtils.js +1 -1
  267. package/lib/util/handlerKeys.js +40 -0
  268. package/lib/util/hash/wasm-hash.js +3 -4
  269. package/lib/util/identifier.js +20 -0
  270. package/lib/util/internalSerializables.js +7 -1
  271. package/lib/util/registerExternalSerializer.js +6 -45
  272. package/lib/util/removeBOM.js +82 -1
  273. package/lib/util/semver.js +5 -3
  274. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +14 -3
  275. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +14 -3
  276. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
  277. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
  278. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +7 -12
  279. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +12 -4
  280. package/lib/wasm-sync/WebAssemblyGenerator.js +6 -1
  281. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -1
  282. package/lib/wasm-sync/WebAssemblyUtils.js +2 -4
  283. package/lib/web/FetchCompileAsyncWasmPlugin.js +10 -6
  284. package/lib/web/FetchCompileWasmPlugin.js +4 -2
  285. package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
  286. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
  287. package/package.json +55 -46
  288. package/schemas/WebpackOptions.check.js +1 -1
  289. package/schemas/WebpackOptions.json +388 -76
  290. package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
  291. package/schemas/plugins/ManifestPlugin.check.js +1 -1
  292. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  293. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  294. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  295. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  296. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  297. package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
  298. package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
  299. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
  300. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  301. package/types.d.ts +1795 -608
  302. package/lib/dependencies/ExportBindingInitFragment.js +0 -191
  303. package/lib/errors/EntrypointOverlapWarning.js +0 -45
  304. package/lib/performance/EntrypointOverlapPlugin.js +0 -122
@@ -5,13 +5,13 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const asyncLib = require("neo-async");
9
8
  const { MultiHook, SyncHook } = require("tapable");
10
9
 
11
10
  const MultiStats = require("./MultiStats");
12
11
  const MultiWatching = require("./MultiWatching");
13
12
  const WebpackError = require("./errors/WebpackError");
14
13
  const ArrayQueue = require("./util/ArrayQueue");
14
+ const asyncLib = require("./util/async");
15
15
  const memoize = require("./util/memoize");
16
16
 
17
17
  const getConcurrentCompilationError = memoize(() =>
@@ -158,11 +158,9 @@ module.exports = class MultiCompiler {
158
158
  doneCompilers--;
159
159
  }
160
160
  });
161
- // Release fields on this child's Compilation once it's done. The
162
- // stage: Infinity tap runs after every afterDone tap at a lower
163
- // stage, so plugins observing compilation state in afterDone still
164
- // see it intact. Stats remains usable; only fields Stats never reads
165
- // (and that the persistent cache never serializes) are dropped.
161
+ // Release this child's Compilation fields once it is done. The
162
+ // `stage: Infinity` tap runs last, so a plugin watching in afterDone still
163
+ // sees it intact, and only fields Stats never reads are dropped.
166
164
 
167
165
  compiler.hooks.afterDone.tap(
168
166
  { name: CLASS_NAME, stage: Infinity },
@@ -478,17 +476,9 @@ module.exports = class MultiCompiler {
478
476
  _runGraph(setup, run, callback) {
479
477
  /** @typedef {{ compiler: Compiler, setupResult: undefined | SetupResult, result: undefined | Stats, state: "pending" | "blocked" | "queued" | "starting" | "running" | "running-outdated" | "done", children: Node[], parents: Node[] }} Node */
480
478
 
481
- // State transitions for nodes:
482
- // -> blocked (initial)
483
- // blocked -> starting [running++] (when all parents done)
484
- // queued -> starting [running++] (when processing the queue)
485
- // starting -> running (when run has been called)
486
- // running -> done [running--] (when compilation is done)
487
- // done -> pending (when invalidated from file change)
488
- // pending -> blocked [add to queue] (when invalidated from aggregated changes)
489
- // done -> blocked [add to queue] (when invalidated, from parent invalidation)
490
- // running -> running-outdated (when invalidated, either from change or parent invalidation)
491
- // running-outdated -> blocked [running--] (when compilation is done)
479
+ // A node starts blocked and reaches `starting` once its parents are done or
480
+ // the queue reaches it, then `running`, then `done`. Invalidation sends it
481
+ // back to `blocked`, or to `running-outdated` if it is mid-compilation.
492
482
 
493
483
  /** @type {Node[]} */
494
484
  const nodes = this.compilers.map((compiler) => ({
@@ -5,7 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const asyncLib = require("neo-async");
8
+ const asyncLib = require("./util/async");
9
9
 
10
10
  /** @import MultiCompiler from "./MultiCompiler" */
11
11
  /** @import Watching from "./Watching" */
@@ -8,9 +8,9 @@
8
8
  const querystring = require("querystring");
9
9
  const {
10
10
  AsyncSeriesBailHook,
11
+ AsyncSeriesWaterfallHook,
11
12
  HookMap,
12
- SyncHook,
13
- SyncWaterfallHook
13
+ SyncHook
14
14
  } = require("tapable");
15
15
  const {
16
16
  CachedSource,
@@ -19,6 +19,7 @@ const {
19
19
  SourceMapSource
20
20
  } = require("webpack-sources");
21
21
  const Dependency = require("./Dependency");
22
+ const { toError } = require("./ErrorHelpers");
22
23
  const Module = require("./Module");
23
24
  const ModuleGraphConnection = require("./ModuleGraphConnection");
24
25
  const { JAVASCRIPT_MODULE_TYPE_AUTO } = require("./ModuleTypeConstants");
@@ -33,6 +34,7 @@ const {
33
34
  const LazySet = require("./util/LazySet");
34
35
  const { isSubset } = require("./util/SetHelpers");
35
36
  const { getScheme } = require("./util/URLAbsoluteSpecifier");
37
+ const { getBuildDiagnostics } = require("./util/buildDiagnostics");
36
38
  const {
37
39
  concatComparators,
38
40
  keepOriginalOrder,
@@ -67,10 +69,6 @@ const getUnhandledSchemeError = memoize(() =>
67
69
  require("./errors/UnhandledSchemeError")
68
70
  );
69
71
 
70
- const getNonErrorEmittedError = memoize(() =>
71
- require("./errors/NonErrorEmittedError")
72
- );
73
-
74
72
  const getModuleWarning = memoize(() => require("./errors/ModuleWarning"));
75
73
 
76
74
  const getModuleParseError = memoize(() => require("./errors/ModuleParseError"));
@@ -79,17 +77,21 @@ const getModuleError = memoize(() => require("./errors/ModuleError"));
79
77
 
80
78
  const getModuleBuildError = memoize(() => require("./errors/ModuleBuildError"));
81
79
 
82
- /** @import { ResolveContext, ResolveRequest } from "enhanced-resolve" */
80
+ /** @import { ResolveContext, ResolveRequest, Resolver } from "enhanced-resolve" */
83
81
  /** @import { Source, RawSourceMap } from "webpack-sources" */
84
82
  /**
85
83
  * @import {
86
84
  * ResolveOptions,
87
85
  * NoParse,
88
- * HashFunction
86
+ * HashFunction,
87
+ * HashDigest,
88
+ * HashDigestLength,
89
+ * HashSalt
89
90
  * } from "../declarations/WebpackOptions"
90
91
  */
91
92
  /**
92
93
  * @import Compilation, {
94
+ * AssetInfo,
93
95
  * FileSystemDependencies,
94
96
  * UnsafeCacheData
95
97
  * } from "./Compilation"
@@ -109,7 +111,6 @@ const getModuleBuildError = memoize(() => require("./errors/ModuleBuildError"));
109
111
  * BuildMeta,
110
112
  * CodeGenerationContext,
111
113
  * CodeGenerationResult,
112
- * CodeGenerationResultData,
113
114
  * ConcatenationBailoutReasonContext,
114
115
  * KnownBuildInfo,
115
116
  * LibIdentOptions,
@@ -119,7 +120,6 @@ const getModuleBuildError = memoize(() => require("./errors/ModuleBuildError"));
119
120
  * NeedBuildCallback,
120
121
  * BuildCallback,
121
122
  * RuntimeRequirements,
122
- * Sources,
123
123
  * SourceType,
124
124
  * SourceTypes
125
125
  * } from "./Module"
@@ -138,7 +138,14 @@ const getModuleBuildError = memoize(() => require("./errors/ModuleBuildError"));
138
138
  */
139
139
  /** @import Parser, { PreparsedAst } from "./Parser" */
140
140
  /** @import RequestShortener from "./RequestShortener" */
141
- /** @import { ResolverWithOptions } from "./ResolverFactory" */
141
+ /** @import Compiler from "./Compiler" */
142
+ /** @import { Logger } from "./logging/Logger" */
143
+ /**
144
+ * @import {
145
+ * ResolverWithOptions,
146
+ * ResolveOptionsWithDependencyType
147
+ * } from "./ResolverFactory"
148
+ */
142
149
  /**
143
150
  * @import {
144
151
  * ObjectDeserializerContext,
@@ -156,14 +163,65 @@ const getModuleBuildError = memoize(() => require("./errors/ModuleBuildError"));
156
163
  /** @typedef {{ [k: string]: EXPECTED_ANY }} ParserOptions */
157
164
  /** @typedef {{ [k: string]: EXPECTED_ANY }} GeneratorOptions */
158
165
 
166
+ /** @typedef {Parameters<Resolver["resolve"]>[4]} ResolveCallback */
167
+ /** @typedef {Parameters<typeof import("schema-utils").validate>[0]} Schema */
168
+
159
169
  /**
160
- * @template T
161
- * @typedef {import("../declarations/LoaderContext").LoaderContext<T>} LoaderContext
170
+ * `getOptions` validates against a schema when given one, and TypeScript reads
171
+ * an intersection of call signatures as an overload set
172
+ * @template OptionsType
173
+ * @typedef {{ (): OptionsType } & { (schema: Schema): OptionsType }} GetOptionsMethod
174
+ */
175
+
176
+ /**
177
+ * @typedef {((context: string, request: string, callback: ResolveCallback) => void) & ((context: string, request: string) => Promise<string>)} DualModeResolve
178
+ */
179
+
180
+ /**
181
+ * @typedef {object} LoaderContextUtils
182
+ * @property {(context: string, request: string) => string} absolutify returns a new request string using absolute paths when possible
183
+ * @property {(context: string, request: string) => string} contextify returns a new request string avoiding absolute paths when possible
184
+ * @property {(algorithm?: string | typeof Hash) => Hash} createHash creates a hash with the compilation's function
185
+ */
186
+
187
+ /**
188
+ * These properties are added by the NormalModule
189
+ * @template OptionsType
190
+ * @typedef {object} NormalModuleLoaderContext
191
+ * @property {number} version
192
+ * @property {GetOptionsMethod<OptionsType>} getOptions Extracts and parses the options of the current loader.
193
+ * Parses string options as JSON or a query string.
194
+ * @property {(warning: Error | string) => void} emitWarning Emits a warning for this module.
195
+ * The warning will be displayed to the user during compilation.
196
+ * @property {(error: Error | string) => void} emitError Emits an error for this module.
197
+ * The error will be displayed to the user and typically causes the compilation to fail.
198
+ * @property {(name?: string) => Logger} getLogger Gets a logger instance scoped to this loader and module.
199
+ * Useful for emitting debug or compilation information in a structured way.
200
+ * @property {(context: string, request: string, callback: ResolveCallback) => void} resolve Resolves a module request (e.g., a relative path or module name) to an absolute file path.
201
+ * It uses Webpack's internal resolver, taking into account configured aliases and extensions.
202
+ * @property {(options?: ResolveOptionsWithDependencyType) => DualModeResolve} getResolve Creates a resolve function with specific options.
203
+ * The returned function can be used as a Promise-based resolver or a callback-based resolver.
204
+ * @property {(name: string, content: string | Buffer, sourceMap?: string, assetInfo?: AssetInfo) => void} emitFile Emits a new file (asset) to the compilation output directory.
205
+ * This allows loaders to generate additional files alongside the main module output.
206
+ * @property {(dep: string) => void} addBuildDependency
207
+ * @property {LoaderContextUtils} utils
208
+ * @property {string} rootContext
209
+ * @property {InputFileSystem} fs
210
+ * @property {boolean=} sourceMap
211
+ * @property {"development" | "production" | "none"} mode
212
+ * @property {boolean=} webpack
213
+ * @property {HashFunction} hashFunction
214
+ * @property {HashDigest} hashDigest
215
+ * @property {HashDigestLength} hashDigestLength
216
+ * @property {HashSalt=} hashSalt
217
+ * @property {NormalModule=} _module
218
+ * @property {Compilation=} _compilation
219
+ * @property {Compiler=} _compiler
162
220
  */
163
221
 
164
222
  /**
165
223
  * @template T
166
- * @typedef {import("../declarations/LoaderContext").NormalModuleLoaderContext<T>} NormalModuleLoaderContext
224
+ * @typedef {NormalModuleLoaderContext<T> & import("./loaders/LoaderRunner").LoaderRunnerLoaderContext<T> & import("./dependencies/LoaderPlugin").LoaderPluginLoaderContext & import("./HotModuleReplacementPlugin").HotModuleReplacementPluginLoaderContext} LoaderContext
167
225
  */
168
226
 
169
227
  /** @typedef {(content: string) => boolean} NoParseFn */
@@ -184,7 +242,9 @@ const recordSideEffectsBailout = (mod, moduleGraph, dep) => {
184
242
  .getOptimizationBailout(mod)
185
243
  .push(
186
244
  () =>
187
- `Dependency (${dep.type}) with side effects at ${formatLocation(dep.loc)}`
245
+ `Dependency (${dep.type}) with side effects at ${formatLocation(
246
+ dep.loc
247
+ )}`
188
248
  );
189
249
  };
190
250
 
@@ -347,10 +407,9 @@ const walkSideEffects = (rootMod, moduleGraph, SideEffectDep) => {
347
407
  }
348
408
  }
349
409
  } else {
350
- // Non-NormalModule (e.g. ConcatenatedModule delegating back
351
- // through here) resolves via a re-entrant walk that may see our
352
- // in-progress modules as circular, so taint this chain: never
353
- // memoize it.
410
+ // A non-NormalModule resolves through a re-entrant walk that may read
411
+ // our in-progress modules as circular, so this chain is tainted and
412
+ // never memoized.
354
413
  state = refModule.getSideEffectsConnectionState(moduleGraph);
355
414
  lowOf.set(mod, -1);
356
415
  }
@@ -542,10 +601,12 @@ const createCompilationHooks = () => {
542
601
  */
543
602
  beforeSnapshot: new SyncHook(["module"]),
544
603
  /**
545
- * @type {SyncWaterfallHook<[Result, NormalModule]>}
604
+ * Async since 5.111.0, so a tap can await work of its own — minifying an
605
+ * asset, say, which before only a loader could do. `tap` keeps working.
606
+ * @type {AsyncSeriesWaterfallHook<[Result, NormalModule]>}
546
607
  * @since 5.99.0
547
608
  */
548
- processResult: new SyncWaterfallHook(["result", "module"]),
609
+ processResult: new AsyncSeriesWaterfallHook(["result", "module"]),
549
610
  /**
550
611
  * @type {AsyncSeriesBailHook<[NormalModule, NeedBuildContext], boolean>}
551
612
  * @since 5.49.0
@@ -728,11 +789,6 @@ class NormalModule extends Module {
728
789
  this._sideEffectsStateGraph = undefined;
729
790
  /** @type {ConnectionState | undefined} */
730
791
  this._sideEffectsStateValue = undefined;
731
- /**
732
- * @private
733
- * @type {CodeGenerationResultData}
734
- */
735
- this._codeGeneratorData = new Map();
736
792
  }
737
793
 
738
794
  /**
@@ -954,7 +1010,7 @@ class NormalModule extends Module {
954
1010
  * @param {Compilation} compilation the compilation
955
1011
  * @param {InputFileSystem} fs file system from reading
956
1012
  * @param {NormalModuleCompilationHooks} hooks the hooks
957
- * @returns {import("../declarations/LoaderContext").LoaderContext<T>} loader context
1013
+ * @returns {LoaderContext<T>} loader context
958
1014
  */
959
1015
  _createLoaderContext(resolver, options, compilation, fs, hooks) {
960
1016
  const { requestShortener } = compilation.runtimeTemplate;
@@ -1052,7 +1108,9 @@ class NormalModule extends Module {
1052
1108
  (parseJson(options));
1053
1109
  } catch (err) {
1054
1110
  throw new Error(
1055
- `Cannot parse string options: ${/** @type {Error} */ (err).message}`,
1111
+ `Cannot parse string options: ${
1112
+ /** @type {Error} */ (err).message
1113
+ }`,
1056
1114
  { cause: err }
1057
1115
  );
1058
1116
  }
@@ -1085,22 +1143,16 @@ class NormalModule extends Module {
1085
1143
  },
1086
1144
  /** @type {LoaderContext<EXPECTED_ANY>["emitWarning"]} */
1087
1145
  emitWarning: (warning) => {
1088
- if (!(warning instanceof Error)) {
1089
- warning = new (getNonErrorEmittedError())(warning);
1090
- }
1091
1146
  this.addWarning(
1092
- new (getModuleWarning())(warning, {
1147
+ new (getModuleWarning())(toError(warning), {
1093
1148
  from: getCurrentLoaderName()
1094
1149
  })
1095
1150
  );
1096
1151
  },
1097
1152
  /** @type {LoaderContext<EXPECTED_ANY>["emitError"]} */
1098
1153
  emitError: (error) => {
1099
- if (!(error instanceof Error)) {
1100
- error = new (getNonErrorEmittedError())(error);
1101
- }
1102
1154
  this.addError(
1103
- new (getModuleError())(error, {
1155
+ new (getModuleError())(toError(error), {
1104
1156
  from: getCurrentLoaderName()
1105
1157
  })
1106
1158
  );
@@ -1124,7 +1176,7 @@ class NormalModule extends Module {
1124
1176
  /** @type {LoaderContext<EXPECTED_ANY>["getResolve"]} */
1125
1177
  getResolve(options) {
1126
1178
  const child = options ? resolver.withOptions(options) : resolver;
1127
- return /** @type {ReturnType<import("../declarations/LoaderContext").NormalModuleLoaderContext<T>["getResolve"]>} */ (
1179
+ return /** @type {ReturnType<NormalModuleLoaderContext<T>["getResolve"]>} */ (
1128
1180
  (context, request, callback) => {
1129
1181
  if (callback) {
1130
1182
  child.resolve(
@@ -1292,11 +1344,8 @@ class NormalModule extends Module {
1292
1344
  */
1293
1345
  const processResult = (err, result_) => {
1294
1346
  if (err) {
1295
- if (!(err instanceof Error)) {
1296
- err = new (getNonErrorEmittedError())(err);
1297
- }
1298
1347
  const currentLoader = this.getCurrentLoader(loaderContext);
1299
- const error = new (getModuleBuildError())(err, {
1348
+ const error = new (getModuleBuildError())(toError(err), {
1300
1349
  from:
1301
1350
  currentLoader &&
1302
1351
  compilation.runtimeTemplate.requestShortener.shorten(
@@ -1305,11 +1354,30 @@ class NormalModule extends Module {
1305
1354
  });
1306
1355
  return callback(error);
1307
1356
  }
1308
- const result = hooks.processResult.call(
1357
+ hooks.processResult.callAsync(
1309
1358
  /** @type {Result} */
1310
1359
  (result_),
1311
- this
1360
+ this,
1361
+ (hookErr, hookResult) => {
1362
+ if (hookErr) {
1363
+ // Named, so a tap's failure is not read as a loader's.
1364
+ return callback(
1365
+ new (getModuleBuildError())(toError(hookErr), {
1366
+ from: "processResult hook"
1367
+ })
1368
+ );
1369
+ }
1370
+
1371
+ finishResult(/** @type {Result} */ (hookResult));
1372
+ }
1312
1373
  );
1374
+ };
1375
+
1376
+ /**
1377
+ * @param {Result} result the result the hook settled on
1378
+ * @returns {void}
1379
+ */
1380
+ const finishResult = (result) => {
1313
1381
  const source = result[0];
1314
1382
  const sourceMap = result.length >= 1 ? result[1] : null;
1315
1383
  const extraInfo = result.length >= 2 ? result[2] : null;
@@ -1441,7 +1509,9 @@ class NormalModule extends Module {
1441
1509
  })
1442
1510
  ).catch((err) => {
1443
1511
  throw new Error(
1444
- `Failed to parse source map. ${/** @type {Error} */ (err).message}`
1512
+ `Failed to parse source map. ${
1513
+ /** @type {Error} */ (err).message
1514
+ }`
1445
1515
  );
1446
1516
  })
1447
1517
  );
@@ -1501,7 +1571,8 @@ class NormalModule extends Module {
1501
1571
  }
1502
1572
  buildInfo.cacheable = buildInfo.cacheable && result.cacheable;
1503
1573
  if (result.notCacheableReasons.length > 0) {
1504
- buildInfo.notCacheableReasons = result.notCacheableReasons;
1574
+ getBuildDiagnostics(buildInfo).notCacheableReasons =
1575
+ result.notCacheableReasons;
1505
1576
  }
1506
1577
  processResult(err, result.result);
1507
1578
  }
@@ -1509,14 +1580,16 @@ class NormalModule extends Module {
1509
1580
  }
1510
1581
 
1511
1582
  /**
1512
- * @param {Error} error the error
1583
+ * Marks the module as failed, so what it generates says so. A tap or a
1584
+ * loader may fail with anything, and what reads the failure expects an error.
1585
+ * @param {EXPECTED_ANY} error what the module failed with
1513
1586
  * @returns {void}
1514
1587
  */
1515
1588
  markModuleAsErrored(error) {
1516
1589
  // Restore build meta from successful build to keep importing state
1517
1590
  this.buildMeta = { ...this._lastSuccessfulBuildMeta };
1518
- this.error = error;
1519
- this.addError(error);
1591
+ this.error = toError(error);
1592
+ this.addError(this.error);
1520
1593
  }
1521
1594
 
1522
1595
  /**
@@ -1609,7 +1682,6 @@ class NormalModule extends Module {
1609
1682
  };
1610
1683
  this.buildInfo = {
1611
1684
  cacheable: false,
1612
- notCacheableReasons: undefined,
1613
1685
  parsed: true,
1614
1686
  fileDependencies: undefined,
1615
1687
  contextDependencies: undefined,
@@ -1627,6 +1699,8 @@ class NormalModule extends Module {
1627
1699
  pureFunctions: undefined,
1628
1700
  inlineExports: undefined,
1629
1701
  moduleConcatenationBailout: undefined,
1702
+ moduleConcatenationRootBailout: undefined,
1703
+ diagnostics: undefined,
1630
1704
  needCreateRequire: undefined,
1631
1705
  usesTopLevelUsingDeclaration: undefined
1632
1706
  };
@@ -1682,7 +1756,7 @@ class NormalModule extends Module {
1682
1756
  try {
1683
1757
  hooks.beforeSnapshot.call(this);
1684
1758
  } catch (err) {
1685
- this.markModuleAsErrored(/** @type {Error} */ (err));
1759
+ this.markModuleAsErrored(err);
1686
1760
  return callback();
1687
1761
  }
1688
1762
 
@@ -1776,7 +1850,7 @@ class NormalModule extends Module {
1776
1850
  try {
1777
1851
  hooks.beforeParse.call(this);
1778
1852
  } catch (err) {
1779
- this.markModuleAsErrored(/** @type {Error} */ (err));
1853
+ this.markModuleAsErrored(err);
1780
1854
  this._initBuildHash(compilation);
1781
1855
  return callback();
1782
1856
  }
@@ -1892,10 +1966,19 @@ class NormalModule extends Module {
1892
1966
  runtimeRequirements.add(RuntimeGlobals.thisAsExports);
1893
1967
  }
1894
1968
 
1895
- const getData = () => this._codeGeneratorData;
1969
+ /** @type {CodeGenerationResult} */
1970
+ const resultEntry = {
1971
+ sources: new Map(),
1972
+ runtimeRequirements,
1973
+ data: undefined,
1974
+ hash: undefined
1975
+ };
1976
+
1977
+ const getData = () => {
1978
+ if (resultEntry.data === undefined) resultEntry.data = new Map();
1979
+ return resultEntry.data;
1980
+ };
1896
1981
 
1897
- /** @type {Sources} */
1898
- const sources = new Map();
1899
1982
  for (const type of sourceTypes || chunkGraph.getModuleSourceTypes(this)) {
1900
1983
  // TODO webpack@6 make generateError required
1901
1984
  const generator =
@@ -1915,7 +1998,13 @@ class NormalModule extends Module {
1915
1998
  getData,
1916
1999
  type
1917
2000
  })
1918
- : new RawSource(getGenerator().throwBuildErrorCode(this.error))
2001
+ : new RawSource(
2002
+ getGenerator().throwBuildErrorCode(
2003
+ this.error,
2004
+ undefined,
2005
+ runtimeTemplate.requestShortener
2006
+ )
2007
+ )
1919
2008
  : generator.generate(this, {
1920
2009
  dependencyTemplates,
1921
2010
  runtimeTemplate,
@@ -1930,17 +2019,10 @@ class NormalModule extends Module {
1930
2019
  });
1931
2020
 
1932
2021
  if (source) {
1933
- sources.set(type, new CachedSource(source));
2022
+ resultEntry.sources.set(type, new CachedSource(source));
1934
2023
  }
1935
2024
  }
1936
2025
 
1937
- /** @type {CodeGenerationResult} */
1938
- const resultEntry = {
1939
- sources,
1940
- runtimeRequirements,
1941
- data: this._codeGeneratorData,
1942
- hash: undefined
1943
- };
1944
2026
  return resultEntry;
1945
2027
  }
1946
2028
 
@@ -2088,10 +2170,8 @@ class NormalModule extends Module {
2088
2170
  /** @type {string} */
2089
2171
  (buildInfo.hash)
2090
2172
  );
2091
- // Clear cached source types and re-compute so that changes in incoming
2092
- // connections (e.g. asset module newly referenced from JS via lazy
2093
- // compilation) are reflected in the hash and trigger code generation
2094
- // cache invalidation.
2173
+ // Recompute the source types, so a change in the incoming connections reaches
2174
+ // the hash and invalidates the code-generation cache.
2095
2175
  // https://github.com/webpack/webpack/issues/20800
2096
2176
  this._sourceTypes = undefined;
2097
2177
  for (const type of this.getSourceTypes()) {
@@ -2116,7 +2196,6 @@ class NormalModule extends Module {
2116
2196
  write(this.error);
2117
2197
  write(this._lastSuccessfulBuildMeta);
2118
2198
  write(this._forceBuild);
2119
- write(this._codeGeneratorData);
2120
2199
  write(this.hot);
2121
2200
  super.serialize(context);
2122
2201
  }
@@ -2143,7 +2222,7 @@ class NormalModule extends Module {
2143
2222
  parserOptions: /** @type {EXPECTED_ANY} */ (null),
2144
2223
  generator: /** @type {EXPECTED_ANY} */ (null),
2145
2224
  generatorOptions: /** @type {EXPECTED_ANY} */ (null),
2146
- resolveOptions: /** @type {EXPECTED_ANY} */ (null),
2225
+ resolveOptions: undefined,
2147
2226
  extractSourceMap: /** @type {EXPECTED_ANY} */ (null)
2148
2227
  });
2149
2228
  obj.deserialize(context);
@@ -2160,7 +2239,6 @@ class NormalModule extends Module {
2160
2239
  this.error = read();
2161
2240
  this._lastSuccessfulBuildMeta = read();
2162
2241
  this._forceBuild = read();
2163
- this._codeGeneratorData = read();
2164
2242
  this.hot = read();
2165
2243
  super.deserialize(context);
2166
2244
  }
@@ -5,7 +5,6 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const asyncLib = require("neo-async");
9
8
  const {
10
9
  AsyncSeriesBailHook,
11
10
  AsyncSeriesHook,
@@ -30,6 +29,7 @@ const RuleSetCompiler = require("./rules/RuleSetCompiler");
30
29
  const UseEffectRulePlugin = require("./rules/UseEffectRulePlugin");
31
30
  const LazySet = require("./util/LazySet");
32
31
  const { getScheme } = require("./util/URLAbsoluteSpecifier");
32
+ const asyncLib = require("./util/async");
33
33
  const { cachedCleverMerge, cachedSetProperty } = require("./util/cleverMerge");
34
34
  const {
35
35
  applyCaseCorrections,
@@ -15,13 +15,6 @@ module.exports.amdDefine = "__webpack_require__.amdD";
15
15
  */
16
16
  module.exports.amdOptions = "__webpack_require__.amdO";
17
17
 
18
- /**
19
- * analyzable single-chunk `import()` that keeps `ensureChunk` timing and deduplication:
20
- * resolves immediately for an installed chunk, else runs the literal import and installs it
21
- * Signature: (chunkId, () => Promise) => Promise
22
- */
23
- module.exports.analyzableChunkImport = "__webpack_require__.ei";
24
-
25
18
  /**
26
19
  * Creates an async module. The body function must be a async function.
27
20
  * "module.exports" will be decorated with an AsyncModulePromise.
@@ -254,12 +247,28 @@ module.exports.hasCssModules = "has css modules";
254
247
  */
255
248
  module.exports.hasFetchPriority = "has fetch priority";
256
249
 
250
+ /**
251
+ * a flag when a deferred startup callback carries a priority
252
+ */
253
+ module.exports.hasChunkPriority = "has chunk priority";
254
+
257
255
  /**
258
256
  * the shorthand for Object.prototype.hasOwnProperty
259
257
  * using of it decreases the compiled bundle size
260
258
  */
261
259
  module.exports.hasOwnProperty = "__webpack_require__.o";
262
260
 
261
+ /**
262
+ * a flag when a deferred namespace is built from a known export list
263
+ */
264
+ module.exports.hasSealedDeferredNamespace = "has sealed deferred namespace";
265
+
266
+ /**
267
+ * a flag when a deferred namespace is synthesized from the module's exports
268
+ */
269
+ module.exports.hasSynthesizedDeferredNamespace =
270
+ "has synthesized deferred namespace";
271
+
263
272
  /**
264
273
  * function downloading the update manifest
265
274
  */
@@ -447,6 +456,11 @@ module.exports.setAnonymousDefaultName = "__webpack_require__.dn";
447
456
  */
448
457
  module.exports.shareScopeMap = "__webpack_require__.S";
449
458
 
459
+ /**
460
+ * wrap an exports object in a spec Module Namespace Exotic Object
461
+ */
462
+ module.exports.specNamespaceObject = "__webpack_require__.ns";
463
+
450
464
  /**
451
465
  * startup signal from runtime
452
466
  * This will be called when the runtime chunk has been loaded.
@@ -136,22 +136,31 @@ class RuntimeModule extends Module {
136
136
  updateHash(hash, context) {
137
137
  hash.update(this.name);
138
138
  hash.update(`${this.stage}`);
139
- try {
140
- const code =
141
- this.fullHash || this.dependentHash
142
- ? // Do not use getGeneratedCode here, because i. e. compilation hash might be not
143
- // ready at this point. We will cache it later instead.
144
- this.generate()
145
- : this.getGeneratedCode();
146
- if (code !== null && code !== undefined) {
147
- hash.update(code);
148
- }
149
- } catch (err) {
150
- hash.update(/** @type {Error} */ (err).message);
139
+ // A failing `generate()` propagates: hashing its message instead pins the etag
140
+ // of the code generation cache to a constant, which then serves stale code.
141
+ const code =
142
+ this.fullHash || this.dependentHash
143
+ ? // Do not use getGeneratedCode here, because i. e. compilation hash might be not
144
+ // ready at this point. We will cache it later instead.
145
+ this.generate()
146
+ : this.getGeneratedCode();
147
+ if (code !== null && code !== undefined) {
148
+ hash.update(code);
151
149
  }
152
150
  super.updateHash(hash, context);
153
151
  }
154
152
 
153
+ /**
154
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
155
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
156
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
157
+ */
158
+ getInstalledChunkHandlers() {
159
+ // Answering `null` rather than "none" keeps a module that never heard of this
160
+ // out of a dispatch that would skip the handler it installs.
161
+ return null;
162
+ }
163
+
155
164
  /**
156
165
  * Returns the source types this module can generate.
157
166
  * @returns {SourceTypes} types available (do not mutate)
@@ -244,6 +253,13 @@ class RuntimeModule extends Module {
244
253
  }
245
254
  }
246
255
 
256
+ /**
257
+ * The answer a runtime module gives when it installs no chunk handler at all
258
+ */
259
+ RuntimeModule.NO_CHUNK_HANDLERS =
260
+ /** @type {[string, string][]} */
261
+ ([]);
262
+
247
263
  /**
248
264
  * Runtime modules without any dependencies to other runtime modules
249
265
  */