webpack 5.107.1 → 5.108.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/hot/dev-server.js +2 -0
- package/lib/APIPlugin.js +8 -4
- package/lib/CacheFacade.js +7 -0
- package/lib/Chunk.js +4 -0
- package/lib/ChunkGraph.js +30 -9
- package/lib/CircularModulesPlugin.js +190 -0
- package/lib/CleanPlugin.js +2 -1
- package/lib/Compilation.js +396 -65
- package/lib/Compiler.js +52 -14
- package/lib/ConcatenationScope.js +10 -3
- package/lib/ContextExclusionPlugin.js +1 -0
- package/lib/ContextModule.js +92 -47
- package/lib/ContextModuleFactory.js +45 -38
- package/lib/ContextReplacementPlugin.js +4 -0
- package/lib/DefinePlugin.js +89 -15
- package/lib/Dependency.js +111 -7
- package/lib/EntryOptionPlugin.js +39 -2
- package/lib/EntryPlugin.js +2 -0
- package/lib/ExportsInfo.js +314 -73
- package/lib/ExternalModule.js +82 -34
- package/lib/ExternalModuleFactoryPlugin.js +1 -0
- package/lib/ExternalsPlugin.js +1 -0
- package/lib/FileSystemInfo.js +173 -23
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -5
- package/lib/FlagDependencyExportsPlugin.js +23 -0
- package/lib/FlagDependencyUsagePlugin.js +87 -5
- package/lib/FlagEntryExportAsUsedPlugin.js +2 -0
- package/lib/Generator.js +8 -0
- package/lib/HotModuleReplacementPlugin.js +65 -28
- package/lib/IgnorePlugin.js +1 -0
- package/lib/InitFragment.js +5 -0
- package/lib/JavascriptMetaInfoPlugin.js +7 -5
- package/lib/LazyBarrel.js +361 -0
- package/lib/LoaderTargetPlugin.js +1 -0
- package/lib/Module.js +21 -42
- package/lib/ModuleGraph.js +3 -2
- package/lib/ModuleProfile.js +27 -1
- package/lib/ModuleTemplate.js +2 -0
- package/lib/MultiCompiler.js +16 -0
- package/lib/MultiStats.js +1 -0
- package/lib/MultiWatching.js +2 -0
- package/lib/NodeStuffPlugin.js +22 -17
- package/lib/NormalModule.js +557 -77
- package/lib/NormalModuleReplacementPlugin.js +2 -0
- package/lib/PrefetchPlugin.js +2 -0
- package/lib/ProgressPlugin.js +9 -1
- package/lib/ProvidePlugin.js +1 -0
- package/lib/RawModule.js +20 -16
- package/lib/RecordIdsPlugin.js +1 -0
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimePlugin.js +58 -26
- package/lib/RuntimeTemplate.js +278 -21
- package/lib/SelfModuleFactory.js +1 -0
- package/lib/SourceMapDevToolPlugin.js +105 -30
- package/lib/Stats.js +1 -0
- package/lib/Template.js +8 -2
- package/lib/TemplatedPathPlugin.js +473 -131
- package/lib/WarnCaseSensitiveModulesPlugin.js +1 -0
- package/lib/WarnDeprecatedOptionPlugin.js +4 -0
- package/lib/WarnNoModeSetPlugin.js +1 -0
- package/lib/WatchIgnorePlugin.js +1 -0
- package/lib/Watching.js +9 -0
- package/lib/WebpackOptionsApply.js +50 -5
- package/lib/asset/AssetBytesGenerator.js +11 -3
- package/lib/asset/AssetGenerator.js +47 -22
- package/lib/asset/AssetModule.js +47 -0
- package/lib/asset/AssetModulesPlugin.js +14 -14
- package/lib/asset/AssetParser.js +2 -2
- package/lib/asset/AssetSourceGenerator.js +8 -0
- package/lib/asset/RawDataUrlModule.js +12 -13
- package/lib/buildChunkGraph.js +88 -9
- package/lib/bun/BunTargetPlugin.js +48 -0
- package/lib/cache/AddBuildDependenciesPlugin.js +1 -0
- package/lib/cache/AddManagedPathsPlugin.js +3 -0
- package/lib/cache/IdleFileCachePlugin.js +4 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +1 -0
- package/lib/cache/ResolverCachePlugin.js +2 -0
- package/lib/cache/getLazyHashedEtag.js +9 -2
- package/lib/cache/mergeEtags.js +2 -0
- package/lib/cli.js +109 -19
- package/lib/config/browserslistTargetHandler.js +99 -0
- package/lib/config/defaults.js +147 -7
- package/lib/config/defineConfig.js +31 -0
- package/lib/config/normalization.js +5 -0
- package/lib/config/target.js +181 -2
- package/lib/container/ContainerEntryModule.js +15 -14
- package/lib/container/ContainerExposedDependency.js +2 -2
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackDependency.js +5 -7
- package/lib/container/FallbackModule.js +10 -9
- package/lib/container/RemoteModule.js +20 -10
- package/lib/container/RemoteRuntimeModule.js +14 -12
- package/lib/css/CssGenerator.js +353 -327
- package/lib/css/CssInjectStyleRuntimeModule.js +36 -8
- package/lib/css/CssLoadingRuntimeModule.js +118 -47
- package/lib/css/CssModule.js +52 -23
- package/lib/css/CssModulesPlugin.js +107 -124
- package/lib/css/CssParser.js +2759 -2205
- package/lib/css/syntax.js +2859 -0
- package/lib/debug/ProfilingPlugin.js +2 -0
- package/lib/deno/DenoTargetPlugin.js +47 -0
- package/lib/dependencies/AMDDefineDependency.js +22 -17
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +7 -11
- package/lib/dependencies/AMDRequireContextDependency.js +7 -11
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -0
- package/lib/dependencies/AMDRequireDependency.js +24 -20
- package/lib/dependencies/CachedConstDependency.js +3 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +1 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +79 -31
- package/lib/dependencies/CommonJsExportsDependency.js +21 -16
- package/lib/dependencies/CommonJsExportsParserPlugin.js +230 -7
- package/lib/dependencies/CommonJsFullRequireDependency.js +27 -19
- package/lib/dependencies/CommonJsImportsParserPlugin.js +51 -16
- package/lib/dependencies/CommonJsPlugin.js +1 -1
- package/lib/dependencies/CommonJsRequireContextDependency.js +10 -13
- package/lib/dependencies/CommonJsRequireDependency.js +42 -11
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +22 -14
- package/lib/dependencies/ConstDependency.js +16 -11
- package/lib/dependencies/ContextDependency.js +4 -0
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +23 -14
- package/lib/dependencies/CreateRequireParserPlugin.js +1 -0
- package/lib/dependencies/CreateScriptUrlDependency.js +5 -7
- package/lib/dependencies/CriticalDependencyWarning.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +512 -574
- package/lib/dependencies/CssIcssImportDependency.js +9 -9
- package/lib/dependencies/CssIcssSymbolDependency.js +22 -15
- package/lib/dependencies/CssImportDependency.js +25 -1
- package/lib/dependencies/CssUrlDependency.js +23 -14
- package/lib/dependencies/DllEntryDependency.js +9 -13
- package/lib/dependencies/ExportBindingInitFragment.js +164 -0
- package/lib/dependencies/ExportsInfoDependency.js +12 -12
- package/lib/dependencies/ExternalModuleDependency.js +8 -5
- package/lib/dependencies/ExternalModuleInitFragment.js +7 -5
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +13 -10
- package/lib/dependencies/HarmonyAcceptDependency.js +11 -11
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +47 -22
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +28 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +46 -22
- package/lib/dependencies/HarmonyExportExpressionDependency.js +107 -30
- package/lib/dependencies/HarmonyExportHeaderDependency.js +7 -9
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +109 -31
- package/lib/dependencies/HarmonyExportInitFragment.js +22 -20
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +83 -18
- package/lib/dependencies/HarmonyExports.js +4 -1
- package/lib/dependencies/HarmonyImportDependency.js +24 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +110 -74
- package/lib/dependencies/HarmonyImportGuard.js +254 -0
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +18 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +118 -14
- package/lib/dependencies/HarmonyLinkingError.js +1 -0
- package/lib/dependencies/HarmonyModulesPlugin.js +1 -0
- package/lib/dependencies/{HtmlScriptSrcDependency.js → HtmlEntryDependency.js} +267 -154
- package/lib/dependencies/HtmlInlineHtmlDependency.js +107 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +20 -27
- package/lib/dependencies/HtmlInlineStyleDependency.js +62 -11
- package/lib/dependencies/HtmlSourceDependency.js +18 -0
- package/lib/dependencies/ImportContextDependency.js +5 -9
- package/lib/dependencies/ImportDependency.js +44 -2
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +1 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +74 -30
- package/lib/dependencies/ImportParserPlugin.js +19 -0
- package/lib/dependencies/ImportWeakDependency.js +1 -0
- package/lib/dependencies/JsonExportsDependency.js +9 -9
- package/lib/dependencies/LoaderImportDependency.js +1 -0
- package/lib/dependencies/LocalModule.js +11 -12
- package/lib/dependencies/LocalModuleDependency.js +11 -13
- package/lib/dependencies/ModuleDecoratorDependency.js +9 -9
- package/lib/dependencies/ModuleDependency.js +7 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +15 -11
- package/lib/dependencies/ProvidedDependency.js +31 -27
- package/lib/dependencies/PureExpressionDependency.js +7 -9
- package/lib/dependencies/RequireEnsureDependency.js +12 -13
- package/lib/dependencies/RequireHeaderDependency.js +3 -4
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
- package/lib/dependencies/RequireResolveContextDependency.js +7 -11
- package/lib/dependencies/RequireResolveDependency.js +1 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +3 -5
- package/lib/dependencies/RuntimeRequirementsDependency.js +6 -7
- package/lib/dependencies/StaticExportsDependency.js +10 -10
- package/lib/dependencies/SystemPlugin.js +2 -0
- package/lib/dependencies/URLContextDependency.js +5 -7
- package/lib/dependencies/URLDependency.js +14 -16
- package/lib/dependencies/UnsupportedDependency.js +8 -13
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +11 -16
- package/lib/dependencies/WebAssemblyImportDependency.js +14 -16
- package/lib/dependencies/WebpackIsIncludedDependency.js +1 -0
- package/lib/dependencies/WorkerDependency.js +19 -8
- package/lib/dependencies/WorkerPlugin.js +40 -10
- package/lib/dependencies/processExportInfo.js +13 -11
- package/lib/dll/DelegatedModule.js +29 -15
- package/lib/dll/DelegatedModuleFactoryPlugin.js +1 -0
- package/lib/dll/DelegatedPlugin.js +1 -0
- package/lib/dll/DllEntryPlugin.js +3 -0
- package/lib/dll/DllModule.js +3 -2
- package/lib/dll/DllPlugin.js +16 -0
- package/lib/dll/DllReferencePlugin.js +3 -0
- package/lib/dll/LibManifestPlugin.js +1 -0
- package/lib/electron/ElectronTargetPlugin.js +22 -4
- package/lib/errors/ConcurrentCompilationError.js +1 -0
- package/lib/errors/HookWebpackError.js +11 -13
- package/lib/errors/IgnoreErrorModuleFactory.js +1 -0
- package/lib/errors/InvalidDependenciesModuleWarning.js +2 -0
- package/lib/errors/JSONParseError.js +9 -8
- package/lib/errors/ModuleBuildError.js +16 -13
- package/lib/errors/ModuleDependencyError.js +8 -1
- package/lib/errors/ModuleDependencyWarning.js +8 -1
- package/lib/errors/ModuleError.js +5 -11
- package/lib/errors/ModuleHashingError.js +4 -0
- package/lib/errors/ModuleNotFoundError.js +3 -0
- package/lib/errors/ModuleParseError.js +5 -11
- package/lib/errors/ModuleRestoreError.js +2 -0
- package/lib/errors/ModuleStoreError.js +3 -0
- package/lib/errors/ModuleWarning.js +7 -11
- package/lib/errors/NodeStuffInWebError.js +1 -0
- package/lib/errors/NonErrorEmittedError.js +2 -0
- package/lib/errors/UnhandledSchemeError.js +1 -0
- package/lib/esm/ModuleChunkLoadingPlugin.js +0 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +28 -23
- package/lib/hmr/HotModuleReplacement.runtime.js +175 -30
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +7 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +173 -26
- package/lib/hmr/LazyCompilationPlugin.js +134 -6
- package/lib/html/HtmlGenerator.js +292 -50
- package/lib/html/HtmlModule.js +40 -0
- package/lib/html/HtmlModulesPlugin.js +287 -60
- package/lib/html/HtmlParser.js +1108 -1099
- package/lib/html/{walkHtmlTokens.js → syntax.js} +4701 -212
- package/lib/ids/IdHelpers.js +4 -2
- package/lib/index.js +19 -0
- package/lib/javascript/BasicEvaluatedExpression.js +1 -0
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -0
- package/lib/javascript/JavascriptGenerator.js +6 -2
- package/lib/javascript/JavascriptModule.js +54 -0
- package/lib/javascript/JavascriptModulesPlugin.js +257 -102
- package/lib/javascript/JavascriptParser.js +286 -159
- package/lib/json/JsonModule.js +40 -0
- package/lib/json/JsonModulesPlugin.js +7 -0
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AssignLibraryPlugin.js +5 -3
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -0
- package/lib/library/FalseIIFEUmdWarning.js +1 -0
- package/lib/library/ModuleLibraryPlugin.js +54 -29
- package/lib/library/SystemLibraryPlugin.js +3 -3
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +38 -22
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -9
- package/lib/node/RequireChunkLoadingRuntimeModule.js +18 -16
- package/lib/optimize/ConcatenatedModule.js +397 -78
- package/lib/optimize/ConstExportsPlugin.js +211 -0
- package/lib/optimize/InlineExports.js +178 -0
- package/lib/optimize/InnerGraph.js +372 -275
- package/lib/optimize/InnerGraphPlugin.js +196 -99
- package/lib/optimize/ModuleConcatenationPlugin.js +56 -25
- package/lib/optimize/RealContentHashPlugin.js +14 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +234 -64
- package/lib/runtime/AsyncModuleRuntimeModule.js +32 -30
- package/lib/runtime/AutoPublicPathRuntimeModule.js +11 -5
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +1 -1
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +6 -4
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +33 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +82 -3
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +1 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +18 -13
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +39 -26
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -4
- package/lib/runtime/RelativeUrlRuntimeModule.js +3 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -1
- package/lib/runtime/StartupEntrypointRuntimeModule.js +4 -3
- package/lib/runtime/WorkerRuntimeModule.js +33 -0
- package/lib/schemes/HttpUriPlugin.js +3 -2
- package/lib/serialization/AggregateErrorSerializer.js +7 -6
- package/lib/serialization/ArraySerializer.js +4 -8
- package/lib/serialization/BinaryMiddleware.js +538 -468
- package/lib/serialization/DateObjectSerializer.js +2 -2
- package/lib/serialization/ErrorObjectSerializer.js +7 -6
- package/lib/serialization/MapObjectSerializer.js +5 -9
- package/lib/serialization/NullPrototypeObjectSerializer.js +7 -9
- package/lib/serialization/ObjectMiddleware.js +50 -13
- package/lib/serialization/PlainObjectSerializer.js +9 -8
- package/lib/serialization/RegExpObjectSerializer.js +2 -2
- package/lib/serialization/Serializer.js +1 -0
- package/lib/serialization/SetObjectSerializer.js +4 -8
- package/lib/sharing/ConsumeSharedModule.js +6 -7
- package/lib/sharing/ConsumeSharedPlugin.js +1 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +46 -41
- package/lib/sharing/ProvideSharedDependency.js +30 -15
- package/lib/sharing/ProvideSharedModule.js +30 -11
- package/lib/sharing/ProvideSharedPlugin.js +4 -2
- package/lib/sharing/SharePlugin.js +3 -0
- package/lib/sharing/ShareRuntimeModule.js +18 -16
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +4 -6
- package/lib/stats/DefaultStatsPrinterPlugin.js +14 -14
- package/lib/stats/StatsFactory.js +11 -9
- package/lib/stats/StatsPrinter.js +9 -2
- package/lib/url/URLParserPlugin.js +5 -2
- package/lib/util/AsyncQueue.js +10 -0
- package/lib/util/LazyBucketSortedSet.js +5 -0
- package/lib/util/LazySet.js +6 -4
- package/lib/util/LocConverter.js +11 -1
- package/lib/util/Semaphore.js +1 -0
- package/lib/util/SourceProcessor.js +106 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/WeakTupleMap.js +27 -1
- package/lib/util/chainedImports.js +3 -3
- package/lib/util/comparators.js +2 -2
- package/lib/util/concatenate.js +31 -7
- package/lib/util/createHash.js +0 -1
- package/lib/util/deterministicGrouping.js +19 -12
- package/lib/util/extractSourceMap.js +1 -1
- package/lib/util/findGraphRoots.js +2 -0
- package/lib/util/fs.js +16 -6
- package/lib/util/hash/DebugHash.js +1 -0
- package/lib/util/hash/hash-digest.js +24 -15
- package/lib/util/identifier.js +7 -0
- package/lib/util/internalSerializables.js +11 -2
- package/lib/util/magicComment.js +42 -0
- package/lib/util/makeSerializable.js +1 -0
- package/lib/util/nonNumericOnlyHash.js +30 -1
- package/lib/util/property.js +7 -1
- package/lib/util/publicPathPlaceholder.js +64 -0
- package/lib/util/registerExternalSerializer.js +4 -4
- package/lib/wasm-async/AsyncWasmModule.js +77 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -96
- package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +1 -1
- package/lib/wasm-sync/SyncWasmModule.js +39 -0
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +1 -0
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +2 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +10 -0
- package/lib/wasm-sync/WebAssemblyParser.js +7 -3
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +45 -39
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +11 -10
- package/package.json +36 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +212 -3
- package/schemas/plugins/HtmlGeneratorOptions.check.js +1 -1
- package/schemas/plugins/HtmlParserOptions.check.d.ts +7 -0
- package/schemas/plugins/HtmlParserOptions.check.js +6 -0
- package/schemas/plugins/HtmlParserOptions.json +3 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/types.d.ts +1592 -314
- package/lib/css/walkCssTokens.js +0 -2020
- package/lib/util/AppendOnlyStackedSet.js +0 -93
package/lib/NormalModule.js
CHANGED
|
@@ -20,6 +20,7 @@ const {
|
|
|
20
20
|
SourceMapSource
|
|
21
21
|
} = require("webpack-sources");
|
|
22
22
|
const Compilation = require("./Compilation");
|
|
23
|
+
const Dependency = require("./Dependency");
|
|
23
24
|
const Module = require("./Module");
|
|
24
25
|
const ModuleGraphConnection = require("./ModuleGraphConnection");
|
|
25
26
|
const { JAVASCRIPT_MODULE_TYPE_AUTO } = require("./ModuleTypeConstants");
|
|
@@ -35,8 +36,6 @@ const LazySet = require("./util/LazySet");
|
|
|
35
36
|
const { isSubset } = require("./util/SetHelpers");
|
|
36
37
|
const { getScheme } = require("./util/URLAbsoluteSpecifier");
|
|
37
38
|
const {
|
|
38
|
-
compareLocations,
|
|
39
|
-
compareSelect,
|
|
40
39
|
concatComparators,
|
|
41
40
|
keepOriginalOrder,
|
|
42
41
|
sortWithSourceOrder
|
|
@@ -46,6 +45,7 @@ const { createFakeHook } = require("./util/deprecation");
|
|
|
46
45
|
const formatLocation = require("./util/formatLocation");
|
|
47
46
|
const { join } = require("./util/fs");
|
|
48
47
|
const {
|
|
48
|
+
ABSOLUTE_PATH_REGEXP,
|
|
49
49
|
absolutify,
|
|
50
50
|
contextify,
|
|
51
51
|
makePathsRelative
|
|
@@ -61,12 +61,13 @@ const parseJson = require("./util/parseJson");
|
|
|
61
61
|
/** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
|
|
62
62
|
/** @typedef {import("../declarations/WebpackOptions").NoParse} NoParse */
|
|
63
63
|
/** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
64
|
-
/** @typedef {import("./Dependency")} Dependency */
|
|
65
64
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
|
66
65
|
/** @typedef {import("./Generator")} Generator */
|
|
67
66
|
/** @typedef {import("./Generator").GenerateErrorFn} GenerateErrorFn */
|
|
67
|
+
/** @typedef {import("./FileSystemInfo").Snapshot} Snapshot */
|
|
68
68
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
|
69
69
|
/** @typedef {import("./Module").FileSystemDependencies} FileSystemDependencies */
|
|
70
|
+
/** @typedef {import("./Module").ValueCacheVersions} ValueCacheVersions */
|
|
70
71
|
/** @typedef {import("./Module").BuildMeta} BuildMeta */
|
|
71
72
|
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
|
72
73
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
|
@@ -86,7 +87,6 @@ const parseJson = require("./util/parseJson");
|
|
|
86
87
|
/** @typedef {import("./Module").UnsafeCacheData} UnsafeCacheData */
|
|
87
88
|
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
|
88
89
|
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
89
|
-
/** @typedef {Iterator<SideEffectsWalk, ConnectionState, ConnectionState>} SideEffectsWalk */
|
|
90
90
|
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
|
|
91
91
|
/** @typedef {import("./NormalModuleFactory").NormalModuleTypes} NormalModuleTypes */
|
|
92
92
|
/** @typedef {import("./NormalModuleFactory").ParserByType} ParserByType */
|
|
@@ -156,27 +156,407 @@ const recordSideEffectsBailout = (mod, moduleGraph, dep) => {
|
|
|
156
156
|
);
|
|
157
157
|
};
|
|
158
158
|
|
|
159
|
+
// Maximum recursive descent depth before switching to the iterative walker.
|
|
160
|
+
// #20986 reported overflow around 1300 modules in webpack 5.107.0 where each
|
|
161
|
+
// step consumed two stack frames (`NormalModule.getSideEffectsConnectionState`
|
|
162
|
+
// plus `HarmonyImportSideEffectDependency.getModuleEvaluationSideEffectsState`).
|
|
163
|
+
// `walkSideEffectsRecursive` folds the second call into the first and uses
|
|
164
|
+
// one frame per module, so this limit caps the native stack at half the depth
|
|
165
|
+
// where the original code overflowed — well within the safe range across
|
|
166
|
+
// platforms while keeping the common (shallow) case purely recursive.
|
|
167
|
+
const SIDE_EFFECTS_RECURSION_LIMIT = 2000;
|
|
168
|
+
|
|
159
169
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
170
|
+
* Iterative form of the side-effects walker. Used as a fallback once the
|
|
171
|
+
* recursive form reaches `SIDE_EFFECTS_RECURSION_LIMIT` so deep chains
|
|
172
|
+
* (#20986) don't overflow V8's stack. Safe to enter while ancestors set
|
|
173
|
+
* `_isEvaluatingSideEffects` on their own modules — those are treated as
|
|
174
|
+
* `CIRCULAR_CONNECTION` if revisited, matching the original recursive
|
|
175
|
+
* behavior.
|
|
176
|
+
* @param {NormalModule} rootMod the module to walk
|
|
164
177
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
165
|
-
* @
|
|
178
|
+
* @param {SideEffectsWalkContext} ctx per-walk cycle-tracking context
|
|
179
|
+
* @returns {ConnectionState} the side-effects connection state
|
|
166
180
|
*/
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
181
|
+
const walkSideEffectsIterative = (rootMod, moduleGraph, ctx) => {
|
|
182
|
+
const SideEffectDep = getHarmonyImportSideEffectDependency();
|
|
183
|
+
|
|
184
|
+
/** @type {NormalModule[]} */
|
|
185
|
+
const modStack = [rootMod];
|
|
186
|
+
/** @type {Dependency[][]} */
|
|
187
|
+
const depsStack = [rootMod.dependencies];
|
|
188
|
+
const indexStack = [0];
|
|
189
|
+
/** @type {ConnectionState[]} */
|
|
190
|
+
const currentStack = [false];
|
|
191
|
+
rootMod._isEvaluatingSideEffects = true;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Result from a just-popped child frame, to be applied to the new
|
|
195
|
+
* top's current dep. `undefined` means "no pending; advance".
|
|
196
|
+
* @type {ConnectionState | undefined}
|
|
197
|
+
*/
|
|
198
|
+
let pending;
|
|
199
|
+
|
|
200
|
+
while (modStack.length > 0) {
|
|
201
|
+
const top = modStack.length - 1;
|
|
202
|
+
const topMod = modStack[top];
|
|
203
|
+
const deps = depsStack[top];
|
|
204
|
+
let index = indexStack[top];
|
|
205
|
+
let current = currentStack[top];
|
|
206
|
+
|
|
207
|
+
if (pending !== undefined) {
|
|
208
|
+
const state = pending;
|
|
209
|
+
pending = undefined;
|
|
210
|
+
const dep = deps[index];
|
|
211
|
+
|
|
212
|
+
if (state === true) {
|
|
213
|
+
recordSideEffectsBailout(topMod, moduleGraph, dep);
|
|
214
|
+
topMod._isEvaluatingSideEffects = false;
|
|
215
|
+
// `true` is monotonic — safe to memoize regardless of cycle
|
|
216
|
+
// status, matching the direct-bailout branch below.
|
|
217
|
+
topMod._sideEffectsStateGraph = moduleGraph;
|
|
218
|
+
topMod._sideEffectsStateValue = true;
|
|
219
|
+
modStack.pop();
|
|
220
|
+
depsStack.pop();
|
|
221
|
+
indexStack.pop();
|
|
222
|
+
currentStack.pop();
|
|
223
|
+
pending = true;
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (state !== ModuleGraphConnection.CIRCULAR_CONNECTION) {
|
|
227
|
+
current = ModuleGraphConnection.addConnectionStates(current, state);
|
|
228
|
+
}
|
|
229
|
+
index++;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
let descended = false;
|
|
233
|
+
const depCount = deps.length;
|
|
234
|
+
while (index < depCount) {
|
|
235
|
+
const dep = deps[index];
|
|
236
|
+
/** @type {ConnectionState} */
|
|
237
|
+
let state;
|
|
238
|
+
|
|
239
|
+
if (dep instanceof SideEffectDep) {
|
|
240
|
+
const refModule = moduleGraph.getModule(dep);
|
|
241
|
+
if (!refModule) {
|
|
242
|
+
state = true;
|
|
243
|
+
} else if (refModule instanceof NormalModule) {
|
|
244
|
+
// Cache hit
|
|
245
|
+
if (refModule._sideEffectsStateGraph === moduleGraph) {
|
|
246
|
+
state = /** @type {ConnectionState} */ (
|
|
247
|
+
refModule._sideEffectsStateValue
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
// Fast-path checks inlined to avoid the helper call.
|
|
251
|
+
else if (refModule.factoryMeta !== undefined) {
|
|
252
|
+
if (refModule.factoryMeta.sideEffectFree) {
|
|
253
|
+
state = false;
|
|
254
|
+
} else if (refModule.factoryMeta.sideEffectFree === false) {
|
|
255
|
+
state = true;
|
|
256
|
+
} else if (
|
|
257
|
+
!(
|
|
258
|
+
refModule.buildMeta !== undefined &&
|
|
259
|
+
refModule.buildMeta.sideEffectFree
|
|
260
|
+
)
|
|
261
|
+
) {
|
|
262
|
+
state = true;
|
|
263
|
+
} else if (refModule._isEvaluatingSideEffects) {
|
|
264
|
+
ctx.circular = true;
|
|
265
|
+
state = ModuleGraphConnection.CIRCULAR_CONNECTION;
|
|
266
|
+
} else {
|
|
267
|
+
// Descend
|
|
268
|
+
indexStack[top] = index;
|
|
269
|
+
currentStack[top] = current;
|
|
270
|
+
refModule._isEvaluatingSideEffects = true;
|
|
271
|
+
modStack.push(refModule);
|
|
272
|
+
depsStack.push(refModule.dependencies);
|
|
273
|
+
indexStack.push(0);
|
|
274
|
+
currentStack.push(false);
|
|
275
|
+
descended = true;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
} else if (
|
|
279
|
+
!(
|
|
280
|
+
refModule.buildMeta !== undefined &&
|
|
281
|
+
refModule.buildMeta.sideEffectFree
|
|
282
|
+
)
|
|
283
|
+
) {
|
|
284
|
+
state = true;
|
|
285
|
+
} else if (refModule._isEvaluatingSideEffects) {
|
|
286
|
+
ctx.circular = true;
|
|
287
|
+
state = ModuleGraphConnection.CIRCULAR_CONNECTION;
|
|
288
|
+
} else {
|
|
289
|
+
// Descend
|
|
290
|
+
indexStack[top] = index;
|
|
291
|
+
currentStack[top] = current;
|
|
292
|
+
refModule._isEvaluatingSideEffects = true;
|
|
293
|
+
modStack.push(refModule);
|
|
294
|
+
depsStack.push(refModule.dependencies);
|
|
295
|
+
indexStack.push(0);
|
|
296
|
+
currentStack.push(false);
|
|
297
|
+
descended = true;
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
ctx.circular = true;
|
|
302
|
+
state = refModule.getSideEffectsConnectionState(moduleGraph);
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
state = dep.getModuleEvaluationSideEffectsState(moduleGraph);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (state === true) {
|
|
309
|
+
recordSideEffectsBailout(topMod, moduleGraph, dep);
|
|
310
|
+
topMod._isEvaluatingSideEffects = false;
|
|
311
|
+
topMod._sideEffectsStateGraph = moduleGraph;
|
|
312
|
+
topMod._sideEffectsStateValue = true;
|
|
313
|
+
modStack.pop();
|
|
314
|
+
depsStack.pop();
|
|
315
|
+
indexStack.pop();
|
|
316
|
+
currentStack.pop();
|
|
317
|
+
pending = true;
|
|
318
|
+
descended = true;
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
if (state !== ModuleGraphConnection.CIRCULAR_CONNECTION) {
|
|
322
|
+
current = ModuleGraphConnection.addConnectionStates(current, state);
|
|
323
|
+
}
|
|
324
|
+
index++;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (descended) continue;
|
|
328
|
+
|
|
329
|
+
topMod._isEvaluatingSideEffects = false;
|
|
330
|
+
if (!ctx.circular) {
|
|
331
|
+
topMod._sideEffectsStateGraph = moduleGraph;
|
|
332
|
+
topMod._sideEffectsStateValue = current;
|
|
333
|
+
}
|
|
334
|
+
pending = current;
|
|
335
|
+
modStack.pop();
|
|
336
|
+
depsStack.pop();
|
|
337
|
+
indexStack.pop();
|
|
338
|
+
currentStack.pop();
|
|
171
339
|
}
|
|
172
|
-
|
|
173
|
-
|
|
340
|
+
|
|
341
|
+
return /** @type {ConnectionState} */ (pending);
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* @typedef {object} SideEffectsWalkContext
|
|
346
|
+
* @property {boolean} circular whether a cycle was seen anywhere in this walk
|
|
347
|
+
*/
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Walks back up a stack of linear-chain ancestors, applying the result
|
|
351
|
+
* `state` of the chain's tail to each ancestor. Each ancestor in the
|
|
352
|
+
* stack had exactly one `HarmonyImportSideEffectDependency` returning
|
|
353
|
+
* `state`, so its result is just `state` (with the usual aggregation
|
|
354
|
+
* rules) and we can avoid building per-frame `current` accumulators.
|
|
355
|
+
* @param {(NormalModule | Dependency)[] | null} ancestors interleaved stack of `[mod, sideEffectDep, mod, sideEffectDep, …]` in descent order; `null` if there were none
|
|
356
|
+
* @param {ConnectionState} state result from the chain's tail
|
|
357
|
+
* @param {ModuleGraph} moduleGraph the module graph
|
|
358
|
+
* @param {SideEffectsWalkContext} ctx per-walk cycle-tracking context
|
|
359
|
+
* @returns {ConnectionState} the root ancestor's result
|
|
360
|
+
*/
|
|
361
|
+
const propagateLinearResult = (ancestors, state, moduleGraph, ctx) => {
|
|
362
|
+
if (ancestors === null) return state;
|
|
363
|
+
while (ancestors.length > 0) {
|
|
364
|
+
const dep = /** @type {Dependency} */ (ancestors.pop());
|
|
365
|
+
const ancestor = /** @type {NormalModule} */ (ancestors.pop());
|
|
366
|
+
ancestor._isEvaluatingSideEffects = false;
|
|
367
|
+
|
|
368
|
+
if (state === true) {
|
|
369
|
+
recordSideEffectsBailout(ancestor, moduleGraph, dep);
|
|
370
|
+
// `true` is monotonic — safe to cache regardless of cycle status.
|
|
371
|
+
ancestor._sideEffectsStateGraph = moduleGraph;
|
|
372
|
+
ancestor._sideEffectsStateValue = true;
|
|
373
|
+
} else if (state === ModuleGraphConnection.CIRCULAR_CONNECTION) {
|
|
374
|
+
// CIRCULAR_CONNECTION is filtered before folding into `current`,
|
|
375
|
+
// so the ancestor's `current` stays at its initial `false`. From
|
|
376
|
+
// this point upward the propagated state is `false`, and the
|
|
377
|
+
// cycle taint prevents memoization further up (handled by
|
|
378
|
+
// `ctx.circular`).
|
|
379
|
+
state = false;
|
|
380
|
+
} else if (!ctx.circular) {
|
|
381
|
+
ancestor._sideEffectsStateGraph = moduleGraph;
|
|
382
|
+
ancestor._sideEffectsStateValue = state;
|
|
383
|
+
}
|
|
174
384
|
}
|
|
175
|
-
|
|
176
|
-
|
|
385
|
+
return state;
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Recursive form of the side-effects walker. Folds the descent through
|
|
390
|
+
* `HarmonyImportSideEffectDependency.getModuleEvaluationSideEffectsState`
|
|
391
|
+
* directly into the loop so each module costs only one V8 stack frame
|
|
392
|
+
* (vs. two in the original recursive code).
|
|
393
|
+
*
|
|
394
|
+
* Linear-chain heads (modules with exactly one
|
|
395
|
+
* `HarmonyImportSideEffectDependency` to another `NormalModule`) are
|
|
396
|
+
* walked iteratively inside the function via an explicit
|
|
397
|
+
* `linearAncestors` stack — no additional V8 frame per descent — and
|
|
398
|
+
* their results are propagated back up by `propagateLinearResult`. This
|
|
399
|
+
* keeps stack consumption at O(1) for the common deep-import-chain
|
|
400
|
+
* pattern that motivated #20986 and also avoids the heavier iterative
|
|
401
|
+
* fallback.
|
|
402
|
+
*
|
|
403
|
+
* Falls back to `walkSideEffectsIterative` only when a *non-linear*
|
|
404
|
+
* walk reaches `SIDE_EFFECTS_RECURSION_LIMIT` — i.e. a deep tree, where
|
|
405
|
+
* each level genuinely needs its own recursion frame.
|
|
406
|
+
*
|
|
407
|
+
* Caches the result on the module when the walk did not encounter a
|
|
408
|
+
* cycle, so subsequent queries (e.g. repeated lookups during
|
|
409
|
+
* `SideEffectsFlagPlugin`'s incoming-connection optimization and its
|
|
410
|
+
* `exportInfo.getTarget` callbacks) return in O(1).
|
|
411
|
+
* @param {NormalModule} mod the module being walked
|
|
412
|
+
* @param {ModuleGraph} moduleGraph the module graph
|
|
413
|
+
* @param {number} depth current recursion depth (only counts true V8 frames)
|
|
414
|
+
* @param {EXPECTED_ANY} SideEffectDep `HarmonyImportSideEffectDependency` constructor, resolved once at the public entry to avoid repeated `require` lookups in the recursive call
|
|
415
|
+
* @param {SideEffectsWalkContext} ctx per-walk cycle-tracking context
|
|
416
|
+
* @returns {ConnectionState} the side-effects connection state
|
|
417
|
+
*/
|
|
418
|
+
const walkSideEffectsRecursive = (
|
|
419
|
+
mod,
|
|
420
|
+
moduleGraph,
|
|
421
|
+
depth,
|
|
422
|
+
SideEffectDep,
|
|
423
|
+
ctx
|
|
424
|
+
) => {
|
|
425
|
+
// Interleaved `[mod, linearDep, mod, linearDep, …]` for the linear
|
|
426
|
+
// chain head; `null` until the first descent.
|
|
427
|
+
/** @type {(NormalModule | Dependency)[] | null} */
|
|
428
|
+
let linearAncestors = null;
|
|
429
|
+
|
|
430
|
+
// Walk the linear-chain head iteratively. Every loop iteration peels
|
|
431
|
+
// off one module without consuming a V8 stack frame.
|
|
432
|
+
while (true) {
|
|
433
|
+
if (mod._sideEffectsStateGraph === moduleGraph) {
|
|
434
|
+
return propagateLinearResult(
|
|
435
|
+
linearAncestors,
|
|
436
|
+
/** @type {ConnectionState} */ (mod._sideEffectsStateValue),
|
|
437
|
+
moduleGraph,
|
|
438
|
+
ctx
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (mod.factoryMeta !== undefined) {
|
|
443
|
+
if (mod.factoryMeta.sideEffectFree) {
|
|
444
|
+
return propagateLinearResult(linearAncestors, false, moduleGraph, ctx);
|
|
445
|
+
}
|
|
446
|
+
if (mod.factoryMeta.sideEffectFree === false) {
|
|
447
|
+
return propagateLinearResult(linearAncestors, true, moduleGraph, ctx);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (!(mod.buildMeta !== undefined && mod.buildMeta.sideEffectFree)) {
|
|
451
|
+
return propagateLinearResult(linearAncestors, true, moduleGraph, ctx);
|
|
452
|
+
}
|
|
453
|
+
if (mod._isEvaluatingSideEffects) {
|
|
454
|
+
ctx.circular = true;
|
|
455
|
+
return propagateLinearResult(
|
|
456
|
+
linearAncestors,
|
|
457
|
+
ModuleGraphConnection.CIRCULAR_CONNECTION,
|
|
458
|
+
moduleGraph,
|
|
459
|
+
ctx
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// A real ESM module's `dependencies` typically include one
|
|
464
|
+
// `HarmonyImportSideEffectDependency` plus several non-recursive deps
|
|
465
|
+
// (export specifiers, const dependencies, …) that report
|
|
466
|
+
// `false`/`CIRCULAR_CONNECTION` from
|
|
467
|
+
// `getModuleEvaluationSideEffectsState`. Walk the deps in order
|
|
468
|
+
// here: as long as at most one is a `SideEffectDep` and no
|
|
469
|
+
// non-recursive dep triggers a bailout or contributes a non-`false`
|
|
470
|
+
// state, we can still tail-call iteratively through that one
|
|
471
|
+
// `SideEffectDep` — no V8 frame needed. This is what keeps the
|
|
472
|
+
// 1300-module cyclic chain from #20986 from overflowing V8's stack
|
|
473
|
+
// even though each generated module has multiple `dependencies`.
|
|
474
|
+
const deps = mod.dependencies;
|
|
475
|
+
/** @type {Dependency | null} */
|
|
476
|
+
let linearDep = null;
|
|
477
|
+
/** @type {ConnectionState} */
|
|
478
|
+
let nonRecursiveCurrent = false;
|
|
479
|
+
let linearOk = true;
|
|
480
|
+
for (let i = 0; i < deps.length; i++) {
|
|
481
|
+
const dep = deps[i];
|
|
482
|
+
if (dep instanceof SideEffectDep) {
|
|
483
|
+
if (linearDep !== null) {
|
|
484
|
+
// Two `SideEffectDep`s in the same module — fall back to
|
|
485
|
+
// the general walk so each can recurse normally.
|
|
486
|
+
linearOk = false;
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
linearDep = dep;
|
|
490
|
+
} else {
|
|
491
|
+
const state = dep.getModuleEvaluationSideEffectsState(moduleGraph);
|
|
492
|
+
if (state === true) {
|
|
493
|
+
recordSideEffectsBailout(mod, moduleGraph, dep);
|
|
494
|
+
mod._sideEffectsStateGraph = moduleGraph;
|
|
495
|
+
mod._sideEffectsStateValue = true;
|
|
496
|
+
return propagateLinearResult(linearAncestors, true, moduleGraph, ctx);
|
|
497
|
+
}
|
|
498
|
+
if (state !== ModuleGraphConnection.CIRCULAR_CONNECTION) {
|
|
499
|
+
nonRecursiveCurrent = ModuleGraphConnection.addConnectionStates(
|
|
500
|
+
nonRecursiveCurrent,
|
|
501
|
+
state
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (!linearOk || nonRecursiveCurrent !== false) {
|
|
508
|
+
// Multiple `SideEffectDep`s, or a non-recursive dep contributed
|
|
509
|
+
// a non-`false` state (e.g. `TRANSITIVE_ONLY`). The linear
|
|
510
|
+
// propagation rule "ancestor's current = chain state" no longer
|
|
511
|
+
// holds, so fall back to the general walk.
|
|
512
|
+
break;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if (linearDep === null) {
|
|
516
|
+
// No `SideEffectDep` — the module is a leaf as far as the
|
|
517
|
+
// side-effects graph is concerned. Cache and propagate `false`.
|
|
518
|
+
if (!ctx.circular) {
|
|
519
|
+
mod._sideEffectsStateGraph = moduleGraph;
|
|
520
|
+
mod._sideEffectsStateValue = false;
|
|
521
|
+
}
|
|
522
|
+
return propagateLinearResult(linearAncestors, false, moduleGraph, ctx);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const refModule = moduleGraph.getModule(linearDep);
|
|
526
|
+
if (!refModule) {
|
|
527
|
+
recordSideEffectsBailout(mod, moduleGraph, linearDep);
|
|
528
|
+
mod._sideEffectsStateGraph = moduleGraph;
|
|
529
|
+
mod._sideEffectsStateValue = true;
|
|
530
|
+
return propagateLinearResult(linearAncestors, true, moduleGraph, ctx);
|
|
531
|
+
}
|
|
532
|
+
if (!(refModule instanceof NormalModule)) {
|
|
533
|
+
// Non-NormalModule's `getSideEffectsConnectionState` re-enters
|
|
534
|
+
// the public method; defer to the general walk for safety.
|
|
535
|
+
break;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
mod._isEvaluatingSideEffects = true;
|
|
539
|
+
if (linearAncestors === null) linearAncestors = [];
|
|
540
|
+
// Push (mod, linearDep) so `propagateLinearResult` records bailouts
|
|
541
|
+
// against the actual `SideEffectDep` that triggered the descent —
|
|
542
|
+
// which may not be `dependencies[0]` when the module also has
|
|
543
|
+
// export / const dependencies.
|
|
544
|
+
linearAncestors.push(mod, linearDep);
|
|
545
|
+
mod = refModule;
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// Non-linear walk. Each genuine recursive call costs one V8 frame, so
|
|
550
|
+
// honour the depth limit here.
|
|
551
|
+
if (depth >= SIDE_EFFECTS_RECURSION_LIMIT) {
|
|
552
|
+
return propagateLinearResult(
|
|
553
|
+
linearAncestors,
|
|
554
|
+
walkSideEffectsIterative(mod, moduleGraph, ctx),
|
|
555
|
+
moduleGraph,
|
|
556
|
+
ctx
|
|
557
|
+
);
|
|
177
558
|
}
|
|
178
559
|
|
|
179
|
-
const SideEffectDep = getHarmonyImportSideEffectDependency();
|
|
180
560
|
mod._isEvaluatingSideEffects = true;
|
|
181
561
|
/** @type {ConnectionState} */
|
|
182
562
|
let current = false;
|
|
@@ -189,8 +569,22 @@ function* walkSideEffects(mod, moduleGraph) {
|
|
|
189
569
|
if (!refModule) {
|
|
190
570
|
state = true;
|
|
191
571
|
} else if (refModule instanceof NormalModule) {
|
|
192
|
-
state =
|
|
572
|
+
state = walkSideEffectsRecursive(
|
|
573
|
+
refModule,
|
|
574
|
+
moduleGraph,
|
|
575
|
+
depth + 1,
|
|
576
|
+
SideEffectDep,
|
|
577
|
+
ctx
|
|
578
|
+
);
|
|
193
579
|
} else {
|
|
580
|
+
// Non-NormalModule's `getSideEffectsConnectionState` (notably
|
|
581
|
+
// `ConcatenatedModule` delegating to its root) re-enters the
|
|
582
|
+
// public method and may walk through modules that the outer
|
|
583
|
+
// walk has marked as evaluating. We can't observe whether
|
|
584
|
+
// the inner walk hit a cycle that reflected the outer's
|
|
585
|
+
// state, so treat the walk as cycle-tainted and skip the
|
|
586
|
+
// cache for safety.
|
|
587
|
+
ctx.circular = true;
|
|
194
588
|
state = refModule.getSideEffectsConnectionState(moduleGraph);
|
|
195
589
|
}
|
|
196
590
|
} else {
|
|
@@ -200,7 +594,12 @@ function* walkSideEffects(mod, moduleGraph) {
|
|
|
200
594
|
if (state === true) {
|
|
201
595
|
recordSideEffectsBailout(mod, moduleGraph, dep);
|
|
202
596
|
mod._isEvaluatingSideEffects = false;
|
|
203
|
-
|
|
597
|
+
// `true` is monotonic — once any dep declares side effects, the
|
|
598
|
+
// answer is `true` regardless of how cycles resolve, so it's
|
|
599
|
+
// always safe to memoize.
|
|
600
|
+
mod._sideEffectsStateGraph = moduleGraph;
|
|
601
|
+
mod._sideEffectsStateValue = true;
|
|
602
|
+
return propagateLinearResult(linearAncestors, true, moduleGraph, ctx);
|
|
204
603
|
}
|
|
205
604
|
if (state !== ModuleGraphConnection.CIRCULAR_CONNECTION) {
|
|
206
605
|
current = ModuleGraphConnection.addConnectionStates(current, state);
|
|
@@ -208,12 +607,19 @@ function* walkSideEffects(mod, moduleGraph) {
|
|
|
208
607
|
}
|
|
209
608
|
|
|
210
609
|
mod._isEvaluatingSideEffects = false;
|
|
211
|
-
// When caching is implemented here, make sure to not cache when
|
|
212
|
-
// at least one circular connection was folded into `current`.
|
|
213
|
-
return current;
|
|
214
|
-
}
|
|
215
610
|
|
|
216
|
-
|
|
611
|
+
// Only memoize when no cycle has been observed anywhere in the walk
|
|
612
|
+
// since the public entry. A cycle anywhere can affect any ancestor's
|
|
613
|
+
// result (the back-edge target's contribution is hidden by
|
|
614
|
+
// CIRCULAR_CONNECTION short-circuiting), so this single flag is the
|
|
615
|
+
// conservative-but-cheap approximation of "this subtree's result is
|
|
616
|
+
// independent of cycle context". The public entry resets the flag.
|
|
617
|
+
if (!ctx.circular) {
|
|
618
|
+
mod._sideEffectsStateGraph = moduleGraph;
|
|
619
|
+
mod._sideEffectsStateValue = current;
|
|
620
|
+
}
|
|
621
|
+
return propagateLinearResult(linearAncestors, current, moduleGraph, ctx);
|
|
622
|
+
};
|
|
217
623
|
|
|
218
624
|
/**
|
|
219
625
|
* @typedef {object} LoaderItem
|
|
@@ -340,6 +746,22 @@ const asBuffer = (input) => {
|
|
|
340
746
|
* @typedef {(resourcePath: string, getLoaderContext: (resourcePath: string) => AnyLoaderContext) => Promise<string | Buffer<ArrayBufferLike>>} ReadResource
|
|
341
747
|
*/
|
|
342
748
|
|
|
749
|
+
/**
|
|
750
|
+
* Defines the build info properties of normal modules (filesystem-backed, loader-processed).
|
|
751
|
+
* @typedef {object} KnownNormalModuleBuildInfo
|
|
752
|
+
* @property {boolean=} parsed
|
|
753
|
+
* @property {string=} hash
|
|
754
|
+
* @property {FileSystemDependencies=} fileDependencies
|
|
755
|
+
* @property {FileSystemDependencies=} contextDependencies
|
|
756
|
+
* @property {FileSystemDependencies=} missingDependencies
|
|
757
|
+
* @property {FileSystemDependencies=} buildDependencies
|
|
758
|
+
* @property {ValueCacheVersions=} valueDependencies
|
|
759
|
+
* @property {(Snapshot | null)=} snapshot
|
|
760
|
+
* @property {string=} resourceIntegrity using in HttpUriPlugin
|
|
761
|
+
*/
|
|
762
|
+
|
|
763
|
+
/** @typedef {BuildInfo & KnownNormalModuleBuildInfo} NormalModuleBuildInfo */
|
|
764
|
+
|
|
343
765
|
/** @type {WeakMap<Compilation, NormalModuleCompilationHooks>} */
|
|
344
766
|
const compilationHooksMap = new WeakMap();
|
|
345
767
|
|
|
@@ -463,7 +885,14 @@ class NormalModule extends Module {
|
|
|
463
885
|
/** @type {NormalModuleCreateData['extractSourceMap']} */
|
|
464
886
|
this.extractSourceMap = extractSourceMap;
|
|
465
887
|
|
|
888
|
+
// Set by HotModuleReplacementPlugin via NormalModuleFactory's `module` hook
|
|
889
|
+
/** @type {boolean} */
|
|
890
|
+
this.hot = false;
|
|
891
|
+
|
|
466
892
|
// Info from Build
|
|
893
|
+
// Redeclared with the normal module specific shape (see KnownNormalModuleBuildInfo)
|
|
894
|
+
/** @type {NormalModuleBuildInfo | undefined} */
|
|
895
|
+
this.buildInfo = undefined;
|
|
467
896
|
/** @type {Error | null} */
|
|
468
897
|
this.error = null;
|
|
469
898
|
/**
|
|
@@ -500,6 +929,18 @@ class NormalModule extends Module {
|
|
|
500
929
|
* @type {WeakSet<ModuleGraph> | undefined}
|
|
501
930
|
*/
|
|
502
931
|
this._addedSideEffectsBailout = undefined;
|
|
932
|
+
/**
|
|
933
|
+
* Memoizes the result of `getSideEffectsConnectionState`. The
|
|
934
|
+
* graph slot keys the cached value to the `ModuleGraph` it was
|
|
935
|
+
* computed against so stale values never leak across compilations
|
|
936
|
+
* — a walk that targets a different graph just overwrites both
|
|
937
|
+
* slots. Populated only for results computed without encountering
|
|
938
|
+
* a circular connection (see `walkSideEffectsRecursive`).
|
|
939
|
+
* @type {ModuleGraph | undefined}
|
|
940
|
+
*/
|
|
941
|
+
this._sideEffectsStateGraph = undefined;
|
|
942
|
+
/** @type {ConnectionState | undefined} */
|
|
943
|
+
this._sideEffectsStateValue = undefined;
|
|
503
944
|
/**
|
|
504
945
|
* @private
|
|
505
946
|
* @type {CodeGenerationResultData}
|
|
@@ -607,6 +1048,11 @@ class NormalModule extends Module {
|
|
|
607
1048
|
this.parserOptions = undefined;
|
|
608
1049
|
this.generator = undefined;
|
|
609
1050
|
this.generatorOptions = undefined;
|
|
1051
|
+
// Drop the side-effects memoization so a long-lived module doesn't
|
|
1052
|
+
// strong-reference a stale `ModuleGraph`/`Compilation` for graphs
|
|
1053
|
+
// that never get re-queried with a fresh one.
|
|
1054
|
+
this._sideEffectsStateGraph = undefined;
|
|
1055
|
+
this._sideEffectsStateValue = undefined;
|
|
610
1056
|
}
|
|
611
1057
|
|
|
612
1058
|
/**
|
|
@@ -779,11 +1225,8 @@ class NormalModule extends Module {
|
|
|
779
1225
|
/** @type {NormalModuleLoaderContext<T>} */
|
|
780
1226
|
const loaderContext = {
|
|
781
1227
|
version: 2,
|
|
782
|
-
/**
|
|
783
|
-
|
|
784
|
-
* @returns {T} options
|
|
785
|
-
*/
|
|
786
|
-
getOptions: (schema) => {
|
|
1228
|
+
/** @type {LoaderContext<EXPECTED_ANY>["getOptions"]} */
|
|
1229
|
+
getOptions: (/** @type {EXPECTED_ANY} */ schema = undefined) => {
|
|
787
1230
|
const loader = this.getCurrentLoader(
|
|
788
1231
|
/** @type {AnyLoaderContext} */
|
|
789
1232
|
(loaderContext)
|
|
@@ -830,6 +1273,7 @@ class NormalModule extends Module {
|
|
|
830
1273
|
|
|
831
1274
|
return /** @type {T} */ (options);
|
|
832
1275
|
},
|
|
1276
|
+
/** @type {LoaderContext<EXPECTED_ANY>["emitWarning"]} */
|
|
833
1277
|
emitWarning: (warning) => {
|
|
834
1278
|
if (!(warning instanceof Error)) {
|
|
835
1279
|
warning = new NonErrorEmittedError(warning);
|
|
@@ -840,6 +1284,7 @@ class NormalModule extends Module {
|
|
|
840
1284
|
})
|
|
841
1285
|
);
|
|
842
1286
|
},
|
|
1287
|
+
/** @type {LoaderContext<EXPECTED_ANY>["emitError"]} */
|
|
843
1288
|
emitError: (error) => {
|
|
844
1289
|
if (!(error instanceof Error)) {
|
|
845
1290
|
error = new NonErrorEmittedError(error);
|
|
@@ -850,6 +1295,7 @@ class NormalModule extends Module {
|
|
|
850
1295
|
})
|
|
851
1296
|
);
|
|
852
1297
|
},
|
|
1298
|
+
/** @type {LoaderContext<EXPECTED_ANY>["getLogger"]} */
|
|
853
1299
|
getLogger: (name) => {
|
|
854
1300
|
const currentLoader = this.getCurrentLoader(
|
|
855
1301
|
/** @type {AnyLoaderContext} */
|
|
@@ -861,9 +1307,11 @@ class NormalModule extends Module {
|
|
|
861
1307
|
.join("|")
|
|
862
1308
|
);
|
|
863
1309
|
},
|
|
1310
|
+
/** @type {LoaderContext<EXPECTED_ANY>["resolve"]} */
|
|
864
1311
|
resolve(context, request, callback) {
|
|
865
1312
|
resolver.resolve({}, context, request, getResolveContext(), callback);
|
|
866
1313
|
},
|
|
1314
|
+
/** @type {LoaderContext<EXPECTED_ANY>["getResolve"]} */
|
|
867
1315
|
getResolve(options) {
|
|
868
1316
|
const child = options ? resolver.withOptions(options) : resolver;
|
|
869
1317
|
return /** @type {ReturnType<import("../declarations/LoaderContext").NormalModuleLoaderContext<T>["getResolve"]>} */ (
|
|
@@ -893,8 +1341,9 @@ class NormalModule extends Module {
|
|
|
893
1341
|
}
|
|
894
1342
|
);
|
|
895
1343
|
},
|
|
1344
|
+
/** @type {LoaderContext<EXPECTED_ANY>["emitFile"]} */
|
|
896
1345
|
emitFile: (name, content, sourceMap, assetInfo) => {
|
|
897
|
-
const buildInfo = /** @type {
|
|
1346
|
+
const buildInfo = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
898
1347
|
|
|
899
1348
|
if (!buildInfo.assets) {
|
|
900
1349
|
buildInfo.assets = Object.create(null);
|
|
@@ -918,7 +1367,7 @@ class NormalModule extends Module {
|
|
|
918
1367
|
assetsInfo.set(name, assetInfo);
|
|
919
1368
|
},
|
|
920
1369
|
addBuildDependency: (dep) => {
|
|
921
|
-
const buildInfo = /** @type {
|
|
1370
|
+
const buildInfo = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
922
1371
|
|
|
923
1372
|
if (buildInfo.buildDependencies === undefined) {
|
|
924
1373
|
buildInfo.buildDependencies = new LazySet();
|
|
@@ -1091,7 +1540,7 @@ class NormalModule extends Module {
|
|
|
1091
1540
|
return callback();
|
|
1092
1541
|
};
|
|
1093
1542
|
|
|
1094
|
-
const buildInfo = /** @type {
|
|
1543
|
+
const buildInfo = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
1095
1544
|
|
|
1096
1545
|
buildInfo.fileDependencies = new LazySet();
|
|
1097
1546
|
buildInfo.contextDependencies = new LazySet();
|
|
@@ -1111,7 +1560,7 @@ class NormalModule extends Module {
|
|
|
1111
1560
|
}
|
|
1112
1561
|
|
|
1113
1562
|
if (this.loaders.length > 0) {
|
|
1114
|
-
/** @type {
|
|
1563
|
+
/** @type {NormalModuleBuildInfo} */
|
|
1115
1564
|
(this.buildInfo).buildDependencies = new LazySet();
|
|
1116
1565
|
}
|
|
1117
1566
|
|
|
@@ -1207,7 +1656,7 @@ class NormalModule extends Module {
|
|
|
1207
1656
|
(undefined);
|
|
1208
1657
|
|
|
1209
1658
|
if (!result) {
|
|
1210
|
-
/** @type {
|
|
1659
|
+
/** @type {NormalModuleBuildInfo} */
|
|
1211
1660
|
(this.buildInfo).cacheable = false;
|
|
1212
1661
|
return processResult(
|
|
1213
1662
|
err || new Error("No result from loader-runner processing"),
|
|
@@ -1215,16 +1664,16 @@ class NormalModule extends Module {
|
|
|
1215
1664
|
);
|
|
1216
1665
|
}
|
|
1217
1666
|
|
|
1218
|
-
const buildInfo = /** @type {
|
|
1667
|
+
const buildInfo = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
1219
1668
|
|
|
1220
1669
|
const fileDependencies =
|
|
1221
|
-
/** @type {NonNullable<
|
|
1670
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["fileDependencies"]>} */
|
|
1222
1671
|
(buildInfo.fileDependencies);
|
|
1223
1672
|
const contextDependencies =
|
|
1224
|
-
/** @type {NonNullable<
|
|
1673
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["contextDependencies"]>} */
|
|
1225
1674
|
(buildInfo.contextDependencies);
|
|
1226
1675
|
const missingDependencies =
|
|
1227
|
-
/** @type {NonNullable<
|
|
1676
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["missingDependencies"]>} */
|
|
1228
1677
|
(buildInfo.missingDependencies);
|
|
1229
1678
|
|
|
1230
1679
|
fileDependencies.addAll(result.fileDependencies);
|
|
@@ -1232,7 +1681,7 @@ class NormalModule extends Module {
|
|
|
1232
1681
|
missingDependencies.addAll(result.missingDependencies);
|
|
1233
1682
|
for (const loader of this.loaders) {
|
|
1234
1683
|
const buildDependencies =
|
|
1235
|
-
/** @type {NonNullable<
|
|
1684
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["buildDependencies"]>} */
|
|
1236
1685
|
(buildInfo.buildDependencies);
|
|
1237
1686
|
|
|
1238
1687
|
buildDependencies.add(loader.loader);
|
|
@@ -1314,7 +1763,7 @@ class NormalModule extends Module {
|
|
|
1314
1763
|
}
|
|
1315
1764
|
hash.update("meta");
|
|
1316
1765
|
hash.update(JSON.stringify(this.buildMeta));
|
|
1317
|
-
/** @type {
|
|
1766
|
+
/** @type {NormalModuleBuildInfo} */
|
|
1318
1767
|
(this.buildInfo).hash = hash.digest("hex");
|
|
1319
1768
|
}
|
|
1320
1769
|
|
|
@@ -1336,7 +1785,12 @@ class NormalModule extends Module {
|
|
|
1336
1785
|
this.error = null;
|
|
1337
1786
|
this.clearWarningsAndErrors();
|
|
1338
1787
|
this.clearDependenciesAndBlocks();
|
|
1339
|
-
this.buildMeta = {
|
|
1788
|
+
this.buildMeta = {
|
|
1789
|
+
exportsType: undefined,
|
|
1790
|
+
defaultObject: undefined,
|
|
1791
|
+
strictHarmonyModule: undefined,
|
|
1792
|
+
async: undefined
|
|
1793
|
+
};
|
|
1340
1794
|
this.buildInfo = {
|
|
1341
1795
|
cacheable: false,
|
|
1342
1796
|
parsed: true,
|
|
@@ -1347,7 +1801,16 @@ class NormalModule extends Module {
|
|
|
1347
1801
|
valueDependencies: undefined,
|
|
1348
1802
|
hash: undefined,
|
|
1349
1803
|
assets: undefined,
|
|
1350
|
-
assetsInfo: undefined
|
|
1804
|
+
assetsInfo: undefined,
|
|
1805
|
+
snapshot: undefined,
|
|
1806
|
+
strict: undefined,
|
|
1807
|
+
exportsArgument: undefined,
|
|
1808
|
+
moduleArgument: undefined,
|
|
1809
|
+
topLevelDeclarations: undefined,
|
|
1810
|
+
pureFunctions: undefined,
|
|
1811
|
+
inlineExports: undefined,
|
|
1812
|
+
moduleConcatenationBailout: undefined,
|
|
1813
|
+
needCreateRequire: undefined
|
|
1351
1814
|
};
|
|
1352
1815
|
|
|
1353
1816
|
const startTime = compilation.compiler.fsStartTime || Date.now();
|
|
@@ -1380,7 +1843,7 @@ class NormalModule extends Module {
|
|
|
1380
1843
|
const handleParseResult = () => {
|
|
1381
1844
|
this.dependencies.sort(
|
|
1382
1845
|
concatComparators(
|
|
1383
|
-
|
|
1846
|
+
Dependency.compareLocations,
|
|
1384
1847
|
keepOriginalOrder(this.dependencies)
|
|
1385
1848
|
)
|
|
1386
1849
|
);
|
|
@@ -1401,7 +1864,9 @@ class NormalModule extends Module {
|
|
|
1401
1864
|
}
|
|
1402
1865
|
|
|
1403
1866
|
const snapshotOptions = compilation.options.snapshot.module;
|
|
1404
|
-
const { cacheable } = /** @type {
|
|
1867
|
+
const { cacheable } = /** @type {NormalModuleBuildInfo} */ (
|
|
1868
|
+
this.buildInfo
|
|
1869
|
+
);
|
|
1405
1870
|
if (!cacheable || !snapshotOptions) {
|
|
1406
1871
|
return callback();
|
|
1407
1872
|
}
|
|
@@ -1414,7 +1879,7 @@ class NormalModule extends Module {
|
|
|
1414
1879
|
*/
|
|
1415
1880
|
const checkDependencies = (deps) => {
|
|
1416
1881
|
for (const dep of deps) {
|
|
1417
|
-
if (!
|
|
1882
|
+
if (!ABSOLUTE_PATH_REGEXP.test(dep)) {
|
|
1418
1883
|
if (nonAbsoluteDependencies === undefined) {
|
|
1419
1884
|
nonAbsoluteDependencies = new Set();
|
|
1420
1885
|
}
|
|
@@ -1428,11 +1893,11 @@ class NormalModule extends Module {
|
|
|
1428
1893
|
(this.context),
|
|
1429
1894
|
depWithoutGlob
|
|
1430
1895
|
);
|
|
1431
|
-
if (absolute !== dep &&
|
|
1896
|
+
if (absolute !== dep && ABSOLUTE_PATH_REGEXP.test(absolute)) {
|
|
1432
1897
|
(depWithoutGlob !== dep
|
|
1433
|
-
? /** @type {NonNullable<
|
|
1898
|
+
? /** @type {NonNullable<KnownNormalModuleBuildInfo["contextDependencies"]>} */
|
|
1434
1899
|
(
|
|
1435
|
-
/** @type {
|
|
1900
|
+
/** @type {NormalModuleBuildInfo} */
|
|
1436
1901
|
(this.buildInfo).contextDependencies
|
|
1437
1902
|
)
|
|
1438
1903
|
: deps
|
|
@@ -1444,15 +1909,15 @@ class NormalModule extends Module {
|
|
|
1444
1909
|
}
|
|
1445
1910
|
}
|
|
1446
1911
|
};
|
|
1447
|
-
const buildInfo = /** @type {
|
|
1912
|
+
const buildInfo = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
1448
1913
|
const fileDependencies =
|
|
1449
|
-
/** @type {NonNullable<
|
|
1914
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["fileDependencies"]>} */
|
|
1450
1915
|
(buildInfo.fileDependencies);
|
|
1451
1916
|
const contextDependencies =
|
|
1452
|
-
/** @type {NonNullable<
|
|
1917
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["contextDependencies"]>} */
|
|
1453
1918
|
(buildInfo.contextDependencies);
|
|
1454
1919
|
const missingDependencies =
|
|
1455
|
-
/** @type {NonNullable<
|
|
1920
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["missingDependencies"]>} */
|
|
1456
1921
|
(buildInfo.missingDependencies);
|
|
1457
1922
|
checkDependencies(fileDependencies);
|
|
1458
1923
|
checkDependencies(missingDependencies);
|
|
@@ -1498,7 +1963,7 @@ class NormalModule extends Module {
|
|
|
1498
1963
|
const noParseRule = options.module && options.module.noParse;
|
|
1499
1964
|
if (this.shouldPreventParsing(noParseRule, this.request)) {
|
|
1500
1965
|
// We assume that we need module and exports
|
|
1501
|
-
/** @type {
|
|
1966
|
+
/** @type {NormalModuleBuildInfo} */
|
|
1502
1967
|
(this.buildInfo).parsed = false;
|
|
1503
1968
|
this._initBuildHash(compilation);
|
|
1504
1969
|
return handleBuildDone();
|
|
@@ -1512,7 +1977,11 @@ class NormalModule extends Module {
|
|
|
1512
1977
|
current: this,
|
|
1513
1978
|
module: this,
|
|
1514
1979
|
compilation,
|
|
1515
|
-
options
|
|
1980
|
+
options,
|
|
1981
|
+
harmonyNamedExports: undefined,
|
|
1982
|
+
harmonyStarExports: undefined,
|
|
1983
|
+
lastHarmonyImportOrder: undefined,
|
|
1984
|
+
localModules: undefined
|
|
1516
1985
|
});
|
|
1517
1986
|
} catch (parseErr) {
|
|
1518
1987
|
handleParseError(/** @type {Error} */ (parseErr));
|
|
@@ -1539,21 +2008,16 @@ class NormalModule extends Module {
|
|
|
1539
2008
|
* @returns {ConnectionState} how this module should be connected to referencing modules when consumed for side-effects only
|
|
1540
2009
|
*/
|
|
1541
2010
|
getSideEffectsConnectionState(moduleGraph) {
|
|
1542
|
-
//
|
|
1543
|
-
//
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
} else {
|
|
1553
|
-
stack.push(step.value);
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
return r;
|
|
2011
|
+
// Fresh per-walk context; re-entrant calls (e.g.
|
|
2012
|
+
// `ConcatenatedModule.getSideEffectsConnectionState` delegating back
|
|
2013
|
+
// through here) get their own and can't clobber the outer walk.
|
|
2014
|
+
return walkSideEffectsRecursive(
|
|
2015
|
+
this,
|
|
2016
|
+
moduleGraph,
|
|
2017
|
+
0,
|
|
2018
|
+
getHarmonyImportSideEffectDependency(),
|
|
2019
|
+
{ circular: false }
|
|
2020
|
+
);
|
|
1557
2021
|
}
|
|
1558
2022
|
|
|
1559
2023
|
/**
|
|
@@ -1569,6 +2033,18 @@ class NormalModule extends Module {
|
|
|
1569
2033
|
return this._sourceTypes;
|
|
1570
2034
|
}
|
|
1571
2035
|
|
|
2036
|
+
/**
|
|
2037
|
+
* Freshly recomputed source types when they depend on incoming connections, for chunk-graph cache invalidation; undefined otherwise. #20800
|
|
2038
|
+
* @returns {SourceTypes | undefined} source types or undefined
|
|
2039
|
+
*/
|
|
2040
|
+
getReferencedSourceTypes() {
|
|
2041
|
+
const generator = /** @type {Generator} */ (this.generator);
|
|
2042
|
+
// Bypass the _sourceTypes cache: it may be stale when the module is not rebuilt.
|
|
2043
|
+
return generator.getTypesDependOnIncomingConnections()
|
|
2044
|
+
? generator.getTypes(this)
|
|
2045
|
+
: undefined;
|
|
2046
|
+
}
|
|
2047
|
+
|
|
1572
2048
|
/**
|
|
1573
2049
|
* Generates code and runtime requirements for this module.
|
|
1574
2050
|
* @param {CodeGenerationContext} context context for code generation
|
|
@@ -1587,7 +2063,7 @@ class NormalModule extends Module {
|
|
|
1587
2063
|
/** @type {RuntimeRequirements} */
|
|
1588
2064
|
const runtimeRequirements = new Set();
|
|
1589
2065
|
|
|
1590
|
-
const { parsed } = /** @type {
|
|
2066
|
+
const { parsed } = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
1591
2067
|
|
|
1592
2068
|
if (!parsed) {
|
|
1593
2069
|
runtimeRequirements.add(RuntimeGlobals.module);
|
|
@@ -1643,7 +2119,8 @@ class NormalModule extends Module {
|
|
|
1643
2119
|
const resultEntry = {
|
|
1644
2120
|
sources,
|
|
1645
2121
|
runtimeRequirements,
|
|
1646
|
-
data: this._codeGeneratorData
|
|
2122
|
+
data: this._codeGeneratorData,
|
|
2123
|
+
hash: undefined
|
|
1647
2124
|
};
|
|
1648
2125
|
return resultEntry;
|
|
1649
2126
|
}
|
|
@@ -1679,7 +2156,7 @@ class NormalModule extends Module {
|
|
|
1679
2156
|
if (this.error) return callback(null, true);
|
|
1680
2157
|
|
|
1681
2158
|
const { cacheable, snapshot, valueDependencies } =
|
|
1682
|
-
/** @type {
|
|
2159
|
+
/** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
1683
2160
|
|
|
1684
2161
|
// always build when module is not cacheable
|
|
1685
2162
|
if (!cacheable) return callback(null, true);
|
|
@@ -1760,7 +2237,7 @@ class NormalModule extends Module {
|
|
|
1760
2237
|
buildDependencies
|
|
1761
2238
|
) {
|
|
1762
2239
|
const { snapshot, buildDependencies: buildDeps } =
|
|
1763
|
-
/** @type {
|
|
2240
|
+
/** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
1764
2241
|
if (snapshot) {
|
|
1765
2242
|
fileDependencies.addAll(snapshot.getFileIterable());
|
|
1766
2243
|
contextDependencies.addAll(snapshot.getContextIterable());
|
|
@@ -1770,7 +2247,7 @@ class NormalModule extends Module {
|
|
|
1770
2247
|
fileDependencies: fileDeps,
|
|
1771
2248
|
contextDependencies: contextDeps,
|
|
1772
2249
|
missingDependencies: missingDeps
|
|
1773
|
-
} = /** @type {
|
|
2250
|
+
} = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
1774
2251
|
if (fileDeps !== undefined) fileDependencies.addAll(fileDeps);
|
|
1775
2252
|
if (contextDeps !== undefined) contextDependencies.addAll(contextDeps);
|
|
1776
2253
|
if (missingDeps !== undefined) missingDependencies.addAll(missingDeps);
|
|
@@ -1787,7 +2264,7 @@ class NormalModule extends Module {
|
|
|
1787
2264
|
* @returns {void}
|
|
1788
2265
|
*/
|
|
1789
2266
|
updateHash(hash, context) {
|
|
1790
|
-
const buildInfo = /** @type {
|
|
2267
|
+
const buildInfo = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
1791
2268
|
hash.update(
|
|
1792
2269
|
/** @type {string} */
|
|
1793
2270
|
(buildInfo.hash)
|
|
@@ -1821,6 +2298,7 @@ class NormalModule extends Module {
|
|
|
1821
2298
|
write(this._lastSuccessfulBuildMeta);
|
|
1822
2299
|
write(this._forceBuild);
|
|
1823
2300
|
write(this._codeGeneratorData);
|
|
2301
|
+
write(this.hot);
|
|
1824
2302
|
super.serialize(context);
|
|
1825
2303
|
}
|
|
1826
2304
|
|
|
@@ -1829,7 +2307,8 @@ class NormalModule extends Module {
|
|
|
1829
2307
|
* @returns {NormalModule} module
|
|
1830
2308
|
*/
|
|
1831
2309
|
static deserialize(context) {
|
|
1832
|
-
|
|
2310
|
+
// `new this` so subclasses without extra constructor options inherit this method
|
|
2311
|
+
const obj = new this({
|
|
1833
2312
|
// will be deserialized by Module
|
|
1834
2313
|
layer: /** @type {EXPECTED_ANY} */ (null),
|
|
1835
2314
|
type: "",
|
|
@@ -1863,6 +2342,7 @@ class NormalModule extends Module {
|
|
|
1863
2342
|
this._lastSuccessfulBuildMeta = read();
|
|
1864
2343
|
this._forceBuild = read();
|
|
1865
2344
|
this._codeGeneratorData = read();
|
|
2345
|
+
this.hot = read();
|
|
1866
2346
|
super.deserialize(context);
|
|
1867
2347
|
}
|
|
1868
2348
|
}
|