@depup/webpack 5.110.3-depup.0 → 5.111.1-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/README.md +7 -8
  2. package/changes.json +7 -11
  3. package/lib/APIPlugin.js +26 -11
  4. package/lib/AutomaticPrefetchPlugin.js +1 -1
  5. package/lib/Cache.js +8 -3
  6. package/lib/CacheFacade.js +1 -1
  7. package/lib/CircularModulesPlugin.js +157 -55
  8. package/lib/CleanPlugin.js +2 -2
  9. package/lib/CompatibilityPlugin.js +3 -4
  10. package/lib/Compilation.js +336 -337
  11. package/lib/Compiler.js +213 -51
  12. package/lib/ConstPlugin.js +16 -132
  13. package/lib/CopyPlugin.js +1054 -0
  14. package/lib/DefinePlugin.js +24 -8
  15. package/lib/DependencyTemplate.js +2 -1
  16. package/lib/DotenvPlugin.js +24 -28
  17. package/lib/ErrorHelpers.js +113 -0
  18. package/lib/ExportsInfo.js +20 -16
  19. package/lib/ExternalModule.js +47 -22
  20. package/lib/FileSystemInfo.js +17 -14
  21. package/lib/FlagDependencyExportsPlugin.js +53 -34
  22. package/lib/FlagDependencyUsagePlugin.js +9 -13
  23. package/lib/Generator.js +24 -2
  24. package/lib/HotModuleReplacementPlugin.js +55 -7
  25. package/lib/IgnorePlugin.js +1 -1
  26. package/lib/JavascriptMetaInfoPlugin.js +5 -3
  27. package/lib/LoaderOptionsPlugin.js +1 -1
  28. package/lib/MainTemplate.js +5 -1
  29. package/lib/Module.js +19 -10
  30. package/lib/ModuleGraph.js +6 -9
  31. package/lib/MultiCompiler.js +7 -17
  32. package/lib/MultiWatching.js +1 -1
  33. package/lib/NormalModule.js +135 -50
  34. package/lib/NormalModuleFactory.js +1 -1
  35. package/lib/RuntimeGlobals.js +21 -7
  36. package/lib/RuntimeModule.js +28 -12
  37. package/lib/RuntimePlugin.js +30 -3
  38. package/lib/RuntimeTemplate.js +813 -518
  39. package/lib/SourceMapDevToolPlugin.js +54 -104
  40. package/lib/TemplatedPathPlugin.js +16 -59
  41. package/lib/Watching.js +9 -0
  42. package/lib/WebpackOptionsApply.js +84 -91
  43. package/lib/asset/AssetBytesGenerator.js +7 -1
  44. package/lib/asset/AssetGenerator.js +50 -24
  45. package/lib/asset/AssetModule.js +3 -0
  46. package/lib/asset/AssetSourceGenerator.js +7 -1
  47. package/lib/asset/WebManifestParser.js +7 -5
  48. package/lib/buildChunkGraph.js +11 -15
  49. package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
  50. package/lib/cache/IdleFileCachePlugin.js +2 -2
  51. package/lib/cache/MemoryCachePlugin.js +4 -4
  52. package/lib/cache/MemoryWithGcCachePlugin.js +7 -8
  53. package/lib/cache/PackFileCacheStrategy.js +17 -19
  54. package/lib/cache/getLazyHashedEtag.js +3 -5
  55. package/lib/config/browserslistTargetHandler.js +17 -4
  56. package/lib/config/defaults.js +138 -128
  57. package/lib/config/getClaimedAssetTypes.js +10 -11
  58. package/lib/config/normalization.js +82 -12
  59. package/lib/config/target.js +13 -4
  60. package/lib/container/ContainerReferencePlugin.js +6 -0
  61. package/lib/container/RemoteRuntimeModule.js +9 -0
  62. package/lib/container/declaredRemotes.js +39 -0
  63. package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
  64. package/lib/{ContextModule.js → context/ContextModule.js} +54 -115
  65. package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +19 -21
  66. package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
  67. package/lib/css/CssGenerator.js +27 -11
  68. package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
  69. package/lib/css/CssLoadingRuntimeModule.js +94 -36
  70. package/lib/css/CssModule.js +1 -1
  71. package/lib/css/CssModulesPlugin.js +7 -6
  72. package/lib/css/CssParser.js +162 -31
  73. package/lib/css/CssServerStylesRuntimeModule.js +9 -0
  74. package/lib/css/cssMinify.js +43 -32
  75. package/lib/css/data.js +3514 -869
  76. package/lib/css/syntax.js +6370 -1220
  77. package/lib/debug/ProfilingPlugin.js +7 -4
  78. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
  79. package/lib/dependencies/AMDRuntimeModules.js +18 -0
  80. package/lib/dependencies/CommonJsExportRequireDependency.js +13 -12
  81. package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
  82. package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -5
  83. package/lib/dependencies/CommonJsPlugin.js +19 -3
  84. package/lib/dependencies/CommonJsRequireDependency.js +14 -5
  85. package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
  86. package/lib/dependencies/ContextDependency.js +1 -1
  87. package/lib/dependencies/ContextDependencyHelpers.js +3 -9
  88. package/lib/dependencies/ContextElementDependency.js +1 -1
  89. package/lib/dependencies/CssIcssExportDependency.js +13 -9
  90. package/lib/dependencies/CssIcssImportDependency.js +3 -6
  91. package/lib/dependencies/CssUrlDependency.js +3 -5
  92. package/lib/dependencies/HarmonyCompatibilityDependency.js +67 -22
  93. package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -4
  94. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +10 -7
  95. package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
  96. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +74 -17
  97. package/lib/dependencies/HarmonyExportInitFragment.js +110 -23
  98. package/lib/dependencies/HarmonyExportSpecifierDependency.js +25 -58
  99. package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
  100. package/lib/dependencies/HarmonyImportDependency.js +6 -1
  101. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +111 -17
  102. package/lib/dependencies/HarmonyImportSideEffectDependency.js +3 -4
  103. package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
  104. package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
  105. package/lib/dependencies/HtmlEntryDependency.js +124 -102
  106. package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
  107. package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
  108. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
  109. package/lib/dependencies/ImportMetaGlobHelpers.js +1 -1
  110. package/lib/dependencies/ImportMetaMainDependency.js +104 -0
  111. package/lib/dependencies/ImportMetaPlugin.js +67 -25
  112. package/lib/dependencies/ImportParserPlugin.js +1 -1
  113. package/lib/dependencies/LoaderPlugin.js +26 -1
  114. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  115. package/lib/dependencies/SystemRuntimeModule.js +9 -0
  116. package/lib/dependencies/URLContextDependency.js +1 -1
  117. package/lib/dependencies/URLDependency.js +6 -5
  118. package/lib/dependencies/WorkerAndWorkletPlugin.js +15 -21
  119. package/lib/dependencies/WorkerDependency.js +7 -7
  120. package/lib/dependencies/WorkletDependency.js +7 -11
  121. package/lib/dll/DelegatedModule.js +18 -1
  122. package/lib/dll/DllReferencePlugin.js +11 -8
  123. package/lib/dll/LibManifestPlugin.js +1 -1
  124. package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
  125. package/lib/errors/DuplicateModulesWarning.js +12 -7
  126. package/lib/errors/EmptyCopyPatternWarning.js +26 -0
  127. package/lib/errors/ExternalStarReexportError.js +44 -0
  128. package/lib/errors/HookWebpackError.js +3 -2
  129. package/lib/errors/MissingSourceMapsWarning.js +36 -0
  130. package/lib/errors/ModuleParseError.js +2 -1
  131. package/lib/errors/UnusedAssetsWarning.js +36 -0
  132. package/lib/errors/UnusedFederationWarning.js +35 -0
  133. package/lib/errors/UnusedModulesWarning.js +38 -0
  134. package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
  135. package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
  136. package/lib/esm/ModuleChunkLoadingPlugin.js +30 -11
  137. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -60
  138. package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
  139. package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
  140. package/lib/hmr/LazyCompilationPlugin.js +3 -5
  141. package/lib/html/HtmlGenerator.js +72 -87
  142. package/lib/html/HtmlModulesPlugin.js +418 -200
  143. package/lib/html/HtmlParser.js +110 -147
  144. package/lib/html/builtinEmbeddedRenderer.js +107 -0
  145. package/lib/html/data.js +142 -7
  146. package/lib/html/htmlMinify.js +92 -122
  147. package/lib/html/syntax.js +1618 -1391
  148. package/lib/ids/HashedModuleIdsPlugin.js +2 -1
  149. package/lib/index.js +49 -3
  150. package/lib/javascript/ChunkFormatHelpers.js +4 -3
  151. package/lib/javascript/JavascriptGenerator.js +8 -1
  152. package/lib/javascript/JavascriptModule.js +1 -0
  153. package/lib/javascript/JavascriptModulesPlugin.js +73 -72
  154. package/lib/javascript/JavascriptParser.js +1970 -900
  155. package/lib/javascript/StartupHelpers.js +27 -3
  156. package/lib/javascript/data.js +172 -0
  157. package/lib/javascript/grammar.js +5546 -0
  158. package/lib/javascript/parser.js +1500 -0
  159. package/lib/javascript/regexp.js +1762 -0
  160. package/lib/javascript/regexpData.js +51 -0
  161. package/lib/javascript/syntax.js +9061 -5262
  162. package/lib/json/JsonGenerator.js +7 -1
  163. package/lib/library/ModuleLibraryPlugin.js +171 -132
  164. package/lib/loaders/LoaderRunner.js +137 -9
  165. package/lib/node/NodeWatchFileSystem.js +3 -9
  166. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
  167. package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
  168. package/lib/optimize/AggressiveMergingPlugin.js +3 -5
  169. package/lib/optimize/ConcatenatedModule.js +178 -120
  170. package/lib/optimize/ConstExportsPlugin.js +50 -39
  171. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
  172. package/lib/optimize/InlineExports.js +20 -123
  173. package/lib/optimize/InnerGraphPlugin.js +7 -13
  174. package/lib/optimize/LimitChunkCountPlugin.js +5 -8
  175. package/lib/optimize/MangleExportsPlugin.js +13 -4
  176. package/lib/optimize/ModuleConcatenationPlugin.js +27 -5
  177. package/lib/optimize/RealContentHashPlugin.js +68 -9
  178. package/lib/optimize/SideEffectsFlagPlugin.js +24 -28
  179. package/lib/optimize/SplitChunksPlugin.js +2 -4
  180. package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
  181. package/lib/performance/BroadContextsPlugin.js +1 -1
  182. package/lib/performance/CacheEffectivenessPlugin.js +7 -7
  183. package/lib/performance/DuplicateModulesPlugin.js +57 -13
  184. package/lib/performance/EvalUsagePlugin.js +5 -2
  185. package/lib/performance/MissingSourceMapsPlugin.js +115 -0
  186. package/lib/performance/PureAnnotationsPlugin.js +6 -3
  187. package/lib/performance/SizeLimitsPlugin.js +2 -4
  188. package/lib/performance/TopLevelThisPlugin.js +5 -4
  189. package/lib/performance/UnusedAssetsPlugin.js +109 -0
  190. package/lib/performance/UnusedFederationPlugin.js +147 -0
  191. package/lib/performance/UnusedModulesPlugin.js +141 -0
  192. package/lib/performance/UnusedReexportsPlugin.js +1 -55
  193. package/lib/performance/isOnlyReexported.js +65 -0
  194. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
  195. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +8 -8
  196. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
  197. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
  198. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
  199. package/lib/prefetch/ResourceHintPlugin.js +18 -23
  200. package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
  201. package/lib/prefetch/StartupAssetHintRuntimeModule.js +16 -10
  202. package/lib/rules/RuleSetCompiler.js +211 -4
  203. package/lib/runtime/AsyncModuleRuntimeModule.js +98 -66
  204. package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
  205. package/lib/runtime/BaseUriRuntimeModule.js +9 -0
  206. package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
  207. package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
  208. package/lib/runtime/GetChunkFilenameRuntimeModule.js +12 -4
  209. package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
  210. package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
  211. package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
  212. package/lib/runtime/GlobalRuntimeModule.js +11 -4
  213. package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
  214. package/lib/runtime/HelperRuntimeModule.js +10 -0
  215. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +305 -224
  216. package/lib/runtime/NonceRuntimeModule.js +9 -0
  217. package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
  218. package/lib/runtime/PublicPathRuntimeModule.js +9 -0
  219. package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
  220. package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
  221. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
  222. package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
  223. package/lib/runtime/SystemContextRuntimeModule.js +9 -0
  224. package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
  225. package/lib/schemes/DataUriPlugin.js +3 -6
  226. package/lib/schemes/VirtualUrlPlugin.js +1 -1
  227. package/lib/serialization/BinaryMiddleware.js +9 -9
  228. package/lib/serialization/FileMiddleware.js +16 -16
  229. package/lib/serialization/ObjectMiddleware.js +168 -139
  230. package/lib/sharing/ConsumeSharedPlugin.js +12 -0
  231. package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
  232. package/lib/sharing/ShareRuntimeModule.js +9 -0
  233. package/lib/sharing/declaredShared.js +47 -0
  234. package/lib/stats/DefaultStatsFactoryPlugin.js +6 -5
  235. package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
  236. package/lib/typescript/TypeScriptPlugin.js +2 -3
  237. package/lib/url/URLParserPlugin.js +6 -8
  238. package/lib/util/LocConverter.js +4 -7
  239. package/lib/util/SourceProcessor.js +91 -91
  240. package/lib/util/async.js +292 -0
  241. package/lib/util/buildDiagnostics.js +69 -0
  242. package/lib/util/chainedImports.js +3 -4
  243. package/lib/util/concatenate.js +4 -4
  244. package/lib/util/createHooksRegistry.js +1 -2
  245. package/lib/util/dataURL.js +2 -3
  246. package/lib/util/deterministicGrouping.js +8 -13
  247. package/lib/util/findGraphRoots.js +6 -13
  248. package/lib/util/fs.js +27 -1
  249. package/lib/util/globUtils.js +1 -1
  250. package/lib/util/handlerKeys.js +40 -0
  251. package/lib/util/hash/wasm-hash.js +3 -4
  252. package/lib/util/identifier.js +20 -0
  253. package/lib/util/internalSerializables.js +5 -1
  254. package/lib/util/registerExternalSerializer.js +6 -45
  255. package/lib/util/semver.js +5 -3
  256. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +9 -0
  257. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
  258. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
  259. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
  260. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +12 -4
  261. package/lib/wasm-sync/WebAssemblyGenerator.js +6 -1
  262. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -1
  263. package/lib/wasm-sync/WebAssemblyUtils.js +2 -4
  264. package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
  265. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
  266. package/package.json +55 -46
  267. package/schemas/WebpackOptions.check.js +1 -1
  268. package/schemas/WebpackOptions.json +379 -66
  269. package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
  270. package/schemas/plugins/ManifestPlugin.check.js +1 -1
  271. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  272. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  273. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  274. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  275. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  276. package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
  277. package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
  278. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
  279. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  280. package/types.d.ts +1723 -604
  281. package/lib/dependencies/ExportBindingInitFragment.js +0 -191
  282. package/lib/errors/EntrypointOverlapWarning.js +0 -45
  283. package/lib/performance/EntrypointOverlapPlugin.js +0 -122
