@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
|
@@ -385,10 +385,9 @@ const collectEntrypointHints = (compilation, entryName, hints) => {
|
|
|
385
385
|
if (dep.fetchPriority) h.fetchPriority = dep.fetchPriority;
|
|
386
386
|
push(h);
|
|
387
387
|
}
|
|
388
|
-
// `hostType
|
|
389
|
-
//
|
|
390
|
-
//
|
|
391
|
-
// `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"`.
|
|
392
391
|
let hostType = /** @type {"html" | "js"} */ ("js");
|
|
393
392
|
|
|
394
393
|
outer: for (const module of compilation.modules) {
|
|
@@ -490,8 +489,7 @@ const collectStartupAssetHintLines = (
|
|
|
490
489
|
dep.options.publicPath,
|
|
491
490
|
workerChunk,
|
|
492
491
|
module,
|
|
493
|
-
chunkGraph
|
|
494
|
-
set
|
|
492
|
+
chunkGraph
|
|
495
493
|
);
|
|
496
494
|
// Without one the call site keeps the runtime form, where it wraps its own
|
|
497
495
|
// href — firing the `<link>` here too would emit the call twice.
|
|
@@ -738,15 +736,14 @@ class ResourceHintPlugin {
|
|
|
738
736
|
const hints = this._hints;
|
|
739
737
|
|
|
740
738
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
741
|
-
//
|
|
742
|
-
// `HtmlEntryDependency`s
|
|
743
|
-
//
|
|
744
|
-
//
|
|
745
|
-
//
|
|
746
|
-
//
|
|
747
|
-
//
|
|
748
|
-
//
|
|
749
|
-
// (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.
|
|
750
747
|
/** @type {Map<string, HtmlHintedAsset[]> | undefined} */
|
|
751
748
|
let perEntry;
|
|
752
749
|
/** @type {WeakSet<Module> | undefined} */
|
|
@@ -774,10 +771,9 @@ class ResourceHintPlugin {
|
|
|
774
771
|
}
|
|
775
772
|
const entrypoint = compilation.entrypoints.get(dep.entryName);
|
|
776
773
|
if (!entrypoint) continue;
|
|
777
|
-
//
|
|
778
|
-
//
|
|
779
|
-
//
|
|
780
|
-
// 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.
|
|
781
777
|
/** @type {Set<import("../Chunk")>} */
|
|
782
778
|
const chunks = new Set(entrypoint.chunks);
|
|
783
779
|
const entry = entrypoint.getEntrypointChunk();
|
|
@@ -865,10 +861,9 @@ class ResourceHintPlugin {
|
|
|
865
861
|
});
|
|
866
862
|
}
|
|
867
863
|
|
|
868
|
-
// SSR manifest
|
|
869
|
-
// asset
|
|
870
|
-
//
|
|
871
|
-
// 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.
|
|
872
867
|
const rhOptions = compilation.outputOptions.resourceHints;
|
|
873
868
|
const manifestPath = rhOptions && rhOptions.manifest;
|
|
874
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
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
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:
|
|
357
|
-
fn: (str) => typeof str === "string" && str.startsWith(
|
|
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
|
|
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)
|
|
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__")};`,
|
|
@@ -148,73 +157,96 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
|
|
|
148
157
|
])})`,
|
|
149
158
|
"deps"
|
|
150
159
|
)};`,
|
|
151
|
-
`${fn} = ${runtimeTemplate.basicFunction(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
"promise[webpackExports] = exports;",
|
|
164
|
-
`promise[webpackQueues] = ${runtimeTemplate.expressionFunction(
|
|
165
|
-
`queue && fn(queue), depQueues.forEach(fn), promise["catch"](${runtimeTemplate.emptyFunction()})`,
|
|
166
|
-
"fn"
|
|
167
|
-
)};`,
|
|
168
|
-
"module.exports = promise;",
|
|
169
|
-
`${cst} handle = ${runtimeTemplate.basicFunction("deps", [
|
|
170
|
-
"currentDeps = wrapDeps(deps);",
|
|
171
|
-
`${lt} fn;`,
|
|
172
|
-
`${cst} getResult = ${runtimeTemplate.returningFunction(
|
|
173
|
-
`currentDeps.map(${runtimeTemplate.basicFunction("d", [
|
|
174
|
-
defer ? "if(d[webpackDefer]) return d;" : "",
|
|
175
|
-
"if(d[webpackError]) throw d[webpackError];",
|
|
176
|
-
"return d[webpackExports];"
|
|
177
|
-
])})`
|
|
178
|
-
)}`,
|
|
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;`,
|
|
179
172
|
`${cst} promise = new Promise(${runtimeTemplate.basicFunction(
|
|
180
|
-
"resolve",
|
|
181
|
-
[
|
|
182
|
-
`fn = ${runtimeTemplate.expressionFunction(
|
|
183
|
-
"resolve(getResult)",
|
|
184
|
-
""
|
|
185
|
-
)};`,
|
|
186
|
-
"fn.r = 0;",
|
|
187
|
-
`${cst} fnQueue = ${runtimeTemplate.expressionFunction(
|
|
188
|
-
"q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn)))",
|
|
189
|
-
"q"
|
|
190
|
-
)};`,
|
|
191
|
-
`currentDeps.forEach(${runtimeTemplate.expressionFunction(
|
|
192
|
-
`${
|
|
193
|
-
defer ? "dep[webpackDefer]||" : ""
|
|
194
|
-
}dep[webpackQueues](fnQueue)`,
|
|
195
|
-
"dep"
|
|
196
|
-
)});`
|
|
197
|
-
]
|
|
173
|
+
"resolve, rej",
|
|
174
|
+
["reject = rej;", "outerResolve = resolve;"]
|
|
198
175
|
)});`,
|
|
199
|
-
"
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
+
)};`
|
|
218
250
|
]);
|
|
219
251
|
}
|
|
220
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
|
|
@@ -27,6 +27,15 @@ class ChunkNameRuntimeModule extends RuntimeModule {
|
|
|
27
27
|
this.chunkName = chunkName;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
32
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
33
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
34
|
+
*/
|
|
35
|
+
getInstalledChunkHandlers() {
|
|
36
|
+
return RuntimeModule.NO_CHUNK_HANDLERS;
|
|
37
|
+
}
|
|
38
|
+
|
|
30
39
|
/**
|
|
31
40
|
* Generates runtime code for this runtime module.
|
|
32
41
|
* @returns {string | null} runtime code
|