@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
@@ -300,7 +300,12 @@ const collectEntrypointHints = (compilation, entryName, hints) => {
300
300
  const out = [];
301
301
  /** @type {Set<string>} */
302
302
  const seenKeys = new Set();
303
- const push = (/** @type {EntrypointHint} */ h) => {
303
+ /**
304
+ * Appends a hint, dropping one already emitted for the same rel + href.
305
+ * @param {EntrypointHint} h hint to append
306
+ * @returns {void}
307
+ */
308
+ const push = (h) => {
304
309
  const key = `${h.rel}\0${h.href}`;
305
310
  if (seenKeys.has(key)) return;
306
311
  seenKeys.add(key);
@@ -380,10 +385,9 @@ const collectEntrypointHints = (compilation, entryName, hints) => {
380
385
  if (dep.fetchPriority) h.fetchPriority = dep.fetchPriority;
381
386
  push(h);
382
387
  }
383
- // `hostType`: `"html"` iff the entrypoint has an extracted HTML page
384
- // (any `HtmlEntryDependency` with elementKind `script`/`script-module` on
385
- // any HTML module points at this entryName); SSR frameworks reading
386
- // `stats.entrypoints[name].resourceHints` see `"js"`.
388
+ // `hostType` is `"html"` only where the entrypoint has an extracted page, that
389
+ // is where some HTML module's script dependency names this entry. An SSR
390
+ // framework reading the stats sees `"js"`.
387
391
  let hostType = /** @type {"html" | "js"} */ ("js");
388
392
 
389
393
  outer: for (const module of compilation.modules) {
@@ -481,19 +485,12 @@ const collectStartupAssetHintLines = (
481
485
  seenWorkerChunks.add(workerChunk.id);
482
486
  // The same specifier the `new Worker(...)` call site bakes, asked of the
483
487
  // same module, so the two agree on whether a literal is spellable.
484
- const specifier = runtimeTemplate.supportsAnalyzable(
485
- "url",
486
- chunkGraph,
487
- module
488
- )
489
- ? runtimeTemplate._getAnalyzableChunkSpecifier(
490
- dep.options.publicPath,
491
- workerChunk,
492
- module,
493
- chunkGraph,
494
- set
495
- )
496
- : null;
488
+ const specifier = runtimeTemplate.getAnalyzableWorkerUrl(
489
+ dep.options.publicPath,
490
+ workerChunk,
491
+ module,
492
+ chunkGraph
493
+ );
497
494
  // Without one the call site keeps the runtime form, where it wraps its own
498
495
  // href — firing the `<link>` here too would emit the call twice.
499
496
  if (specifier === null) continue;
@@ -739,15 +736,14 @@ class ResourceHintPlugin {
739
736
  const hints = this._hints;
740
737
 
741
738
  compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
742
- // Lazy-computed on first access — walk every HTML module's
743
- // `HtmlEntryDependency`s, resolve each named entry, and collect
744
- // every URL asset dep target reachable from its ordered chunks.
745
- // One pass produces two views: a per-entry list (consumed by
746
- // `HtmlEntryDependency.Template` to emit `<link>` tags) and a
747
- // global `WeakSet` (consumed by `StartupAssetHintRuntimeModule`
748
- // to skip the JS runtime `<link>` for the same asset).
749
- // Deterministic (module graph is fixed by seal time) and cheap
750
- // (only fires when a JS chunk actually produces hints).
739
+ // WHY: computed on first access. One walk of every HTML module's
740
+ // `HtmlEntryDependency`s — resolving each named entry and collecting every
741
+ // URL asset dep reachable from its ordered chunks — yields both views: a
742
+ // per-entry list, which `HtmlEntryDependency.Template` emits the `<link>`
743
+ // tags from, and a global `WeakSet`, which `StartupAssetHintRuntimeModule`
744
+ // reads to skip the JS runtime `<link>` for the same asset. Deterministic,
745
+ // the module graph being fixed by seal time, and cheap, since it only fires
746
+ // when a JS chunk actually produces hints.
751
747
  /** @type {Map<string, HtmlHintedAsset[]> | undefined} */
752
748
  let perEntry;
753
749
  /** @type {WeakSet<Module> | undefined} */
@@ -775,10 +771,9 @@ class ResourceHintPlugin {
775
771
  }
776
772
  const entrypoint = compilation.entrypoints.get(dep.entryName);
777
773
  if (!entrypoint) continue;
778
- // Mirror `getEntrypointChunksInLoadOrder`: entry chunk +
779
- // runtime chunk + all initial siblings (`entrypoint.chunks`
780
- // includes splitChunks output). Async `import()` chunks
781
- // stay on the on-demand runtime and are NOT HTML-hinted.
774
+ // Mirrors `getEntrypointChunksInLoadOrder`: the entry, runtime and
775
+ // every initial sibling. An async `import()` chunk stays on the
776
+ // on-demand runtime and is never HTML-hinted.
782
777
  /** @type {Set<import("../Chunk")>} */
783
778
  const chunks = new Set(entrypoint.chunks);
784
779
  const entry = entrypoint.getEntrypointChunk();
@@ -866,10 +861,9 @@ class ResourceHintPlugin {
866
861
  });
867
862
  }
868
863
 
869
- // SSR manifest: serialize each entrypoint's resolved hints to a JSON
870
- // asset (the same descriptors as `stats.entrypoints[].resourceHints`)
871
- // so an SSR server can inject the `<link>` tags itself. `"none"`
872
- // yields empty lists (via `collectEntrypointHints`).
864
+ // The SSR manifest serializes each entrypoint's resolved hints to a JSON
865
+ // asset, the same descriptors the stats carry, so an SSR server can inject
866
+ // the tags itself. `"none"` yields empty lists.
873
867
  const rhOptions = compilation.outputOptions.resourceHints;
874
868
  const manifestPath = rhOptions && rhOptions.manifest;
875
869
  if (manifestPath) {
@@ -50,6 +50,15 @@ class ResourceHintRuntimeModule extends RuntimeModule {
50
50
  this._rel = rel;
51
51
  }
52
52
 
53
+ /**
54
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
55
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
56
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
57
+ */
58
+ getInstalledChunkHandlers() {
59
+ return RuntimeModule.NO_CHUNK_HANDLERS;
60
+ }
61
+
53
62
  /**
54
63
  * Generates runtime code for this runtime module.
55
64
  * @returns {string | null} runtime code
@@ -30,6 +30,15 @@ class StartupAssetHintRuntimeModule extends RuntimeModule {
30
30
  this._lines = lines;
31
31
  }
32
32
 
33
+ /**
34
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
35
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
36
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
37
+ */
38
+ getInstalledChunkHandlers() {
39
+ return RuntimeModule.NO_CHUNK_HANDLERS;
40
+ }
41
+
33
42
  /**
34
43
  * Generates runtime code for this runtime module.
35
44
  * @returns {string | null} runtime code
@@ -38,16 +47,13 @@ class StartupAssetHintRuntimeModule extends RuntimeModule {
38
47
  const compilation = /** @type {Compilation} */ (this.compilation);
39
48
  const lines = this._lines;
40
49
  if (lines.length === 0) return null;
41
- // `__webpack_nonce__` set inside the entry module is too late — the
42
- // entry hasn't run yet. Read the nonce off the `<script>` tag that
43
- // loaded the bundle, so prefetch / preload links match a CSP that
44
- // demands the same nonce as the script.
45
- //
46
- // - For classic script output, `document.currentScript` is the
47
- // loading `<script>` element while the runtime executes.
48
- // - For ESM output (`output.module: true`), `document.currentScript`
49
- // is `null`; locate the loading `<script type="module">` by
50
- // matching `script.src` against `import.meta.url`.
50
+ // `__webpack_nonce__` set in the entry module comes too late, the entry not
51
+ // having run, so the nonce is read off the `<script>` that loaded the bundle
52
+ // and the links match a CSP demanding the script's own.
53
+
54
+ // Classic output finds it on `document.currentScript`. ESM output leaves that
55
+ // null, so the loading `<script type="module">` is found by matching its
56
+ // `src` against `import.meta.url`.
51
57
  const { module: isModule, importMetaName } = compilation.outputOptions;
52
58
  const nonceSetup = isModule
53
59
  ? [
@@ -7,6 +7,7 @@
7
7
 
8
8
  const { SyncHook } = require("tapable");
9
9
  const { createPathGlobMatcher } = require("../util/globUtils");
10
+ const { fileUrlToPath } = require("../util/identifier");
10
11
 
11
12
  /** @import { ResolveRequest } from "enhanced-resolve" */
12
13
  /**
@@ -352,9 +353,10 @@ class RuleSetCompiler {
352
353
  );
353
354
  }
354
355
  if (typeof condition === "string") {
356
+ const prefix = fileUrlToPath(condition);
355
357
  return {
356
- matchWhenEmpty: condition.length === 0,
357
- fn: (str) => typeof str === "string" && str.startsWith(condition)
358
+ matchWhenEmpty: prefix.length === 0,
359
+ fn: (str) => typeof str === "string" && str.startsWith(prefix)
358
360
  };
359
361
  }
360
362
  if (typeof condition === "function") {
@@ -640,6 +642,200 @@ const matchRuleSetCondition = (condition, resource) => {
640
642
  }
641
643
  };
642
644
 
645
+ // Cap on the spellings one pattern is expanded into, so a pattern built from
646
+ // many alternations stays cheap to probe.
647
+ const MAX_EXPANDED_SPELLINGS = 64;
648
+
649
+ // A rule naming an extension is short; a pattern generated from a list of paths
650
+ // runs to kilobytes and costs more to expand than the answer is worth.
651
+ const MAX_EXPANDED_PATTERN_LENGTH = 256;
652
+
653
+ /**
654
+ * Index of the `]` closing the character class opened at `start`, or the end of
655
+ * the source when it is unterminated.
656
+ * @param {string} source regexp source
657
+ * @param {number} start index of the opening `[`
658
+ * @returns {number} index of the closing `]`
659
+ */
660
+ const findCharacterClassEnd = (source, start) => {
661
+ for (let i = start + 1; i < source.length; i++) {
662
+ if (source[i] === "\\") i++;
663
+ else if (source[i] === "]") return i;
664
+ }
665
+ return source.length;
666
+ };
667
+
668
+ /**
669
+ * Index of the `)` closing the group opened at `start`, skipping nested groups
670
+ * and character classes, or the end of the source when it is unterminated.
671
+ * @param {string} source regexp source
672
+ * @param {number} start index of the opening `(`
673
+ * @returns {number} index of the closing `)`
674
+ */
675
+ const findGroupEnd = (source, start) => {
676
+ let depth = 0;
677
+ for (let i = start; i < source.length; i++) {
678
+ const char = source[i];
679
+ if (char === "\\") i++;
680
+ else if (char === "[") i = findCharacterClassEnd(source, i);
681
+ else if (char === "(") depth++;
682
+ else if (char === ")" && --depth === 0) return i;
683
+ }
684
+ return source.length;
685
+ };
686
+
687
+ /**
688
+ * Splits a group body on its top-level `|`, skipping nested groups and
689
+ * character classes.
690
+ * @param {string} body group body without the enclosing parentheses
691
+ * @returns {string[]} the alternatives
692
+ */
693
+ const splitAlternatives = (body) => {
694
+ const alternatives = [];
695
+ let depth = 0;
696
+ let start = 0;
697
+ for (let i = 0; i < body.length; i++) {
698
+ const char = body[i];
699
+ if (char === "\\") {
700
+ i++;
701
+ } else if (char === "[") {
702
+ i = findCharacterClassEnd(body, i);
703
+ } else if (char === "(") {
704
+ depth++;
705
+ } else if (char === ")") {
706
+ depth--;
707
+ } else if (char === "|" && depth === 0) {
708
+ alternatives.push(body.slice(start, i));
709
+ start = i + 1;
710
+ }
711
+ }
712
+ alternatives.push(body.slice(start));
713
+ return alternatives;
714
+ };
715
+
716
+ /**
717
+ * The part of a group body that the match spells — past a `?:` or `?<name>`
718
+ * prefix, and nothing at all for a lookaround, which spells nothing.
719
+ * @param {string} body group body without the enclosing parentheses
720
+ * @returns {string | undefined} the spelled part, or `undefined` for a lookaround
721
+ */
722
+ const groupContent = (body) => {
723
+ if (!body.startsWith("?")) return body;
724
+ if (body.startsWith("?:")) return body.slice(2);
725
+ const named = /^\?<[^=!][^>]*>/.exec(body);
726
+ return named ? body.slice(named[0].length) : undefined;
727
+ };
728
+
729
+ /**
730
+ * Rewrites the first group, word-character class or optional atom
731
+ * in the source into the spellings it can match, leaving the rest as written.
732
+ * @param {string} source regexp source
733
+ * @returns {string[] | undefined} the rewritten sources, or `undefined` when the source holds no such construct
734
+ */
735
+ const expandFirstConstruct = (source) => {
736
+ for (let i = 0; i < source.length; i++) {
737
+ const char = source[i];
738
+ let end = i + 1;
739
+ /** @type {string[] | undefined} */
740
+ let spellings;
741
+ if (char === "\\") {
742
+ end = i + 2;
743
+ } else if (char === "[") {
744
+ const close = findCharacterClassEnd(source, i);
745
+ end = close + 1;
746
+ const body = source.slice(i + 1, close);
747
+ // only a plain list of word characters spells out safely (no range,
748
+ // no negation, no escape)
749
+ if (/^\w+$/.test(body)) spellings = [...body];
750
+ } else if (char === "(") {
751
+ const close = findGroupEnd(source, i);
752
+ end = close + 1;
753
+ const content = groupContent(source.slice(i + 1, close));
754
+ if (content !== undefined) spellings = splitAlternatives(content);
755
+ }
756
+ // `?` makes the atom optional, so its absence is a spelling as well
757
+ if (source[end] === "?") {
758
+ spellings = [...(spellings || [source.slice(i, end)]), ""];
759
+ end += 1;
760
+ }
761
+ if (spellings) {
762
+ return spellings.map(
763
+ (spelling) => source.slice(0, i) + spelling + source.slice(end)
764
+ );
765
+ }
766
+ i = end - 1;
767
+ }
768
+ };
769
+
770
+ /**
771
+ * Rewrites the first brace alternative in a glob pattern (e.g. `*.{css,scss}`)
772
+ * into the spellings it can match.
773
+ * @param {string} pattern glob pattern
774
+ * @returns {string[] | undefined} the rewritten patterns, or `undefined` when the pattern holds no brace
775
+ */
776
+ const expandFirstBrace = (pattern) => {
777
+ const open = pattern.indexOf("{");
778
+ const close = open === -1 ? -1 : pattern.indexOf("}", open);
779
+ if (close === -1) return;
780
+ return pattern
781
+ .slice(open + 1, close)
782
+ .split(",")
783
+ .map(
784
+ (alternative) =>
785
+ pattern.slice(0, open) + alternative + pattern.slice(close + 1)
786
+ );
787
+ };
788
+
789
+ /**
790
+ * Whether `probe` occurs in `pattern` as a subsequence. Expanding a pattern only
791
+ * ever drops characters, so a probe failing this is spelled by none of its
792
+ * spellings and the expansion is not worth starting.
793
+ * @param {string} pattern pattern to search
794
+ * @param {string} probe probe to find
795
+ * @returns {boolean} whether the probe is a subsequence of the pattern
796
+ */
797
+ const containsSubsequence = (pattern, probe) => {
798
+ let found = 0;
799
+ for (let i = 0; i < pattern.length && found < probe.length; i++) {
800
+ if (pattern[i] === probe[found]) found++;
801
+ }
802
+ return found === probe.length;
803
+ };
804
+
805
+ /**
806
+ * Whether any spelling of the pattern contains the probe, rewriting one
807
+ * construct at a time until none is left or `MAX_EXPANDED_SPELLINGS` is reached.
808
+ * @param {string} pattern pattern to expand
809
+ * @param {string} probe probe the spellings are searched for
810
+ * @param {(pattern: string) => string[] | undefined} expandFirst rewrites the first expandable construct
811
+ * @returns {boolean} whether a spelling contains the probe
812
+ */
813
+ const someSpellingContains = (pattern, probe, expandFirst) => {
814
+ if (pattern.includes(probe)) return true;
815
+ if (pattern.length > MAX_EXPANDED_PATTERN_LENGTH) return false;
816
+ if (!containsSubsequence(pattern, probe)) return false;
817
+ let spellings = [pattern];
818
+ for (;;) {
819
+ /** @type {string[]} */
820
+ const expanded = [];
821
+ for (const spelling of spellings) {
822
+ const rewritten = expandFirst(spelling);
823
+ // every spelling was searched as it was produced, so one with nothing
824
+ // left to rewrite is settled
825
+ if (!rewritten) continue;
826
+ for (const alternative of rewritten) {
827
+ if (alternative.includes(probe)) return true;
828
+ // an alternative that dropped the probe's characters expands no
829
+ // further into it
830
+ if (containsSubsequence(alternative, probe)) expanded.push(alternative);
831
+ }
832
+ if (expanded.length > MAX_EXPANDED_SPELLINGS) return false;
833
+ }
834
+ if (expanded.length === 0) return false;
835
+ spellings = expanded;
836
+ }
837
+ };
838
+
643
839
  /**
644
840
  * @param {EXPECTED_ANY} glob glob pattern(s)
645
841
  * @param {string} extension extension including the dot (e.g. `".css"`)
@@ -648,7 +844,10 @@ const matchRuleSetCondition = (condition, resource) => {
648
844
  const globReferencesExtension = (glob, extension) => {
649
845
  // a `!` pattern subtracts the extension instead of targeting it
650
846
  if (typeof glob === "string") {
651
- return !glob.startsWith("!") && glob.includes(extension);
847
+ return (
848
+ !glob.startsWith("!") &&
849
+ someSpellingContains(glob, extension, expandFirstBrace)
850
+ );
652
851
  }
653
852
  return (
654
853
  Array.isArray(glob) &&
@@ -660,12 +859,20 @@ const globReferencesExtension = (glob, extension) => {
660
859
  * Whether any regexp or glob in the condition references the extension probe
661
860
  * (e.g. `\.css`), i.e. the rule clearly targets that extension even if the
662
861
  * generic sample path doesn't match its (possibly filename-scoped) pattern.
862
+ * The extension may be spelled by an alternation (`\.(css|scss)$`) or a
863
+ * character class (`\.[jt]sx?$`), so those are expanded before probing.
663
864
  * @param {EXPECTED_ANY} condition condition
664
865
  * @param {string} extProbe escaped extension probe (e.g. `"\\.css"`)
665
866
  * @returns {boolean} whether a regexp in the condition targets the extension
666
867
  */
667
868
  const conditionReferencesExtension = (condition, extProbe) => {
668
- if (condition instanceof RegExp) return condition.source.includes(extProbe);
869
+ if (condition instanceof RegExp) {
870
+ // an `/i` rule spells the extension in any case; the probe is lower case
871
+ const source = condition.ignoreCase
872
+ ? condition.source.toLowerCase()
873
+ : condition.source;
874
+ return someSpellingContains(source, extProbe, expandFirstConstruct);
875
+ }
669
876
  if (Array.isArray(condition)) {
670
877
  return condition.some((c) => conditionReferencesExtension(c, extProbe));
671
878
  }
@@ -13,11 +13,14 @@ const HelperRuntimeModule = require("./HelperRuntimeModule");
13
13
  class AsyncModuleRuntimeModule extends HelperRuntimeModule {
14
14
  /**
15
15
  * @param {boolean=} deferInterop if defer import is used.
16
+ * @param {boolean=} strictModuleErrorHandling if a recorded evaluation error is kept.
16
17
  */
17
- constructor(deferInterop = false) {
18
+ constructor(deferInterop = false, strictModuleErrorHandling = false) {
18
19
  super("async module");
19
20
  /** @type {boolean} */
20
21
  this._deferInterop = deferInterop;
22
+ /** @type {boolean} */
23
+ this._strictModuleErrorHandling = strictModuleErrorHandling;
21
24
  }
22
25
 
23
26
  /**
@@ -29,6 +32,11 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
29
32
  const { runtimeTemplate } = compilation;
30
33
  const fn = RuntimeGlobals.asyncModule;
31
34
  const defer = this._deferInterop;
35
+ const strictErrors = this._strictModuleErrorHandling;
36
+ const rejectCall = "reject(promise[webpackError] = err)";
37
+ const rejectExpression = strictErrors
38
+ ? `(markCycle(err), ${rejectCall})`
39
+ : rejectCall;
32
40
  const cst = runtimeTemplate.renderConst();
33
41
  const lt = runtimeTemplate.renderLet();
34
42
  const supportsSymbol = runtimeTemplate.supportsSymbol();
@@ -46,6 +54,7 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
46
54
  defer ? `${RuntimeGlobals.asyncModuleExportSymbol}= ` : ""
47
55
  }${renderSymbol("webpack exports", RuntimeGlobals.exports)};`,
48
56
  `${cst} webpackError = ${renderSymbol("webpack error", "__webpack_error__")};`,
57
+ ...(strictErrors ? [`${cst} cycleGroups = {};`] : []),
49
58
  defer
50
59
  ? Template.asString([
51
60
  `${cst} webpackDone = ${RuntimeGlobals.asyncModuleDoneSymbol} = ${renderSymbol("webpack done", "__webpack_done__")};`,
@@ -57,7 +66,11 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
57
66
  `${cst} hasUnresolvedAsyncSubgraph = asyncDeps.some((id) => {`,
58
67
  Template.indent([
59
68
  `${cst} cache = __webpack_module_cache__[id];`,
60
- "return !cache || cache[webpackDone] === false;"
69
+ "if (!cache) return true;",
70
+ // A cached entry no longer means finished, and a rejected
71
+ // one is done but its error must still reach the importer.
72
+ `${cst} deps = cache.exports;`,
73
+ "return deps[webpackDone] !== true || deps[webpackError] !== undefined;"
61
74
  ]),
62
75
  "});",
63
76
  "if (hasUnresolvedAsyncSubgraph) {",
@@ -144,73 +157,96 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
144
157
  ])})`,
145
158
  "deps"
146
159
  )};`,
147
- `${fn} = ${runtimeTemplate.basicFunction("module, body, hasAwait", [
148
- `${lt} queue;`,
149
- "hasAwait && ((queue = []).d = -1);",
150
- `${cst} depQueues = new Set();`,
151
- `${cst} exports = module.exports;`,
152
- `${lt} currentDeps;`,
153
- `${lt} outerResolve;`,
154
- `${lt} reject;`,
155
- `${cst} promise = new Promise(${runtimeTemplate.basicFunction(
156
- "resolve, rej",
157
- ["reject = rej;", "outerResolve = resolve;"]
158
- )});`,
159
- "promise[webpackExports] = exports;",
160
- `promise[webpackQueues] = ${runtimeTemplate.expressionFunction(
161
- `queue && fn(queue), depQueues.forEach(fn), promise["catch"](${runtimeTemplate.emptyFunction()})`,
162
- "fn"
163
- )};`,
164
- "module.exports = promise;",
165
- `${cst} handle = ${runtimeTemplate.basicFunction("deps", [
166
- "currentDeps = wrapDeps(deps);",
167
- `${lt} fn;`,
168
- `${cst} getResult = ${runtimeTemplate.returningFunction(
169
- `currentDeps.map(${runtimeTemplate.basicFunction("d", [
170
- defer ? "if(d[webpackDefer]) return d;" : "",
171
- "if(d[webpackError]) throw d[webpackError];",
172
- "return d[webpackExports];"
173
- ])})`
174
- )}`,
160
+ `${fn} = ${runtimeTemplate.basicFunction(
161
+ strictErrors
162
+ ? "module, body, hasAwait, cycleGroup"
163
+ : "module, body, hasAwait",
164
+ [
165
+ `${lt} queue;`,
166
+ "hasAwait && ((queue = []).d = -1);",
167
+ `${cst} depQueues = new Set();`,
168
+ `${cst} exports = module.exports;`,
169
+ `${lt} currentDeps;`,
170
+ `${lt} outerResolve;`,
171
+ `${lt} reject;`,
175
172
  `${cst} promise = new Promise(${runtimeTemplate.basicFunction(
176
- "resolve",
177
- [
178
- `fn = ${runtimeTemplate.expressionFunction(
179
- "resolve(getResult)",
180
- ""
181
- )};`,
182
- "fn.r = 0;",
183
- `${cst} fnQueue = ${runtimeTemplate.expressionFunction(
184
- "q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn)))",
185
- "q"
186
- )};`,
187
- `currentDeps.forEach(${runtimeTemplate.expressionFunction(
188
- `${
189
- defer ? "dep[webpackDefer]||" : ""
190
- }dep[webpackQueues](fnQueue)`,
191
- "dep"
192
- )});`
193
- ]
173
+ "resolve, rej",
174
+ ["reject = rej;", "outerResolve = resolve;"]
194
175
  )});`,
195
- "return fn.r ? promise : getResult();"
196
- ])}`,
197
- `${cst} done = ${runtimeTemplate.expressionFunction(
198
- `(err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue)${
199
- defer
200
- ? ", promise[webpackDone] = true, module.evaluatingAsync = false"
201
- : ""
202
- }`,
203
- "err"
204
- )}`,
205
- // Track the async body's whole lifetime (evaluating +
206
- // evaluating-async states) with a dedicated flag — the sync require
207
- // wrapper clears `module.evaluating` as soon as `.a` returns, so a
208
- // deferred namespace reaching this module through a cycle relies on
209
- // `evaluatingAsync` to keep throwing until it is fully evaluated.
210
- defer ? "module.evaluatingAsync = true;" : "",
211
- "body(handle, done);",
212
- `${runtimeTemplate.optionalChaining("queue", "d < 0")} && (queue.d = 0);`
213
- ])};`
176
+ "promise[webpackExports] = exports;",
177
+ `promise[webpackQueues] = ${runtimeTemplate.expressionFunction(
178
+ `queue && fn(queue), depQueues.forEach(fn), promise["catch"](${runtimeTemplate.emptyFunction()})`,
179
+ "fn"
180
+ )};`,
181
+ "module.exports = promise;",
182
+ `${cst} handle = ${runtimeTemplate.basicFunction("deps", [
183
+ "currentDeps = wrapDeps(deps);",
184
+ `${lt} fn;`,
185
+ `${cst} getResult = ${runtimeTemplate.returningFunction(
186
+ `currentDeps.map(${runtimeTemplate.basicFunction("d", [
187
+ defer ? "if(d[webpackDefer]) return d;" : "",
188
+ "if(d[webpackError]) throw d[webpackError];",
189
+ "return d[webpackExports];"
190
+ ])})`
191
+ )}`,
192
+ `${cst} promise = new Promise(${runtimeTemplate.basicFunction(
193
+ "resolve",
194
+ [
195
+ `fn = ${runtimeTemplate.expressionFunction(
196
+ "resolve(getResult)",
197
+ ""
198
+ )};`,
199
+ "fn.r = 0;",
200
+ `${cst} fnQueue = ${runtimeTemplate.expressionFunction(
201
+ "q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn)))",
202
+ "q"
203
+ )};`,
204
+ `currentDeps.forEach(${runtimeTemplate.expressionFunction(
205
+ `${
206
+ defer ? "dep[webpackDefer]||" : ""
207
+ }dep[webpackQueues](fnQueue)`,
208
+ "dep"
209
+ )});`
210
+ ]
211
+ )});`,
212
+ "return fn.r ? promise : getResult();"
213
+ ])}`,
214
+ // One `[[EvaluationError]]` is recorded for a whole strongly-connected
215
+ // component, so a peer that already fulfilled must report it too.
216
+ ...(strictErrors
217
+ ? [
218
+ `${cst} group = cycleGroup === undefined ? undefined : (cycleGroups[cycleGroup] = cycleGroups[cycleGroup] || []);`,
219
+ // Ids, not module objects: hot replacement swaps a member for a
220
+ // new object under the same id, and the error belongs to that one.
221
+ "group && group.indexOf(module.id) < 0 && group.push(module.id);",
222
+ `${cst} markCycle = ${runtimeTemplate.expressionFunction(
223
+ `group && group.forEach(${runtimeTemplate.basicFunction(
224
+ "id",
225
+ [
226
+ `${cst} peer = __webpack_module_cache__[id];`,
227
+ "if (peer && peer.error === undefined) peer.error = err;"
228
+ ]
229
+ )})`,
230
+ "err"
231
+ )};`
232
+ ]
233
+ : []),
234
+ `${cst} done = ${runtimeTemplate.expressionFunction(
235
+ `(err ? ${rejectExpression} : outerResolve(exports)), resolveQueue(queue)${
236
+ defer
237
+ ? ", promise[webpackDone] = true, module.evaluatingAsync = false"
238
+ : ""
239
+ }`,
240
+ "err"
241
+ )}`,
242
+ // The sync require wrapper clears `module.evaluating` the moment `.a`
243
+ // returns, so a deferred namespace reaching this module through a cycle
244
+ // needs `evaluatingAsync` to keep throwing until evaluation ends.
245
+ defer ? "module.evaluatingAsync = true;" : "",
246
+ "body(handle, done);",
247
+ `${runtimeTemplate.optionalChaining("queue", "d < 0")} && (queue.d = 0);`
248
+ ]
249
+ )};`
214
250
  ]);
215
251
  }
216
252
  }
@@ -17,6 +17,15 @@ class AutoPublicPathRuntimeModule extends RuntimeModule {
17
17
  super("publicPath", RuntimeModule.STAGE_BASIC);
18
18
  }
19
19
 
20
+ /**
21
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
22
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
23
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
24
+ */
25
+ getInstalledChunkHandlers() {
26
+ return RuntimeModule.NO_CHUNK_HANDLERS;
27
+ }
28
+
20
29
  /**
21
30
  * Generates runtime code for this runtime module.
22
31
  * @returns {string | null} runtime code
@@ -32,6 +32,15 @@ class BaseUriRuntimeModule extends RuntimeModule {
32
32
  return false;
33
33
  }
34
34
 
35
+ /**
36
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
37
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
38
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
39
+ */
40
+ getInstalledChunkHandlers() {
41
+ return RuntimeModule.NO_CHUNK_HANDLERS;
42
+ }
43
+
35
44
  /**
36
45
  * Generates runtime code for this runtime module.
37
46
  * @returns {string | null} runtime code