@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.
- package/README.md +7 -8
- package/changes.json +7 -11
- package/lib/APIPlugin.js +26 -11
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/Cache.js +8 -3
- package/lib/CacheFacade.js +1 -1
- package/lib/CircularModulesPlugin.js +157 -55
- package/lib/CleanPlugin.js +2 -2
- package/lib/CompatibilityPlugin.js +3 -4
- package/lib/Compilation.js +336 -337
- package/lib/Compiler.js +213 -51
- package/lib/ConstPlugin.js +16 -132
- package/lib/CopyPlugin.js +1054 -0
- package/lib/DefinePlugin.js +24 -8
- package/lib/DependencyTemplate.js +2 -1
- package/lib/DotenvPlugin.js +24 -28
- package/lib/ErrorHelpers.js +113 -0
- package/lib/ExportsInfo.js +20 -16
- package/lib/ExternalModule.js +47 -22
- package/lib/FileSystemInfo.js +17 -14
- package/lib/FlagDependencyExportsPlugin.js +53 -34
- package/lib/FlagDependencyUsagePlugin.js +9 -13
- package/lib/Generator.js +24 -2
- package/lib/HotModuleReplacementPlugin.js +55 -7
- package/lib/IgnorePlugin.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +5 -3
- package/lib/LoaderOptionsPlugin.js +1 -1
- package/lib/MainTemplate.js +5 -1
- package/lib/Module.js +19 -10
- package/lib/ModuleGraph.js +6 -9
- package/lib/MultiCompiler.js +7 -17
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +135 -50
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/RuntimeGlobals.js +21 -7
- package/lib/RuntimeModule.js +28 -12
- package/lib/RuntimePlugin.js +30 -3
- package/lib/RuntimeTemplate.js +813 -518
- package/lib/SourceMapDevToolPlugin.js +54 -104
- package/lib/TemplatedPathPlugin.js +16 -59
- package/lib/Watching.js +9 -0
- package/lib/WebpackOptionsApply.js +84 -91
- package/lib/asset/AssetBytesGenerator.js +7 -1
- package/lib/asset/AssetGenerator.js +50 -24
- package/lib/asset/AssetModule.js +3 -0
- package/lib/asset/AssetSourceGenerator.js +7 -1
- package/lib/asset/WebManifestParser.js +7 -5
- package/lib/buildChunkGraph.js +11 -15
- package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
- package/lib/cache/IdleFileCachePlugin.js +2 -2
- package/lib/cache/MemoryCachePlugin.js +4 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +7 -8
- package/lib/cache/PackFileCacheStrategy.js +17 -19
- package/lib/cache/getLazyHashedEtag.js +3 -5
- package/lib/config/browserslistTargetHandler.js +17 -4
- package/lib/config/defaults.js +138 -128
- package/lib/config/getClaimedAssetTypes.js +10 -11
- package/lib/config/normalization.js +82 -12
- package/lib/config/target.js +13 -4
- package/lib/container/ContainerReferencePlugin.js +6 -0
- package/lib/container/RemoteRuntimeModule.js +9 -0
- package/lib/container/declaredRemotes.js +39 -0
- package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
- package/lib/{ContextModule.js → context/ContextModule.js} +54 -115
- package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +19 -21
- package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
- package/lib/css/CssGenerator.js +27 -11
- package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
- package/lib/css/CssLoadingRuntimeModule.js +94 -36
- package/lib/css/CssModule.js +1 -1
- package/lib/css/CssModulesPlugin.js +7 -6
- package/lib/css/CssParser.js +162 -31
- package/lib/css/CssServerStylesRuntimeModule.js +9 -0
- package/lib/css/cssMinify.js +43 -32
- package/lib/css/data.js +3514 -869
- package/lib/css/syntax.js +6370 -1220
- package/lib/debug/ProfilingPlugin.js +7 -4
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
- package/lib/dependencies/AMDRuntimeModules.js +18 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +13 -12
- package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
- package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -5
- package/lib/dependencies/CommonJsPlugin.js +19 -3
- package/lib/dependencies/CommonJsRequireDependency.js +14 -5
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -9
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +13 -9
- package/lib/dependencies/CssIcssImportDependency.js +3 -6
- package/lib/dependencies/CssUrlDependency.js +3 -5
- package/lib/dependencies/HarmonyCompatibilityDependency.js +67 -22
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +10 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +74 -17
- package/lib/dependencies/HarmonyExportInitFragment.js +110 -23
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +25 -58
- package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
- package/lib/dependencies/HarmonyImportDependency.js +6 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +111 -17
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +3 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
- package/lib/dependencies/HtmlEntryDependency.js +124 -102
- package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
- package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportMetaGlobHelpers.js +1 -1
- package/lib/dependencies/ImportMetaMainDependency.js +104 -0
- package/lib/dependencies/ImportMetaPlugin.js +67 -25
- package/lib/dependencies/ImportParserPlugin.js +1 -1
- package/lib/dependencies/LoaderPlugin.js +26 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/SystemRuntimeModule.js +9 -0
- package/lib/dependencies/URLContextDependency.js +1 -1
- package/lib/dependencies/URLDependency.js +6 -5
- package/lib/dependencies/WorkerAndWorkletPlugin.js +15 -21
- package/lib/dependencies/WorkerDependency.js +7 -7
- package/lib/dependencies/WorkletDependency.js +7 -11
- package/lib/dll/DelegatedModule.js +18 -1
- package/lib/dll/DllReferencePlugin.js +11 -8
- package/lib/dll/LibManifestPlugin.js +1 -1
- package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
- package/lib/errors/DuplicateModulesWarning.js +12 -7
- package/lib/errors/EmptyCopyPatternWarning.js +26 -0
- package/lib/errors/ExternalStarReexportError.js +44 -0
- package/lib/errors/HookWebpackError.js +3 -2
- package/lib/errors/MissingSourceMapsWarning.js +36 -0
- package/lib/errors/ModuleParseError.js +2 -1
- package/lib/errors/UnusedAssetsWarning.js +36 -0
- package/lib/errors/UnusedFederationWarning.js +35 -0
- package/lib/errors/UnusedModulesWarning.js +38 -0
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +30 -11
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -60
- package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
- package/lib/hmr/LazyCompilationPlugin.js +3 -5
- package/lib/html/HtmlGenerator.js +72 -87
- package/lib/html/HtmlModulesPlugin.js +418 -200
- package/lib/html/HtmlParser.js +110 -147
- package/lib/html/builtinEmbeddedRenderer.js +107 -0
- package/lib/html/data.js +142 -7
- package/lib/html/htmlMinify.js +92 -122
- package/lib/html/syntax.js +1618 -1391
- package/lib/ids/HashedModuleIdsPlugin.js +2 -1
- package/lib/index.js +49 -3
- package/lib/javascript/ChunkFormatHelpers.js +4 -3
- package/lib/javascript/JavascriptGenerator.js +8 -1
- package/lib/javascript/JavascriptModule.js +1 -0
- package/lib/javascript/JavascriptModulesPlugin.js +73 -72
- package/lib/javascript/JavascriptParser.js +1970 -900
- package/lib/javascript/StartupHelpers.js +27 -3
- package/lib/javascript/data.js +172 -0
- package/lib/javascript/grammar.js +5546 -0
- package/lib/javascript/parser.js +1500 -0
- package/lib/javascript/regexp.js +1762 -0
- package/lib/javascript/regexpData.js +51 -0
- package/lib/javascript/syntax.js +9061 -5262
- package/lib/json/JsonGenerator.js +7 -1
- package/lib/library/ModuleLibraryPlugin.js +171 -132
- package/lib/loaders/LoaderRunner.js +137 -9
- package/lib/node/NodeWatchFileSystem.js +3 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
- package/lib/optimize/AggressiveMergingPlugin.js +3 -5
- package/lib/optimize/ConcatenatedModule.js +178 -120
- package/lib/optimize/ConstExportsPlugin.js +50 -39
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
- package/lib/optimize/InlineExports.js +20 -123
- package/lib/optimize/InnerGraphPlugin.js +7 -13
- package/lib/optimize/LimitChunkCountPlugin.js +5 -8
- package/lib/optimize/MangleExportsPlugin.js +13 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +27 -5
- package/lib/optimize/RealContentHashPlugin.js +68 -9
- package/lib/optimize/SideEffectsFlagPlugin.js +24 -28
- package/lib/optimize/SplitChunksPlugin.js +2 -4
- package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
- package/lib/performance/BroadContextsPlugin.js +1 -1
- package/lib/performance/CacheEffectivenessPlugin.js +7 -7
- package/lib/performance/DuplicateModulesPlugin.js +57 -13
- package/lib/performance/EvalUsagePlugin.js +5 -2
- package/lib/performance/MissingSourceMapsPlugin.js +115 -0
- package/lib/performance/PureAnnotationsPlugin.js +6 -3
- package/lib/performance/SizeLimitsPlugin.js +2 -4
- package/lib/performance/TopLevelThisPlugin.js +5 -4
- package/lib/performance/UnusedAssetsPlugin.js +109 -0
- package/lib/performance/UnusedFederationPlugin.js +147 -0
- package/lib/performance/UnusedModulesPlugin.js +141 -0
- package/lib/performance/UnusedReexportsPlugin.js +1 -55
- package/lib/performance/isOnlyReexported.js +65 -0
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +8 -8
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
- package/lib/prefetch/ResourceHintPlugin.js +18 -23
- package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
- package/lib/prefetch/StartupAssetHintRuntimeModule.js +16 -10
- package/lib/rules/RuleSetCompiler.js +211 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +98 -66
- package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
- package/lib/runtime/BaseUriRuntimeModule.js +9 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +12 -4
- package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
- package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
- package/lib/runtime/GlobalRuntimeModule.js +11 -4
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
- package/lib/runtime/HelperRuntimeModule.js +10 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +305 -224
- package/lib/runtime/NonceRuntimeModule.js +9 -0
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
- package/lib/runtime/PublicPathRuntimeModule.js +9 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
- package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
- package/lib/runtime/SystemContextRuntimeModule.js +9 -0
- package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
- package/lib/schemes/DataUriPlugin.js +3 -6
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +9 -9
- package/lib/serialization/FileMiddleware.js +16 -16
- package/lib/serialization/ObjectMiddleware.js +168 -139
- package/lib/sharing/ConsumeSharedPlugin.js +12 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
- package/lib/sharing/ShareRuntimeModule.js +9 -0
- package/lib/sharing/declaredShared.js +47 -0
- package/lib/stats/DefaultStatsFactoryPlugin.js +6 -5
- package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
- package/lib/typescript/TypeScriptPlugin.js +2 -3
- package/lib/url/URLParserPlugin.js +6 -8
- package/lib/util/LocConverter.js +4 -7
- package/lib/util/SourceProcessor.js +91 -91
- package/lib/util/async.js +292 -0
- package/lib/util/buildDiagnostics.js +69 -0
- package/lib/util/chainedImports.js +3 -4
- package/lib/util/concatenate.js +4 -4
- package/lib/util/createHooksRegistry.js +1 -2
- package/lib/util/dataURL.js +2 -3
- package/lib/util/deterministicGrouping.js +8 -13
- package/lib/util/findGraphRoots.js +6 -13
- package/lib/util/fs.js +27 -1
- package/lib/util/globUtils.js +1 -1
- package/lib/util/handlerKeys.js +40 -0
- package/lib/util/hash/wasm-hash.js +3 -4
- package/lib/util/identifier.js +20 -0
- package/lib/util/internalSerializables.js +5 -1
- package/lib/util/registerExternalSerializer.js +6 -45
- package/lib/util/semver.js +5 -3
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +9 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +12 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +6 -1
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -4
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
- package/package.json +55 -46
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +379 -66
- package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
- package/schemas/plugins/ManifestPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
- package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/types.d.ts +1723 -604
- package/lib/dependencies/ExportBindingInitFragment.js +0 -191
- package/lib/errors/EntrypointOverlapWarning.js +0 -45
- 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
|
|
267
|
-
//
|
|
268
|
-
//
|
|
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
|
-
? // `
|
|
294
|
-
//
|
|
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 &&
|
|
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(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
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
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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
|
-
? `
|
|
388
|
+
? `if (${RuntimeGlobals.asyncModuleExportSymbol} in exports) exports = exports[${RuntimeGlobals.asyncModuleExportSymbol}];`
|
|
493
389
|
: "",
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
"
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
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
|
-
//
|
|
521
|
-
//
|
|
522
|
-
//
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
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
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
"}",
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
"
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
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
|