webpack 5.106.1 → 5.107.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/APIPlugin.js +4 -2
- package/lib/AsyncDependenciesBlock.js +3 -0
- package/lib/AutomaticPrefetchPlugin.js +6 -1
- package/lib/BannerPlugin.js +10 -1
- package/lib/Cache.js +27 -5
- package/lib/CacheFacade.js +26 -0
- package/lib/Chunk.js +46 -0
- package/lib/ChunkGraph.js +111 -0
- package/lib/ChunkGroup.js +57 -13
- package/lib/ChunkTemplate.js +9 -0
- package/lib/CleanPlugin.js +14 -1
- package/lib/CodeGenerationResults.js +19 -0
- package/lib/CompatibilityPlugin.js +23 -8
- package/lib/Compilation.js +161 -27
- package/lib/Compiler.js +41 -17
- package/lib/ConcatenationScope.js +24 -1
- package/lib/ConditionalInitFragment.js +6 -0
- package/lib/ConstPlugin.js +4 -1
- package/lib/ContextExclusionPlugin.js +2 -1
- package/lib/ContextModule.js +14 -2
- package/lib/ContextModuleFactory.js +10 -0
- package/lib/ContextReplacementPlugin.js +4 -1
- package/lib/DefinePlugin.js +22 -9
- package/lib/DependenciesBlock.js +6 -1
- package/lib/Dependency.js +48 -4
- package/lib/DependencyTemplate.js +7 -1
- package/lib/DependencyTemplates.js +4 -0
- package/lib/DotenvPlugin.js +3 -0
- package/lib/DynamicEntryPlugin.js +3 -1
- package/lib/EntryOptionPlugin.js +3 -0
- package/lib/EntryPlugin.js +2 -1
- package/lib/Entrypoint.js +4 -0
- package/lib/EnvironmentPlugin.js +3 -2
- package/lib/ErrorHelpers.js +7 -0
- package/lib/EvalDevToolModulePlugin.js +3 -1
- package/lib/EvalSourceMapDevToolPlugin.js +11 -10
- package/lib/ExportsInfo.js +56 -2
- package/lib/ExportsInfoApiPlugin.js +2 -1
- package/lib/ExternalModule.js +114 -15
- package/lib/ExternalModuleFactoryPlugin.js +15 -0
- package/lib/ExternalsPlugin.js +2 -1
- package/lib/FileSystemInfo.js +291 -71
- package/lib/FlagAllModulesAsUsedPlugin.js +2 -1
- package/lib/FlagDependencyExportsPlugin.js +4 -1
- package/lib/FlagDependencyUsagePlugin.js +5 -1
- package/lib/FlagEntryExportAsUsedPlugin.js +2 -1
- package/lib/Generator.js +16 -3
- package/lib/HotModuleReplacementPlugin.js +35 -9
- package/lib/IgnorePlugin.js +4 -2
- package/lib/IgnoreWarningsPlugin.js +2 -1
- package/lib/InitFragment.js +10 -0
- package/lib/JavascriptMetaInfoPlugin.js +2 -1
- package/lib/LibraryTemplatePlugin.js +2 -1
- package/lib/LoaderOptionsPlugin.js +3 -1
- package/lib/LoaderTargetPlugin.js +2 -1
- package/lib/MainTemplate.js +15 -0
- package/lib/ManifestPlugin.js +9 -2
- package/lib/Module.js +101 -19
- package/lib/ModuleFactory.js +6 -1
- package/lib/ModuleFilenameHelpers.js +3 -0
- package/lib/ModuleGraph.js +66 -0
- package/lib/ModuleGraphConnection.js +9 -0
- package/lib/ModuleInfoHeaderPlugin.js +5 -0
- package/lib/ModuleSourceTypeConstants.js +32 -1
- package/lib/ModuleTemplate.js +8 -0
- package/lib/ModuleTypeConstants.js +12 -3
- package/lib/MultiCompiler.js +30 -2
- package/lib/MultiStats.js +8 -0
- package/lib/MultiWatching.js +3 -0
- package/lib/NoEmitOnErrorsPlugin.js +1 -1
- package/lib/NodeStuffPlugin.js +11 -2
- package/lib/NormalModule.js +43 -33
- package/lib/NormalModuleFactory.js +35 -2
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/NullFactory.js +1 -0
- package/lib/OptionsApply.js +1 -0
- package/lib/Parser.js +3 -1
- package/lib/PlatformPlugin.js +2 -1
- package/lib/PrefetchPlugin.js +2 -1
- package/lib/ProgressPlugin.js +158 -68
- package/lib/ProvidePlugin.js +3 -1
- package/lib/RawModule.js +12 -0
- package/lib/RecordIdsPlugin.js +8 -0
- package/lib/RequestShortener.js +8 -0
- package/lib/ResolverFactory.js +5 -0
- package/lib/RuntimeGlobals.js +6 -5
- package/lib/RuntimeModule.js +22 -7
- package/lib/RuntimePlugin.js +13 -0
- package/lib/RuntimeTemplate.js +35 -1
- package/lib/SelfModuleFactory.js +2 -0
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -0
- package/lib/SourceMapDevToolPlugin.js +3 -1
- package/lib/Stats.js +5 -0
- package/lib/Template.js +20 -0
- package/lib/TemplatedPathPlugin.js +10 -3
- package/lib/UseStrictPlugin.js +2 -1
- package/lib/WarnCaseSensitiveModulesPlugin.js +71 -3
- package/lib/WarnDeprecatedOptionPlugin.js +2 -2
- package/lib/WarnNoModeSetPlugin.js +17 -2
- package/lib/WatchIgnorePlugin.js +4 -1
- package/lib/Watching.js +16 -3
- package/lib/WebpackError.js +3 -74
- package/lib/WebpackIsIncludedPlugin.js +3 -1
- package/lib/WebpackOptionsApply.js +14 -1
- package/lib/WebpackOptionsDefaulter.js +1 -0
- package/lib/asset/AssetBytesGenerator.js +12 -2
- package/lib/asset/AssetBytesParser.js +1 -0
- package/lib/asset/AssetGenerator.js +42 -10
- package/lib/asset/AssetModulesPlugin.js +7 -2
- package/lib/asset/AssetParser.js +2 -0
- package/lib/asset/AssetSourceGenerator.js +12 -2
- package/lib/asset/AssetSourceParser.js +1 -0
- package/lib/asset/RawDataUrlModule.js +11 -0
- package/lib/async-modules/AsyncModuleHelpers.js +1 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -0
- package/lib/async-modules/InferAsyncModulesPlugin.js +1 -1
- package/lib/buildChunkGraph.js +19 -6
- package/lib/cache/AddBuildDependenciesPlugin.js +2 -1
- package/lib/cache/AddManagedPathsPlugin.js +2 -1
- package/lib/cache/IdleFileCachePlugin.js +2 -1
- package/lib/cache/MemoryCachePlugin.js +1 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +3 -1
- package/lib/cache/PackFileCacheStrategy.js +33 -4
- package/lib/cache/ResolverCachePlugin.js +10 -1
- package/lib/cache/getLazyHashedEtag.js +4 -0
- package/lib/cache/mergeEtags.js +2 -0
- package/lib/cli.js +33 -1
- package/lib/config/browserslistTargetHandler.js +2 -0
- package/lib/config/defaults.js +232 -12
- package/lib/config/normalization.js +15 -1
- package/lib/config/target.js +11 -0
- package/lib/container/ContainerEntryDependency.js +2 -0
- package/lib/container/ContainerEntryModule.js +12 -0
- package/lib/container/ContainerEntryModuleFactory.js +1 -0
- package/lib/container/ContainerExposedDependency.js +4 -0
- package/lib/container/ContainerPlugin.js +2 -1
- package/lib/container/ContainerReferencePlugin.js +2 -1
- package/lib/container/FallbackDependency.js +4 -0
- package/lib/container/FallbackItemDependency.js +1 -0
- package/lib/container/FallbackModule.js +12 -0
- package/lib/container/FallbackModuleFactory.js +1 -0
- package/lib/container/ModuleFederationPlugin.js +3 -1
- package/lib/container/RemoteModule.js +13 -0
- package/lib/container/RemoteRuntimeModule.js +1 -0
- package/lib/container/RemoteToExternalDependency.js +1 -0
- package/lib/container/options.js +7 -0
- package/lib/css/CssGenerator.js +336 -100
- package/lib/css/CssInjectStyleRuntimeModule.js +45 -42
- package/lib/css/CssLoadingRuntimeModule.js +23 -4
- package/lib/{CssModule.js → css/CssModule.js} +21 -15
- package/lib/css/CssModulesPlugin.js +235 -89
- package/lib/css/CssParser.js +616 -261
- package/lib/css/walkCssTokens.js +179 -2
- package/lib/debug/ProfilingPlugin.js +19 -1
- package/lib/dependencies/AMDDefineDependency.js +7 -0
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -0
- package/lib/dependencies/AMDPlugin.js +4 -1
- package/lib/dependencies/AMDRequireArrayDependency.js +6 -0
- package/lib/dependencies/AMDRequireContextDependency.js +3 -0
- package/lib/dependencies/AMDRequireDependenciesBlock.js +1 -0
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +14 -1
- package/lib/dependencies/AMDRequireDependency.js +4 -0
- package/lib/dependencies/AMDRequireItemDependency.js +1 -0
- package/lib/dependencies/AMDRuntimeModules.js +3 -0
- package/lib/dependencies/CachedConstDependency.js +6 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +64 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +62 -10
- package/lib/dependencies/CommonJsExportsDependency.js +4 -0
- package/lib/dependencies/CommonJsExportsParserPlugin.js +9 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +36 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +24 -3
- package/lib/dependencies/CommonJsPlugin.js +4 -1
- package/lib/dependencies/CommonJsRequireContextDependency.js +3 -0
- package/lib/dependencies/CommonJsRequireDependency.js +70 -4
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +5 -0
- package/lib/dependencies/ConstDependency.js +6 -1
- package/lib/dependencies/ContextDependency.js +9 -2
- package/lib/dependencies/ContextDependencyHelpers.js +4 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/ContextElementDependency.js +4 -0
- package/lib/dependencies/CreateRequireParserPlugin.js +7 -1
- package/lib/dependencies/CreateScriptUrlDependency.js +4 -0
- package/lib/dependencies/CriticalDependencyWarning.js +2 -1
- package/lib/dependencies/CssIcssExportDependency.js +339 -66
- package/lib/dependencies/CssIcssImportDependency.js +53 -8
- package/lib/dependencies/CssIcssSymbolDependency.js +16 -4
- package/lib/dependencies/CssImportDependency.js +12 -0
- package/lib/dependencies/CssUrlDependency.js +32 -0
- package/lib/dependencies/DelegatedSourceDependency.js +1 -0
- package/lib/dependencies/DllEntryDependency.js +3 -0
- package/lib/dependencies/DynamicExports.js +5 -0
- package/lib/dependencies/EntryDependency.js +1 -0
- package/lib/dependencies/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/ExternalModuleDependency.js +5 -0
- package/lib/dependencies/ExternalModuleInitFragment.js +3 -0
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +4 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +6 -0
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -0
- package/lib/dependencies/HarmonyCompatibilityDependency.js +1 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -0
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +10 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +27 -14
- package/lib/dependencies/HarmonyExportHeaderDependency.js +4 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +143 -5
- package/lib/dependencies/HarmonyExportInitFragment.js +6 -0
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +5 -0
- package/lib/dependencies/HarmonyExports.js +2 -0
- package/lib/dependencies/HarmonyImportDependency.js +21 -2
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +31 -1
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -0
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +18 -3
- package/lib/{HarmonyLinkingError.js → dependencies/HarmonyLinkingError.js} +5 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +4 -1
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +133 -0
- package/lib/dependencies/HtmlInlineStyleDependency.js +101 -0
- package/lib/dependencies/HtmlScriptSrcDependency.js +318 -0
- package/lib/dependencies/HtmlSourceDependency.js +127 -0
- package/lib/dependencies/ImportContextDependency.js +4 -0
- package/lib/dependencies/ImportDependency.js +5 -0
- package/lib/dependencies/ImportEagerDependency.js +2 -0
- package/lib/dependencies/ImportMetaContextDependency.js +1 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -1
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +1 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +6 -0
- package/lib/dependencies/ImportParserPlugin.js +9 -2
- package/lib/dependencies/ImportPhase.js +7 -3
- package/lib/dependencies/ImportPlugin.js +2 -1
- package/lib/dependencies/ImportWeakDependency.js +2 -0
- package/lib/dependencies/JsonExportsDependency.js +6 -1
- package/lib/dependencies/LoaderDependency.js +2 -0
- package/lib/dependencies/LoaderImportDependency.js +2 -0
- package/lib/dependencies/LoaderPlugin.js +4 -1
- package/lib/dependencies/LocalModule.js +4 -0
- package/lib/dependencies/LocalModuleDependency.js +4 -0
- package/lib/dependencies/LocalModulesHelpers.js +3 -0
- package/lib/dependencies/ModuleDecoratorDependency.js +7 -1
- package/lib/dependencies/ModuleDependency.js +7 -0
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +4 -0
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/PrefetchDependency.js +1 -0
- package/lib/dependencies/ProvidedDependency.js +6 -1
- package/lib/dependencies/PureExpressionDependency.js +7 -1
- package/lib/dependencies/RequireContextDependency.js +1 -0
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +2 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +1 -0
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -0
- package/lib/dependencies/RequireEnsureDependency.js +4 -0
- package/lib/dependencies/RequireEnsureItemDependency.js +1 -0
- package/lib/dependencies/RequireEnsurePlugin.js +2 -1
- package/lib/dependencies/RequireHeaderDependency.js +4 -0
- package/lib/dependencies/RequireIncludeDependency.js +2 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +4 -1
- package/lib/dependencies/RequireIncludePlugin.js +2 -1
- package/lib/{RequireJsStuffPlugin.js → dependencies/RequireJsStuffPlugin.js} +9 -8
- package/lib/dependencies/RequireResolveContextDependency.js +3 -0
- package/lib/dependencies/RequireResolveDependency.js +1 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +5 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +5 -1
- package/lib/dependencies/StaticExportsDependency.js +3 -0
- package/lib/dependencies/SystemPlugin.js +5 -2
- package/lib/dependencies/SystemRuntimeModule.js +1 -0
- package/lib/dependencies/URLContextDependency.js +3 -0
- package/lib/dependencies/URLDependency.js +6 -0
- package/lib/dependencies/URLPlugin.js +2 -0
- package/lib/dependencies/UnsupportedDependency.js +4 -0
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +4 -0
- package/lib/dependencies/WebAssemblyImportDependency.js +5 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -0
- package/lib/dependencies/WorkerDependency.js +6 -1
- package/lib/dependencies/WorkerPlugin.js +11 -3
- package/lib/dependencies/getFunctionExpression.js +1 -0
- package/lib/dependencies/processExportInfo.js +1 -0
- package/lib/{DelegatedModule.js → dll/DelegatedModule.js} +44 -31
- package/lib/{DelegatedModuleFactoryPlugin.js → dll/DelegatedModuleFactoryPlugin.js} +7 -4
- package/lib/{DelegatedPlugin.js → dll/DelegatedPlugin.js} +4 -3
- package/lib/{DllEntryPlugin.js → dll/DllEntryPlugin.js} +6 -5
- package/lib/{DllModule.js → dll/DllModule.js} +35 -24
- package/lib/{DllModuleFactory.js → dll/DllModuleFactory.js} +5 -4
- package/lib/{DllPlugin.js → dll/DllPlugin.js} +8 -6
- package/lib/{DllReferencePlugin.js → dll/DllReferencePlugin.js} +23 -18
- package/lib/{LibManifestPlugin.js → dll/LibManifestPlugin.js} +13 -10
- package/lib/electron/ElectronTargetPlugin.js +2 -1
- package/lib/{AbstractMethodError.js → errors/AbstractMethodError.js} +10 -1
- package/lib/{AsyncDependencyToInitialChunkError.js → errors/AsyncDependencyToInitialChunkError.js} +8 -3
- package/lib/errors/BuildCycleError.js +1 -1
- package/lib/{ChunkRenderError.js → errors/ChunkRenderError.js} +1 -1
- package/lib/{CodeGenerationError.js → errors/CodeGenerationError.js} +1 -1
- package/lib/{CommentCompilationWarning.js → errors/CommentCompilationWarning.js} +9 -3
- package/lib/{ConcurrentCompilationError.js → errors/ConcurrentCompilationError.js} +4 -2
- package/lib/{EnvironmentNotSupportAsyncWarning.js → errors/EnvironmentNotSupportAsyncWarning.js} +4 -4
- package/lib/{HookWebpackError.js → errors/HookWebpackError.js} +11 -5
- package/lib/{IgnoreErrorModuleFactory.js → errors/IgnoreErrorModuleFactory.js} +6 -4
- package/lib/{InvalidDependenciesModuleWarning.js → errors/InvalidDependenciesModuleWarning.js} +4 -3
- package/lib/errors/JSONParseError.js +114 -0
- package/lib/{ModuleBuildError.js → errors/ModuleBuildError.js} +8 -5
- package/lib/{ModuleDependencyError.js → errors/ModuleDependencyError.js} +2 -2
- package/lib/{ModuleDependencyWarning.js → errors/ModuleDependencyWarning.js} +5 -4
- package/lib/{ModuleError.js → errors/ModuleError.js} +7 -5
- package/lib/{ModuleHashingError.js → errors/ModuleHashingError.js} +1 -1
- package/lib/{ModuleNotFoundError.js → errors/ModuleNotFoundError.js} +3 -2
- package/lib/{ModuleParseError.js → errors/ModuleParseError.js} +11 -6
- package/lib/{ModuleRestoreError.js → errors/ModuleRestoreError.js} +2 -1
- package/lib/{ModuleStoreError.js → errors/ModuleStoreError.js} +2 -1
- package/lib/{ModuleWarning.js → errors/ModuleWarning.js} +8 -5
- package/lib/{NodeStuffInWebError.js → errors/NodeStuffInWebError.js} +5 -4
- package/lib/errors/NonErrorEmittedError.js +28 -0
- package/lib/{UnhandledSchemeError.js → errors/UnhandledSchemeError.js} +8 -2
- package/lib/{UnsupportedFeatureWarning.js → errors/UnsupportedFeatureWarning.js} +4 -3
- package/lib/errors/WebpackError.js +84 -0
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +2 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +5 -1
- package/lib/esm/ModuleChunkLoadingPlugin.js +3 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +5 -0
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +20 -1
- package/lib/hmr/lazyCompilationBackend.js +2 -0
- package/lib/html/HtmlGenerator.js +379 -0
- package/lib/html/HtmlModulesPlugin.js +433 -0
- package/lib/html/HtmlParser.js +1489 -0
- package/lib/html/walkHtmlTokens.js +2733 -0
- package/lib/ids/ChunkModuleIdRangePlugin.js +3 -1
- package/lib/ids/DeterministicChunkIdsPlugin.js +3 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +3 -1
- package/lib/ids/HashedModuleIdsPlugin.js +2 -1
- package/lib/ids/IdHelpers.js +22 -1
- package/lib/ids/NamedChunkIdsPlugin.js +3 -1
- package/lib/ids/NamedModuleIdsPlugin.js +3 -1
- package/lib/ids/NaturalChunkIdsPlugin.js +1 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -1
- package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -1
- package/lib/ids/SyncModuleIdsPlugin.js +3 -1
- package/lib/index.js +39 -15
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -1
- package/lib/javascript/BasicEvaluatedExpression.js +4 -2
- package/lib/javascript/ChunkFormatHelpers.js +2 -1
- package/lib/javascript/ChunkHelpers.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/EnableChunkLoadingPlugin.js +5 -1
- package/lib/javascript/JavascriptGenerator.js +10 -0
- package/lib/javascript/JavascriptModulesPlugin.js +112 -9
- package/lib/javascript/JavascriptParser.js +360 -16
- package/lib/javascript/JavascriptParserHelpers.js +7 -1
- package/lib/javascript/StartupHelpers.js +5 -0
- package/lib/json/JsonData.js +5 -0
- package/lib/json/JsonGenerator.js +21 -0
- package/lib/json/JsonModulesPlugin.js +1 -1
- package/lib/json/JsonParser.js +14 -25
- package/lib/library/AbstractLibraryPlugin.js +17 -2
- package/lib/library/AmdLibraryPlugin.js +8 -0
- package/lib/library/AssignLibraryPlugin.js +16 -0
- package/lib/library/EnableLibraryPlugin.js +8 -2
- package/lib/library/ExportPropertyLibraryPlugin.js +9 -0
- package/lib/{FalseIIFEUmdWarning.js → library/FalseIIFEUmdWarning.js} +1 -1
- package/lib/library/JsonpLibraryPlugin.js +8 -0
- package/lib/library/ModuleLibraryPlugin.js +86 -1
- package/lib/library/SystemLibraryPlugin.js +8 -0
- package/lib/library/UmdLibraryPlugin.js +16 -0
- package/lib/logging/Logger.js +17 -0
- package/lib/logging/createConsoleLogger.js +7 -0
- package/lib/logging/runtime.js +2 -0
- package/lib/logging/truncateArgs.js +2 -0
- package/lib/node/CommonJsChunkLoadingPlugin.js +5 -1
- package/lib/node/NodeEnvironmentPlugin.js +7 -3
- package/lib/node/NodeSourcePlugin.js +1 -1
- package/lib/node/NodeTargetPlugin.js +2 -1
- package/lib/node/NodeTemplatePlugin.js +3 -1
- package/lib/node/NodeWatchFileSystem.js +2 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +3 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +4 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +4 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +3 -0
- package/lib/node/nodeConsole.js +116 -64
- package/lib/optimize/AggressiveMergingPlugin.js +3 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +6 -1
- package/lib/optimize/ConcatenatedModule.js +62 -6
- package/lib/optimize/EnsureChunkConditionsPlugin.js +2 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +2 -1
- package/lib/optimize/InnerGraph.js +16 -1
- package/lib/optimize/InnerGraphPlugin.js +14 -2
- package/lib/optimize/LimitChunkCountPlugin.js +9 -0
- package/lib/optimize/MangleExportsPlugin.js +5 -1
- package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -0
- package/lib/optimize/MinChunkSizePlugin.js +2 -1
- package/lib/optimize/MinMaxSizeWarning.js +5 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +36 -8
- package/lib/optimize/RealContentHashPlugin.js +104 -26
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -1
- package/lib/optimize/RuntimeChunkPlugin.js +2 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +118 -4
- package/lib/optimize/SplitChunksPlugin.js +50 -2
- package/lib/performance/AssetsOverSizeLimitWarning.js +3 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +3 -2
- package/lib/performance/NoAsyncChunksWarning.js +5 -3
- package/lib/performance/SizeLimitsPlugin.js +8 -2
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +1 -0
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +6 -0
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +1 -0
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +5 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -0
- package/lib/rules/BasicEffectRulePlugin.js +3 -0
- package/lib/rules/BasicMatcherRulePlugin.js +3 -0
- package/lib/rules/ObjectMatcherRulePlugin.js +3 -0
- package/lib/rules/RuleSetCompiler.js +18 -0
- package/lib/rules/UseEffectRulePlugin.js +10 -3
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
- package/lib/runtime/AutoPublicPathRuntimeModule.js +1 -0
- package/lib/runtime/BaseUriRuntimeModule.js +1 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +1 -0
- package/lib/runtime/CompatRuntimeModule.js +2 -0
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -0
- package/lib/runtime/CreateScriptRuntimeModule.js +1 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +1 -0
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +1 -0
- package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -0
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
- package/lib/runtime/GlobalRuntimeModule.js +1 -0
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +1 -0
- package/lib/runtime/HelperRuntimeModule.js +5 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +1 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +121 -13
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +1 -0
- package/lib/runtime/NonceRuntimeModule.js +1 -0
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +1 -0
- package/lib/runtime/PublicPathRuntimeModule.js +1 -0
- package/lib/runtime/RelativeUrlRuntimeModule.js +1 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +1 -0
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +35 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +13 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
- package/lib/runtime/SystemContextRuntimeModule.js +1 -0
- package/lib/runtime/ToBinaryRuntimeModule.js +1 -0
- package/lib/schemes/DataUriPlugin.js +14 -2
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +43 -1
- package/lib/schemes/VirtualUrlPlugin.js +7 -2
- package/lib/serialization/AggregateErrorSerializer.js +2 -0
- package/lib/serialization/ArraySerializer.js +2 -0
- package/lib/serialization/BinaryMiddleware.js +20 -1
- package/lib/serialization/DateObjectSerializer.js +2 -0
- package/lib/serialization/ErrorObjectSerializer.js +3 -0
- package/lib/serialization/FileMiddleware.js +21 -0
- package/lib/serialization/MapObjectSerializer.js +2 -0
- package/lib/serialization/NullPrototypeObjectSerializer.js +2 -0
- package/lib/serialization/ObjectMiddleware.js +23 -0
- package/lib/serialization/PlainObjectSerializer.js +7 -0
- package/lib/serialization/RegExpObjectSerializer.js +2 -0
- package/lib/serialization/Serializer.js +5 -0
- package/lib/serialization/SerializerMiddleware.js +14 -2
- package/lib/serialization/SetObjectSerializer.js +2 -0
- package/lib/serialization/SingleItemMiddleware.js +3 -0
- package/lib/sharing/ConsumeSharedFallbackDependency.js +1 -0
- package/lib/sharing/ConsumeSharedModule.js +15 -0
- package/lib/sharing/ConsumeSharedPlugin.js +8 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -4
- package/lib/sharing/ProvideForSharedDependency.js +1 -0
- package/lib/sharing/ProvideSharedDependency.js +4 -0
- package/lib/sharing/ProvideSharedModule.js +12 -1
- package/lib/sharing/ProvideSharedModuleFactory.js +1 -0
- package/lib/sharing/ProvideSharedPlugin.js +5 -2
- package/lib/sharing/SharePlugin.js +2 -1
- package/lib/sharing/ShareRuntimeModule.js +1 -0
- package/lib/sharing/resolveMatchedConfigs.js +4 -1
- package/lib/sharing/utils.js +8 -0
- package/lib/stats/DefaultStatsFactoryPlugin.js +58 -3
- package/lib/stats/DefaultStatsPresetPlugin.js +12 -2
- package/lib/stats/DefaultStatsPrinterPlugin.js +38 -2
- package/lib/stats/StatsFactory.js +13 -1
- package/lib/stats/StatsPrinter.js +7 -0
- package/lib/typescript/TypeScriptPlugin.js +210 -0
- package/lib/url/URLParserPlugin.js +8 -2
- package/lib/util/AppendOnlyStackedSet.js +15 -0
- package/lib/util/ArrayHelpers.js +1 -0
- package/lib/util/ArrayQueue.js +10 -5
- package/lib/util/AsyncQueue.js +22 -2
- package/lib/util/Hash.js +2 -2
- package/lib/util/IterableHelpers.js +3 -0
- package/lib/util/LazyBucketSortedSet.js +21 -0
- package/lib/util/LazySet.js +39 -0
- package/lib/util/LocConverter.js +53 -0
- package/lib/util/ParallelismFactorCalculator.js +1 -0
- package/lib/util/Queue.js +6 -3
- package/lib/util/Semaphore.js +14 -1
- package/lib/util/SetHelpers.js +3 -0
- package/lib/util/SortableSet.js +7 -1
- package/lib/util/StackedCacheMap.js +20 -3
- package/lib/util/StackedMap.js +45 -0
- package/lib/util/StringXor.js +1 -1
- package/lib/util/TupleQueue.js +7 -3
- package/lib/util/TupleSet.js +13 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -0
- package/lib/util/WeakTupleMap.js +33 -0
- package/lib/util/binarySearchBounds.js +1 -0
- package/lib/util/cleverMerge.js +19 -2
- package/lib/util/comparators.js +34 -3
- package/lib/util/compileBooleanMatcher.js +9 -0
- package/lib/util/concatenate.js +9 -3
- package/lib/util/conventions.js +46 -1
- package/lib/util/createMappings.js +118 -0
- package/lib/util/dataURL.js +1 -0
- package/lib/util/deprecation.js +19 -0
- package/lib/util/deterministicGrouping.js +20 -0
- package/lib/util/extractSourceMap.js +1 -0
- package/lib/util/extractUrlAndGlobal.js +1 -0
- package/lib/util/findGraphRoots.js +5 -0
- package/lib/{formatLocation.js → util/formatLocation.js} +4 -2
- package/lib/{SizeFormatHelpers.js → util/formatSize.js} +4 -1
- package/lib/util/fs.js +71 -8
- package/lib/util/generateDebugId.js +1 -0
- package/lib/util/hash/BatchedHash.js +1 -0
- package/lib/util/hash/BulkUpdateHash.js +1 -0
- package/lib/util/hash/hash-digest.js +8 -0
- package/lib/util/hash/md4.js +1 -1
- package/lib/util/hash/wasm-hash.js +5 -0
- package/lib/util/hash/xxhash64.js +1 -1
- package/lib/util/identifier.js +67 -0
- package/lib/util/internalSerializables.js +35 -19
- package/lib/util/magicComment.js +10 -6
- package/lib/util/makeSerializable.js +6 -0
- package/lib/util/memoize.js +2 -0
- package/lib/util/mimeTypes.js +176 -0
- package/lib/util/nonNumericOnlyHash.js +1 -0
- package/lib/util/parseJson.js +41 -0
- package/lib/util/processAsyncTree.js +8 -0
- package/lib/util/property.js +1 -0
- package/lib/util/registerExternalSerializer.js +20 -0
- package/lib/util/removeBOM.js +1 -0
- package/lib/util/runtime.js +32 -0
- package/lib/util/semver.js +15 -0
- package/lib/util/serialization.js +2 -0
- package/lib/util/smartGrouping.js +8 -0
- package/lib/util/source.js +23 -0
- package/lib/util/topologicalSort.js +69 -0
- package/lib/validateSchema.js +1 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +15 -1
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +1 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +1 -0
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +12 -3
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +12 -1
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +6 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +1 -0
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +26 -1
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +7 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +4 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +10 -1
- package/lib/wasm-sync/WebAssemblyParser.js +2 -0
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -0
- package/lib/web/FetchCompileAsyncWasmPlugin.js +10 -1
- package/lib/web/FetchCompileWasmPlugin.js +13 -1
- package/lib/web/JsonpChunkLoadingPlugin.js +11 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
- package/lib/web/JsonpTemplatePlugin.js +2 -1
- package/lib/webpack.js +13 -1
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +10 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -0
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -1
- package/package.json +31 -31
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +161 -57
- package/schemas/plugins/{DllPlugin.check.d.ts → HtmlGeneratorOptions.check.d.ts} +1 -1
- package/schemas/plugins/HtmlGeneratorOptions.check.js +6 -0
- package/schemas/plugins/HtmlGeneratorOptions.json +3 -0
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +22 -0
- package/schemas/plugins/{DllReferencePlugin.check.d.ts → css/CssAutoOrModuleParserOptions.check.d.ts} +1 -1
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.json +3 -0
- package/schemas/plugins/dll/DllPlugin.check.d.ts +7 -0
- package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +7 -0
- package/types.d.ts +5325 -353
- package/lib/CaseSensitiveModulesWarning.js +0 -72
- package/lib/GraphHelpers.js +0 -46
- package/lib/NoModeWarning.js +0 -23
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +0 -56
- /package/schemas/plugins/{DllPlugin.check.js → dll/DllPlugin.check.js} +0 -0
- /package/schemas/plugins/{DllPlugin.json → dll/DllPlugin.json} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.check.js → dll/DllReferencePlugin.check.js} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.json → dll/DllReferencePlugin.json} +0 -0
package/lib/FileSystemInfo.js
CHANGED
|
@@ -20,19 +20,21 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|
|
20
20
|
|
|
21
21
|
/** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
|
|
22
22
|
/** @typedef {import("enhanced-resolve").ResolveFunctionAsync} ResolveFunctionAsync */
|
|
23
|
-
/** @typedef {import("./WebpackError")} WebpackError */
|
|
24
|
-
/** @typedef {import("./logging/Logger").Logger} Logger */
|
|
25
|
-
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
26
|
-
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
27
23
|
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
|
24
|
+
/** @typedef {import("./logging/Logger").Logger} Logger */
|
|
25
|
+
/** @typedef {import("./errors/WebpackError")} WebpackError */
|
|
28
26
|
/** @typedef {import("./util/fs").JsonObject} JsonObject */
|
|
29
27
|
/** @typedef {import("./util/fs").IStats} IStats */
|
|
30
28
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
29
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
30
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
31
31
|
/**
|
|
32
|
+
* Defines the processor callback type used by this module.
|
|
32
33
|
* @template T
|
|
33
34
|
* @typedef {import("./util/AsyncQueue").Callback<T>} ProcessorCallback
|
|
34
35
|
*/
|
|
35
36
|
/**
|
|
37
|
+
* Defines the processor type used by this module.
|
|
36
38
|
* @template T, R
|
|
37
39
|
* @typedef {import("./util/AsyncQueue").Processor<T, R>} Processor
|
|
38
40
|
*/
|
|
@@ -66,12 +68,14 @@ const INVALID = Symbol("invalid");
|
|
|
66
68
|
/** @typedef {{ }} ExistenceOnlyTimeEntry */
|
|
67
69
|
|
|
68
70
|
/**
|
|
71
|
+
* Defines the file system info entry type used by this module.
|
|
69
72
|
* @typedef {object} FileSystemInfoEntry
|
|
70
73
|
* @property {number} safeTime
|
|
71
74
|
* @property {number=} timestamp
|
|
72
75
|
*/
|
|
73
76
|
|
|
74
77
|
/**
|
|
78
|
+
* Defines the resolved context file system info entry type used by this module.
|
|
75
79
|
* @typedef {object} ResolvedContextFileSystemInfoEntry
|
|
76
80
|
* @property {number} safeTime
|
|
77
81
|
* @property {string=} timestampHash
|
|
@@ -80,6 +84,7 @@ const INVALID = Symbol("invalid");
|
|
|
80
84
|
/** @typedef {Set<string>} Symlinks */
|
|
81
85
|
|
|
82
86
|
/**
|
|
87
|
+
* Defines the context file system info entry type used by this module.
|
|
83
88
|
* @typedef {object} ContextFileSystemInfoEntry
|
|
84
89
|
* @property {number} safeTime
|
|
85
90
|
* @property {string=} timestampHash
|
|
@@ -88,6 +93,7 @@ const INVALID = Symbol("invalid");
|
|
|
88
93
|
*/
|
|
89
94
|
|
|
90
95
|
/**
|
|
96
|
+
* Defines the timestamp and hash type used by this module.
|
|
91
97
|
* @typedef {object} TimestampAndHash
|
|
92
98
|
* @property {number} safeTime
|
|
93
99
|
* @property {number=} timestamp
|
|
@@ -95,6 +101,7 @@ const INVALID = Symbol("invalid");
|
|
|
95
101
|
*/
|
|
96
102
|
|
|
97
103
|
/**
|
|
104
|
+
* Defines the resolved context timestamp and hash type used by this module.
|
|
98
105
|
* @typedef {object} ResolvedContextTimestampAndHash
|
|
99
106
|
* @property {number} safeTime
|
|
100
107
|
* @property {string=} timestampHash
|
|
@@ -102,6 +109,7 @@ const INVALID = Symbol("invalid");
|
|
|
102
109
|
*/
|
|
103
110
|
|
|
104
111
|
/**
|
|
112
|
+
* Defines the context timestamp and hash type used by this module.
|
|
105
113
|
* @typedef {object} ContextTimestampAndHash
|
|
106
114
|
* @property {number} safeTime
|
|
107
115
|
* @property {string=} timestampHash
|
|
@@ -111,6 +119,7 @@ const INVALID = Symbol("invalid");
|
|
|
111
119
|
*/
|
|
112
120
|
|
|
113
121
|
/**
|
|
122
|
+
* Defines the context hash type used by this module.
|
|
114
123
|
* @typedef {object} ContextHash
|
|
115
124
|
* @property {string} hash
|
|
116
125
|
* @property {string=} resolved
|
|
@@ -120,6 +129,7 @@ const INVALID = Symbol("invalid");
|
|
|
120
129
|
/** @typedef {Set<string>} SnapshotContent */
|
|
121
130
|
|
|
122
131
|
/**
|
|
132
|
+
* Defines the snapshot optimization entry type used by this module.
|
|
123
133
|
* @typedef {object} SnapshotOptimizationEntry
|
|
124
134
|
* @property {Snapshot} snapshot
|
|
125
135
|
* @property {number} shared
|
|
@@ -134,6 +144,7 @@ const INVALID = Symbol("invalid");
|
|
|
134
144
|
/** @typedef {Set<string>} Missing */
|
|
135
145
|
|
|
136
146
|
/**
|
|
147
|
+
* Defines the resolve dependencies type used by this module.
|
|
137
148
|
* @typedef {object} ResolveDependencies
|
|
138
149
|
* @property {Files} files list of files
|
|
139
150
|
* @property {Directories} directories list of directories
|
|
@@ -141,6 +152,7 @@ const INVALID = Symbol("invalid");
|
|
|
141
152
|
*/
|
|
142
153
|
|
|
143
154
|
/**
|
|
155
|
+
* Defines the resolve build dependencies result type used by this module.
|
|
144
156
|
* @typedef {object} ResolveBuildDependenciesResult
|
|
145
157
|
* @property {Files} files list of files
|
|
146
158
|
* @property {Directories} directories list of directories
|
|
@@ -150,6 +162,7 @@ const INVALID = Symbol("invalid");
|
|
|
150
162
|
*/
|
|
151
163
|
|
|
152
164
|
/**
|
|
165
|
+
* Defines the snapshot options type used by this module.
|
|
153
166
|
* @typedef {object} SnapshotOptions
|
|
154
167
|
* @property {boolean=} hash should use hash to snapshot
|
|
155
168
|
* @property {boolean=} timestamp should use timestamp to snapshot
|
|
@@ -163,6 +176,7 @@ const DONE_ITERATOR_RESULT = new Set().keys().next();
|
|
|
163
176
|
|
|
164
177
|
class SnapshotIterator {
|
|
165
178
|
/**
|
|
179
|
+
* Creates an instance of SnapshotIterator.
|
|
166
180
|
* @param {() => IteratorResult<string>} next next
|
|
167
181
|
*/
|
|
168
182
|
constructor(next) {
|
|
@@ -171,15 +185,18 @@ class SnapshotIterator {
|
|
|
171
185
|
}
|
|
172
186
|
|
|
173
187
|
/**
|
|
188
|
+
* Defines the get maps function type used by this module.
|
|
174
189
|
* @template T
|
|
175
190
|
* @typedef {(snapshot: Snapshot) => T[]} GetMapsFunction
|
|
176
191
|
*/
|
|
177
192
|
|
|
178
193
|
/**
|
|
194
|
+
* Represents SnapshotIterable.
|
|
179
195
|
* @template T
|
|
180
196
|
*/
|
|
181
197
|
class SnapshotIterable {
|
|
182
198
|
/**
|
|
199
|
+
* Creates an instance of SnapshotIterable.
|
|
183
200
|
* @param {Snapshot} snapshot snapshot
|
|
184
201
|
* @param {GetMapsFunction<T>} getMaps get maps function
|
|
185
202
|
*/
|
|
@@ -214,7 +231,7 @@ class SnapshotIterable {
|
|
|
214
231
|
const map = maps.pop();
|
|
215
232
|
if (map !== undefined) {
|
|
216
233
|
it =
|
|
217
|
-
/** @type {Set<
|
|
234
|
+
/** @type {Set<string> | Map<string, EXPECTED_ANY>} */
|
|
218
235
|
(map).keys();
|
|
219
236
|
state = 2;
|
|
220
237
|
} else {
|
|
@@ -320,6 +337,7 @@ class Snapshot {
|
|
|
320
337
|
}
|
|
321
338
|
|
|
322
339
|
/**
|
|
340
|
+
* Updates start time using the provided value.
|
|
323
341
|
* @param {number} value start value
|
|
324
342
|
*/
|
|
325
343
|
setStartTime(value) {
|
|
@@ -328,6 +346,7 @@ class Snapshot {
|
|
|
328
346
|
}
|
|
329
347
|
|
|
330
348
|
/**
|
|
349
|
+
* Sets merged start time.
|
|
331
350
|
* @param {number | undefined} value value
|
|
332
351
|
* @param {Snapshot} snapshot snapshot
|
|
333
352
|
*/
|
|
@@ -357,6 +376,7 @@ class Snapshot {
|
|
|
357
376
|
}
|
|
358
377
|
|
|
359
378
|
/**
|
|
379
|
+
* Sets file timestamps.
|
|
360
380
|
* @param {FileTimestamps} value file timestamps
|
|
361
381
|
*/
|
|
362
382
|
setFileTimestamps(value) {
|
|
@@ -369,6 +389,7 @@ class Snapshot {
|
|
|
369
389
|
}
|
|
370
390
|
|
|
371
391
|
/**
|
|
392
|
+
* Updates file hashes using the provided value.
|
|
372
393
|
* @param {FileHashes} value file hashes
|
|
373
394
|
*/
|
|
374
395
|
setFileHashes(value) {
|
|
@@ -381,6 +402,7 @@ class Snapshot {
|
|
|
381
402
|
}
|
|
382
403
|
|
|
383
404
|
/**
|
|
405
|
+
* Updates file tshs using the provided value.
|
|
384
406
|
* @param {FileTshs} value file tshs
|
|
385
407
|
*/
|
|
386
408
|
setFileTshs(value) {
|
|
@@ -393,6 +415,7 @@ class Snapshot {
|
|
|
393
415
|
}
|
|
394
416
|
|
|
395
417
|
/**
|
|
418
|
+
* Sets context timestamps.
|
|
396
419
|
* @param {ContextTimestamps} value context timestamps
|
|
397
420
|
*/
|
|
398
421
|
setContextTimestamps(value) {
|
|
@@ -405,6 +428,7 @@ class Snapshot {
|
|
|
405
428
|
}
|
|
406
429
|
|
|
407
430
|
/**
|
|
431
|
+
* Sets context hashes.
|
|
408
432
|
* @param {ContextHashes} value context hashes
|
|
409
433
|
*/
|
|
410
434
|
setContextHashes(value) {
|
|
@@ -417,6 +441,7 @@ class Snapshot {
|
|
|
417
441
|
}
|
|
418
442
|
|
|
419
443
|
/**
|
|
444
|
+
* Updates context tshs using the provided value.
|
|
420
445
|
* @param {ContextTshs} value context tshs
|
|
421
446
|
*/
|
|
422
447
|
setContextTshs(value) {
|
|
@@ -429,6 +454,7 @@ class Snapshot {
|
|
|
429
454
|
}
|
|
430
455
|
|
|
431
456
|
/**
|
|
457
|
+
* Sets missing existence.
|
|
432
458
|
* @param {MissingExistence} value context tshs
|
|
433
459
|
*/
|
|
434
460
|
setMissingExistence(value) {
|
|
@@ -441,6 +467,7 @@ class Snapshot {
|
|
|
441
467
|
}
|
|
442
468
|
|
|
443
469
|
/**
|
|
470
|
+
* Sets managed item info.
|
|
444
471
|
* @param {ManagedItemInfo} value managed item info
|
|
445
472
|
*/
|
|
446
473
|
setManagedItemInfo(value) {
|
|
@@ -453,6 +480,7 @@ class Snapshot {
|
|
|
453
480
|
}
|
|
454
481
|
|
|
455
482
|
/**
|
|
483
|
+
* Sets managed files.
|
|
456
484
|
* @param {ManagedFiles} value managed files
|
|
457
485
|
*/
|
|
458
486
|
setManagedFiles(value) {
|
|
@@ -465,6 +493,7 @@ class Snapshot {
|
|
|
465
493
|
}
|
|
466
494
|
|
|
467
495
|
/**
|
|
496
|
+
* Sets managed contexts.
|
|
468
497
|
* @param {ManagedContexts} value managed contexts
|
|
469
498
|
*/
|
|
470
499
|
setManagedContexts(value) {
|
|
@@ -477,6 +506,7 @@ class Snapshot {
|
|
|
477
506
|
}
|
|
478
507
|
|
|
479
508
|
/**
|
|
509
|
+
* Sets managed missing.
|
|
480
510
|
* @param {ManagedMissing} value managed missing
|
|
481
511
|
*/
|
|
482
512
|
setManagedMissing(value) {
|
|
@@ -489,6 +519,7 @@ class Snapshot {
|
|
|
489
519
|
}
|
|
490
520
|
|
|
491
521
|
/**
|
|
522
|
+
* Updates children using the provided value.
|
|
492
523
|
* @param {Children} value children
|
|
493
524
|
*/
|
|
494
525
|
setChildren(value) {
|
|
@@ -497,6 +528,7 @@ class Snapshot {
|
|
|
497
528
|
}
|
|
498
529
|
|
|
499
530
|
/**
|
|
531
|
+
* Adds the provided child to the snapshot.
|
|
500
532
|
* @param {Snapshot} child children
|
|
501
533
|
*/
|
|
502
534
|
addChild(child) {
|
|
@@ -508,6 +540,7 @@ class Snapshot {
|
|
|
508
540
|
}
|
|
509
541
|
|
|
510
542
|
/**
|
|
543
|
+
* Serializes this instance into the provided serializer context.
|
|
511
544
|
* @param {ObjectSerializerContext} context context
|
|
512
545
|
*/
|
|
513
546
|
serialize({ write }) {
|
|
@@ -528,6 +561,7 @@ class Snapshot {
|
|
|
528
561
|
}
|
|
529
562
|
|
|
530
563
|
/**
|
|
564
|
+
* Restores this instance from the provided deserializer context.
|
|
531
565
|
* @param {ObjectDeserializerContext} context context
|
|
532
566
|
*/
|
|
533
567
|
deserialize({ read }) {
|
|
@@ -548,6 +582,7 @@ class Snapshot {
|
|
|
548
582
|
}
|
|
549
583
|
|
|
550
584
|
/**
|
|
585
|
+
* Creates an iterable from the provided get map.
|
|
551
586
|
* @template T
|
|
552
587
|
* @param {GetMapsFunction<T>} getMaps first
|
|
553
588
|
* @returns {SnapshotIterable<T>} iterable
|
|
@@ -557,6 +592,7 @@ class Snapshot {
|
|
|
557
592
|
}
|
|
558
593
|
|
|
559
594
|
/**
|
|
595
|
+
* Gets file iterable.
|
|
560
596
|
* @returns {Iterable<string>} iterable
|
|
561
597
|
*/
|
|
562
598
|
getFileIterable() {
|
|
@@ -572,6 +608,7 @@ class Snapshot {
|
|
|
572
608
|
}
|
|
573
609
|
|
|
574
610
|
/**
|
|
611
|
+
* Gets context iterable.
|
|
575
612
|
* @returns {Iterable<string>} iterable
|
|
576
613
|
*/
|
|
577
614
|
getContextIterable() {
|
|
@@ -587,6 +624,7 @@ class Snapshot {
|
|
|
587
624
|
}
|
|
588
625
|
|
|
589
626
|
/**
|
|
627
|
+
* Gets missing iterable.
|
|
590
628
|
* @returns {Iterable<string>} iterable
|
|
591
629
|
*/
|
|
592
630
|
getMissingIterable() {
|
|
@@ -605,16 +643,19 @@ makeSerializable(Snapshot, "webpack/lib/FileSystemInfo", "Snapshot");
|
|
|
605
643
|
const MIN_COMMON_SNAPSHOT_SIZE = 3;
|
|
606
644
|
|
|
607
645
|
/**
|
|
646
|
+
* Defines the snapshot optimization value type used by this module.
|
|
608
647
|
* @template U, T
|
|
609
648
|
* @typedef {U extends true ? Set<string> : Map<string, T>} SnapshotOptimizationValue
|
|
610
649
|
*/
|
|
611
650
|
|
|
612
651
|
/**
|
|
652
|
+
* Represents SnapshotOptimization.
|
|
613
653
|
* @template T
|
|
614
654
|
* @template {boolean} [U=false]
|
|
615
655
|
*/
|
|
616
656
|
class SnapshotOptimization {
|
|
617
657
|
/**
|
|
658
|
+
* Creates an instance of SnapshotOptimization.
|
|
618
659
|
* @param {(snapshot: Snapshot) => boolean} has has value
|
|
619
660
|
* @param {(snapshot: Snapshot) => SnapshotOptimizationValue<U, T> | undefined} get get value
|
|
620
661
|
* @param {(snapshot: Snapshot, value: SnapshotOptimizationValue<U, T>) => void} set set value
|
|
@@ -663,6 +704,7 @@ class SnapshotOptimization {
|
|
|
663
704
|
}
|
|
664
705
|
|
|
665
706
|
/**
|
|
707
|
+
* Processes the provided new snapshot.
|
|
666
708
|
* @param {Snapshot} newSnapshot snapshot
|
|
667
709
|
* @param {Set<string>} capturedFiles files to snapshot/share
|
|
668
710
|
* @returns {void}
|
|
@@ -672,6 +714,7 @@ class SnapshotOptimization {
|
|
|
672
714
|
return;
|
|
673
715
|
}
|
|
674
716
|
/**
|
|
717
|
+
* Increase shared and store optimization entry.
|
|
675
718
|
* @param {SnapshotOptimizationEntry} entry optimization entry
|
|
676
719
|
* @returns {void}
|
|
677
720
|
*/
|
|
@@ -685,6 +728,7 @@ class SnapshotOptimization {
|
|
|
685
728
|
storeOptimizationEntry(entry);
|
|
686
729
|
};
|
|
687
730
|
/**
|
|
731
|
+
* Stores optimization entry.
|
|
688
732
|
* @param {SnapshotOptimizationEntry} entry optimization entry
|
|
689
733
|
* @returns {void}
|
|
690
734
|
*/
|
|
@@ -886,6 +930,7 @@ class SnapshotOptimization {
|
|
|
886
930
|
}
|
|
887
931
|
|
|
888
932
|
/**
|
|
933
|
+
* Returns result.
|
|
889
934
|
* @param {string} str input
|
|
890
935
|
* @returns {string} result
|
|
891
936
|
*/
|
|
@@ -898,6 +943,7 @@ const parseString = (str) => {
|
|
|
898
943
|
|
|
899
944
|
/* istanbul ignore next */
|
|
900
945
|
/**
|
|
946
|
+
* Processes the provided mtime.
|
|
901
947
|
* @param {number} mtime mtime
|
|
902
948
|
*/
|
|
903
949
|
const applyMtime = (mtime) => {
|
|
@@ -908,6 +954,7 @@ const applyMtime = (mtime) => {
|
|
|
908
954
|
};
|
|
909
955
|
|
|
910
956
|
/**
|
|
957
|
+
* Merges the provided values into a single result.
|
|
911
958
|
* @template T
|
|
912
959
|
* @template K
|
|
913
960
|
* @param {Map<T, K> | undefined} a source map
|
|
@@ -926,6 +973,7 @@ const mergeMaps = (a, b) => {
|
|
|
926
973
|
};
|
|
927
974
|
|
|
928
975
|
/**
|
|
976
|
+
* Merges the provided values into a single result.
|
|
929
977
|
* @template T
|
|
930
978
|
* @param {Set<T> | undefined} a source map
|
|
931
979
|
* @param {Set<T> | undefined} b joining map
|
|
@@ -1027,6 +1075,7 @@ const getManagedItem = (managedPath, path) => {
|
|
|
1027
1075
|
};
|
|
1028
1076
|
|
|
1029
1077
|
/**
|
|
1078
|
+
* Gets resolved timestamp.
|
|
1030
1079
|
* @template {ContextFileSystemInfoEntry | ContextTimestampAndHash} T
|
|
1031
1080
|
* @param {T | null} entry entry
|
|
1032
1081
|
* @returns {T["resolved"] | null | undefined} the resolved entry
|
|
@@ -1038,6 +1087,7 @@ const getResolvedTimestamp = (entry) => {
|
|
|
1038
1087
|
};
|
|
1039
1088
|
|
|
1040
1089
|
/**
|
|
1090
|
+
* Gets resolved hash.
|
|
1041
1091
|
* @param {ContextHash | null} entry entry
|
|
1042
1092
|
* @returns {string | null | undefined} the resolved entry
|
|
1043
1093
|
*/
|
|
@@ -1048,6 +1098,7 @@ const getResolvedHash = (entry) => {
|
|
|
1048
1098
|
};
|
|
1049
1099
|
|
|
1050
1100
|
/**
|
|
1101
|
+
* Adds the provided source to the snapshot optimization.
|
|
1051
1102
|
* @template T
|
|
1052
1103
|
* @param {Set<T>} source source
|
|
1053
1104
|
* @param {Set<T>} target target
|
|
@@ -1060,10 +1111,26 @@ const getEsModuleLexer = memoize(() => require("es-module-lexer"));
|
|
|
1060
1111
|
|
|
1061
1112
|
/** @typedef {Set<string>} LoggedPaths */
|
|
1062
1113
|
|
|
1063
|
-
/** @typedef {FileSystemInfoEntry | "ignore" | null} FileTimestamp */
|
|
1064
|
-
/** @typedef {ContextFileSystemInfoEntry | "ignore" | null} ContextTimestamp */
|
|
1114
|
+
/** @typedef {FileSystemInfoEntry | ExistenceOnlyTimeEntry | "ignore" | null} FileTimestamp */
|
|
1115
|
+
/** @typedef {ContextFileSystemInfoEntry | ExistenceOnlyTimeEntry | "ignore" | null} ContextTimestamp */
|
|
1065
1116
|
/** @typedef {ResolvedContextFileSystemInfoEntry | "ignore" | null} ResolvedContextTimestamp */
|
|
1066
1117
|
|
|
1118
|
+
/**
|
|
1119
|
+
* `watchpack` may report `{}` (existence-only) for files and directories it
|
|
1120
|
+
* is watching but has no time information for. Such entries cannot be used
|
|
1121
|
+
* for snapshot comparison, so cache lookups treat them as "no cached value"
|
|
1122
|
+
* and fall back to a fresh on-disk read.
|
|
1123
|
+
* @param {FileTimestamp | ContextTimestamp | undefined} entry cache entry
|
|
1124
|
+
* @returns {entry is ExistenceOnlyTimeEntry} true if the entry exists but carries no time info
|
|
1125
|
+
*/
|
|
1126
|
+
const isExistenceOnly = (entry) => {
|
|
1127
|
+
if (entry === undefined || entry === null || entry === "ignore") return false;
|
|
1128
|
+
return (
|
|
1129
|
+
/** @type {Partial<FileSystemInfoEntry> & Partial<ContextFileSystemInfoEntry>} */
|
|
1130
|
+
(entry).safeTime === undefined
|
|
1131
|
+
);
|
|
1132
|
+
};
|
|
1133
|
+
|
|
1067
1134
|
/** @typedef {(err?: WebpackError | null, result?: boolean) => void} CheckSnapshotValidCallback */
|
|
1068
1135
|
|
|
1069
1136
|
/**
|
|
@@ -1071,6 +1138,7 @@ const getEsModuleLexer = memoize(() => require("es-module-lexer"));
|
|
|
1071
1138
|
*/
|
|
1072
1139
|
class FileSystemInfo {
|
|
1073
1140
|
/**
|
|
1141
|
+
* Creates an instance of FileSystemInfo.
|
|
1074
1142
|
* @param {InputFileSystem} fs file system
|
|
1075
1143
|
* @param {object} options options
|
|
1076
1144
|
* @param {Iterable<string | RegExp>=} options.unmanagedPaths paths that are not managed by a package manager and the contents are subject to change
|
|
@@ -1264,6 +1332,7 @@ class FileSystemInfo {
|
|
|
1264
1332
|
logStatistics() {
|
|
1265
1333
|
const logger = /** @type {Logger} */ (this.logger);
|
|
1266
1334
|
/**
|
|
1335
|
+
* Processes the provided header.
|
|
1267
1336
|
* @param {string} header header
|
|
1268
1337
|
* @param {string | undefined} message message
|
|
1269
1338
|
*/
|
|
@@ -1351,6 +1420,7 @@ class FileSystemInfo {
|
|
|
1351
1420
|
}
|
|
1352
1421
|
|
|
1353
1422
|
/**
|
|
1423
|
+
* Processes the provided path.
|
|
1354
1424
|
* @private
|
|
1355
1425
|
* @param {string} path path
|
|
1356
1426
|
* @param {string} reason reason
|
|
@@ -1408,64 +1478,84 @@ class FileSystemInfo {
|
|
|
1408
1478
|
}
|
|
1409
1479
|
|
|
1410
1480
|
/**
|
|
1411
|
-
*
|
|
1481
|
+
* Adds file timestamps.
|
|
1482
|
+
* @param {ReadonlyMap<string, FileTimestamp>} map timestamps
|
|
1412
1483
|
* @param {boolean=} immutable if 'map' is immutable and FileSystemInfo can keep referencing it
|
|
1413
1484
|
* @returns {void}
|
|
1414
1485
|
*/
|
|
1415
1486
|
addFileTimestamps(map, immutable) {
|
|
1416
|
-
this._fileTimestamps.addAll(
|
|
1417
|
-
/** @type {ReadonlyMap<string, FileTimestamp>} */
|
|
1418
|
-
(map),
|
|
1419
|
-
immutable
|
|
1420
|
-
);
|
|
1487
|
+
this._fileTimestamps.addAll(map, immutable);
|
|
1421
1488
|
this._cachedDeprecatedFileTimestamps = undefined;
|
|
1422
1489
|
}
|
|
1423
1490
|
|
|
1424
1491
|
/**
|
|
1425
|
-
*
|
|
1492
|
+
* Adds context timestamps.
|
|
1493
|
+
* @param {ReadonlyMap<string, ContextTimestamp>} map timestamps
|
|
1426
1494
|
* @param {boolean=} immutable if 'map' is immutable and FileSystemInfo can keep referencing it
|
|
1427
1495
|
* @returns {void}
|
|
1428
1496
|
*/
|
|
1429
1497
|
addContextTimestamps(map, immutable) {
|
|
1430
|
-
this._contextTimestamps.addAll(
|
|
1431
|
-
/** @type {ReadonlyMap<string, ContextTimestamp>} */
|
|
1432
|
-
(map),
|
|
1433
|
-
immutable
|
|
1434
|
-
);
|
|
1498
|
+
this._contextTimestamps.addAll(map, immutable);
|
|
1435
1499
|
this._cachedDeprecatedContextTimestamps = undefined;
|
|
1436
1500
|
}
|
|
1437
1501
|
|
|
1438
1502
|
/**
|
|
1503
|
+
* Gets file timestamp.
|
|
1439
1504
|
* @param {string} path file path
|
|
1440
|
-
* @param {(err?: WebpackError | null, fileTimestamp?:
|
|
1505
|
+
* @param {(err?: WebpackError | null, fileTimestamp?: FileSystemInfoEntry | "ignore" | null) => void} callback callback function
|
|
1441
1506
|
* @returns {void}
|
|
1442
1507
|
*/
|
|
1443
1508
|
getFileTimestamp(path, callback) {
|
|
1444
1509
|
const cache = this._fileTimestamps.get(path);
|
|
1445
|
-
if (cache !== undefined
|
|
1510
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
1511
|
+
return callback(
|
|
1512
|
+
null,
|
|
1513
|
+
/** @type {FileSystemInfoEntry | "ignore" | null} */ (cache)
|
|
1514
|
+
);
|
|
1515
|
+
}
|
|
1446
1516
|
this.fileTimestampQueue.add(path, callback);
|
|
1447
1517
|
}
|
|
1448
1518
|
|
|
1449
1519
|
/**
|
|
1520
|
+
* Gets context timestamp.
|
|
1450
1521
|
* @param {string} path context path
|
|
1451
1522
|
* @param {(err?: WebpackError | null, resolvedContextTimestamp?: ResolvedContextTimestamp) => void} callback callback function
|
|
1452
1523
|
* @returns {void}
|
|
1453
1524
|
*/
|
|
1454
1525
|
getContextTimestamp(path, callback) {
|
|
1455
1526
|
const cache = this._contextTimestamps.get(path);
|
|
1456
|
-
if (cache !== undefined) {
|
|
1527
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
1457
1528
|
if (cache === "ignore") return callback(null, "ignore");
|
|
1458
|
-
const
|
|
1529
|
+
const fullEntry =
|
|
1530
|
+
/** @type {ContextFileSystemInfoEntry | null} */
|
|
1531
|
+
(cache);
|
|
1532
|
+
const resolved = getResolvedTimestamp(fullEntry);
|
|
1459
1533
|
if (resolved !== undefined) return callback(null, resolved);
|
|
1460
1534
|
return this._resolveContextTimestamp(
|
|
1461
|
-
/** @type {
|
|
1462
|
-
(
|
|
1535
|
+
/** @type {ContextFileSystemInfoEntry} */
|
|
1536
|
+
(fullEntry),
|
|
1463
1537
|
callback
|
|
1464
1538
|
);
|
|
1465
1539
|
}
|
|
1540
|
+
this._readFreshContextTimestamp(path, callback);
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
/**
|
|
1544
|
+
* Reads a context timestamp directly from disk, bypassing any cached
|
|
1545
|
+
* entry. Used by `getContextTimestamp` and the snapshot validity
|
|
1546
|
+
* checks when the cached entry is missing or is an `ExistenceOnlyTimeEntry`
|
|
1547
|
+
* (`{}`) supplied by watchpack — both cases require a fresh read to
|
|
1548
|
+
* obtain the `timestampHash`.
|
|
1549
|
+
* @private
|
|
1550
|
+
* @param {string} path context path
|
|
1551
|
+
* @param {(err?: WebpackError | null, resolvedContextTimestamp?: ResolvedContextTimestamp) => void} callback callback function
|
|
1552
|
+
* @returns {void}
|
|
1553
|
+
*/
|
|
1554
|
+
_readFreshContextTimestamp(path, callback) {
|
|
1466
1555
|
this.contextTimestampQueue.add(path, (err, _entry) => {
|
|
1467
1556
|
if (err) return callback(err);
|
|
1468
|
-
const entry = /** @type {ContextFileSystemInfoEntry} */ (_entry);
|
|
1557
|
+
const entry = /** @type {ContextFileSystemInfoEntry | null} */ (_entry);
|
|
1558
|
+
if (entry === null) return callback(null, null);
|
|
1469
1559
|
const resolved = getResolvedTimestamp(entry);
|
|
1470
1560
|
if (resolved !== undefined) return callback(null, resolved);
|
|
1471
1561
|
this._resolveContextTimestamp(entry, callback);
|
|
@@ -1473,18 +1563,27 @@ class FileSystemInfo {
|
|
|
1473
1563
|
}
|
|
1474
1564
|
|
|
1475
1565
|
/**
|
|
1566
|
+
* Get unresolved context timestamp. Existence-only cache entries (`{}`)
|
|
1567
|
+
* are bypassed so the callback always receives a complete entry, "ignore"
|
|
1568
|
+
* or null.
|
|
1476
1569
|
* @private
|
|
1477
1570
|
* @param {string} path context path
|
|
1478
|
-
* @param {(err?: WebpackError | null, contextTimestamp?:
|
|
1571
|
+
* @param {(err?: WebpackError | null, contextTimestamp?: ContextFileSystemInfoEntry | "ignore" | null) => void} callback callback function
|
|
1479
1572
|
* @returns {void}
|
|
1480
1573
|
*/
|
|
1481
1574
|
_getUnresolvedContextTimestamp(path, callback) {
|
|
1482
1575
|
const cache = this._contextTimestamps.get(path);
|
|
1483
|
-
if (cache !== undefined
|
|
1576
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
1577
|
+
return callback(
|
|
1578
|
+
null,
|
|
1579
|
+
/** @type {ContextFileSystemInfoEntry | "ignore" | null} */ (cache)
|
|
1580
|
+
);
|
|
1581
|
+
}
|
|
1484
1582
|
this.contextTimestampQueue.add(path, callback);
|
|
1485
1583
|
}
|
|
1486
1584
|
|
|
1487
1585
|
/**
|
|
1586
|
+
* Returns file hash.
|
|
1488
1587
|
* @param {string} path file path
|
|
1489
1588
|
* @param {(err?: WebpackError | null, hash?: string | null) => void} callback callback function
|
|
1490
1589
|
* @returns {void}
|
|
@@ -1496,6 +1595,7 @@ class FileSystemInfo {
|
|
|
1496
1595
|
}
|
|
1497
1596
|
|
|
1498
1597
|
/**
|
|
1598
|
+
* Returns context hash.
|
|
1499
1599
|
* @param {string} path context path
|
|
1500
1600
|
* @param {(err?: WebpackError | null, contextHash?: string) => void} callback callback function
|
|
1501
1601
|
* @returns {void}
|
|
@@ -1521,6 +1621,7 @@ class FileSystemInfo {
|
|
|
1521
1621
|
}
|
|
1522
1622
|
|
|
1523
1623
|
/**
|
|
1624
|
+
* Get unresolved context hash.
|
|
1524
1625
|
* @private
|
|
1525
1626
|
* @param {string} path context path
|
|
1526
1627
|
* @param {(err?: WebpackError | null, contextHash?: ContextHash | null) => void} callback callback function
|
|
@@ -1533,6 +1634,7 @@ class FileSystemInfo {
|
|
|
1533
1634
|
}
|
|
1534
1635
|
|
|
1535
1636
|
/**
|
|
1637
|
+
* Returns context tsh.
|
|
1536
1638
|
* @param {string} path context path
|
|
1537
1639
|
* @param {(err?: WebpackError | null, resolvedContextTimestampAndHash?: ResolvedContextTimestampAndHash | null) => void} callback callback function
|
|
1538
1640
|
* @returns {void}
|
|
@@ -1554,6 +1656,7 @@ class FileSystemInfo {
|
|
|
1554
1656
|
}
|
|
1555
1657
|
|
|
1556
1658
|
/**
|
|
1659
|
+
* Get unresolved context tsh.
|
|
1557
1660
|
* @private
|
|
1558
1661
|
* @param {string} path context path
|
|
1559
1662
|
* @param {(err?: WebpackError | null, contextTimestampAndHash?: ContextTimestampAndHash | null) => void} callback callback function
|
|
@@ -1573,20 +1676,20 @@ class FileSystemInfo {
|
|
|
1573
1676
|
});
|
|
1574
1677
|
const resolveCjs = createResolver({
|
|
1575
1678
|
extensions: [".js", ".json", ".node"],
|
|
1576
|
-
conditionNames: ["require", "node"],
|
|
1679
|
+
conditionNames: ["require", "module-sync", "node"],
|
|
1577
1680
|
exportsFields: ["exports"],
|
|
1578
1681
|
fileSystem: this.fs
|
|
1579
1682
|
});
|
|
1580
1683
|
const resolveCjsAsChild = createResolver({
|
|
1581
1684
|
extensions: [".js", ".json", ".node"],
|
|
1582
|
-
conditionNames: ["require", "node"],
|
|
1685
|
+
conditionNames: ["require", "module-sync", "node"],
|
|
1583
1686
|
exportsFields: [],
|
|
1584
1687
|
fileSystem: this.fs
|
|
1585
1688
|
});
|
|
1586
1689
|
const resolveEsm = createResolver({
|
|
1587
1690
|
extensions: [".js", ".json", ".node"],
|
|
1588
1691
|
fullySpecified: true,
|
|
1589
|
-
conditionNames: ["import", "node"],
|
|
1692
|
+
conditionNames: ["import", "module-sync", "node"],
|
|
1590
1693
|
exportsFields: ["exports"],
|
|
1591
1694
|
fileSystem: this.fs
|
|
1592
1695
|
});
|
|
@@ -1594,6 +1697,7 @@ class FileSystemInfo {
|
|
|
1594
1697
|
}
|
|
1595
1698
|
|
|
1596
1699
|
/**
|
|
1700
|
+
* Resolves build dependencies.
|
|
1597
1701
|
* @param {string} context context directory
|
|
1598
1702
|
* @param {Iterable<string>} deps dependencies
|
|
1599
1703
|
* @param {(err?: Error | null, resolveBuildDependenciesResult?: ResolveBuildDependenciesResult) => void} callback callback function
|
|
@@ -1629,6 +1733,7 @@ class FileSystemInfo {
|
|
|
1629
1733
|
missingDependencies: resolveMissing
|
|
1630
1734
|
};
|
|
1631
1735
|
/**
|
|
1736
|
+
* Expected to string.
|
|
1632
1737
|
* @param {undefined | boolean | string} expected expected result
|
|
1633
1738
|
* @returns {string} expected result
|
|
1634
1739
|
*/
|
|
@@ -1637,6 +1742,7 @@ class FileSystemInfo {
|
|
|
1637
1742
|
/** @typedef {{ type: JobType, context: string | undefined, path: string, issuer: Job | undefined, expected: undefined | boolean | string }} Job */
|
|
1638
1743
|
|
|
1639
1744
|
/**
|
|
1745
|
+
* Returns result.
|
|
1640
1746
|
* @param {Job} job job
|
|
1641
1747
|
* @returns {string} result
|
|
1642
1748
|
*/
|
|
@@ -1666,6 +1772,7 @@ class FileSystemInfo {
|
|
|
1666
1772
|
return `unknown ${job.type} ${job.path}`;
|
|
1667
1773
|
};
|
|
1668
1774
|
/**
|
|
1775
|
+
* Returns string value.
|
|
1669
1776
|
* @param {Job} job job
|
|
1670
1777
|
* @returns {string} string value
|
|
1671
1778
|
*/
|
|
@@ -1696,6 +1803,7 @@ class FileSystemInfo {
|
|
|
1696
1803
|
(job, push, callback) => {
|
|
1697
1804
|
const { type, context, path, expected } = job;
|
|
1698
1805
|
/**
|
|
1806
|
+
* Resolves directory.
|
|
1699
1807
|
* @param {string} path path
|
|
1700
1808
|
* @returns {void}
|
|
1701
1809
|
*/
|
|
@@ -1733,6 +1841,7 @@ class FileSystemInfo {
|
|
|
1733
1841
|
);
|
|
1734
1842
|
};
|
|
1735
1843
|
/**
|
|
1844
|
+
* Processes the provided path.
|
|
1736
1845
|
* @param {string} path path
|
|
1737
1846
|
* @param {("f" | "c" | "e")=} symbol symbol
|
|
1738
1847
|
* @param {(ResolveFunctionAsync)=} resolve resolve fn
|
|
@@ -2128,6 +2237,7 @@ class FileSystemInfo {
|
|
|
2128
2237
|
}
|
|
2129
2238
|
|
|
2130
2239
|
/**
|
|
2240
|
+
* Checks resolve results valid.
|
|
2131
2241
|
* @param {ResolveResults} resolveResults results from resolving
|
|
2132
2242
|
* @param {(err?: Error | null, result?: boolean) => void} callback callback with true when resolveResults resolve the same way
|
|
2133
2243
|
* @returns {void}
|
|
@@ -2191,6 +2301,7 @@ class FileSystemInfo {
|
|
|
2191
2301
|
}
|
|
2192
2302
|
},
|
|
2193
2303
|
/**
|
|
2304
|
+
* Processes the provided err.
|
|
2194
2305
|
* @param {Error | typeof INVALID=} err error or invalid flag
|
|
2195
2306
|
* @returns {void}
|
|
2196
2307
|
*/
|
|
@@ -2209,6 +2320,7 @@ class FileSystemInfo {
|
|
|
2209
2320
|
}
|
|
2210
2321
|
|
|
2211
2322
|
/**
|
|
2323
|
+
* Creates a snapshot.
|
|
2212
2324
|
* @param {number | null | undefined} startTime when processing the files has started
|
|
2213
2325
|
* @param {Iterable<string> | null | undefined} files all files
|
|
2214
2326
|
* @param {Iterable<string> | null | undefined} directories all directories
|
|
@@ -2308,6 +2420,7 @@ class FileSystemInfo {
|
|
|
2308
2420
|
}
|
|
2309
2421
|
};
|
|
2310
2422
|
/**
|
|
2423
|
+
* Checks true when managed.
|
|
2311
2424
|
* @param {string} path path
|
|
2312
2425
|
* @param {ManagedFiles} managedSet managed set
|
|
2313
2426
|
* @returns {boolean} true when managed
|
|
@@ -2355,6 +2468,7 @@ class FileSystemInfo {
|
|
|
2355
2468
|
return false;
|
|
2356
2469
|
};
|
|
2357
2470
|
/**
|
|
2471
|
+
* Capture non managed.
|
|
2358
2472
|
* @param {Iterable<string>} items items
|
|
2359
2473
|
* @param {Set<string>} managedSet managed set
|
|
2360
2474
|
* @returns {Set<string>} result
|
|
@@ -2368,6 +2482,7 @@ class FileSystemInfo {
|
|
|
2368
2482
|
return capturedItems;
|
|
2369
2483
|
};
|
|
2370
2484
|
/**
|
|
2485
|
+
* Process captured files.
|
|
2371
2486
|
* @param {ManagedFiles} capturedFiles captured files
|
|
2372
2487
|
*/
|
|
2373
2488
|
const processCapturedFiles = (capturedFiles) => {
|
|
@@ -2427,9 +2542,12 @@ class FileSystemInfo {
|
|
|
2427
2542
|
this._fileTimestampsOptimization.optimize(snapshot, capturedFiles);
|
|
2428
2543
|
for (const path of capturedFiles) {
|
|
2429
2544
|
const cache = this._fileTimestamps.get(path);
|
|
2430
|
-
if (cache !== undefined) {
|
|
2545
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
2431
2546
|
if (cache !== "ignore") {
|
|
2432
|
-
fileTimestamps.set(
|
|
2547
|
+
fileTimestamps.set(
|
|
2548
|
+
path,
|
|
2549
|
+
/** @type {FileSystemInfoEntry | null} */ (cache)
|
|
2550
|
+
);
|
|
2433
2551
|
}
|
|
2434
2552
|
} else {
|
|
2435
2553
|
jobs++;
|
|
@@ -2459,6 +2577,7 @@ class FileSystemInfo {
|
|
|
2459
2577
|
processCapturedFiles(captureNonManaged(files, managedFiles));
|
|
2460
2578
|
}
|
|
2461
2579
|
/**
|
|
2580
|
+
* Process captured directories.
|
|
2462
2581
|
* @param {ManagedContexts} capturedDirectories captured directories
|
|
2463
2582
|
*/
|
|
2464
2583
|
const processCapturedDirectories = (capturedDirectories) => {
|
|
@@ -2480,6 +2599,7 @@ class FileSystemInfo {
|
|
|
2480
2599
|
} else {
|
|
2481
2600
|
jobs++;
|
|
2482
2601
|
/**
|
|
2602
|
+
* Processes the provided err.
|
|
2483
2603
|
* @param {(WebpackError | null)=} err error
|
|
2484
2604
|
* @param {(ResolvedContextTimestampAndHash | null)=} entry entry
|
|
2485
2605
|
* @returns {void}
|
|
@@ -2526,6 +2646,7 @@ class FileSystemInfo {
|
|
|
2526
2646
|
} else {
|
|
2527
2647
|
jobs++;
|
|
2528
2648
|
/**
|
|
2649
|
+
* Processes the provided err.
|
|
2529
2650
|
* @param {(WebpackError | null)=} err err
|
|
2530
2651
|
* @param {string=} entry entry
|
|
2531
2652
|
*/
|
|
@@ -2558,18 +2679,33 @@ class FileSystemInfo {
|
|
|
2558
2679
|
for (const path of capturedDirectories) {
|
|
2559
2680
|
const cache = this._contextTimestamps.get(path);
|
|
2560
2681
|
if (cache === "ignore") continue;
|
|
2682
|
+
/** @type {ContextFileSystemInfoEntry | null | undefined} */
|
|
2683
|
+
const usableCache =
|
|
2684
|
+
cache === undefined || isExistenceOnly(cache)
|
|
2685
|
+
? undefined
|
|
2686
|
+
: /** @type {ContextFileSystemInfoEntry | null} */ (cache);
|
|
2687
|
+
// A non-null cache entry without `timestampHash` cannot be
|
|
2688
|
+
// used to populate the snapshot — the snapshot would then
|
|
2689
|
+
// miss directory-change detection, since validity relies on
|
|
2690
|
+
// `timestampHash`. Re-read the directory in that case.
|
|
2691
|
+
const cacheLacksHash =
|
|
2692
|
+
usableCache !== undefined &&
|
|
2693
|
+
usableCache !== null &&
|
|
2694
|
+
usableCache.timestampHash === undefined;
|
|
2561
2695
|
/** @type {undefined | null | ResolvedContextFileSystemInfoEntry} */
|
|
2562
2696
|
let resolved;
|
|
2563
2697
|
if (
|
|
2564
|
-
|
|
2565
|
-
|
|
2698
|
+
usableCache !== undefined &&
|
|
2699
|
+
!cacheLacksHash &&
|
|
2700
|
+
(resolved = getResolvedTimestamp(usableCache)) !== undefined
|
|
2566
2701
|
) {
|
|
2567
2702
|
contextTimestamps.set(path, resolved);
|
|
2568
2703
|
} else {
|
|
2569
2704
|
jobs++;
|
|
2570
2705
|
/**
|
|
2571
|
-
*
|
|
2572
|
-
* @param {
|
|
2706
|
+
* Processes the provided err.
|
|
2707
|
+
* @param {(WebpackError | null)=} err error
|
|
2708
|
+
* @param {ResolvedContextTimestamp=} entry entry
|
|
2573
2709
|
* @returns {void}
|
|
2574
2710
|
*/
|
|
2575
2711
|
const callback = (err, entry) => {
|
|
@@ -2583,20 +2719,20 @@ class FileSystemInfo {
|
|
|
2583
2719
|
} else {
|
|
2584
2720
|
contextTimestamps.set(
|
|
2585
2721
|
path,
|
|
2586
|
-
/** @type {
|
|
2722
|
+
/** @type {ResolvedContextFileSystemInfoEntry | null} */
|
|
2587
2723
|
(entry)
|
|
2588
2724
|
);
|
|
2589
2725
|
jobDone();
|
|
2590
2726
|
}
|
|
2591
2727
|
};
|
|
2592
|
-
if (
|
|
2593
|
-
this.
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
callback
|
|
2597
|
-
);
|
|
2728
|
+
if (cacheLacksHash) {
|
|
2729
|
+
this._readFreshContextTimestamp(path, callback);
|
|
2730
|
+
} else if (usableCache !== undefined && usableCache !== null) {
|
|
2731
|
+
this._resolveContextTimestamp(usableCache, callback);
|
|
2598
2732
|
} else {
|
|
2599
|
-
|
|
2733
|
+
// Force a fresh on-disk read so the snapshot stores a
|
|
2734
|
+
// complete entry (with `timestampHash`).
|
|
2735
|
+
this._readFreshContextTimestamp(path, callback);
|
|
2600
2736
|
}
|
|
2601
2737
|
}
|
|
2602
2738
|
}
|
|
@@ -2609,6 +2745,7 @@ class FileSystemInfo {
|
|
|
2609
2745
|
);
|
|
2610
2746
|
}
|
|
2611
2747
|
/**
|
|
2748
|
+
* Process captured missing.
|
|
2612
2749
|
* @param {ManagedMissing} capturedMissing captured missing
|
|
2613
2750
|
*/
|
|
2614
2751
|
const processCapturedMissing = (capturedMissing) => {
|
|
@@ -2618,7 +2755,7 @@ class FileSystemInfo {
|
|
|
2618
2755
|
this._missingExistenceOptimization.optimize(snapshot, capturedMissing);
|
|
2619
2756
|
for (const path of capturedMissing) {
|
|
2620
2757
|
const cache = this._fileTimestamps.get(path);
|
|
2621
|
-
if (cache !== undefined) {
|
|
2758
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
2622
2759
|
if (cache !== "ignore") {
|
|
2623
2760
|
missingExistence.set(path, Boolean(cache));
|
|
2624
2761
|
}
|
|
@@ -2674,6 +2811,7 @@ class FileSystemInfo {
|
|
|
2674
2811
|
} else {
|
|
2675
2812
|
// Fallback to normal snapshotting
|
|
2676
2813
|
/**
|
|
2814
|
+
* Processes the provided set.
|
|
2677
2815
|
* @param {Set<string>} set set
|
|
2678
2816
|
* @param {(set: Set<string>) => void} fn fn
|
|
2679
2817
|
*/
|
|
@@ -2698,6 +2836,7 @@ class FileSystemInfo {
|
|
|
2698
2836
|
}
|
|
2699
2837
|
|
|
2700
2838
|
/**
|
|
2839
|
+
* Merges the provided values into a single result.
|
|
2701
2840
|
* @param {Snapshot} snapshot1 a snapshot
|
|
2702
2841
|
* @param {Snapshot} snapshot2 a snapshot
|
|
2703
2842
|
* @returns {Snapshot} merged snapshot
|
|
@@ -2784,6 +2923,7 @@ class FileSystemInfo {
|
|
|
2784
2923
|
}
|
|
2785
2924
|
|
|
2786
2925
|
/**
|
|
2926
|
+
* Checks snapshot valid.
|
|
2787
2927
|
* @param {Snapshot} snapshot the snapshot made
|
|
2788
2928
|
* @param {CheckSnapshotValidCallback} callback callback function
|
|
2789
2929
|
* @returns {void}
|
|
@@ -2804,6 +2944,7 @@ class FileSystemInfo {
|
|
|
2804
2944
|
}
|
|
2805
2945
|
|
|
2806
2946
|
/**
|
|
2947
|
+
* Check snapshot valid no cache.
|
|
2807
2948
|
* @private
|
|
2808
2949
|
* @param {Snapshot} snapshot the snapshot made
|
|
2809
2950
|
* @param {CheckSnapshotValidCallback} callback callback function
|
|
@@ -2831,6 +2972,7 @@ class FileSystemInfo {
|
|
|
2831
2972
|
}
|
|
2832
2973
|
};
|
|
2833
2974
|
/**
|
|
2975
|
+
* Invalid with error.
|
|
2834
2976
|
* @param {string} path path
|
|
2835
2977
|
* @param {WebpackError} err err
|
|
2836
2978
|
*/
|
|
@@ -2841,6 +2983,7 @@ class FileSystemInfo {
|
|
|
2841
2983
|
invalid();
|
|
2842
2984
|
};
|
|
2843
2985
|
/**
|
|
2986
|
+
* Checks true, if ok.
|
|
2844
2987
|
* @param {string} path file path
|
|
2845
2988
|
* @param {string | null} current current hash
|
|
2846
2989
|
* @param {string | null} snap snapshot hash
|
|
@@ -2857,6 +3000,7 @@ class FileSystemInfo {
|
|
|
2857
3000
|
return true;
|
|
2858
3001
|
};
|
|
2859
3002
|
/**
|
|
3003
|
+
* Checks true, if ok.
|
|
2860
3004
|
* @param {string} path file path
|
|
2861
3005
|
* @param {boolean} current current entry
|
|
2862
3006
|
* @param {boolean} snap entry from snapshot
|
|
@@ -2877,6 +3021,7 @@ class FileSystemInfo {
|
|
|
2877
3021
|
return true;
|
|
2878
3022
|
};
|
|
2879
3023
|
/**
|
|
3024
|
+
* Checks true, if ok.
|
|
2880
3025
|
* @param {string} path file path
|
|
2881
3026
|
* @param {FileSystemInfoEntry | null} c current entry
|
|
2882
3027
|
* @param {FileSystemInfoEntry | null} s entry from snapshot
|
|
@@ -2919,6 +3064,7 @@ class FileSystemInfo {
|
|
|
2919
3064
|
return true;
|
|
2920
3065
|
};
|
|
2921
3066
|
/**
|
|
3067
|
+
* Checks true, if ok.
|
|
2922
3068
|
* @param {string} path file path
|
|
2923
3069
|
* @param {ResolvedContextFileSystemInfoEntry | null} c current entry
|
|
2924
3070
|
* @param {ResolvedContextFileSystemInfoEntry | null} s entry from snapshot
|
|
@@ -2965,6 +3111,7 @@ class FileSystemInfo {
|
|
|
2965
3111
|
};
|
|
2966
3112
|
if (snapshot.hasChildren()) {
|
|
2967
3113
|
/**
|
|
3114
|
+
* Processes the provided err.
|
|
2968
3115
|
* @param {(WebpackError | null)=} err err
|
|
2969
3116
|
* @param {boolean=} result result
|
|
2970
3117
|
* @returns {void}
|
|
@@ -3001,8 +3148,15 @@ class FileSystemInfo {
|
|
|
3001
3148
|
this._statTestedEntries += fileTimestamps.size;
|
|
3002
3149
|
for (const [path, ts] of fileTimestamps) {
|
|
3003
3150
|
const cache = this._fileTimestamps.get(path);
|
|
3004
|
-
if (cache !== undefined) {
|
|
3005
|
-
if (
|
|
3151
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
3152
|
+
if (
|
|
3153
|
+
cache !== "ignore" &&
|
|
3154
|
+
!checkFile(
|
|
3155
|
+
path,
|
|
3156
|
+
/** @type {FileSystemInfoEntry | null} */ (cache),
|
|
3157
|
+
ts
|
|
3158
|
+
)
|
|
3159
|
+
) {
|
|
3006
3160
|
invalid();
|
|
3007
3161
|
return;
|
|
3008
3162
|
}
|
|
@@ -3026,6 +3180,7 @@ class FileSystemInfo {
|
|
|
3026
3180
|
}
|
|
3027
3181
|
}
|
|
3028
3182
|
/**
|
|
3183
|
+
* Process file hash snapshot.
|
|
3029
3184
|
* @param {string} path file path
|
|
3030
3185
|
* @param {string | null} hash hash
|
|
3031
3186
|
*/
|
|
@@ -3062,8 +3217,16 @@ class FileSystemInfo {
|
|
|
3062
3217
|
processFileHashSnapshot(path, tsh);
|
|
3063
3218
|
} else {
|
|
3064
3219
|
const cache = this._fileTimestamps.get(path);
|
|
3065
|
-
if (cache !== undefined) {
|
|
3066
|
-
if (
|
|
3220
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
3221
|
+
if (
|
|
3222
|
+
cache === "ignore" ||
|
|
3223
|
+
!checkFile(
|
|
3224
|
+
path,
|
|
3225
|
+
/** @type {FileSystemInfoEntry | null} */ (cache),
|
|
3226
|
+
tsh,
|
|
3227
|
+
false
|
|
3228
|
+
)
|
|
3229
|
+
) {
|
|
3067
3230
|
processFileHashSnapshot(path, tsh && tsh.hash);
|
|
3068
3231
|
}
|
|
3069
3232
|
} else {
|
|
@@ -3095,11 +3258,29 @@ class FileSystemInfo {
|
|
|
3095
3258
|
for (const [path, ts] of contextTimestamps) {
|
|
3096
3259
|
const cache = this._contextTimestamps.get(path);
|
|
3097
3260
|
if (cache === "ignore") continue;
|
|
3261
|
+
// Treat existence-only entries (`{}` from watchpack) as a cache
|
|
3262
|
+
// miss — they carry no time info, so we cannot compare them to
|
|
3263
|
+
// the snapshot.
|
|
3264
|
+
/** @type {ContextFileSystemInfoEntry | null | undefined} */
|
|
3265
|
+
const usableCache =
|
|
3266
|
+
cache === undefined || isExistenceOnly(cache)
|
|
3267
|
+
? undefined
|
|
3268
|
+
: /** @type {ContextFileSystemInfoEntry | null} */ (cache);
|
|
3269
|
+
// A non-null cache entry that lacks `timestampHash` while the
|
|
3270
|
+
// snapshot has one cannot be used either; we re-read the
|
|
3271
|
+
// directory through the disk-backed queue instead.
|
|
3272
|
+
const cacheLacksHash =
|
|
3273
|
+
usableCache !== undefined &&
|
|
3274
|
+
usableCache !== null &&
|
|
3275
|
+
usableCache.timestampHash === undefined &&
|
|
3276
|
+
ts !== null &&
|
|
3277
|
+
ts.timestampHash !== undefined;
|
|
3098
3278
|
/** @type {undefined | null | ResolvedContextFileSystemInfoEntry} */
|
|
3099
3279
|
let resolved;
|
|
3100
3280
|
if (
|
|
3101
|
-
|
|
3102
|
-
|
|
3281
|
+
usableCache !== undefined &&
|
|
3282
|
+
!cacheLacksHash &&
|
|
3283
|
+
(resolved = getResolvedTimestamp(usableCache)) !== undefined
|
|
3103
3284
|
) {
|
|
3104
3285
|
if (!checkContext(path, resolved, ts)) {
|
|
3105
3286
|
invalid();
|
|
@@ -3108,6 +3289,7 @@ class FileSystemInfo {
|
|
|
3108
3289
|
} else {
|
|
3109
3290
|
jobs++;
|
|
3110
3291
|
/**
|
|
3292
|
+
* Processes the provided err.
|
|
3111
3293
|
* @param {(WebpackError | null)=} err error
|
|
3112
3294
|
* @param {ResolvedContextTimestamp=} entry entry
|
|
3113
3295
|
* @returns {void}
|
|
@@ -3127,12 +3309,10 @@ class FileSystemInfo {
|
|
|
3127
3309
|
jobDone();
|
|
3128
3310
|
}
|
|
3129
3311
|
};
|
|
3130
|
-
if (
|
|
3131
|
-
this.
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
callback
|
|
3135
|
-
);
|
|
3312
|
+
if (cacheLacksHash) {
|
|
3313
|
+
this._readFreshContextTimestamp(path, callback);
|
|
3314
|
+
} else if (usableCache !== undefined && usableCache !== null) {
|
|
3315
|
+
this._resolveContextTimestamp(usableCache, callback);
|
|
3136
3316
|
} else {
|
|
3137
3317
|
this.getContextTimestamp(path, callback);
|
|
3138
3318
|
}
|
|
@@ -3140,6 +3320,7 @@ class FileSystemInfo {
|
|
|
3140
3320
|
}
|
|
3141
3321
|
}
|
|
3142
3322
|
/**
|
|
3323
|
+
* Process context hash snapshot.
|
|
3143
3324
|
* @param {string} path path
|
|
3144
3325
|
* @param {string | null} hash hash
|
|
3145
3326
|
*/
|
|
@@ -3157,6 +3338,7 @@ class FileSystemInfo {
|
|
|
3157
3338
|
} else {
|
|
3158
3339
|
jobs++;
|
|
3159
3340
|
/**
|
|
3341
|
+
* Processes the provided err.
|
|
3160
3342
|
* @param {(WebpackError | null)=} err err
|
|
3161
3343
|
* @param {string=} entry entry
|
|
3162
3344
|
* @returns {void}
|
|
@@ -3194,11 +3376,24 @@ class FileSystemInfo {
|
|
|
3194
3376
|
} else {
|
|
3195
3377
|
const cache = this._contextTimestamps.get(path);
|
|
3196
3378
|
if (cache === "ignore") continue;
|
|
3379
|
+
// See the matching block in `hasContextTimestamps` above.
|
|
3380
|
+
/** @type {ContextFileSystemInfoEntry | null | undefined} */
|
|
3381
|
+
const usableCache =
|
|
3382
|
+
cache === undefined || isExistenceOnly(cache)
|
|
3383
|
+
? undefined
|
|
3384
|
+
: /** @type {ContextFileSystemInfoEntry | null} */ (cache);
|
|
3385
|
+
const cacheLacksHash =
|
|
3386
|
+
usableCache !== undefined &&
|
|
3387
|
+
usableCache !== null &&
|
|
3388
|
+
usableCache.timestampHash === undefined &&
|
|
3389
|
+
tsh !== null &&
|
|
3390
|
+
tsh.timestampHash !== undefined;
|
|
3197
3391
|
/** @type {undefined | null | ResolvedContextFileSystemInfoEntry} */
|
|
3198
3392
|
let resolved;
|
|
3199
3393
|
if (
|
|
3200
|
-
|
|
3201
|
-
|
|
3394
|
+
usableCache !== undefined &&
|
|
3395
|
+
!cacheLacksHash &&
|
|
3396
|
+
(resolved = getResolvedTimestamp(usableCache)) !== undefined
|
|
3202
3397
|
) {
|
|
3203
3398
|
if (!checkContext(path, resolved, tsh, false)) {
|
|
3204
3399
|
processContextHashSnapshot(path, tsh && tsh.hash);
|
|
@@ -3206,6 +3401,7 @@ class FileSystemInfo {
|
|
|
3206
3401
|
} else {
|
|
3207
3402
|
jobs++;
|
|
3208
3403
|
/**
|
|
3404
|
+
* Processes the provided err.
|
|
3209
3405
|
* @param {(WebpackError | null)=} err error
|
|
3210
3406
|
* @param {ResolvedContextTimestamp=} entry entry
|
|
3211
3407
|
* @returns {void}
|
|
@@ -3226,12 +3422,10 @@ class FileSystemInfo {
|
|
|
3226
3422
|
}
|
|
3227
3423
|
jobDone();
|
|
3228
3424
|
};
|
|
3229
|
-
if (
|
|
3230
|
-
this.
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
callback
|
|
3234
|
-
);
|
|
3425
|
+
if (cacheLacksHash) {
|
|
3426
|
+
this._readFreshContextTimestamp(path, callback);
|
|
3427
|
+
} else if (usableCache !== undefined && usableCache !== null) {
|
|
3428
|
+
this._resolveContextTimestamp(usableCache, callback);
|
|
3235
3429
|
} else {
|
|
3236
3430
|
this.getContextTimestamp(path, callback);
|
|
3237
3431
|
}
|
|
@@ -3246,7 +3440,7 @@ class FileSystemInfo {
|
|
|
3246
3440
|
this._statTestedEntries += missingExistence.size;
|
|
3247
3441
|
for (const [path, existence] of missingExistence) {
|
|
3248
3442
|
const cache = this._fileTimestamps.get(path);
|
|
3249
|
-
if (cache !== undefined) {
|
|
3443
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
3250
3444
|
if (
|
|
3251
3445
|
cache !== "ignore" &&
|
|
3252
3446
|
!checkExistence(path, Boolean(cache), Boolean(existence))
|
|
@@ -3382,12 +3576,14 @@ class FileSystemInfo {
|
|
|
3382
3576
|
}
|
|
3383
3577
|
|
|
3384
3578
|
/**
|
|
3579
|
+
* Get file timestamp and hash.
|
|
3385
3580
|
* @private
|
|
3386
3581
|
* @param {string} path path
|
|
3387
3582
|
* @param {(err: WebpackError | null, timestampAndHash?: TimestampAndHash | string) => void} callback callback
|
|
3388
3583
|
*/
|
|
3389
3584
|
_getFileTimestampAndHash(path, callback) {
|
|
3390
3585
|
/**
|
|
3586
|
+
* Continue with hash.
|
|
3391
3587
|
* @param {string} hash hash
|
|
3392
3588
|
* @returns {void}
|
|
3393
3589
|
*/
|
|
@@ -3434,6 +3630,7 @@ class FileSystemInfo {
|
|
|
3434
3630
|
}
|
|
3435
3631
|
|
|
3436
3632
|
/**
|
|
3633
|
+
* Processes the provided object.
|
|
3437
3634
|
* @private
|
|
3438
3635
|
* @template T
|
|
3439
3636
|
* @template ItemType
|
|
@@ -3573,8 +3770,13 @@ class FileSystemInfo {
|
|
|
3573
3770
|
fromFile: (file, stat, callback) => {
|
|
3574
3771
|
// Prefer the cached value over our new stat to report consistent results
|
|
3575
3772
|
const cache = this._fileTimestamps.get(file);
|
|
3576
|
-
if (cache !== undefined) {
|
|
3577
|
-
return callback(
|
|
3773
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
3774
|
+
return callback(
|
|
3775
|
+
null,
|
|
3776
|
+
cache === "ignore"
|
|
3777
|
+
? null
|
|
3778
|
+
: /** @type {FileSystemInfoEntry | null} */ (cache)
|
|
3779
|
+
);
|
|
3578
3780
|
}
|
|
3579
3781
|
|
|
3580
3782
|
const mtime = Number(stat.mtime);
|
|
@@ -3663,6 +3865,7 @@ class FileSystemInfo {
|
|
|
3663
3865
|
}
|
|
3664
3866
|
|
|
3665
3867
|
/**
|
|
3868
|
+
* Resolve context timestamp.
|
|
3666
3869
|
* @private
|
|
3667
3870
|
* @param {ContextFileSystemInfoEntry} entry entry
|
|
3668
3871
|
* @param {(err?: WebpackError | null, resolvedContextTimestamp?: ResolvedContextTimestamp) => void} callback callback
|
|
@@ -3744,6 +3947,7 @@ class FileSystemInfo {
|
|
|
3744
3947
|
});
|
|
3745
3948
|
},
|
|
3746
3949
|
/**
|
|
3950
|
+
* Returns reduced hash.
|
|
3747
3951
|
* @param {string[]} files files
|
|
3748
3952
|
* @param {(string | ContextHash)[]} fileHashes hashes
|
|
3749
3953
|
* @returns {ContextHash} reduced hash
|
|
@@ -3784,6 +3988,7 @@ class FileSystemInfo {
|
|
|
3784
3988
|
}
|
|
3785
3989
|
|
|
3786
3990
|
/**
|
|
3991
|
+
* Resolve context hash.
|
|
3787
3992
|
* @private
|
|
3788
3993
|
* @param {ContextHash} entry context hash
|
|
3789
3994
|
* @param {(err: WebpackError | null, contextHash?: string) => void} callback callback
|
|
@@ -3826,6 +4031,7 @@ class FileSystemInfo {
|
|
|
3826
4031
|
*/
|
|
3827
4032
|
_readContextTimestampAndHash(path, callback) {
|
|
3828
4033
|
/**
|
|
4034
|
+
* Processes the provided timestamp.
|
|
3829
4035
|
* @param {ContextTimestamp} timestamp timestamp
|
|
3830
4036
|
* @param {ContextHash} hash hash
|
|
3831
4037
|
*/
|
|
@@ -3887,6 +4093,7 @@ class FileSystemInfo {
|
|
|
3887
4093
|
});
|
|
3888
4094
|
},
|
|
3889
4095
|
/**
|
|
4096
|
+
* Returns tsh.
|
|
3890
4097
|
* @param {string[]} files files
|
|
3891
4098
|
* @param {(Partial<TimestampAndHash> & Partial<ContextTimestampAndHash> | string | null)[]} results results
|
|
3892
4099
|
* @returns {ContextTimestampAndHash} tsh
|
|
@@ -3951,6 +4158,7 @@ class FileSystemInfo {
|
|
|
3951
4158
|
}
|
|
3952
4159
|
|
|
3953
4160
|
/**
|
|
4161
|
+
* Resolve context tsh.
|
|
3954
4162
|
* @private
|
|
3955
4163
|
* @param {ContextTimestampAndHash} entry entry
|
|
3956
4164
|
* @param {ProcessorCallback<ResolvedContextTimestampAndHash>} callback callback
|
|
@@ -4111,7 +4319,13 @@ class FileSystemInfo {
|
|
|
4111
4319
|
/** @type {Map<string, number | null>} */
|
|
4112
4320
|
const map = new Map();
|
|
4113
4321
|
for (const [path, info] of this._fileTimestamps) {
|
|
4114
|
-
if (info)
|
|
4322
|
+
if (info) {
|
|
4323
|
+
const safeTime =
|
|
4324
|
+
typeof info === "object"
|
|
4325
|
+
? /** @type {Partial<FileSystemInfoEntry>} */ (info).safeTime
|
|
4326
|
+
: undefined;
|
|
4327
|
+
map.set(path, safeTime === undefined ? null : safeTime);
|
|
4328
|
+
}
|
|
4115
4329
|
}
|
|
4116
4330
|
return (this._cachedDeprecatedFileTimestamps = map);
|
|
4117
4331
|
}
|
|
@@ -4123,7 +4337,13 @@ class FileSystemInfo {
|
|
|
4123
4337
|
/** @type {Map<string, number | null>} */
|
|
4124
4338
|
const map = new Map();
|
|
4125
4339
|
for (const [path, info] of this._contextTimestamps) {
|
|
4126
|
-
if (info)
|
|
4340
|
+
if (info) {
|
|
4341
|
+
const safeTime =
|
|
4342
|
+
typeof info === "object"
|
|
4343
|
+
? /** @type {Partial<ContextFileSystemInfoEntry>} */ (info).safeTime
|
|
4344
|
+
: undefined;
|
|
4345
|
+
map.set(path, safeTime === undefined ? null : safeTime);
|
|
4346
|
+
}
|
|
4127
4347
|
}
|
|
4128
4348
|
return (this._cachedDeprecatedContextTimestamps = map);
|
|
4129
4349
|
}
|