webpack 5.110.3 → 5.111.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 +5 -0
- package/lib/APIPlugin.js +23 -7
- 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/Compilation.js +320 -302
- package/lib/Compiler.js +209 -46
- package/lib/ContextModule.js +17 -81
- package/lib/ContextModuleFactory.js +1 -1
- package/lib/CopyPlugin.js +1054 -0
- package/lib/DefinePlugin.js +24 -8
- package/lib/ExternalModule.js +41 -14
- package/lib/FileSystemInfo.js +17 -14
- package/lib/FlagDependencyExportsPlugin.js +45 -21
- package/lib/HotModuleReplacementPlugin.js +53 -7
- package/lib/JavascriptMetaInfoPlugin.js +5 -3
- package/lib/MainTemplate.js +5 -1
- package/lib/Module.js +16 -7
- package/lib/MultiCompiler.js +1 -1
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +45 -12
- 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 +780 -475
- package/lib/SourceMapDevToolPlugin.js +1 -1
- package/lib/Watching.js +9 -0
- package/lib/WebpackOptionsApply.js +84 -91
- package/lib/asset/AssetGenerator.js +25 -8
- package/lib/asset/AssetModule.js +3 -0
- package/lib/asset/WebManifestParser.js +7 -5
- package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
- package/lib/cache/IdleFileCachePlugin.js +2 -2
- package/lib/cache/PackFileCacheStrategy.js +14 -1
- package/lib/config/browserslistTargetHandler.js +19 -0
- package/lib/config/defaults.js +86 -50
- package/lib/config/normalization.js +82 -12
- package/lib/config/target.js +10 -0
- package/lib/container/ContainerReferencePlugin.js +6 -0
- package/lib/container/RemoteRuntimeModule.js +9 -0
- package/lib/container/declaredRemotes.js +39 -0
- package/lib/css/CssGenerator.js +8 -0
- 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 +144 -11
- package/lib/css/CssServerStylesRuntimeModule.js +9 -0
- package/lib/css/cssMinify.js +11 -3
- package/lib/css/data.js +2814 -678
- package/lib/css/syntax.js +4082 -248
- package/lib/debug/ProfilingPlugin.js +4 -0
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
- package/lib/dependencies/AMDRuntimeModules.js +18 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +3 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
- package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -0
- package/lib/dependencies/CommonJsPlugin.js +19 -3
- package/lib/dependencies/CommonJsRequireDependency.js +14 -5
- package/lib/dependencies/CssIcssExportDependency.js +7 -1
- package/lib/dependencies/HarmonyCompatibilityDependency.js +58 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +8 -3
- package/lib/dependencies/HarmonyExportExpressionDependency.js +44 -29
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +71 -13
- package/lib/dependencies/HarmonyExportInitFragment.js +99 -19
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +18 -30
- package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
- package/lib/dependencies/HarmonyImportDependency.js +6 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +8 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +24 -1
- package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
- package/lib/dependencies/HtmlEntryDependency.js +50 -0
- package/lib/dependencies/ImportMetaMainDependency.js +104 -0
- package/lib/dependencies/ImportMetaPlugin.js +59 -15
- package/lib/dependencies/SystemRuntimeModule.js +9 -0
- package/lib/dependencies/WorkerDependency.js +1 -2
- package/lib/dependencies/WorkletDependency.js +1 -2
- 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/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/html/HtmlGenerator.js +11 -5
- package/lib/html/HtmlModulesPlugin.js +331 -62
- package/lib/html/HtmlParser.js +13 -6
- package/lib/html/builtinEmbeddedRenderer.js +107 -0
- package/lib/html/data.js +121 -7
- package/lib/html/htmlMinify.js +84 -113
- package/lib/html/syntax.js +763 -426
- package/lib/ids/HashedModuleIdsPlugin.js +2 -1
- package/lib/index.js +3 -0
- package/lib/javascript/JavascriptModule.js +1 -0
- package/lib/javascript/JavascriptModulesPlugin.js +52 -24
- package/lib/javascript/JavascriptParser.js +1255 -728
- 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 +1494 -0
- package/lib/javascript/regexp.js +1762 -0
- package/lib/javascript/regexpData.js +51 -0
- package/lib/javascript/syntax.js +8696 -5225
- package/lib/library/ModuleLibraryPlugin.js +116 -5
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
- package/lib/optimize/ConcatenatedModule.js +97 -20
- package/lib/optimize/ConstExportsPlugin.js +50 -39
- package/lib/optimize/InlineExports.js +20 -123
- package/lib/optimize/MangleExportsPlugin.js +10 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +24 -1
- package/lib/optimize/RealContentHashPlugin.js +68 -9
- package/lib/optimize/SideEffectsFlagPlugin.js +17 -9
- package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
- package/lib/performance/CacheEffectivenessPlugin.js +4 -3
- 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/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 +2 -0
- 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 +1 -2
- package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
- package/lib/prefetch/StartupAssetHintRuntimeModule.js +9 -0
- package/lib/rules/RuleSetCompiler.js +211 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +100 -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 +9 -0
- 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 +9 -0
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
- package/lib/runtime/HelperRuntimeModule.js +10 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +330 -219
- 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/serialization/ObjectMiddleware.js +138 -106
- 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 +3 -1
- package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
- package/lib/util/SourceProcessor.js +76 -69
- package/lib/util/async.js +292 -0
- package/lib/util/buildDiagnostics.js +69 -0
- package/lib/util/fs.js +27 -1
- package/lib/util/handlerKeys.js +40 -0
- package/lib/util/identifier.js +20 -0
- package/lib/util/internalSerializables.js +4 -0
- package/lib/util/registerExternalSerializer.js +6 -45
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +9 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +9 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
- package/package.json +22 -16
- 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 +1414 -314
- package/lib/dependencies/ExportBindingInitFragment.js +0 -191
- package/lib/errors/EntrypointOverlapWarning.js +0 -45
- package/lib/performance/EntrypointOverlapPlugin.js +0 -122
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Alexander Akait @alexander-akait
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency");
|
|
9
|
+
const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
|
|
10
|
+
|
|
11
|
+
/** @import Module from "../Module" */
|
|
12
|
+
/** @import ModuleGraph from "../ModuleGraph" */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Tells whether every module pulling this one in does so by re-exporting it.
|
|
16
|
+
* One an importer wants for its side effects alone is deliberate, not a
|
|
17
|
+
* barrel's leftover.
|
|
18
|
+
* @param {Module} module the module to look up
|
|
19
|
+
* @param {ModuleGraph} moduleGraph the module graph
|
|
20
|
+
* @returns {boolean} true when only re-exports pull it in
|
|
21
|
+
*/
|
|
22
|
+
const isOnlyReexported = (module, moduleGraph) => {
|
|
23
|
+
// A re-export emits a side-effect edge of its own, so edges are grouped by
|
|
24
|
+
// the statement they come from — `sourceOrder` — rather than by their type.
|
|
25
|
+
/** @type {Map<Module, Set<number | undefined>>} */
|
|
26
|
+
const reexportedStatements = new Map();
|
|
27
|
+
/** @type {[Module, number | undefined][]} */
|
|
28
|
+
const edges = [];
|
|
29
|
+
|
|
30
|
+
for (const connection of moduleGraph.getIncomingConnections(module)) {
|
|
31
|
+
const origin = connection.originModule;
|
|
32
|
+
|
|
33
|
+
// An entry has no origin: it is in the build because it was asked for.
|
|
34
|
+
if (!origin) return false;
|
|
35
|
+
|
|
36
|
+
const dependency = connection.dependency;
|
|
37
|
+
|
|
38
|
+
// Only an ESM import statement can carry a re-export.
|
|
39
|
+
if (!(dependency instanceof HarmonyImportDependency)) return false;
|
|
40
|
+
|
|
41
|
+
if (dependency instanceof HarmonyExportImportedSpecifierDependency) {
|
|
42
|
+
const statements = reexportedStatements.get(origin);
|
|
43
|
+
|
|
44
|
+
if (statements === undefined) {
|
|
45
|
+
reexportedStatements.set(origin, new Set([dependency.sourceOrder]));
|
|
46
|
+
} else {
|
|
47
|
+
statements.add(dependency.sourceOrder);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
edges.push([origin, dependency.sourceOrder]);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (edges.length === 0) return false;
|
|
55
|
+
|
|
56
|
+
for (const [origin, sourceOrder] of edges) {
|
|
57
|
+
const statements = reexportedStatements.get(origin);
|
|
58
|
+
|
|
59
|
+
if (statements === undefined || !statements.has(sourceOrder)) return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return true;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
module.exports = isOnlyReexported;
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
const RuntimeModule = require("../RuntimeModule");
|
|
8
8
|
const Template = require("../Template");
|
|
9
|
+
const { getOnlyHandlerKey } = require("../util/handlerKeys");
|
|
10
|
+
const { propertyAccess } = require("../util/property");
|
|
9
11
|
|
|
10
12
|
/** @import Compilation from "../Compilation" */
|
|
11
13
|
|
|
@@ -33,6 +35,17 @@ class ChunkPrefetchFunctionRuntimeModule extends RuntimeModule {
|
|
|
33
35
|
this.runtimeHandlers = runtimeHandlers;
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
/**
|
|
39
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
40
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
41
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
42
|
+
*/
|
|
43
|
+
getInstalledChunkHandlers() {
|
|
44
|
+
// Reads a map rather than installing onto one, so reading its code back would
|
|
45
|
+
// render it in a cycle.
|
|
46
|
+
return RuntimeModule.NO_CHUNK_HANDLERS;
|
|
47
|
+
}
|
|
48
|
+
|
|
36
49
|
/**
|
|
37
50
|
* Generates runtime code for this runtime module.
|
|
38
51
|
* @returns {string | null} runtime code
|
|
@@ -41,17 +54,24 @@ class ChunkPrefetchFunctionRuntimeModule extends RuntimeModule {
|
|
|
41
54
|
const { runtimeFunction, runtimeHandlers } = this;
|
|
42
55
|
const compilation = /** @type {Compilation} */ (this.compilation);
|
|
43
56
|
const { runtimeTemplate } = compilation;
|
|
57
|
+
const only =
|
|
58
|
+
runtimeFunction === null
|
|
59
|
+
? null
|
|
60
|
+
: getOnlyHandlerKey(this, runtimeHandlers);
|
|
44
61
|
return Template.asString([
|
|
45
62
|
`${runtimeHandlers} = {};`,
|
|
46
63
|
...(runtimeFunction === null
|
|
47
64
|
? []
|
|
48
65
|
: [
|
|
49
66
|
`${runtimeFunction} = ${runtimeTemplate.basicFunction("chunkId", [
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
// One handler needs no walk over the others, and most chunks carry one.
|
|
68
|
+
only === null
|
|
69
|
+
? // map is shorter than forEach
|
|
70
|
+
`Object.keys(${runtimeHandlers}).map(${runtimeTemplate.basicFunction(
|
|
71
|
+
"key",
|
|
72
|
+
`${runtimeHandlers}[key](chunkId);`
|
|
73
|
+
)});`
|
|
74
|
+
: `${runtimeHandlers}${propertyAccess([only])}(chunkId);`
|
|
55
75
|
])};`
|
|
56
76
|
])
|
|
57
77
|
]);
|
|
@@ -50,6 +50,8 @@ class ChunkPrefetchPreloadPlugin {
|
|
|
50
50
|
if (startupChildChunks) {
|
|
51
51
|
set.add(RuntimeGlobals.prefetchChunk);
|
|
52
52
|
set.add(RuntimeGlobals.onChunksLoaded);
|
|
53
|
+
// This is the one startup callback that is queued behind a priority.
|
|
54
|
+
set.add(RuntimeGlobals.hasChunkPriority);
|
|
53
55
|
set.add(RuntimeGlobals.exports);
|
|
54
56
|
compilation.addLazyRuntimeModule(
|
|
55
57
|
chunk,
|
|
@@ -21,6 +21,15 @@ class ChunkPrefetchStartupRuntimeModule extends RuntimeModule {
|
|
|
21
21
|
this.startupChunks = startupChunks;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
26
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
27
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
28
|
+
*/
|
|
29
|
+
getInstalledChunkHandlers() {
|
|
30
|
+
return RuntimeModule.NO_CHUNK_HANDLERS;
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
/**
|
|
25
34
|
* Generates runtime code for this runtime module.
|
|
26
35
|
* @returns {string | null} runtime code
|
|
@@ -21,6 +21,15 @@ class ChunkPrefetchTriggerRuntimeModule extends RuntimeModule {
|
|
|
21
21
|
this.chunkMap = chunkMap;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
26
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
27
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
28
|
+
*/
|
|
29
|
+
getInstalledChunkHandlers() {
|
|
30
|
+
return [[RuntimeGlobals.ensureChunkHandlers, "prefetch"]];
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
/**
|
|
25
34
|
* Generates runtime code for this runtime module.
|
|
26
35
|
* @returns {string | null} runtime code
|
|
@@ -24,6 +24,15 @@ class ChunkPreloadTriggerRuntimeModule extends RuntimeModule {
|
|
|
24
24
|
this.handlerKey = handlerKey;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
29
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
30
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
31
|
+
*/
|
|
32
|
+
getInstalledChunkHandlers() {
|
|
33
|
+
return [[RuntimeGlobals.ensureChunkHandlers, this.handlerKey]];
|
|
34
|
+
}
|
|
35
|
+
|
|
27
36
|
/**
|
|
28
37
|
* Generates runtime code for this runtime module.
|
|
29
38
|
* @returns {string | null} runtime code
|
|
@@ -490,8 +490,7 @@ const collectStartupAssetHintLines = (
|
|
|
490
490
|
dep.options.publicPath,
|
|
491
491
|
workerChunk,
|
|
492
492
|
module,
|
|
493
|
-
chunkGraph
|
|
494
|
-
set
|
|
493
|
+
chunkGraph
|
|
495
494
|
);
|
|
496
495
|
// Without one the call site keeps the runtime form, where it wraps its own
|
|
497
496
|
// href — firing the `<link>` here too would emit the call twice.
|
|
@@ -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
|
|
@@ -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,98 @@ 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
|
+
// Track the async body's whole lifetime (evaluating +
|
|
243
|
+
// evaluating-async states) with a dedicated flag — the sync require
|
|
244
|
+
// wrapper clears `module.evaluating` as soon as `.a` returns, so a
|
|
245
|
+
// deferred namespace reaching this module through a cycle relies on
|
|
246
|
+
// `evaluatingAsync` to keep throwing until it is fully evaluated.
|
|
247
|
+
defer ? "module.evaluatingAsync = true;" : "",
|
|
248
|
+
"body(handle, done);",
|
|
249
|
+
`${runtimeTemplate.optionalChaining("queue", "d < 0")} && (queue.d = 0);`
|
|
250
|
+
]
|
|
251
|
+
)};`
|
|
218
252
|
]);
|
|
219
253
|
}
|
|
220
254
|
}
|