@@ -263,11 +263,9 @@ class MakeOptimizedDeferredNamespaceObjectRuntimeModule extends HelperRuntimeMod
263
263
  Template.indent([
264
264
  "get a() {",
265
265
  Template.indent([
266
- // Forcing evaluation of a module that is currently evaluating
267
- // (a cycle reached through a deferred import) must throw rather
268
- // than expose its partial exports. `syncDeps` (present only for
269
- // cyclic deferred modules) carries the transitive static closure,
270
- // so an evaluating dependency is caught before any evaluation.
266
+ // Forcing a module that is already evaluating, a cycle reached
267
+ // through a deferred import, must throw rather than expose partial
268
+ // exports. `syncDeps` carries the closure that catches it first.
271
269
  `${cst} cachedModule = __webpack_module_cache__[moduleId];`,
272
270
  'if (cachedModule !== undefined && (cachedModule.evaluating || cachedModule.evaluatingAsync)) throw new TypeError("Cannot access a deferred module namespace while the module is being evaluated");',
273
271
  "if (syncDeps) for (var i = 0; i < syncDeps.length; i++) {",
@@ -290,13 +288,13 @@ class MakeOptimizedDeferredNamespaceObjectRuntimeModule extends HelperRuntimeMod
290
288
  ]),
291
289
  "};",
292
290
  hasAsync
293
- ? // `GatherAsynchronousTransitiveDependencies` skips a module that is
294
- // already evaluating, and evaluates the rest right here.
291
+ ? // `evaluating` is on the stack, so awaiting it would deadlock;
292
+ // `evaluating-async` is suspended and must still be awaited.
295
293
  `if(isAsync) obj[${RuntimeGlobals.deferredModuleAsyncTransitiveDependenciesSymbol}] = asyncDeps.filter(${runtimeTemplate.basicFunction(
296
294
  "id",
297
295
  [
298
296
  `${cst} dep = __webpack_module_cache__[id];`,
299
- "if (dep && (dep.evaluating || dep.evaluatingAsync)) return false;",
297
+ "if (dep && dep.evaluating) return false;",
300
298
  "r(id);",
301
299
  "return true;"
302
300
  ]
@@ -322,11 +320,17 @@ class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
322
320
 
323
321
  /**
324
322
  * @param {boolean} hasAsyncRuntime if async module is used.
323
+ * @param {boolean} sealed a call site builds a namespace from a known export list
324
+ * @param {boolean} synthesized a call site builds one from the module's exports
325
325
  */
326
- constructor(hasAsyncRuntime) {
326
+ constructor(hasAsyncRuntime, sealed, synthesized) {
327
327
  super("make deferred namespace object");
328
328
  /** @type {boolean} */
329
329
  this.hasAsyncRuntime = hasAsyncRuntime;
330
+ /** @type {boolean} */
331
+ this.sealed = sealed;
332
+ /** @type {boolean} */
333
+ this.synthesized = synthesized;
330
334
  }
331
335
 
332
336
  /**
@@ -340,237 +344,314 @@ class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
340
344
  const lt = runtimeTemplate.renderLet();
341
345
  const fn = RuntimeGlobals.makeDeferredNamespaceObject;
342
346
  const hasAsync = this.hasAsyncRuntime;
347
+ // A build reaches only the shapes its call sites ask for, so the other
348
+ // one's branches are dead weight in every bundle that ships this runtime.
349
+ const sealed = this.sealed;
350
+ const synthesized = this.synthesized;
343
351
  const init = `${runtimeTemplate.optionalChaining("init", "()")};`;
344
- return `${fn} = ${runtimeTemplate.basicFunction("moduleId, mode", [
345
- // Per the TC39 import-defer spec, deferred namespaces are
346
- // distinct from their eager counterparts and the same module
347
- // referenced from multiple defer-import sites must yield the
348
- // same object. Cache the Proxy / fake namespace per-moduleId so
349
- // repeated calls (including across files) share identity.
350
- //
351
- // Bit 16 (`createFakeNamespaceObject`'s "return value when
352
- // it's Promise-like" flag added by
353
- // `RuntimeTemplate.moduleNamespacePromise` for dynamic
354
- // imports) is irrelevant for deferred namespaces — the value
355
- // passed into `createFakeNamespaceObject` here is always the
356
- // resolved module exports (after unwrapping the async-module
357
- // export symbol when present), never a Promise. Strip it
358
- // once so all downstream behavior, the cache key, and the
359
- // `createFakeNamespaceObject` call below see the same shape
360
- // mode. This keeps static defer (mode 8) and dynamic
361
- // `await import.defer` (mode 8 | 16) sharing the same
362
- // Deferred Module Namespace object, while still keying by
363
- // `(moduleId, mode)` so distinct exports-type shapes
364
- // (e.g. one importer treats a CJS module as
365
- // "default-with-named", another as "namespace") get
366
- // distinct cache entries.
367
- "mode &= ~16;",
368
- `${lt} byMode = __webpack_module_deferred_namespace_cache__[moduleId];`,
369
- "if (byMode && byMode[mode] !== undefined) return byMode[mode];",
370
- "if (!byMode) byMode = __webpack_module_deferred_namespace_cache__[moduleId] = {};",
371
- `${cst} cachedModule = __webpack_module_cache__[moduleId];`,
372
- "if (cachedModule && cachedModule.error === undefined && !(mode & 8)) {",
373
- Template.indent([
374
- `${lt} exports = cachedModule.exports;`,
375
- hasAsync
376
- ? `if (${RuntimeGlobals.asyncModuleExportSymbol} in exports) exports = exports[${RuntimeGlobals.asyncModuleExportSymbol}];`
352
+ return `${fn} = ${runtimeTemplate.basicFunction(
353
+ "moduleId, mode, exportNames",
354
+ [
355
+ // WHY: the TC39 import-defer spec makes a deferred namespace distinct
356
+ // from its eager counterpart, and one module reached from several defer
357
+ // sites must yield the same object, so the Proxy is cached per moduleId.
358
+ //
359
+ // Bit 16 is `createFakeNamespaceObject`'s "return value when it's
360
+ // Promise-like" flag, which `RuntimeTemplate.moduleNamespacePromise` adds
361
+ // for a dynamic import. It is irrelevant here: what is passed in is
362
+ // always the resolved module exports, after unwrapping the async-module
363
+ // export symbol where there is one, and never a Promise. Stripping it
364
+ // once leaves the cache key, the call below and everything downstream on
365
+ // one shape mode, so static defer (mode 8) and `await import.defer`
366
+ // (mode 8 | 16) share the same object. The key stays `(moduleId, mode)`
367
+ // so two importers reading one CJS module differently — as
368
+ // "default-with-named" against "namespace" — still get distinct entries.
369
+ "mode &= ~16;",
370
+ // Only a real ES module namespace has the spec's exotic shape; a
371
+ // synthesized one (JSON, asset, CommonJS interop) keeps the old form.
372
+ sealed && synthesized
373
+ ? "if (!(mode & 8)) exportNames = undefined;"
377
374
  : "",
378
- `return byMode[mode] = ${RuntimeGlobals.createFakeNamespaceObject}(exports, mode);`
379
- ]),
380
- "}",
381
- "",
382
- `${lt} init = ${runtimeTemplate.basicFunction("", [
383
- // A deferred namespace that forces evaluation of a module that is
384
- // already evaluating (a cycle) must throw rather than expose its
385
- // partial exports.
386
- `${cst} evaluatingModule = __webpack_module_cache__[moduleId];`,
387
- 'if (evaluatingModule !== undefined && (evaluatingModule.evaluating || evaluatingModule.evaluatingAsync)) throw new TypeError("Cannot access a deferred module namespace while the module is being evaluated");',
388
- `ns = ${RuntimeGlobals.require}(moduleId);`,
389
- hasAsync
390
- ? `if (${RuntimeGlobals.asyncModuleExportSymbol} in ns) ns = ns[${RuntimeGlobals.asyncModuleExportSymbol}];`
375
+ `${lt} byMode = __webpack_module_deferred_namespace_cache__[moduleId];`,
376
+ "if (byMode && byMode[mode] !== undefined) return byMode[mode];",
377
+ "if (!byMode) byMode = __webpack_module_deferred_namespace_cache__[moduleId] = {};",
378
+ synthesized
379
+ ? `${cst} cachedModule = __webpack_module_cache__[moduleId];`
391
380
  : "",
392
- "init = null;",
393
- "if (mode & 8 || mode & 4 && ns.__esModule && typeof ns === 'object') {",
394
- Template.indent([
395
- // Drop only the read-side traps after init: with the
396
- // resolved namespace's own keys mirrored onto
397
- // `ns_target` below, the default `Reflect` behavior
398
- // returns the right values via the live-binding
399
- // getters, so we no longer need to intercept `get` /
400
- // `has` / `ownKeys` / `getOwnPropertyDescriptor`.
401
- //
402
- // The mutation traps (`set`, `deleteProperty`,
403
- // `defineProperty`) are kept because per the TC39
404
- // import-defer spec, `[[Set]]` / `[[Delete]]` /
405
- // `[[DefineOwnProperty]]` on a Deferred Module
406
- // Namespace Exotic Object never succeed — and the
407
- // proxy target itself remains extensible
408
- // (architecturally we cannot freeze it up-front),
409
- // so without these traps `ns.notExported = "x"`
410
- // after evaluation would silently create a property
411
- // on the target instead of returning false.
412
- "delete handler.get;",
413
- "delete handler.has;",
414
- "delete handler.ownKeys;",
415
- "delete handler.getOwnPropertyDescriptor;"
416
- ]),
417
- "} else {",
418
- Template.indent([
419
- `ns = ${RuntimeGlobals.createFakeNamespaceObject}(ns, mode);`
420
- ]),
421
- "}",
422
- // Mirror own properties from the resolved namespace onto the proxy
423
- // target so that proxy invariants hold for callers that structurally
424
- // introspect via `Object.keys` / `Object.getOwnPropertyNames` /
425
- // `Object.getOwnPropertyDescriptor`: when our trap reports a
426
- // non-configurable descriptor for a key, the target must also have
427
- // that key with a matching descriptor.
428
- //
429
- // `__esModule` and `Symbol.toStringTag` are intentionally skipped:
430
- // the proxy synthesizes "Deferred Module" / true regardless of what
431
- // the underlying namespace exposes (per the TC39 import-defer
432
- // proposal, the [[StringTag]] of a Deferred Module Namespace
433
- // Exotic Object is "Deferred Module"), and the target was already
434
- // pre-populated with those values below.
435
- `${cst} keys = Reflect.ownKeys(ns);`,
436
- "for (var i = 0; i < keys.length; i++) {",
437
- Template.indent([
438
- `${cst} k = keys[i];`,
439
- 'if (k === "__esModule" || k === Symbol.toStringTag) continue;',
440
- `if (!${runtimeTemplate.objectHasOwn("ns_target", "k")}) {`,
441
- Template.indent([
442
- "try { Object.defineProperty(ns_target, k, Reflect.getOwnPropertyDescriptor(ns, k)); } catch (_) {}"
443
- ]),
444
- "}"
445
- ]),
446
- "}"
447
- ])};`,
448
- "",
449
- // The proxy target is a fresh placeholder, separate from
450
- // `__webpack_module_deferred_exports__[moduleId]` (which is reused
451
- // by `__webpack_require__` as `module.exports` for deferred-loaded
452
- // modules and would conflict with our pre-populated synthetic
453
- // `__esModule` / `Symbol.toStringTag` non-configurable properties).
454
- // Using a dedicated target keeps the proxy invariant-compliant
455
- // without interfering with the module's own exports object.
456
- `${cst} ns_target = { __proto__: null };`,
457
- // Pre-populate the synthetic deferred-namespace properties with
458
- // fully non-configurable, non-writable, non-enumerable descriptors
459
- // (matching the TC39 import-defer spec for Module Namespace
460
- // Exotic Objects). The trap returns the same descriptors below.
461
- 'Object.defineProperty(ns_target, "__esModule", { value: true });',
462
- 'Object.defineProperty(ns_target, Symbol.toStringTag, { value: "Deferred Module" });',
463
- `${lt} ns = ns_target;`,
464
- `${cst} handler = {`,
465
- Template.indent([
466
- "__proto__: null,",
467
- // Per the TC39 import-defer proposal, `IsSymbolLikeNamespaceKey`
468
- // returns true for any Symbol-keyed access (and for "then"); such
469
- // accesses go through `OrdinaryGetOwnProperty` and must not
470
- // trigger evaluation of the deferred module. The Symbol checks
471
- // below short-circuit to the pre-populated target without
472
- // running `init()`.
473
- `${runtimeTemplate.method("get", "_, name", [
474
- "switch (name) {",
475
- Template.indent([
476
- 'case "__esModule": return true;',
477
- 'case Symbol.toStringTag: return "Deferred Module";',
478
- 'case "then": return undefined;'
479
- ]),
480
- "}",
481
- 'if (typeof name === "symbol") return ns_target[name];',
482
- init,
483
- "return ns[name];"
484
- ])},`,
485
- `${runtimeTemplate.method("has", "_, name", [
486
- "switch (name) {",
487
- Template.indent(
488
- [
489
- 'case "__esModule":',
490
- "case Symbol.toStringTag:",
381
+ synthesized
382
+ ? "if (cachedModule && cachedModule.error === undefined && !(mode & 8)) {"
383
+ : "",
384
+ synthesized
385
+ ? Template.indent([
386
+ `${lt} exports = cachedModule.exports;`,
491
387
  hasAsync
492
- ? `case ${RuntimeGlobals.deferredModuleAsyncTransitiveDependenciesSymbol}:`
388
+ ? `if (${RuntimeGlobals.asyncModuleExportSymbol} in exports) exports = exports[${RuntimeGlobals.asyncModuleExportSymbol}];`
493
389
  : "",
494
- Template.indent("return true;"),
495
- 'case "then":',
496
- Template.indent("return false;")
497
- ].filter(Boolean)
498
- ),
499
- "}",
500
- 'if (typeof name === "symbol") return name in ns_target;',
501
- init,
502
- "return name in ns;"
503
- ])},`,
504
- `${runtimeTemplate.method("ownKeys", "", [
505
- init,
506
- `${cst} filtered = Reflect.ownKeys(ns).filter(${runtimeTemplate.expressionFunction(
507
- 'x !== "then" && x !== Symbol.toStringTag',
508
- "x"
509
- )});`,
510
- `${cst} keys = ${
511
- runtimeTemplate.supportsSpread()
512
- ? "[...filtered, Symbol.toStringTag]"
513
- : "filtered.concat([Symbol.toStringTag])"
514
- };`,
515
- "return keys;"
516
- ])},`,
517
- `${runtimeTemplate.method("getOwnPropertyDescriptor", "_, name", [
518
- "switch (name) {",
390
+ `return byMode[mode] = ${RuntimeGlobals.createFakeNamespaceObject}(exports, mode);`
391
+ ])
392
+ : "",
393
+ synthesized ? "}" : "",
394
+ "",
395
+ `${lt} init = ${runtimeTemplate.basicFunction("", [
396
+ // A deferred namespace that forces evaluation of a module that is
397
+ // already evaluating (a cycle) must throw rather than expose its
398
+ // partial exports.
399
+ `${cst} evaluatingModule = __webpack_module_cache__[moduleId];`,
400
+ 'if (evaluatingModule !== undefined && (evaluatingModule.evaluating || evaluatingModule.evaluatingAsync)) throw new TypeError("Cannot access a deferred module namespace while the module is being evaluated");',
401
+ `ns = ${RuntimeGlobals.require}(moduleId);`,
402
+ hasAsync
403
+ ? `if (${RuntimeGlobals.asyncModuleExportSymbol} in ns) ns = ns[${RuntimeGlobals.asyncModuleExportSymbol}];`
404
+ : "",
405
+ "init = null;",
406
+ synthesized
407
+ ? "if (mode & 8 || mode & 4 && ns.__esModule && typeof ns === 'object') {"
408
+ : "",
519
409
  Template.indent([
520
- // Match the descriptors actually defined on `ns_target`
521
- // (non-configurable, non-writable, non-enumerable) so the
522
- // proxy invariant holds for both the trap result and any
523
- // post-init forwarding via the deleted-handler path.
524
- 'case "__esModule": return { value: true, writable: false, enumerable: false, configurable: false };',
525
- 'case Symbol.toStringTag: return { value: "Deferred Module", writable: false, enumerable: false, configurable: false };',
526
- 'case "then": return undefined;'
410
+ // Drop only the read traps after init: with the namespace's own keys
411
+ // mirrored onto `ns_target`, default `Reflect` behavior already
412
+ // returns the right values through the live-binding getters.
413
+
414
+ // WHY: the spec makes `[[Set]]`, `[[Delete]]` and
415
+ // `[[DefineOwnProperty]]` on a Deferred Module Namespace always
416
+ // fail, yet the target stays extensible because it cannot be frozen
417
+ // up front — so without the mutation traps `ns.notExported = "x"`
418
+ // would silently create a property instead of returning false.
419
+
420
+ // A sealed target holds placeholder values, so the read traps stay to
421
+ // keep the live bindings visible.
422
+ sealed && synthesized ? "if (!exportNames) {" : "",
423
+ synthesized
424
+ ? Template.indent([
425
+ "delete handler.get;",
426
+ "delete handler.has;",
427
+ "delete handler.ownKeys;",
428
+ "delete handler.getOwnPropertyDescriptor;"
429
+ ])
430
+ : "",
431
+ sealed && synthesized ? "}" : ""
527
432
  ]),
528
- "}",
529
- 'if (typeof name === "symbol") return Reflect.getOwnPropertyDescriptor(ns_target, name);',
530
- init,
531
- `${lt} desc = Reflect.getOwnPropertyDescriptor(ns, name);`,
532
- 'if (mode & 2 && name == "default" && !desc) {',
533
- Template.indent("desc = { value: ns, configurable: true };"),
534
- "}",
535
- "return desc;"
536
- ])},`,
537
- // `defineProperty` always rejects, but per the TC39 spec it
538
- // must still trigger evaluation for string keys (the spec
539
- // algorithm calls `[[GetOwnProperty]]` first, which forces
540
- // evaluation on a deferred namespace). Symbol keys go through
541
- // OrdinaryDefineOwnProperty and do not trigger eval.
542
- `${runtimeTemplate.method("defineProperty", "_, name", [
543
- 'if (typeof name === "symbol" || name === "then") return false;',
544
- init,
545
- "return false;"
546
- ])},`,
547
- // `deleteProperty` rejects, but per the TC39 spec it must
548
- // still trigger evaluation for string keys (the spec
549
- // algorithm calls `GetModuleExportsList` for non-symbol-like
550
- // keys, forcing evaluation on a deferred namespace).
551
- `${runtimeTemplate.method("deleteProperty", "_, name", [
552
- 'if (typeof name === "symbol" || name === "then") return false;',
553
- init,
554
- "return false;"
555
- ])},`,
556
- // `set` always returns false without triggering evaluation —
557
- // the spec [[Set]] algorithm for Module Namespaces is just
558
- // "return false" (no [[GetOwnProperty]], no eval).
559
- `set: ${runtimeTemplate.returningFunction("false")},`
560
- ]),
561
- "}",
562
- // we don't fully emulate ES Module semantics in this Proxy to align with normal webpack esm namespace object.
563
- "return byMode[mode] = new Proxy(ns_target, handler);"
564
- ])};`;
433
+ synthesized ? "} else {" : "",
434
+ synthesized
435
+ ? Template.indent([
436
+ `ns = ${RuntimeGlobals.createFakeNamespaceObject}(ns, mode);`
437
+ ])
438
+ : "",
439
+ synthesized ? "}" : "",
440
+ // Mirror the resolved namespace's own properties onto the target, or
441
+ // the proxy invariants break: where a trap reports a non-configurable
442
+ // descriptor, the target must carry a matching one.
443
+
444
+ // `__esModule` and `Symbol.toStringTag` are skipped: the proxy
445
+ // synthesizes them whatever the namespace exposes, and the target is
446
+ // pre-populated with those values below.
447
+ synthesized
448
+ ? `${cst} keys = ${sealed ? "exportNames ? [] : " : ""}Reflect.ownKeys(ns);`
449
+ : "",
450
+ synthesized ? "for (var i = 0; i < keys.length; i++) {" : "",
451
+ synthesized
452
+ ? Template.indent([
453
+ `${cst} k = keys[i];`,
454
+ 'if (k === "__esModule" || k === Symbol.toStringTag) continue;',
455
+ `if (!${runtimeTemplate.objectHasOwn("ns_target", "k")}) {`,
456
+ Template.indent([
457
+ "try { Object.defineProperty(ns_target, k, Reflect.getOwnPropertyDescriptor(ns, k)); } catch (_) {}"
458
+ ]),
459
+ "}"
460
+ ])
461
+ : "",
462
+ synthesized ? "}" : ""
463
+ ])};`,
464
+ "",
465
+ // WHY: the proxy target is a fresh placeholder, separate from
466
+ // `__webpack_module_deferred_exports__[moduleId]`, which
467
+ // `__webpack_require__` reuses as `module.exports` for a deferred-loaded
468
+ // module and would conflict with the pre-populated synthetic `__esModule`
469
+ // and `Symbol.toStringTag` non-configurable properties. A dedicated
470
+ // target keeps the proxy invariant-compliant without interfering with the
471
+ // module's own exports object.
472
+ `${cst} ns_target = { __proto__: null };`,
473
+ // With the export list known at build time the target carries the spec's
474
+ // keys and is sealed, so `[[IsExtensible]]` is false up front.
475
+ sealed
476
+ ? `${synthesized ? "if (exportNames) " : ""}for (var e = 0; e < exportNames.length; e++) ns_target[exportNames[e]] = undefined;`
477
+ : "",
478
+ // Pre-populate the synthetic properties with the non-configurable,
479
+ // non-writable, non-enumerable descriptors the spec gives a Module
480
+ // Namespace, which the trap below returns unchanged.
481
+
482
+ // `__esModule` is not one of the spec's keys, so a sealed namespace omits
483
+ // it; the synthesized form keeps it for interop.
484
+ synthesized
485
+ ? `${sealed ? "if (!exportNames) " : ""}Object.defineProperty(ns_target, "__esModule", { value: true });`
486
+ : "",
487
+ 'Object.defineProperty(ns_target, Symbol.toStringTag, { value: "Deferred Module" });',
488
+ sealed
489
+ ? `${synthesized ? "if (exportNames) " : ""}Object.seal(ns_target);`
490
+ : "",
491
+ `${lt} ns = ns_target;`,
492
+ `${cst} handler = {`,
493
+ Template.indent([
494
+ "__proto__: null,",
495
+ // `IsSymbolLikeNamespaceKey` holds for any Symbol key and for `then`,
496
+ // and such a read must not evaluate the deferred module, so the checks
497
+ // below reach the pre-populated target without running `init()`.
498
+ `${runtimeTemplate.method("get", "_, name", [
499
+ "switch (name) {",
500
+ Template.indent([
501
+ // webpack's interop marker, read as a property by
502
+ // `o.__esModule ? o.default : o`, so a sealed namespace
503
+ // answers it too even though it is not one of its keys.
504
+ 'case "__esModule": return true;',
505
+ 'case Symbol.toStringTag: return "Deferred Module";',
506
+ 'case "then": return undefined;'
507
+ ]),
508
+ "}",
509
+ 'if (typeof name === "symbol") return ns_target[name];',
510
+ init,
511
+ // A sealed namespace has exactly the spec's keys, so anything
512
+ // else is absent rather than read off the exports object.
513
+ sealed
514
+ ? `${synthesized ? "if (exportNames) " : ""}return name in ns_target ? ns[name] : undefined;`
515
+ : "",
516
+ synthesized ? "return ns[name];" : ""
517
+ ])},`,
518
+ `${runtimeTemplate.method("has", "_, name", [
519
+ "switch (name) {",
520
+ Template.indent(
521
+ [
522
+ synthesized
523
+ ? `case "__esModule": ${sealed ? "if (!exportNames) " : ""}return true;${sealed ? " break;" : ""}`
524
+ : "",
525
+ "case Symbol.toStringTag:",
526
+ hasAsync
527
+ ? `case ${RuntimeGlobals.deferredModuleAsyncTransitiveDependenciesSymbol}:`
528
+ : "",
529
+ Template.indent("return true;"),
530
+ 'case "then":',
531
+ Template.indent("return false;")
532
+ ].filter(Boolean)
533
+ ),
534
+ "}",
535
+ 'if (typeof name === "symbol") return name in ns_target;',
536
+ init,
537
+ sealed
538
+ ? `${synthesized ? "if (exportNames) " : ""}return name in ns_target;`
539
+ : "",
540
+ synthesized ? "return name in ns;" : ""
541
+ ])},`,
542
+ `${runtimeTemplate.method("ownKeys", "", [
543
+ init,
544
+ // The sealed target already carries the spec's keys, sorted.
545
+ sealed
546
+ ? `${synthesized ? "if (exportNames) " : ""}return Reflect.ownKeys(ns_target);`
547
+ : "",
548
+ synthesized
549
+ ? `${cst} filtered = Reflect.ownKeys(ns).filter(${runtimeTemplate.expressionFunction(
550
+ 'x !== "then" && x !== Symbol.toStringTag',
551
+ "x"
552
+ )});`
553
+ : "",
554
+ synthesized
555
+ ? `${cst} keys = ${
556
+ runtimeTemplate.supportsSpread()
557
+ ? "[...filtered, Symbol.toStringTag]"
558
+ : "filtered.concat([Symbol.toStringTag])"
559
+ };`
560
+ : "",
561
+ synthesized ? "return keys;" : ""
562
+ ])},`,
563
+ `${runtimeTemplate.method("getOwnPropertyDescriptor", "_, name", [
564
+ "switch (name) {",
565
+ Template.indent([
566
+ // Match the descriptors actually defined on `ns_target`, so the
567
+ // proxy invariant holds both for this result and for the
568
+ // post-init forwarding through the deleted-handler path.
569
+ synthesized
570
+ ? `case "__esModule": ${sealed ? "if (!exportNames) " : ""}return { value: true, writable: false, enumerable: false, configurable: false };${sealed ? " break;" : ""}`
571
+ : "",
572
+ 'case Symbol.toStringTag: return { value: "Deferred Module", writable: false, enumerable: false, configurable: false };',
573
+ 'case "then": return undefined;'
574
+ ]),
575
+ "}",
576
+ 'if (typeof name === "symbol") return Reflect.getOwnPropertyDescriptor(ns_target, name);',
577
+ init,
578
+ // A namespace exposes data properties; webpack backs the exports
579
+ // with getters, so the spec's shape is synthesized here.
580
+ sealed
581
+ ? `${synthesized ? "if (exportNames) " : ""}return name in ns_target ? { value: ns[name], writable: true, enumerable: true, configurable: false } : undefined;`
582
+ : "",
583
+ synthesized
584
+ ? `${lt} desc = Reflect.getOwnPropertyDescriptor(ns, name);`
585
+ : "",
586
+ synthesized ? 'if (mode & 2 && name == "default" && !desc) {' : "",
587
+ synthesized
588
+ ? Template.indent("desc = { value: ns, configurable: true };")
589
+ : "",
590
+ synthesized ? "}" : "",
591
+ synthesized ? "return desc;" : ""
592
+ ])},`,
593
+ // `defineProperty` always rejects, yet must still evaluate on a string
594
+ // key, since the spec calls `[[GetOwnProperty]]` first. A Symbol key
595
+ // takes OrdinaryDefineOwnProperty and evaluates nothing.
596
+ `${runtimeTemplate.method("defineProperty", "_, name", [
597
+ 'if (typeof name === "symbol" || name === "then") return false;',
598
+ init,
599
+ "return false;"
600
+ ])},`,
601
+ // `deleteProperty` rejects too, and likewise still evaluates on a
602
+ // string key: the spec calls `GetModuleExportsList` for every
603
+ // non-symbol-like key.
604
+ `${runtimeTemplate.method("deleteProperty", "_, name", [
605
+ 'if (typeof name === "symbol" || name === "then") return false;',
606
+ init,
607
+ "return false;"
608
+ ])},`,
609
+ // `set` always returns false without triggering evaluation —
610
+ // the spec [[Set]] algorithm for Module Namespaces is just
611
+ // "return false" (no [[GetOwnProperty]], no eval).
612
+ `set: ${runtimeTemplate.returningFunction("false")},`
613
+ ]),
614
+ "}",
615
+ // we don't fully emulate ES Module semantics in this Proxy to align with normal webpack esm namespace object.
616
+ "return byMode[mode] = new Proxy(ns_target, handler);"
617
+ ]
618
+ )};`;
565
619
  }
566
620
  }
567
621
 
622
+ /**
623
+ * The module's export names, sorted, when the graph knows them exhaustively.
624
+ * Only a `namespace` module takes the sealed path, and names are never mangled
625
+ * here: materializing a namespace clears `canMangleUse` on every export.
626
+ * @param {ModuleGraph} moduleGraph the module graph
627
+ * @param {Module} module the deferred module
628
+ * @param {ExportsType} exportsType the module's exports type
629
+ * @returns {string[] | null} sorted export names, or null when unknown
630
+ */
631
+ const getKnownExportNames = (moduleGraph, module, exportsType) => {
632
+ if (exportsType !== "namespace") return null;
633
+ const exportsInfo = moduleGraph.getExportsInfo(module);
634
+ if (exportsInfo.otherExportsInfo.provided !== false) return null;
635
+ const names = [];
636
+ for (const exportInfo of exportsInfo.orderedExports) {
637
+ // `false` is a definitive "not an export" (webpack records `__esModule`
638
+ // that way); anything but a definitive answer means the list is unknown.
639
+ if (exportInfo.provided === false) continue;
640
+ if (exportInfo.provided !== true) return null;
641
+ // A namespace never exposes `then`, so it is not one of the spec's keys.
642
+ if (exportInfo.name === "then") continue;
643
+ names.push(exportInfo.name);
644
+ }
645
+ return names.sort();
646
+ };
647
+
568
648
  module.exports.MakeDeferredNamespaceObjectRuntimeModule =
569
649
  MakeDeferredNamespaceObjectRuntimeModule;
570
650
  module.exports.MakeOptimizedDeferredNamespaceObjectRuntimeModule =
571
651
  MakeOptimizedDeferredNamespaceObjectRuntimeModule;
572
652
  module.exports.getDeferredCycleModuleIds = getDeferredCycleModuleIds;
573
653
  module.exports.getDeferredCycleModules = getDeferredCycleModules;
654
+ module.exports.getKnownExportNames = getKnownExportNames;
574
655
  module.exports.getMakeDeferredNamespaceModeFromExportsType =
575
656
  getMakeDeferredNamespaceModeFromExportsType;
576
657
  module.exports.getOptimizedDeferredModule = getOptimizedDeferredModule;
@@ -23,6 +23,15 @@ class NonceRuntimeModule extends RuntimeModule {
23
23
  return false;
24
24
  }
25
25
 
26
+ /**
27
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
28
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
29
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
30
+ */
31
+ getInstalledChunkHandlers() {
32
+ return RuntimeModule.NO_CHUNK_HANDLERS;
33
+ }
34
+
26
35
  /**
27
36
  * Generates runtime code for this runtime module.
28
37
  * @returns {string | null} runtime code