webpack 5.107.2 → 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 +25 -11
- package/lib/ConcatenationScope.js +10 -3
- package/lib/ContextExclusionPlugin.js +1 -0
- package/lib/ContextModule.js +92 -47
- 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 +2 -0
- package/lib/MultiStats.js +1 -0
- package/lib/MultiWatching.js +2 -0
- package/lib/NodeStuffPlugin.js +22 -17
- package/lib/NormalModule.js +142 -80
- package/lib/NormalModuleReplacementPlugin.js +2 -0
- package/lib/PrefetchPlugin.js +2 -0
- package/lib/ProgressPlugin.js +8 -0
- 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 +3 -5
- 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 +64 -7
- 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/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 +18 -15
- 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} +261 -109
- package/lib/dependencies/HtmlInlineHtmlDependency.js +107 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +17 -13
- package/lib/dependencies/HtmlInlineStyleDependency.js +45 -11
- 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 +22 -6
- 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 +30 -6
- package/lib/html/HtmlGenerator.js +217 -23
- package/lib/html/HtmlModule.js +40 -0
- package/lib/html/HtmlModulesPlugin.js +219 -55
- 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 +285 -158
- 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 +24 -5
- package/lib/library/SystemLibraryPlugin.js +3 -3
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/node/NodeWatchFileSystem.js +1 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -9
- package/lib/node/RequireChunkLoadingRuntimeModule.js +18 -16
- package/lib/optimize/ConcatenatedModule.js +395 -77
- 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 +10 -5
- 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 +35 -27
- 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 +1456 -290
- 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 */
|
|
@@ -174,9 +175,10 @@ const SIDE_EFFECTS_RECURSION_LIMIT = 2000;
|
|
|
174
175
|
* behavior.
|
|
175
176
|
* @param {NormalModule} rootMod the module to walk
|
|
176
177
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
178
|
+
* @param {SideEffectsWalkContext} ctx per-walk cycle-tracking context
|
|
177
179
|
* @returns {ConnectionState} the side-effects connection state
|
|
178
180
|
*/
|
|
179
|
-
const walkSideEffectsIterative = (rootMod, moduleGraph) => {
|
|
181
|
+
const walkSideEffectsIterative = (rootMod, moduleGraph, ctx) => {
|
|
180
182
|
const SideEffectDep = getHarmonyImportSideEffectDependency();
|
|
181
183
|
|
|
182
184
|
/** @type {NormalModule[]} */
|
|
@@ -259,7 +261,7 @@ const walkSideEffectsIterative = (rootMod, moduleGraph) => {
|
|
|
259
261
|
) {
|
|
260
262
|
state = true;
|
|
261
263
|
} else if (refModule._isEvaluatingSideEffects) {
|
|
262
|
-
|
|
264
|
+
ctx.circular = true;
|
|
263
265
|
state = ModuleGraphConnection.CIRCULAR_CONNECTION;
|
|
264
266
|
} else {
|
|
265
267
|
// Descend
|
|
@@ -281,7 +283,7 @@ const walkSideEffectsIterative = (rootMod, moduleGraph) => {
|
|
|
281
283
|
) {
|
|
282
284
|
state = true;
|
|
283
285
|
} else if (refModule._isEvaluatingSideEffects) {
|
|
284
|
-
|
|
286
|
+
ctx.circular = true;
|
|
285
287
|
state = ModuleGraphConnection.CIRCULAR_CONNECTION;
|
|
286
288
|
} else {
|
|
287
289
|
// Descend
|
|
@@ -296,7 +298,7 @@ const walkSideEffectsIterative = (rootMod, moduleGraph) => {
|
|
|
296
298
|
break;
|
|
297
299
|
}
|
|
298
300
|
} else {
|
|
299
|
-
|
|
301
|
+
ctx.circular = true;
|
|
300
302
|
state = refModule.getSideEffectsConnectionState(moduleGraph);
|
|
301
303
|
}
|
|
302
304
|
} else {
|
|
@@ -325,7 +327,7 @@ const walkSideEffectsIterative = (rootMod, moduleGraph) => {
|
|
|
325
327
|
if (descended) continue;
|
|
326
328
|
|
|
327
329
|
topMod._isEvaluatingSideEffects = false;
|
|
328
|
-
if (!
|
|
330
|
+
if (!ctx.circular) {
|
|
329
331
|
topMod._sideEffectsStateGraph = moduleGraph;
|
|
330
332
|
topMod._sideEffectsStateValue = current;
|
|
331
333
|
}
|
|
@@ -340,15 +342,9 @@ const walkSideEffectsIterative = (rootMod, moduleGraph) => {
|
|
|
340
342
|
};
|
|
341
343
|
|
|
342
344
|
/**
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
* an intermediate result is safe to memoize on the module: a result
|
|
346
|
-
* computed in the presence of a cycle can differ from the result computed
|
|
347
|
-
* fresh, because cycle short-circuiting hides the contribution of the
|
|
348
|
-
* back-edge target. Reset to `false` at the top-level entry; read and
|
|
349
|
-
* propagated by each recursive frame.
|
|
345
|
+
* @typedef {object} SideEffectsWalkContext
|
|
346
|
+
* @property {boolean} circular whether a cycle was seen anywhere in this walk
|
|
350
347
|
*/
|
|
351
|
-
let _sideEffectsCircularSeen = false;
|
|
352
348
|
|
|
353
349
|
/**
|
|
354
350
|
* Walks back up a stack of linear-chain ancestors, applying the result
|
|
@@ -359,9 +355,10 @@ let _sideEffectsCircularSeen = false;
|
|
|
359
355
|
* @param {(NormalModule | Dependency)[] | null} ancestors interleaved stack of `[mod, sideEffectDep, mod, sideEffectDep, …]` in descent order; `null` if there were none
|
|
360
356
|
* @param {ConnectionState} state result from the chain's tail
|
|
361
357
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
358
|
+
* @param {SideEffectsWalkContext} ctx per-walk cycle-tracking context
|
|
362
359
|
* @returns {ConnectionState} the root ancestor's result
|
|
363
360
|
*/
|
|
364
|
-
const propagateLinearResult = (ancestors, state, moduleGraph) => {
|
|
361
|
+
const propagateLinearResult = (ancestors, state, moduleGraph, ctx) => {
|
|
365
362
|
if (ancestors === null) return state;
|
|
366
363
|
while (ancestors.length > 0) {
|
|
367
364
|
const dep = /** @type {Dependency} */ (ancestors.pop());
|
|
@@ -378,9 +375,9 @@ const propagateLinearResult = (ancestors, state, moduleGraph) => {
|
|
|
378
375
|
// so the ancestor's `current` stays at its initial `false`. From
|
|
379
376
|
// this point upward the propagated state is `false`, and the
|
|
380
377
|
// cycle taint prevents memoization further up (handled by
|
|
381
|
-
// `
|
|
378
|
+
// `ctx.circular`).
|
|
382
379
|
state = false;
|
|
383
|
-
} else if (!
|
|
380
|
+
} else if (!ctx.circular) {
|
|
384
381
|
ancestor._sideEffectsStateGraph = moduleGraph;
|
|
385
382
|
ancestor._sideEffectsStateValue = state;
|
|
386
383
|
}
|
|
@@ -415,9 +412,16 @@ const propagateLinearResult = (ancestors, state, moduleGraph) => {
|
|
|
415
412
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
416
413
|
* @param {number} depth current recursion depth (only counts true V8 frames)
|
|
417
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
|
|
418
416
|
* @returns {ConnectionState} the side-effects connection state
|
|
419
417
|
*/
|
|
420
|
-
const walkSideEffectsRecursive = (
|
|
418
|
+
const walkSideEffectsRecursive = (
|
|
419
|
+
mod,
|
|
420
|
+
moduleGraph,
|
|
421
|
+
depth,
|
|
422
|
+
SideEffectDep,
|
|
423
|
+
ctx
|
|
424
|
+
) => {
|
|
421
425
|
// Interleaved `[mod, linearDep, mod, linearDep, …]` for the linear
|
|
422
426
|
// chain head; `null` until the first descent.
|
|
423
427
|
/** @type {(NormalModule | Dependency)[] | null} */
|
|
@@ -430,27 +434,29 @@ const walkSideEffectsRecursive = (mod, moduleGraph, depth, SideEffectDep) => {
|
|
|
430
434
|
return propagateLinearResult(
|
|
431
435
|
linearAncestors,
|
|
432
436
|
/** @type {ConnectionState} */ (mod._sideEffectsStateValue),
|
|
433
|
-
moduleGraph
|
|
437
|
+
moduleGraph,
|
|
438
|
+
ctx
|
|
434
439
|
);
|
|
435
440
|
}
|
|
436
441
|
|
|
437
442
|
if (mod.factoryMeta !== undefined) {
|
|
438
443
|
if (mod.factoryMeta.sideEffectFree) {
|
|
439
|
-
return propagateLinearResult(linearAncestors, false, moduleGraph);
|
|
444
|
+
return propagateLinearResult(linearAncestors, false, moduleGraph, ctx);
|
|
440
445
|
}
|
|
441
446
|
if (mod.factoryMeta.sideEffectFree === false) {
|
|
442
|
-
return propagateLinearResult(linearAncestors, true, moduleGraph);
|
|
447
|
+
return propagateLinearResult(linearAncestors, true, moduleGraph, ctx);
|
|
443
448
|
}
|
|
444
449
|
}
|
|
445
450
|
if (!(mod.buildMeta !== undefined && mod.buildMeta.sideEffectFree)) {
|
|
446
|
-
return propagateLinearResult(linearAncestors, true, moduleGraph);
|
|
451
|
+
return propagateLinearResult(linearAncestors, true, moduleGraph, ctx);
|
|
447
452
|
}
|
|
448
453
|
if (mod._isEvaluatingSideEffects) {
|
|
449
|
-
|
|
454
|
+
ctx.circular = true;
|
|
450
455
|
return propagateLinearResult(
|
|
451
456
|
linearAncestors,
|
|
452
457
|
ModuleGraphConnection.CIRCULAR_CONNECTION,
|
|
453
|
-
moduleGraph
|
|
458
|
+
moduleGraph,
|
|
459
|
+
ctx
|
|
454
460
|
);
|
|
455
461
|
}
|
|
456
462
|
|
|
@@ -487,7 +493,7 @@ const walkSideEffectsRecursive = (mod, moduleGraph, depth, SideEffectDep) => {
|
|
|
487
493
|
recordSideEffectsBailout(mod, moduleGraph, dep);
|
|
488
494
|
mod._sideEffectsStateGraph = moduleGraph;
|
|
489
495
|
mod._sideEffectsStateValue = true;
|
|
490
|
-
return propagateLinearResult(linearAncestors, true, moduleGraph);
|
|
496
|
+
return propagateLinearResult(linearAncestors, true, moduleGraph, ctx);
|
|
491
497
|
}
|
|
492
498
|
if (state !== ModuleGraphConnection.CIRCULAR_CONNECTION) {
|
|
493
499
|
nonRecursiveCurrent = ModuleGraphConnection.addConnectionStates(
|
|
@@ -509,11 +515,11 @@ const walkSideEffectsRecursive = (mod, moduleGraph, depth, SideEffectDep) => {
|
|
|
509
515
|
if (linearDep === null) {
|
|
510
516
|
// No `SideEffectDep` — the module is a leaf as far as the
|
|
511
517
|
// side-effects graph is concerned. Cache and propagate `false`.
|
|
512
|
-
if (!
|
|
518
|
+
if (!ctx.circular) {
|
|
513
519
|
mod._sideEffectsStateGraph = moduleGraph;
|
|
514
520
|
mod._sideEffectsStateValue = false;
|
|
515
521
|
}
|
|
516
|
-
return propagateLinearResult(linearAncestors, false, moduleGraph);
|
|
522
|
+
return propagateLinearResult(linearAncestors, false, moduleGraph, ctx);
|
|
517
523
|
}
|
|
518
524
|
|
|
519
525
|
const refModule = moduleGraph.getModule(linearDep);
|
|
@@ -521,7 +527,7 @@ const walkSideEffectsRecursive = (mod, moduleGraph, depth, SideEffectDep) => {
|
|
|
521
527
|
recordSideEffectsBailout(mod, moduleGraph, linearDep);
|
|
522
528
|
mod._sideEffectsStateGraph = moduleGraph;
|
|
523
529
|
mod._sideEffectsStateValue = true;
|
|
524
|
-
return propagateLinearResult(linearAncestors, true, moduleGraph);
|
|
530
|
+
return propagateLinearResult(linearAncestors, true, moduleGraph, ctx);
|
|
525
531
|
}
|
|
526
532
|
if (!(refModule instanceof NormalModule)) {
|
|
527
533
|
// Non-NormalModule's `getSideEffectsConnectionState` re-enters
|
|
@@ -545,8 +551,9 @@ const walkSideEffectsRecursive = (mod, moduleGraph, depth, SideEffectDep) => {
|
|
|
545
551
|
if (depth >= SIDE_EFFECTS_RECURSION_LIMIT) {
|
|
546
552
|
return propagateLinearResult(
|
|
547
553
|
linearAncestors,
|
|
548
|
-
walkSideEffectsIterative(mod, moduleGraph),
|
|
549
|
-
moduleGraph
|
|
554
|
+
walkSideEffectsIterative(mod, moduleGraph, ctx),
|
|
555
|
+
moduleGraph,
|
|
556
|
+
ctx
|
|
550
557
|
);
|
|
551
558
|
}
|
|
552
559
|
|
|
@@ -566,7 +573,8 @@ const walkSideEffectsRecursive = (mod, moduleGraph, depth, SideEffectDep) => {
|
|
|
566
573
|
refModule,
|
|
567
574
|
moduleGraph,
|
|
568
575
|
depth + 1,
|
|
569
|
-
SideEffectDep
|
|
576
|
+
SideEffectDep,
|
|
577
|
+
ctx
|
|
570
578
|
);
|
|
571
579
|
} else {
|
|
572
580
|
// Non-NormalModule's `getSideEffectsConnectionState` (notably
|
|
@@ -576,7 +584,7 @@ const walkSideEffectsRecursive = (mod, moduleGraph, depth, SideEffectDep) => {
|
|
|
576
584
|
// the inner walk hit a cycle that reflected the outer's
|
|
577
585
|
// state, so treat the walk as cycle-tainted and skip the
|
|
578
586
|
// cache for safety.
|
|
579
|
-
|
|
587
|
+
ctx.circular = true;
|
|
580
588
|
state = refModule.getSideEffectsConnectionState(moduleGraph);
|
|
581
589
|
}
|
|
582
590
|
} else {
|
|
@@ -591,7 +599,7 @@ const walkSideEffectsRecursive = (mod, moduleGraph, depth, SideEffectDep) => {
|
|
|
591
599
|
// always safe to memoize.
|
|
592
600
|
mod._sideEffectsStateGraph = moduleGraph;
|
|
593
601
|
mod._sideEffectsStateValue = true;
|
|
594
|
-
return propagateLinearResult(linearAncestors, true, moduleGraph);
|
|
602
|
+
return propagateLinearResult(linearAncestors, true, moduleGraph, ctx);
|
|
595
603
|
}
|
|
596
604
|
if (state !== ModuleGraphConnection.CIRCULAR_CONNECTION) {
|
|
597
605
|
current = ModuleGraphConnection.addConnectionStates(current, state);
|
|
@@ -606,15 +614,13 @@ const walkSideEffectsRecursive = (mod, moduleGraph, depth, SideEffectDep) => {
|
|
|
606
614
|
// CIRCULAR_CONNECTION short-circuiting), so this single flag is the
|
|
607
615
|
// conservative-but-cheap approximation of "this subtree's result is
|
|
608
616
|
// independent of cycle context". The public entry resets the flag.
|
|
609
|
-
if (!
|
|
617
|
+
if (!ctx.circular) {
|
|
610
618
|
mod._sideEffectsStateGraph = moduleGraph;
|
|
611
619
|
mod._sideEffectsStateValue = current;
|
|
612
620
|
}
|
|
613
|
-
return propagateLinearResult(linearAncestors, current, moduleGraph);
|
|
621
|
+
return propagateLinearResult(linearAncestors, current, moduleGraph, ctx);
|
|
614
622
|
};
|
|
615
623
|
|
|
616
|
-
const ABSOLUTE_PATH_REGEX = /^(?:[a-z]:\\|\\\\|\/)/i;
|
|
617
|
-
|
|
618
624
|
/**
|
|
619
625
|
* @typedef {object} LoaderItem
|
|
620
626
|
* @property {string} loader
|
|
@@ -740,6 +746,22 @@ const asBuffer = (input) => {
|
|
|
740
746
|
* @typedef {(resourcePath: string, getLoaderContext: (resourcePath: string) => AnyLoaderContext) => Promise<string | Buffer<ArrayBufferLike>>} ReadResource
|
|
741
747
|
*/
|
|
742
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
|
+
|
|
743
765
|
/** @type {WeakMap<Compilation, NormalModuleCompilationHooks>} */
|
|
744
766
|
const compilationHooksMap = new WeakMap();
|
|
745
767
|
|
|
@@ -863,7 +885,14 @@ class NormalModule extends Module {
|
|
|
863
885
|
/** @type {NormalModuleCreateData['extractSourceMap']} */
|
|
864
886
|
this.extractSourceMap = extractSourceMap;
|
|
865
887
|
|
|
888
|
+
// Set by HotModuleReplacementPlugin via NormalModuleFactory's `module` hook
|
|
889
|
+
/** @type {boolean} */
|
|
890
|
+
this.hot = false;
|
|
891
|
+
|
|
866
892
|
// Info from Build
|
|
893
|
+
// Redeclared with the normal module specific shape (see KnownNormalModuleBuildInfo)
|
|
894
|
+
/** @type {NormalModuleBuildInfo | undefined} */
|
|
895
|
+
this.buildInfo = undefined;
|
|
867
896
|
/** @type {Error | null} */
|
|
868
897
|
this.error = null;
|
|
869
898
|
/**
|
|
@@ -1314,7 +1343,7 @@ class NormalModule extends Module {
|
|
|
1314
1343
|
},
|
|
1315
1344
|
/** @type {LoaderContext<EXPECTED_ANY>["emitFile"]} */
|
|
1316
1345
|
emitFile: (name, content, sourceMap, assetInfo) => {
|
|
1317
|
-
const buildInfo = /** @type {
|
|
1346
|
+
const buildInfo = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
1318
1347
|
|
|
1319
1348
|
if (!buildInfo.assets) {
|
|
1320
1349
|
buildInfo.assets = Object.create(null);
|
|
@@ -1338,7 +1367,7 @@ class NormalModule extends Module {
|
|
|
1338
1367
|
assetsInfo.set(name, assetInfo);
|
|
1339
1368
|
},
|
|
1340
1369
|
addBuildDependency: (dep) => {
|
|
1341
|
-
const buildInfo = /** @type {
|
|
1370
|
+
const buildInfo = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
1342
1371
|
|
|
1343
1372
|
if (buildInfo.buildDependencies === undefined) {
|
|
1344
1373
|
buildInfo.buildDependencies = new LazySet();
|
|
@@ -1511,7 +1540,7 @@ class NormalModule extends Module {
|
|
|
1511
1540
|
return callback();
|
|
1512
1541
|
};
|
|
1513
1542
|
|
|
1514
|
-
const buildInfo = /** @type {
|
|
1543
|
+
const buildInfo = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
1515
1544
|
|
|
1516
1545
|
buildInfo.fileDependencies = new LazySet();
|
|
1517
1546
|
buildInfo.contextDependencies = new LazySet();
|
|
@@ -1531,7 +1560,7 @@ class NormalModule extends Module {
|
|
|
1531
1560
|
}
|
|
1532
1561
|
|
|
1533
1562
|
if (this.loaders.length > 0) {
|
|
1534
|
-
/** @type {
|
|
1563
|
+
/** @type {NormalModuleBuildInfo} */
|
|
1535
1564
|
(this.buildInfo).buildDependencies = new LazySet();
|
|
1536
1565
|
}
|
|
1537
1566
|
|
|
@@ -1627,7 +1656,7 @@ class NormalModule extends Module {
|
|
|
1627
1656
|
(undefined);
|
|
1628
1657
|
|
|
1629
1658
|
if (!result) {
|
|
1630
|
-
/** @type {
|
|
1659
|
+
/** @type {NormalModuleBuildInfo} */
|
|
1631
1660
|
(this.buildInfo).cacheable = false;
|
|
1632
1661
|
return processResult(
|
|
1633
1662
|
err || new Error("No result from loader-runner processing"),
|
|
@@ -1635,16 +1664,16 @@ class NormalModule extends Module {
|
|
|
1635
1664
|
);
|
|
1636
1665
|
}
|
|
1637
1666
|
|
|
1638
|
-
const buildInfo = /** @type {
|
|
1667
|
+
const buildInfo = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
1639
1668
|
|
|
1640
1669
|
const fileDependencies =
|
|
1641
|
-
/** @type {NonNullable<
|
|
1670
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["fileDependencies"]>} */
|
|
1642
1671
|
(buildInfo.fileDependencies);
|
|
1643
1672
|
const contextDependencies =
|
|
1644
|
-
/** @type {NonNullable<
|
|
1673
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["contextDependencies"]>} */
|
|
1645
1674
|
(buildInfo.contextDependencies);
|
|
1646
1675
|
const missingDependencies =
|
|
1647
|
-
/** @type {NonNullable<
|
|
1676
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["missingDependencies"]>} */
|
|
1648
1677
|
(buildInfo.missingDependencies);
|
|
1649
1678
|
|
|
1650
1679
|
fileDependencies.addAll(result.fileDependencies);
|
|
@@ -1652,7 +1681,7 @@ class NormalModule extends Module {
|
|
|
1652
1681
|
missingDependencies.addAll(result.missingDependencies);
|
|
1653
1682
|
for (const loader of this.loaders) {
|
|
1654
1683
|
const buildDependencies =
|
|
1655
|
-
/** @type {NonNullable<
|
|
1684
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["buildDependencies"]>} */
|
|
1656
1685
|
(buildInfo.buildDependencies);
|
|
1657
1686
|
|
|
1658
1687
|
buildDependencies.add(loader.loader);
|
|
@@ -1734,7 +1763,7 @@ class NormalModule extends Module {
|
|
|
1734
1763
|
}
|
|
1735
1764
|
hash.update("meta");
|
|
1736
1765
|
hash.update(JSON.stringify(this.buildMeta));
|
|
1737
|
-
/** @type {
|
|
1766
|
+
/** @type {NormalModuleBuildInfo} */
|
|
1738
1767
|
(this.buildInfo).hash = hash.digest("hex");
|
|
1739
1768
|
}
|
|
1740
1769
|
|
|
@@ -1756,7 +1785,12 @@ class NormalModule extends Module {
|
|
|
1756
1785
|
this.error = null;
|
|
1757
1786
|
this.clearWarningsAndErrors();
|
|
1758
1787
|
this.clearDependenciesAndBlocks();
|
|
1759
|
-
this.buildMeta = {
|
|
1788
|
+
this.buildMeta = {
|
|
1789
|
+
exportsType: undefined,
|
|
1790
|
+
defaultObject: undefined,
|
|
1791
|
+
strictHarmonyModule: undefined,
|
|
1792
|
+
async: undefined
|
|
1793
|
+
};
|
|
1760
1794
|
this.buildInfo = {
|
|
1761
1795
|
cacheable: false,
|
|
1762
1796
|
parsed: true,
|
|
@@ -1767,7 +1801,16 @@ class NormalModule extends Module {
|
|
|
1767
1801
|
valueDependencies: undefined,
|
|
1768
1802
|
hash: undefined,
|
|
1769
1803
|
assets: undefined,
|
|
1770
|
-
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
|
|
1771
1814
|
};
|
|
1772
1815
|
|
|
1773
1816
|
const startTime = compilation.compiler.fsStartTime || Date.now();
|
|
@@ -1800,7 +1843,7 @@ class NormalModule extends Module {
|
|
|
1800
1843
|
const handleParseResult = () => {
|
|
1801
1844
|
this.dependencies.sort(
|
|
1802
1845
|
concatComparators(
|
|
1803
|
-
|
|
1846
|
+
Dependency.compareLocations,
|
|
1804
1847
|
keepOriginalOrder(this.dependencies)
|
|
1805
1848
|
)
|
|
1806
1849
|
);
|
|
@@ -1821,7 +1864,9 @@ class NormalModule extends Module {
|
|
|
1821
1864
|
}
|
|
1822
1865
|
|
|
1823
1866
|
const snapshotOptions = compilation.options.snapshot.module;
|
|
1824
|
-
const { cacheable } = /** @type {
|
|
1867
|
+
const { cacheable } = /** @type {NormalModuleBuildInfo} */ (
|
|
1868
|
+
this.buildInfo
|
|
1869
|
+
);
|
|
1825
1870
|
if (!cacheable || !snapshotOptions) {
|
|
1826
1871
|
return callback();
|
|
1827
1872
|
}
|
|
@@ -1834,7 +1879,7 @@ class NormalModule extends Module {
|
|
|
1834
1879
|
*/
|
|
1835
1880
|
const checkDependencies = (deps) => {
|
|
1836
1881
|
for (const dep of deps) {
|
|
1837
|
-
if (!
|
|
1882
|
+
if (!ABSOLUTE_PATH_REGEXP.test(dep)) {
|
|
1838
1883
|
if (nonAbsoluteDependencies === undefined) {
|
|
1839
1884
|
nonAbsoluteDependencies = new Set();
|
|
1840
1885
|
}
|
|
@@ -1848,11 +1893,11 @@ class NormalModule extends Module {
|
|
|
1848
1893
|
(this.context),
|
|
1849
1894
|
depWithoutGlob
|
|
1850
1895
|
);
|
|
1851
|
-
if (absolute !== dep &&
|
|
1896
|
+
if (absolute !== dep && ABSOLUTE_PATH_REGEXP.test(absolute)) {
|
|
1852
1897
|
(depWithoutGlob !== dep
|
|
1853
|
-
? /** @type {NonNullable<
|
|
1898
|
+
? /** @type {NonNullable<KnownNormalModuleBuildInfo["contextDependencies"]>} */
|
|
1854
1899
|
(
|
|
1855
|
-
/** @type {
|
|
1900
|
+
/** @type {NormalModuleBuildInfo} */
|
|
1856
1901
|
(this.buildInfo).contextDependencies
|
|
1857
1902
|
)
|
|
1858
1903
|
: deps
|
|
@@ -1864,15 +1909,15 @@ class NormalModule extends Module {
|
|
|
1864
1909
|
}
|
|
1865
1910
|
}
|
|
1866
1911
|
};
|
|
1867
|
-
const buildInfo = /** @type {
|
|
1912
|
+
const buildInfo = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
1868
1913
|
const fileDependencies =
|
|
1869
|
-
/** @type {NonNullable<
|
|
1914
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["fileDependencies"]>} */
|
|
1870
1915
|
(buildInfo.fileDependencies);
|
|
1871
1916
|
const contextDependencies =
|
|
1872
|
-
/** @type {NonNullable<
|
|
1917
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["contextDependencies"]>} */
|
|
1873
1918
|
(buildInfo.contextDependencies);
|
|
1874
1919
|
const missingDependencies =
|
|
1875
|
-
/** @type {NonNullable<
|
|
1920
|
+
/** @type {NonNullable<KnownNormalModuleBuildInfo["missingDependencies"]>} */
|
|
1876
1921
|
(buildInfo.missingDependencies);
|
|
1877
1922
|
checkDependencies(fileDependencies);
|
|
1878
1923
|
checkDependencies(missingDependencies);
|
|
@@ -1918,7 +1963,7 @@ class NormalModule extends Module {
|
|
|
1918
1963
|
const noParseRule = options.module && options.module.noParse;
|
|
1919
1964
|
if (this.shouldPreventParsing(noParseRule, this.request)) {
|
|
1920
1965
|
// We assume that we need module and exports
|
|
1921
|
-
/** @type {
|
|
1966
|
+
/** @type {NormalModuleBuildInfo} */
|
|
1922
1967
|
(this.buildInfo).parsed = false;
|
|
1923
1968
|
this._initBuildHash(compilation);
|
|
1924
1969
|
return handleBuildDone();
|
|
@@ -1932,7 +1977,11 @@ class NormalModule extends Module {
|
|
|
1932
1977
|
current: this,
|
|
1933
1978
|
module: this,
|
|
1934
1979
|
compilation,
|
|
1935
|
-
options
|
|
1980
|
+
options,
|
|
1981
|
+
harmonyNamedExports: undefined,
|
|
1982
|
+
harmonyStarExports: undefined,
|
|
1983
|
+
lastHarmonyImportOrder: undefined,
|
|
1984
|
+
localModules: undefined
|
|
1936
1985
|
});
|
|
1937
1986
|
} catch (parseErr) {
|
|
1938
1987
|
handleParseError(/** @type {Error} */ (parseErr));
|
|
@@ -1959,19 +2008,16 @@ class NormalModule extends Module {
|
|
|
1959
2008
|
* @returns {ConnectionState} how this module should be connected to referencing modules when consumed for side-effects only
|
|
1960
2009
|
*/
|
|
1961
2010
|
getSideEffectsConnectionState(moduleGraph) {
|
|
1962
|
-
//
|
|
1963
|
-
//
|
|
1964
|
-
//
|
|
1965
|
-
|
|
1966
|
-
_sideEffectsCircularSeen = false;
|
|
1967
|
-
const result = walkSideEffectsRecursive(
|
|
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(
|
|
1968
2015
|
this,
|
|
1969
2016
|
moduleGraph,
|
|
1970
2017
|
0,
|
|
1971
|
-
getHarmonyImportSideEffectDependency()
|
|
2018
|
+
getHarmonyImportSideEffectDependency(),
|
|
2019
|
+
{ circular: false }
|
|
1972
2020
|
);
|
|
1973
|
-
_sideEffectsCircularSeen = savedCircular;
|
|
1974
|
-
return result;
|
|
1975
2021
|
}
|
|
1976
2022
|
|
|
1977
2023
|
/**
|
|
@@ -1987,6 +2033,18 @@ class NormalModule extends Module {
|
|
|
1987
2033
|
return this._sourceTypes;
|
|
1988
2034
|
}
|
|
1989
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
|
+
|
|
1990
2048
|
/**
|
|
1991
2049
|
* Generates code and runtime requirements for this module.
|
|
1992
2050
|
* @param {CodeGenerationContext} context context for code generation
|
|
@@ -2005,7 +2063,7 @@ class NormalModule extends Module {
|
|
|
2005
2063
|
/** @type {RuntimeRequirements} */
|
|
2006
2064
|
const runtimeRequirements = new Set();
|
|
2007
2065
|
|
|
2008
|
-
const { parsed } = /** @type {
|
|
2066
|
+
const { parsed } = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
2009
2067
|
|
|
2010
2068
|
if (!parsed) {
|
|
2011
2069
|
runtimeRequirements.add(RuntimeGlobals.module);
|
|
@@ -2061,7 +2119,8 @@ class NormalModule extends Module {
|
|
|
2061
2119
|
const resultEntry = {
|
|
2062
2120
|
sources,
|
|
2063
2121
|
runtimeRequirements,
|
|
2064
|
-
data: this._codeGeneratorData
|
|
2122
|
+
data: this._codeGeneratorData,
|
|
2123
|
+
hash: undefined
|
|
2065
2124
|
};
|
|
2066
2125
|
return resultEntry;
|
|
2067
2126
|
}
|
|
@@ -2097,7 +2156,7 @@ class NormalModule extends Module {
|
|
|
2097
2156
|
if (this.error) return callback(null, true);
|
|
2098
2157
|
|
|
2099
2158
|
const { cacheable, snapshot, valueDependencies } =
|
|
2100
|
-
/** @type {
|
|
2159
|
+
/** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
2101
2160
|
|
|
2102
2161
|
// always build when module is not cacheable
|
|
2103
2162
|
if (!cacheable) return callback(null, true);
|
|
@@ -2178,7 +2237,7 @@ class NormalModule extends Module {
|
|
|
2178
2237
|
buildDependencies
|
|
2179
2238
|
) {
|
|
2180
2239
|
const { snapshot, buildDependencies: buildDeps } =
|
|
2181
|
-
/** @type {
|
|
2240
|
+
/** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
2182
2241
|
if (snapshot) {
|
|
2183
2242
|
fileDependencies.addAll(snapshot.getFileIterable());
|
|
2184
2243
|
contextDependencies.addAll(snapshot.getContextIterable());
|
|
@@ -2188,7 +2247,7 @@ class NormalModule extends Module {
|
|
|
2188
2247
|
fileDependencies: fileDeps,
|
|
2189
2248
|
contextDependencies: contextDeps,
|
|
2190
2249
|
missingDependencies: missingDeps
|
|
2191
|
-
} = /** @type {
|
|
2250
|
+
} = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
2192
2251
|
if (fileDeps !== undefined) fileDependencies.addAll(fileDeps);
|
|
2193
2252
|
if (contextDeps !== undefined) contextDependencies.addAll(contextDeps);
|
|
2194
2253
|
if (missingDeps !== undefined) missingDependencies.addAll(missingDeps);
|
|
@@ -2205,7 +2264,7 @@ class NormalModule extends Module {
|
|
|
2205
2264
|
* @returns {void}
|
|
2206
2265
|
*/
|
|
2207
2266
|
updateHash(hash, context) {
|
|
2208
|
-
const buildInfo = /** @type {
|
|
2267
|
+
const buildInfo = /** @type {NormalModuleBuildInfo} */ (this.buildInfo);
|
|
2209
2268
|
hash.update(
|
|
2210
2269
|
/** @type {string} */
|
|
2211
2270
|
(buildInfo.hash)
|
|
@@ -2239,6 +2298,7 @@ class NormalModule extends Module {
|
|
|
2239
2298
|
write(this._lastSuccessfulBuildMeta);
|
|
2240
2299
|
write(this._forceBuild);
|
|
2241
2300
|
write(this._codeGeneratorData);
|
|
2301
|
+
write(this.hot);
|
|
2242
2302
|
super.serialize(context);
|
|
2243
2303
|
}
|
|
2244
2304
|
|
|
@@ -2247,7 +2307,8 @@ class NormalModule extends Module {
|
|
|
2247
2307
|
* @returns {NormalModule} module
|
|
2248
2308
|
*/
|
|
2249
2309
|
static deserialize(context) {
|
|
2250
|
-
|
|
2310
|
+
// `new this` so subclasses without extra constructor options inherit this method
|
|
2311
|
+
const obj = new this({
|
|
2251
2312
|
// will be deserialized by Module
|
|
2252
2313
|
layer: /** @type {EXPECTED_ANY} */ (null),
|
|
2253
2314
|
type: "",
|
|
@@ -2281,6 +2342,7 @@ class NormalModule extends Module {
|
|
|
2281
2342
|
this._lastSuccessfulBuildMeta = read();
|
|
2282
2343
|
this._forceBuild = read();
|
|
2283
2344
|
this._codeGeneratorData = read();
|
|
2345
|
+
this.hot = read();
|
|
2284
2346
|
super.deserialize(context);
|
|
2285
2347
|
}
|
|
2286
2348
|
}
|
|
@@ -22,7 +22,9 @@ class NormalModuleReplacementPlugin {
|
|
|
22
22
|
* @param {string | ModuleReplacer} newResource the resource replacement
|
|
23
23
|
*/
|
|
24
24
|
constructor(resourceRegExp, newResource) {
|
|
25
|
+
/** @type {RegExp} */
|
|
25
26
|
this.resourceRegExp = resourceRegExp;
|
|
27
|
+
/** @type {string | ModuleReplacer} */
|
|
26
28
|
this.newResource = newResource;
|
|
27
29
|
}
|
|
28
30
|
|
package/lib/PrefetchPlugin.js
CHANGED
package/lib/ProgressPlugin.js
CHANGED
|
@@ -242,13 +242,21 @@ class ProgressPlugin {
|
|
|
242
242
|
this.options = options;
|
|
243
243
|
|
|
244
244
|
const merged = { ...DEFAULT_OPTIONS, ...options };
|
|
245
|
+
/** @type {boolean | null} */
|
|
245
246
|
this.profile = merged.profile;
|
|
247
|
+
/** @type {HandlerFn | undefined} */
|
|
246
248
|
this.handler = merged.handler;
|
|
249
|
+
/** @type {number} */
|
|
247
250
|
this.modulesCount = merged.modulesCount;
|
|
251
|
+
/** @type {number} */
|
|
248
252
|
this.dependenciesCount = merged.dependenciesCount;
|
|
253
|
+
/** @type {boolean} */
|
|
249
254
|
this.showEntries = merged.entries;
|
|
255
|
+
/** @type {boolean} */
|
|
250
256
|
this.showModules = merged.modules;
|
|
257
|
+
/** @type {boolean} */
|
|
251
258
|
this.showDependencies = merged.dependencies;
|
|
259
|
+
/** @type {boolean} */
|
|
252
260
|
this.showActiveModules = merged.activeModules;
|
|
253
261
|
this.percentBy = merged.percentBy;
|
|
254
262
|
|
package/lib/ProvidePlugin.js
CHANGED