@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
package/lib/NormalModule.js
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
const querystring = require("querystring");
|
|
9
9
|
const {
|
|
10
10
|
AsyncSeriesBailHook,
|
|
11
|
+
AsyncSeriesWaterfallHook,
|
|
11
12
|
HookMap,
|
|
12
|
-
SyncHook
|
|
13
|
-
SyncWaterfallHook
|
|
13
|
+
SyncHook
|
|
14
14
|
} = require("tapable");
|
|
15
15
|
const {
|
|
16
16
|
CachedSource,
|
|
@@ -19,6 +19,7 @@ const {
|
|
|
19
19
|
SourceMapSource
|
|
20
20
|
} = require("webpack-sources");
|
|
21
21
|
const Dependency = require("./Dependency");
|
|
22
|
+
const { toError } = require("./ErrorHelpers");
|
|
22
23
|
const Module = require("./Module");
|
|
23
24
|
const ModuleGraphConnection = require("./ModuleGraphConnection");
|
|
24
25
|
const { JAVASCRIPT_MODULE_TYPE_AUTO } = require("./ModuleTypeConstants");
|
|
@@ -33,6 +34,7 @@ const {
|
|
|
33
34
|
const LazySet = require("./util/LazySet");
|
|
34
35
|
const { isSubset } = require("./util/SetHelpers");
|
|
35
36
|
const { getScheme } = require("./util/URLAbsoluteSpecifier");
|
|
37
|
+
const { getBuildDiagnostics } = require("./util/buildDiagnostics");
|
|
36
38
|
const {
|
|
37
39
|
concatComparators,
|
|
38
40
|
keepOriginalOrder,
|
|
@@ -67,10 +69,6 @@ const getUnhandledSchemeError = memoize(() =>
|
|
|
67
69
|
require("./errors/UnhandledSchemeError")
|
|
68
70
|
);
|
|
69
71
|
|
|
70
|
-
const getNonErrorEmittedError = memoize(() =>
|
|
71
|
-
require("./errors/NonErrorEmittedError")
|
|
72
|
-
);
|
|
73
|
-
|
|
74
72
|
const getModuleWarning = memoize(() => require("./errors/ModuleWarning"));
|
|
75
73
|
|
|
76
74
|
const getModuleParseError = memoize(() => require("./errors/ModuleParseError"));
|
|
@@ -79,17 +77,21 @@ const getModuleError = memoize(() => require("./errors/ModuleError"));
|
|
|
79
77
|
|
|
80
78
|
const getModuleBuildError = memoize(() => require("./errors/ModuleBuildError"));
|
|
81
79
|
|
|
82
|
-
/** @import { ResolveContext, ResolveRequest } from "enhanced-resolve" */
|
|
80
|
+
/** @import { ResolveContext, ResolveRequest, Resolver } from "enhanced-resolve" */
|
|
83
81
|
/** @import { Source, RawSourceMap } from "webpack-sources" */
|
|
84
82
|
/**
|
|
85
83
|
* @import {
|
|
86
84
|
* ResolveOptions,
|
|
87
85
|
* NoParse,
|
|
88
|
-
* HashFunction
|
|
86
|
+
* HashFunction,
|
|
87
|
+
* HashDigest,
|
|
88
|
+
* HashDigestLength,
|
|
89
|
+
* HashSalt
|
|
89
90
|
* } from "../declarations/WebpackOptions"
|
|
90
91
|
*/
|
|
91
92
|
/**
|
|
92
93
|
* @import Compilation, {
|
|
94
|
+
* AssetInfo,
|
|
93
95
|
* FileSystemDependencies,
|
|
94
96
|
* UnsafeCacheData
|
|
95
97
|
* } from "./Compilation"
|
|
@@ -136,7 +138,14 @@ const getModuleBuildError = memoize(() => require("./errors/ModuleBuildError"));
|
|
|
136
138
|
*/
|
|
137
139
|
/** @import Parser, { PreparsedAst } from "./Parser" */
|
|
138
140
|
/** @import RequestShortener from "./RequestShortener" */
|
|
139
|
-
/** @import
|
|
141
|
+
/** @import Compiler from "./Compiler" */
|
|
142
|
+
/** @import { Logger } from "./logging/Logger" */
|
|
143
|
+
/**
|
|
144
|
+
* @import {
|
|
145
|
+
* ResolverWithOptions,
|
|
146
|
+
* ResolveOptionsWithDependencyType
|
|
147
|
+
* } from "./ResolverFactory"
|
|
148
|
+
*/
|
|
140
149
|
/**
|
|
141
150
|
* @import {
|
|
142
151
|
* ObjectDeserializerContext,
|
|
@@ -154,14 +163,65 @@ const getModuleBuildError = memoize(() => require("./errors/ModuleBuildError"));
|
|
|
154
163
|
/** @typedef {{ [k: string]: EXPECTED_ANY }} ParserOptions */
|
|
155
164
|
/** @typedef {{ [k: string]: EXPECTED_ANY }} GeneratorOptions */
|
|
156
165
|
|
|
166
|
+
/** @typedef {Parameters<Resolver["resolve"]>[4]} ResolveCallback */
|
|
167
|
+
/** @typedef {Parameters<typeof import("schema-utils").validate>[0]} Schema */
|
|
168
|
+
|
|
157
169
|
/**
|
|
158
|
-
*
|
|
159
|
-
*
|
|
170
|
+
* `getOptions` validates against a schema when given one, and TypeScript reads
|
|
171
|
+
* an intersection of call signatures as an overload set
|
|
172
|
+
* @template OptionsType
|
|
173
|
+
* @typedef {{ (): OptionsType } & { (schema: Schema): OptionsType }} GetOptionsMethod
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @typedef {((context: string, request: string, callback: ResolveCallback) => void) & ((context: string, request: string) => Promise<string>)} DualModeResolve
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* @typedef {object} LoaderContextUtils
|
|
182
|
+
* @property {(context: string, request: string) => string} absolutify returns a new request string using absolute paths when possible
|
|
183
|
+
* @property {(context: string, request: string) => string} contextify returns a new request string avoiding absolute paths when possible
|
|
184
|
+
* @property {(algorithm?: string | typeof Hash) => Hash} createHash creates a hash with the compilation's function
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* These properties are added by the NormalModule
|
|
189
|
+
* @template OptionsType
|
|
190
|
+
* @typedef {object} NormalModuleLoaderContext
|
|
191
|
+
* @property {number} version
|
|
192
|
+
* @property {GetOptionsMethod<OptionsType>} getOptions Extracts and parses the options of the current loader.
|
|
193
|
+
* Parses string options as JSON or a query string.
|
|
194
|
+
* @property {(warning: Error | string) => void} emitWarning Emits a warning for this module.
|
|
195
|
+
* The warning will be displayed to the user during compilation.
|
|
196
|
+
* @property {(error: Error | string) => void} emitError Emits an error for this module.
|
|
197
|
+
* The error will be displayed to the user and typically causes the compilation to fail.
|
|
198
|
+
* @property {(name?: string) => Logger} getLogger Gets a logger instance scoped to this loader and module.
|
|
199
|
+
* Useful for emitting debug or compilation information in a structured way.
|
|
200
|
+
* @property {(context: string, request: string, callback: ResolveCallback) => void} resolve Resolves a module request (e.g., a relative path or module name) to an absolute file path.
|
|
201
|
+
* It uses Webpack's internal resolver, taking into account configured aliases and extensions.
|
|
202
|
+
* @property {(options?: ResolveOptionsWithDependencyType) => DualModeResolve} getResolve Creates a resolve function with specific options.
|
|
203
|
+
* The returned function can be used as a Promise-based resolver or a callback-based resolver.
|
|
204
|
+
* @property {(name: string, content: string | Buffer, sourceMap?: string, assetInfo?: AssetInfo) => void} emitFile Emits a new file (asset) to the compilation output directory.
|
|
205
|
+
* This allows loaders to generate additional files alongside the main module output.
|
|
206
|
+
* @property {(dep: string) => void} addBuildDependency
|
|
207
|
+
* @property {LoaderContextUtils} utils
|
|
208
|
+
* @property {string} rootContext
|
|
209
|
+
* @property {InputFileSystem} fs
|
|
210
|
+
* @property {boolean=} sourceMap
|
|
211
|
+
* @property {"development" | "production" | "none"} mode
|
|
212
|
+
* @property {boolean=} webpack
|
|
213
|
+
* @property {HashFunction} hashFunction
|
|
214
|
+
* @property {HashDigest} hashDigest
|
|
215
|
+
* @property {HashDigestLength} hashDigestLength
|
|
216
|
+
* @property {HashSalt=} hashSalt
|
|
217
|
+
* @property {NormalModule=} _module
|
|
218
|
+
* @property {Compilation=} _compilation
|
|
219
|
+
* @property {Compiler=} _compiler
|
|
160
220
|
*/
|
|
161
221
|
|
|
162
222
|
/**
|
|
163
223
|
* @template T
|
|
164
|
-
* @typedef {import("
|
|
224
|
+
* @typedef {NormalModuleLoaderContext<T> & import("./loaders/LoaderRunner").LoaderRunnerLoaderContext<T> & import("./dependencies/LoaderPlugin").LoaderPluginLoaderContext & import("./HotModuleReplacementPlugin").HotModuleReplacementPluginLoaderContext} LoaderContext
|
|
165
225
|
*/
|
|
166
226
|
|
|
167
227
|
/** @typedef {(content: string) => boolean} NoParseFn */
|
|
@@ -182,7 +242,9 @@ const recordSideEffectsBailout = (mod, moduleGraph, dep) => {
|
|
|
182
242
|
.getOptimizationBailout(mod)
|
|
183
243
|
.push(
|
|
184
244
|
() =>
|
|
185
|
-
`Dependency (${dep.type}) with side effects at ${formatLocation(
|
|
245
|
+
`Dependency (${dep.type}) with side effects at ${formatLocation(
|
|
246
|
+
dep.loc
|
|
247
|
+
)}`
|
|
186
248
|
);
|
|
187
249
|
};
|
|
188
250
|
|
|
@@ -345,10 +407,9 @@ const walkSideEffects = (rootMod, moduleGraph, SideEffectDep) => {
|
|
|
345
407
|
}
|
|
346
408
|
}
|
|
347
409
|
} else {
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
//
|
|
351
|
-
// memoize it.
|
|
410
|
+
// A non-NormalModule resolves through a re-entrant walk that may read
|
|
411
|
+
// our in-progress modules as circular, so this chain is tainted and
|
|
412
|
+
// never memoized.
|
|
352
413
|
state = refModule.getSideEffectsConnectionState(moduleGraph);
|
|
353
414
|
lowOf.set(mod, -1);
|
|
354
415
|
}
|
|
@@ -540,10 +601,12 @@ const createCompilationHooks = () => {
|
|
|
540
601
|
*/
|
|
541
602
|
beforeSnapshot: new SyncHook(["module"]),
|
|
542
603
|
/**
|
|
543
|
-
*
|
|
604
|
+
* Async since 5.111.0, so a tap can await work of its own — minifying an
|
|
605
|
+
* asset, say, which before only a loader could do. `tap` keeps working.
|
|
606
|
+
* @type {AsyncSeriesWaterfallHook<[Result, NormalModule]>}
|
|
544
607
|
* @since 5.99.0
|
|
545
608
|
*/
|
|
546
|
-
processResult: new
|
|
609
|
+
processResult: new AsyncSeriesWaterfallHook(["result", "module"]),
|
|
547
610
|
/**
|
|
548
611
|
* @type {AsyncSeriesBailHook<[NormalModule, NeedBuildContext], boolean>}
|
|
549
612
|
* @since 5.49.0
|
|
@@ -947,7 +1010,7 @@ class NormalModule extends Module {
|
|
|
947
1010
|
* @param {Compilation} compilation the compilation
|
|
948
1011
|
* @param {InputFileSystem} fs file system from reading
|
|
949
1012
|
* @param {NormalModuleCompilationHooks} hooks the hooks
|
|
950
|
-
* @returns {
|
|
1013
|
+
* @returns {LoaderContext<T>} loader context
|
|
951
1014
|
*/
|
|
952
1015
|
_createLoaderContext(resolver, options, compilation, fs, hooks) {
|
|
953
1016
|
const { requestShortener } = compilation.runtimeTemplate;
|
|
@@ -1045,7 +1108,9 @@ class NormalModule extends Module {
|
|
|
1045
1108
|
(parseJson(options));
|
|
1046
1109
|
} catch (err) {
|
|
1047
1110
|
throw new Error(
|
|
1048
|
-
`Cannot parse string options: ${
|
|
1111
|
+
`Cannot parse string options: ${
|
|
1112
|
+
/** @type {Error} */ (err).message
|
|
1113
|
+
}`,
|
|
1049
1114
|
{ cause: err }
|
|
1050
1115
|
);
|
|
1051
1116
|
}
|
|
@@ -1078,22 +1143,16 @@ class NormalModule extends Module {
|
|
|
1078
1143
|
},
|
|
1079
1144
|
/** @type {LoaderContext<EXPECTED_ANY>["emitWarning"]} */
|
|
1080
1145
|
emitWarning: (warning) => {
|
|
1081
|
-
if (!(warning instanceof Error)) {
|
|
1082
|
-
warning = new (getNonErrorEmittedError())(warning);
|
|
1083
|
-
}
|
|
1084
1146
|
this.addWarning(
|
|
1085
|
-
new (getModuleWarning())(warning, {
|
|
1147
|
+
new (getModuleWarning())(toError(warning), {
|
|
1086
1148
|
from: getCurrentLoaderName()
|
|
1087
1149
|
})
|
|
1088
1150
|
);
|
|
1089
1151
|
},
|
|
1090
1152
|
/** @type {LoaderContext<EXPECTED_ANY>["emitError"]} */
|
|
1091
1153
|
emitError: (error) => {
|
|
1092
|
-
if (!(error instanceof Error)) {
|
|
1093
|
-
error = new (getNonErrorEmittedError())(error);
|
|
1094
|
-
}
|
|
1095
1154
|
this.addError(
|
|
1096
|
-
new (getModuleError())(error, {
|
|
1155
|
+
new (getModuleError())(toError(error), {
|
|
1097
1156
|
from: getCurrentLoaderName()
|
|
1098
1157
|
})
|
|
1099
1158
|
);
|
|
@@ -1117,7 +1176,7 @@ class NormalModule extends Module {
|
|
|
1117
1176
|
/** @type {LoaderContext<EXPECTED_ANY>["getResolve"]} */
|
|
1118
1177
|
getResolve(options) {
|
|
1119
1178
|
const child = options ? resolver.withOptions(options) : resolver;
|
|
1120
|
-
return /** @type {ReturnType<
|
|
1179
|
+
return /** @type {ReturnType<NormalModuleLoaderContext<T>["getResolve"]>} */ (
|
|
1121
1180
|
(context, request, callback) => {
|
|
1122
1181
|
if (callback) {
|
|
1123
1182
|
child.resolve(
|
|
@@ -1285,11 +1344,8 @@ class NormalModule extends Module {
|
|
|
1285
1344
|
*/
|
|
1286
1345
|
const processResult = (err, result_) => {
|
|
1287
1346
|
if (err) {
|
|
1288
|
-
if (!(err instanceof Error)) {
|
|
1289
|
-
err = new (getNonErrorEmittedError())(err);
|
|
1290
|
-
}
|
|
1291
1347
|
const currentLoader = this.getCurrentLoader(loaderContext);
|
|
1292
|
-
const error = new (getModuleBuildError())(err, {
|
|
1348
|
+
const error = new (getModuleBuildError())(toError(err), {
|
|
1293
1349
|
from:
|
|
1294
1350
|
currentLoader &&
|
|
1295
1351
|
compilation.runtimeTemplate.requestShortener.shorten(
|
|
@@ -1298,11 +1354,30 @@ class NormalModule extends Module {
|
|
|
1298
1354
|
});
|
|
1299
1355
|
return callback(error);
|
|
1300
1356
|
}
|
|
1301
|
-
|
|
1357
|
+
hooks.processResult.callAsync(
|
|
1302
1358
|
/** @type {Result} */
|
|
1303
1359
|
(result_),
|
|
1304
|
-
this
|
|
1360
|
+
this,
|
|
1361
|
+
(hookErr, hookResult) => {
|
|
1362
|
+
if (hookErr) {
|
|
1363
|
+
// Named, so a tap's failure is not read as a loader's.
|
|
1364
|
+
return callback(
|
|
1365
|
+
new (getModuleBuildError())(toError(hookErr), {
|
|
1366
|
+
from: "processResult hook"
|
|
1367
|
+
})
|
|
1368
|
+
);
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
finishResult(/** @type {Result} */ (hookResult));
|
|
1372
|
+
}
|
|
1305
1373
|
);
|
|
1374
|
+
};
|
|
1375
|
+
|
|
1376
|
+
/**
|
|
1377
|
+
* @param {Result} result the result the hook settled on
|
|
1378
|
+
* @returns {void}
|
|
1379
|
+
*/
|
|
1380
|
+
const finishResult = (result) => {
|
|
1306
1381
|
const source = result[0];
|
|
1307
1382
|
const sourceMap = result.length >= 1 ? result[1] : null;
|
|
1308
1383
|
const extraInfo = result.length >= 2 ? result[2] : null;
|
|
@@ -1434,7 +1509,9 @@ class NormalModule extends Module {
|
|
|
1434
1509
|
})
|
|
1435
1510
|
).catch((err) => {
|
|
1436
1511
|
throw new Error(
|
|
1437
|
-
`Failed to parse source map. ${
|
|
1512
|
+
`Failed to parse source map. ${
|
|
1513
|
+
/** @type {Error} */ (err).message
|
|
1514
|
+
}`
|
|
1438
1515
|
);
|
|
1439
1516
|
})
|
|
1440
1517
|
);
|
|
@@ -1494,7 +1571,8 @@ class NormalModule extends Module {
|
|
|
1494
1571
|
}
|
|
1495
1572
|
buildInfo.cacheable = buildInfo.cacheable && result.cacheable;
|
|
1496
1573
|
if (result.notCacheableReasons.length > 0) {
|
|
1497
|
-
buildInfo.notCacheableReasons =
|
|
1574
|
+
getBuildDiagnostics(buildInfo).notCacheableReasons =
|
|
1575
|
+
result.notCacheableReasons;
|
|
1498
1576
|
}
|
|
1499
1577
|
processResult(err, result.result);
|
|
1500
1578
|
}
|
|
@@ -1502,14 +1580,16 @@ class NormalModule extends Module {
|
|
|
1502
1580
|
}
|
|
1503
1581
|
|
|
1504
1582
|
/**
|
|
1505
|
-
*
|
|
1583
|
+
* Marks the module as failed, so what it generates says so. A tap or a
|
|
1584
|
+
* loader may fail with anything, and what reads the failure expects an error.
|
|
1585
|
+
* @param {EXPECTED_ANY} error what the module failed with
|
|
1506
1586
|
* @returns {void}
|
|
1507
1587
|
*/
|
|
1508
1588
|
markModuleAsErrored(error) {
|
|
1509
1589
|
// Restore build meta from successful build to keep importing state
|
|
1510
1590
|
this.buildMeta = { ...this._lastSuccessfulBuildMeta };
|
|
1511
|
-
this.error = error;
|
|
1512
|
-
this.addError(error);
|
|
1591
|
+
this.error = toError(error);
|
|
1592
|
+
this.addError(this.error);
|
|
1513
1593
|
}
|
|
1514
1594
|
|
|
1515
1595
|
/**
|
|
@@ -1602,7 +1682,6 @@ class NormalModule extends Module {
|
|
|
1602
1682
|
};
|
|
1603
1683
|
this.buildInfo = {
|
|
1604
1684
|
cacheable: false,
|
|
1605
|
-
notCacheableReasons: undefined,
|
|
1606
1685
|
parsed: true,
|
|
1607
1686
|
fileDependencies: undefined,
|
|
1608
1687
|
contextDependencies: undefined,
|
|
@@ -1620,6 +1699,8 @@ class NormalModule extends Module {
|
|
|
1620
1699
|
pureFunctions: undefined,
|
|
1621
1700
|
inlineExports: undefined,
|
|
1622
1701
|
moduleConcatenationBailout: undefined,
|
|
1702
|
+
moduleConcatenationRootBailout: undefined,
|
|
1703
|
+
diagnostics: undefined,
|
|
1623
1704
|
needCreateRequire: undefined,
|
|
1624
1705
|
usesTopLevelUsingDeclaration: undefined
|
|
1625
1706
|
};
|
|
@@ -1675,7 +1756,7 @@ class NormalModule extends Module {
|
|
|
1675
1756
|
try {
|
|
1676
1757
|
hooks.beforeSnapshot.call(this);
|
|
1677
1758
|
} catch (err) {
|
|
1678
|
-
this.markModuleAsErrored(
|
|
1759
|
+
this.markModuleAsErrored(err);
|
|
1679
1760
|
return callback();
|
|
1680
1761
|
}
|
|
1681
1762
|
|
|
@@ -1769,7 +1850,7 @@ class NormalModule extends Module {
|
|
|
1769
1850
|
try {
|
|
1770
1851
|
hooks.beforeParse.call(this);
|
|
1771
1852
|
} catch (err) {
|
|
1772
|
-
this.markModuleAsErrored(
|
|
1853
|
+
this.markModuleAsErrored(err);
|
|
1773
1854
|
this._initBuildHash(compilation);
|
|
1774
1855
|
return callback();
|
|
1775
1856
|
}
|
|
@@ -1917,7 +1998,13 @@ class NormalModule extends Module {
|
|
|
1917
1998
|
getData,
|
|
1918
1999
|
type
|
|
1919
2000
|
})
|
|
1920
|
-
: new RawSource(
|
|
2001
|
+
: new RawSource(
|
|
2002
|
+
getGenerator().throwBuildErrorCode(
|
|
2003
|
+
this.error,
|
|
2004
|
+
undefined,
|
|
2005
|
+
runtimeTemplate.requestShortener
|
|
2006
|
+
)
|
|
2007
|
+
)
|
|
1921
2008
|
: generator.generate(this, {
|
|
1922
2009
|
dependencyTemplates,
|
|
1923
2010
|
runtimeTemplate,
|
|
@@ -2083,10 +2170,8 @@ class NormalModule extends Module {
|
|
|
2083
2170
|
/** @type {string} */
|
|
2084
2171
|
(buildInfo.hash)
|
|
2085
2172
|
);
|
|
2086
|
-
//
|
|
2087
|
-
//
|
|
2088
|
-
// compilation) are reflected in the hash and trigger code generation
|
|
2089
|
-
// cache invalidation.
|
|
2173
|
+
// Recompute the source types, so a change in the incoming connections reaches
|
|
2174
|
+
// the hash and invalidates the code-generation cache.
|
|
2090
2175
|
// https://github.com/webpack/webpack/issues/20800
|
|
2091
2176
|
this._sourceTypes = undefined;
|
|
2092
2177
|
for (const type of this.getSourceTypes()) {
|
|
@@ -2137,7 +2222,7 @@ class NormalModule extends Module {
|
|
|
2137
2222
|
parserOptions: /** @type {EXPECTED_ANY} */ (null),
|
|
2138
2223
|
generator: /** @type {EXPECTED_ANY} */ (null),
|
|
2139
2224
|
generatorOptions: /** @type {EXPECTED_ANY} */ (null),
|
|
2140
|
-
resolveOptions:
|
|
2225
|
+
resolveOptions: undefined,
|
|
2141
2226
|
extractSourceMap: /** @type {EXPECTED_ANY} */ (null)
|
|
2142
2227
|
});
|
|
2143
2228
|
obj.deserialize(context);
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const asyncLib = require("neo-async");
|
|
9
8
|
const {
|
|
10
9
|
AsyncSeriesBailHook,
|
|
11
10
|
AsyncSeriesHook,
|
|
@@ -30,6 +29,7 @@ const RuleSetCompiler = require("./rules/RuleSetCompiler");
|
|
|
30
29
|
const UseEffectRulePlugin = require("./rules/UseEffectRulePlugin");
|
|
31
30
|
const LazySet = require("./util/LazySet");
|
|
32
31
|
const { getScheme } = require("./util/URLAbsoluteSpecifier");
|
|
32
|
+
const asyncLib = require("./util/async");
|
|
33
33
|
const { cachedCleverMerge, cachedSetProperty } = require("./util/cleverMerge");
|
|
34
34
|
const {
|
|
35
35
|
applyCaseCorrections,
|
package/lib/RuntimeGlobals.js
CHANGED
|
@@ -15,13 +15,6 @@ module.exports.amdDefine = "__webpack_require__.amdD";
|
|
|
15
15
|
*/
|
|
16
16
|
module.exports.amdOptions = "__webpack_require__.amdO";
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* analyzable single-chunk `import()` that keeps `ensureChunk` timing and deduplication:
|
|
20
|
-
* resolves immediately for an installed chunk, else runs the literal import and installs it
|
|
21
|
-
* Signature: (chunkId, () => Promise) => Promise
|
|
22
|
-
*/
|
|
23
|
-
module.exports.analyzableChunkImport = "__webpack_require__.ei";
|
|
24
|
-
|
|
25
18
|
/**
|
|
26
19
|
* Creates an async module. The body function must be a async function.
|
|
27
20
|
* "module.exports" will be decorated with an AsyncModulePromise.
|
|
@@ -254,12 +247,28 @@ module.exports.hasCssModules = "has css modules";
|
|
|
254
247
|
*/
|
|
255
248
|
module.exports.hasFetchPriority = "has fetch priority";
|
|
256
249
|
|
|
250
|
+
/**
|
|
251
|
+
* a flag when a deferred startup callback carries a priority
|
|
252
|
+
*/
|
|
253
|
+
module.exports.hasChunkPriority = "has chunk priority";
|
|
254
|
+
|
|
257
255
|
/**
|
|
258
256
|
* the shorthand for Object.prototype.hasOwnProperty
|
|
259
257
|
* using of it decreases the compiled bundle size
|
|
260
258
|
*/
|
|
261
259
|
module.exports.hasOwnProperty = "__webpack_require__.o";
|
|
262
260
|
|
|
261
|
+
/**
|
|
262
|
+
* a flag when a deferred namespace is built from a known export list
|
|
263
|
+
*/
|
|
264
|
+
module.exports.hasSealedDeferredNamespace = "has sealed deferred namespace";
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* a flag when a deferred namespace is synthesized from the module's exports
|
|
268
|
+
*/
|
|
269
|
+
module.exports.hasSynthesizedDeferredNamespace =
|
|
270
|
+
"has synthesized deferred namespace";
|
|
271
|
+
|
|
263
272
|
/**
|
|
264
273
|
* function downloading the update manifest
|
|
265
274
|
*/
|
|
@@ -447,6 +456,11 @@ module.exports.setAnonymousDefaultName = "__webpack_require__.dn";
|
|
|
447
456
|
*/
|
|
448
457
|
module.exports.shareScopeMap = "__webpack_require__.S";
|
|
449
458
|
|
|
459
|
+
/**
|
|
460
|
+
* wrap an exports object in a spec Module Namespace Exotic Object
|
|
461
|
+
*/
|
|
462
|
+
module.exports.specNamespaceObject = "__webpack_require__.ns";
|
|
463
|
+
|
|
450
464
|
/**
|
|
451
465
|
* startup signal from runtime
|
|
452
466
|
* This will be called when the runtime chunk has been loaded.
|
package/lib/RuntimeModule.js
CHANGED
|
@@ -136,22 +136,31 @@ class RuntimeModule extends Module {
|
|
|
136
136
|
updateHash(hash, context) {
|
|
137
137
|
hash.update(this.name);
|
|
138
138
|
hash.update(`${this.stage}`);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
} catch (err) {
|
|
150
|
-
hash.update(/** @type {Error} */ (err).message);
|
|
139
|
+
// A failing `generate()` propagates: hashing its message instead pins the etag
|
|
140
|
+
// of the code generation cache to a constant, which then serves stale code.
|
|
141
|
+
const code =
|
|
142
|
+
this.fullHash || this.dependentHash
|
|
143
|
+
? // Do not use getGeneratedCode here, because i. e. compilation hash might be not
|
|
144
|
+
// ready at this point. We will cache it later instead.
|
|
145
|
+
this.generate()
|
|
146
|
+
: this.getGeneratedCode();
|
|
147
|
+
if (code !== null && code !== undefined) {
|
|
148
|
+
hash.update(code);
|
|
151
149
|
}
|
|
152
150
|
super.updateHash(hash, context);
|
|
153
151
|
}
|
|
154
152
|
|
|
153
|
+
/**
|
|
154
|
+
* The `[handlerMap, key]` pairs this module installs onto a chunk handler map
|
|
155
|
+
* such as `__webpack_require__.f`, or `null` where it cannot name them.
|
|
156
|
+
* @returns {[string, string][] | null} installed chunk handlers (do not mutate)
|
|
157
|
+
*/
|
|
158
|
+
getInstalledChunkHandlers() {
|
|
159
|
+
// Answering `null` rather than "none" keeps a module that never heard of this
|
|
160
|
+
// out of a dispatch that would skip the handler it installs.
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
|
|
155
164
|
/**
|
|
156
165
|
* Returns the source types this module can generate.
|
|
157
166
|
* @returns {SourceTypes} types available (do not mutate)
|
|
@@ -244,6 +253,13 @@ class RuntimeModule extends Module {
|
|
|
244
253
|
}
|
|
245
254
|
}
|
|
246
255
|
|
|
256
|
+
/**
|
|
257
|
+
* The answer a runtime module gives when it installs no chunk handler at all
|
|
258
|
+
*/
|
|
259
|
+
RuntimeModule.NO_CHUNK_HANDLERS =
|
|
260
|
+
/** @type {[string, string][]} */
|
|
261
|
+
([]);
|
|
262
|
+
|
|
247
263
|
/**
|
|
248
264
|
* Runtime modules without any dependencies to other runtime modules
|
|
249
265
|
*/
|
package/lib/RuntimePlugin.js
CHANGED
|
@@ -81,6 +81,9 @@ const getGetWorkletBootstrapRuntimeModule = lazyModule(() =>
|
|
|
81
81
|
const getGlobalRuntimeModule = lazyModule(() =>
|
|
82
82
|
require("./runtime/GlobalRuntimeModule")
|
|
83
83
|
);
|
|
84
|
+
const getSpecNamespaceObjectRuntimeModule = lazyModule(() =>
|
|
85
|
+
require("./runtime/SpecNamespaceObjectRuntimeModule")
|
|
86
|
+
);
|
|
84
87
|
const getHasOwnPropertyRuntimeModule = lazyModule(() =>
|
|
85
88
|
require("./runtime/HasOwnPropertyRuntimeModule")
|
|
86
89
|
);
|
|
@@ -214,6 +217,7 @@ const SIMPLE_TREE_RUNTIME_MODULES = [
|
|
|
214
217
|
getCreateFakeNamespaceObjectRuntimeModule
|
|
215
218
|
],
|
|
216
219
|
[RuntimeGlobals.hasOwnProperty, getHasOwnPropertyRuntimeModule],
|
|
220
|
+
[RuntimeGlobals.specNamespaceObject, getSpecNamespaceObjectRuntimeModule],
|
|
217
221
|
[
|
|
218
222
|
RuntimeGlobals.compatGetDefaultExport,
|
|
219
223
|
getCompatGetDefaultExportRuntimeModule
|
|
@@ -229,7 +233,6 @@ const SIMPLE_TREE_RUNTIME_MODULES = [
|
|
|
229
233
|
[RuntimeGlobals.shareScopeMap, getShareRuntimeModule],
|
|
230
234
|
[RuntimeGlobals.relativeUrl, getRelativeUrlRuntimeModule],
|
|
231
235
|
[RuntimeGlobals.worker, getWorkerRuntimeModule],
|
|
232
|
-
[RuntimeGlobals.onChunksLoaded, getOnChunksLoadedRuntimeModule],
|
|
233
236
|
[RuntimeGlobals.scriptNonce, getNonceRuntimeModule],
|
|
234
237
|
[RuntimeGlobals.toBinary, getToBinaryRuntimeModule]
|
|
235
238
|
];
|
|
@@ -316,6 +319,16 @@ class RuntimePlugin {
|
|
|
316
319
|
return true;
|
|
317
320
|
});
|
|
318
321
|
}
|
|
322
|
+
compilation.hooks.runtimeRequirementInTree
|
|
323
|
+
.for(RuntimeGlobals.onChunksLoaded)
|
|
324
|
+
.tap(PLUGIN_NAME, (chunk, runtimeRequirement) => {
|
|
325
|
+
compilation.addLazyRuntimeModule(
|
|
326
|
+
chunk,
|
|
327
|
+
getOnChunksLoadedRuntimeModule,
|
|
328
|
+
(Ctor) => new Ctor(runtimeRequirement)
|
|
329
|
+
);
|
|
330
|
+
return true;
|
|
331
|
+
});
|
|
319
332
|
compilation.hooks.runtimeRequirementInTree
|
|
320
333
|
.for(RuntimeGlobals.definePropertyGetters)
|
|
321
334
|
.tap(PLUGIN_NAME, (chunk, runtimeRequirement) => {
|
|
@@ -345,10 +358,20 @@ class RuntimePlugin {
|
|
|
345
358
|
const asyncModule = runtimeRequirement.has(
|
|
346
359
|
RuntimeGlobals.asyncModule
|
|
347
360
|
);
|
|
361
|
+
const sealed = runtimeRequirement.has(
|
|
362
|
+
RuntimeGlobals.hasSealedDeferredNamespace
|
|
363
|
+
);
|
|
364
|
+
// An unmarked build keeps both shapes, so a call site that
|
|
365
|
+
// predates the markers still gets the permissive runtime.
|
|
366
|
+
const synthesized =
|
|
367
|
+
!sealed ||
|
|
368
|
+
runtimeRequirement.has(
|
|
369
|
+
RuntimeGlobals.hasSynthesizedDeferredNamespace
|
|
370
|
+
);
|
|
348
371
|
compilation.addLazyRuntimeModule(
|
|
349
372
|
chunk,
|
|
350
373
|
getMakeDeferredNamespaceObjectRuntimeModule,
|
|
351
|
-
(Ctor) => new Ctor(asyncModule)
|
|
374
|
+
(Ctor) => new Ctor(asyncModule, sealed, synthesized)
|
|
352
375
|
);
|
|
353
376
|
return true;
|
|
354
377
|
});
|
|
@@ -402,7 +425,11 @@ class RuntimePlugin {
|
|
|
402
425
|
compilation.addLazyRuntimeModule(
|
|
403
426
|
chunk,
|
|
404
427
|
getAsyncModuleRuntimeModule,
|
|
405
|
-
(Ctor) =>
|
|
428
|
+
(Ctor) =>
|
|
429
|
+
new Ctor(
|
|
430
|
+
experiments.deferImport,
|
|
431
|
+
compilation.outputOptions.strictModuleErrorHandling
|
|
432
|
+
)
|
|
406
433
|
);
|
|
407
434
|
return true;
|
|
408
435
|
});
|