@depup/webpack 5.106.1-depup.0 → 5.109.2-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -11
- package/bin/webpack.js +12 -0
- package/changes.json +16 -24
- package/hot/dev-server.js +2 -0
- package/lib/APIPlugin.js +60 -35
- package/lib/AsyncDependenciesBlock.js +3 -0
- package/lib/AutomaticPrefetchPlugin.js +6 -1
- package/lib/BannerPlugin.js +13 -5
- package/lib/Cache.js +27 -5
- package/lib/CacheFacade.js +41 -0
- package/lib/Chunk.js +71 -25
- package/lib/ChunkGraph.js +153 -19
- package/lib/ChunkGroup.js +115 -28
- package/lib/ChunkTemplate.js +9 -0
- package/lib/CircularModulesPlugin.js +190 -0
- package/lib/CleanPlugin.js +27 -28
- package/lib/CodeGenerationResults.js +19 -0
- package/lib/CompatibilityPlugin.js +85 -37
- package/lib/Compilation.js +656 -112
- package/lib/Compiler.js +109 -35
- package/lib/ConcatenationScope.js +34 -4
- package/lib/ConditionalInitFragment.js +6 -0
- package/lib/ConstPlugin.js +15 -12
- package/lib/ContextExclusionPlugin.js +3 -1
- package/lib/ContextModule.js +345 -55
- package/lib/ContextModuleFactory.js +193 -51
- package/lib/ContextReplacementPlugin.js +8 -1
- package/lib/DefinePlugin.js +537 -139
- package/lib/DependenciesBlock.js +6 -1
- package/lib/Dependency.js +159 -11
- 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 +42 -2
- package/lib/EntryPlugin.js +4 -1
- package/lib/Entrypoint.js +5 -1
- package/lib/EnvironmentPlugin.js +3 -2
- package/lib/ErrorHelpers.js +7 -0
- package/lib/EvalDevToolModulePlugin.js +3 -1
- package/lib/EvalSourceMapDevToolPlugin.js +11 -11
- package/lib/ExportsInfo.js +421 -113
- package/lib/ExportsInfoApiPlugin.js +4 -3
- package/lib/ExternalModule.js +381 -80
- package/lib/ExternalModuleFactoryPlugin.js +75 -3
- package/lib/ExternalsPlugin.js +3 -1
- package/lib/FileSystemInfo.js +701 -175
- package/lib/FlagAllModulesAsUsedPlugin.js +3 -6
- package/lib/FlagDependencyExportsPlugin.js +82 -9
- package/lib/FlagDependencyUsagePlugin.js +115 -8
- package/lib/FlagEntryExportAsUsedPlugin.js +4 -1
- package/lib/Generator.js +24 -3
- package/lib/HotModuleReplacementPlugin.js +110 -44
- package/lib/IgnorePlugin.js +5 -2
- package/lib/IgnoreWarningsPlugin.js +2 -1
- package/lib/InitFragment.js +33 -30
- package/lib/JavascriptMetaInfoPlugin.js +9 -6
- package/lib/LazyBarrel.js +389 -0
- package/lib/LibraryTemplatePlugin.js +2 -1
- package/lib/LoaderOptionsPlugin.js +3 -1
- package/lib/LoaderTargetPlugin.js +3 -1
- package/lib/MainTemplate.js +15 -0
- package/lib/ManifestPlugin.js +9 -2
- package/lib/Module.js +121 -57
- package/lib/ModuleFactory.js +6 -1
- package/lib/ModuleFilenameHelpers.js +18 -4
- package/lib/ModuleGraph.js +69 -2
- package/lib/ModuleGraphConnection.js +9 -0
- package/lib/ModuleInfoHeaderPlugin.js +5 -0
- package/lib/ModuleNotFoundError.js +3 -83
- package/lib/ModuleProfile.js +27 -1
- package/lib/ModuleSourceTypeConstants.js +52 -19
- package/lib/ModuleTemplate.js +10 -0
- package/lib/ModuleTypeConstants.js +20 -4
- package/lib/MultiCompiler.js +59 -4
- package/lib/MultiStats.js +9 -0
- package/lib/MultiWatching.js +6 -0
- package/lib/NoEmitOnErrorsPlugin.js +1 -1
- package/lib/NodeStuffPlugin.js +78 -46
- package/lib/NormalModule.js +519 -206
- package/lib/NormalModuleFactory.js +156 -31
- package/lib/NormalModuleReplacementPlugin.js +3 -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 +4 -1
- package/lib/ProgressPlugin.js +351 -161
- package/lib/ProvidePlugin.js +6 -3
- package/lib/RawModule.js +32 -16
- package/lib/RecordIdsPlugin.js +9 -0
- package/lib/RequestShortener.js +8 -0
- package/lib/ResolverFactory.js +5 -0
- package/lib/RuntimeGlobals.js +58 -5
- package/lib/RuntimeModule.js +22 -7
- package/lib/RuntimePlugin.js +123 -118
- package/lib/RuntimeTemplate.js +616 -37
- package/lib/SelfModuleFactory.js +3 -0
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -0
- package/lib/SourceMapDevToolPlugin.js +341 -63
- package/lib/Stats.js +6 -0
- package/lib/Template.js +52 -6
- package/lib/TemplatedPathPlugin.js +505 -138
- package/lib/UseStrictPlugin.js +3 -2
- package/lib/WarnCaseSensitiveModulesPlugin.js +72 -3
- package/lib/WarnDeprecatedOptionPlugin.js +6 -2
- package/lib/WarnNoModeSetPlugin.js +18 -2
- package/lib/WatchIgnorePlugin.js +5 -1
- package/lib/Watching.js +25 -3
- package/lib/WebpackError.js +3 -74
- package/lib/WebpackIsIncludedPlugin.js +4 -2
- package/lib/WebpackOptionsApply.js +88 -25
- package/lib/WebpackOptionsDefaulter.js +1 -0
- package/lib/asset/AssetBytesGenerator.js +28 -10
- package/lib/asset/AssetBytesParser.js +1 -0
- package/lib/asset/AssetGenerator.js +199 -60
- package/lib/asset/AssetModule.js +47 -0
- package/lib/asset/AssetModulesPlugin.js +115 -24
- package/lib/asset/AssetParser.js +4 -2
- package/lib/asset/AssetSourceGenerator.js +26 -8
- package/lib/asset/AssetSourceParser.js +1 -0
- package/lib/asset/RawDataUrlModule.js +23 -13
- package/lib/asset/WebManifestGenerator.js +164 -0
- package/lib/asset/WebManifestParser.js +130 -0
- package/lib/async-modules/AsyncModuleHelpers.js +1 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +18 -4
- package/lib/async-modules/InferAsyncModulesPlugin.js +1 -1
- package/lib/async-modules/isGeneratorLowered.js +26 -0
- package/lib/buildChunkGraph.js +107 -15
- package/lib/bun/BunTargetPlugin.js +42 -0
- package/lib/cache/AddBuildDependenciesPlugin.js +3 -1
- package/lib/cache/AddManagedPathsPlugin.js +5 -1
- package/lib/cache/IdleFileCachePlugin.js +6 -1
- package/lib/cache/MemoryCachePlugin.js +1 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +4 -1
- package/lib/cache/PackFileCacheStrategy.js +302 -12
- package/lib/cache/ResolverCachePlugin.js +12 -1
- package/lib/cache/getLazyHashedEtag.js +13 -2
- package/lib/cache/mergeEtags.js +4 -0
- package/lib/cli.js +142 -20
- package/lib/config/browserslistTargetHandler.js +141 -0
- package/lib/config/defaults.js +612 -43
- package/lib/config/defineConfig.js +31 -0
- package/lib/config/normalization.js +46 -1
- package/lib/config/target.js +200 -2
- package/lib/container/ContainerEntryDependency.js +2 -0
- package/lib/container/ContainerEntryModule.js +27 -14
- package/lib/container/ContainerEntryModuleFactory.js +1 -0
- package/lib/container/ContainerExposedDependency.js +6 -2
- package/lib/container/ContainerPlugin.js +2 -1
- package/lib/container/ContainerReferencePlugin.js +3 -2
- package/lib/container/FallbackDependency.js +9 -7
- package/lib/container/FallbackItemDependency.js +1 -0
- package/lib/container/FallbackModule.js +22 -9
- package/lib/container/FallbackModuleFactory.js +1 -0
- package/lib/container/HoistContainerReferencesPlugin.js +47 -55
- package/lib/container/ModuleFederationPlugin.js +21 -29
- package/lib/container/RemoteModule.js +33 -10
- package/lib/container/RemoteRuntimeModule.js +15 -12
- package/lib/container/RemoteToExternalDependency.js +1 -0
- package/lib/container/options.js +7 -0
- package/lib/css/CssGenerator.js +540 -272
- package/lib/css/CssInjectStyleRuntimeModule.js +86 -70
- package/lib/css/CssLoadingRuntimeModule.js +173 -81
- package/lib/{CssModule.js → css/CssModule.js} +72 -37
- package/lib/css/CssModulesPlugin.js +371 -208
- package/lib/css/CssParser.js +3538 -1963
- package/lib/css/syntax.js +4155 -0
- package/lib/debug/ProfilingPlugin.js +33 -2
- package/lib/deno/DenoTargetPlugin.js +41 -0
- package/lib/dependencies/AMDDefineDependency.js +29 -17
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +19 -6
- package/lib/dependencies/AMDPlugin.js +6 -3
- package/lib/dependencies/AMDRequireArrayDependency.js +13 -11
- package/lib/dependencies/AMDRequireContextDependency.js +10 -11
- package/lib/dependencies/AMDRequireDependenciesBlock.js +1 -0
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -14
- package/lib/dependencies/AMDRequireDependency.js +28 -20
- package/lib/dependencies/AMDRequireItemDependency.js +1 -0
- package/lib/dependencies/AMDRuntimeModules.js +3 -0
- package/lib/dependencies/CachedConstDependency.js +9 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +104 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +157 -38
- package/lib/dependencies/CommonJsExportsDependency.js +74 -20
- package/lib/dependencies/CommonJsExportsParserPlugin.js +246 -15
- package/lib/dependencies/CommonJsFullRequireDependency.js +91 -27
- package/lib/dependencies/CommonJsImportsParserPlugin.js +189 -24
- package/lib/dependencies/CommonJsPlugin.js +7 -4
- package/lib/dependencies/CommonJsRequireContextDependency.js +13 -13
- package/lib/dependencies/CommonJsRequireDependency.js +135 -13
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +60 -16
- package/lib/dependencies/ConstDependency.js +22 -12
- package/lib/dependencies/ContextDependency.js +13 -2
- package/lib/dependencies/ContextDependencyHelpers.js +7 -4
- package/lib/dependencies/ContextDependencyTemplateAsId.js +2 -1
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/ContextElementDependency.js +27 -14
- package/lib/dependencies/CreateRequireParserPlugin.js +14 -7
- package/lib/dependencies/CreateScriptUrlDependency.js +9 -7
- package/lib/dependencies/CriticalDependencyWarning.js +3 -1
- package/lib/dependencies/CssIcssExportDependency.js +681 -367
- package/lib/dependencies/CssIcssImportDependency.js +62 -17
- package/lib/dependencies/CssIcssSymbolDependency.js +36 -17
- package/lib/dependencies/CssImportDependency.js +37 -1
- package/lib/dependencies/CssUrlDependency.js +87 -14
- package/lib/dependencies/DelegatedSourceDependency.js +1 -0
- package/lib/dependencies/DllEntryDependency.js +12 -13
- package/lib/dependencies/DynamicExports.js +5 -0
- package/lib/dependencies/EntryDependency.js +1 -0
- package/lib/dependencies/ExportBindingInitFragment.js +164 -0
- package/lib/dependencies/ExportsInfoDependency.js +18 -12
- package/lib/dependencies/ExternalModuleDependency.js +13 -5
- package/lib/dependencies/ExternalModuleInitFragment.js +10 -5
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +19 -12
- package/lib/dependencies/HarmonyAcceptDependency.js +24 -26
- package/lib/dependencies/HarmonyAcceptImportDependency.js +2 -0
- package/lib/dependencies/HarmonyCompatibilityDependency.js +33 -14
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +108 -30
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +34 -3
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +70 -33
- package/lib/dependencies/HarmonyExportExpressionDependency.js +133 -43
- package/lib/dependencies/HarmonyExportHeaderDependency.js +11 -9
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +268 -44
- package/lib/dependencies/HarmonyExportInitFragment.js +28 -20
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +88 -18
- package/lib/dependencies/HarmonyExports.js +6 -1
- package/lib/dependencies/HarmonyImportDependency.js +60 -4
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +139 -146
- package/lib/dependencies/HarmonyImportGuard.js +427 -0
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +22 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +146 -24
- package/lib/{HarmonyLinkingError.js → dependencies/HarmonyLinkingError.js} +6 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +11 -1
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +2 -1
- package/lib/dependencies/HtmlEntryDependency.js +1295 -0
- package/lib/dependencies/HtmlInlineHtmlDependency.js +107 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +126 -0
- package/lib/dependencies/HtmlInlineStyleDependency.js +152 -0
- package/lib/dependencies/HtmlSourceDependency.js +172 -0
- package/lib/dependencies/ImportContextDependency.js +9 -9
- package/lib/dependencies/ImportDependency.js +92 -3
- package/lib/dependencies/ImportEagerDependency.js +2 -0
- package/lib/dependencies/ImportMetaContextDependency.js +1 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +35 -19
- package/lib/dependencies/ImportMetaContextPlugin.js +40 -8
- package/lib/dependencies/ImportMetaGlobDependency.js +81 -0
- package/lib/dependencies/ImportMetaGlobDependencyParserPlugin.js +78 -0
- package/lib/dependencies/ImportMetaGlobHelpers.js +660 -0
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +2 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +2 -0
- package/lib/dependencies/ImportMetaPlugin.js +595 -209
- package/lib/dependencies/ImportMetaResolveDependency.js +90 -0
- package/lib/dependencies/ImportParserPlugin.js +114 -27
- package/lib/dependencies/ImportPhase.js +17 -11
- package/lib/dependencies/ImportPlugin.js +2 -1
- package/lib/dependencies/ImportWeakDependency.js +3 -0
- package/lib/dependencies/JsonExportsDependency.js +15 -10
- package/lib/dependencies/LoaderDependency.js +2 -0
- package/lib/dependencies/LoaderImportDependency.js +3 -0
- package/lib/dependencies/LoaderPlugin.js +9 -2
- package/lib/dependencies/LocalModule.js +15 -12
- package/lib/dependencies/LocalModuleDependency.js +15 -13
- package/lib/dependencies/LocalModulesHelpers.js +3 -0
- package/lib/dependencies/ModuleDecoratorDependency.js +16 -10
- package/lib/dependencies/ModuleDependency.js +14 -0
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +2 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +2 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +19 -11
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/PrefetchDependency.js +1 -0
- package/lib/dependencies/ProvidedDependency.js +36 -27
- package/lib/dependencies/PureExpressionDependency.js +14 -10
- package/lib/dependencies/RequireContextDependency.js +1 -0
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +2 -1
- package/lib/dependencies/RequireContextPlugin.js +2 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +1 -0
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +4 -6
- package/lib/dependencies/RequireEnsureDependency.js +16 -13
- package/lib/dependencies/RequireEnsureItemDependency.js +1 -0
- package/lib/dependencies/RequireEnsurePlugin.js +2 -1
- package/lib/dependencies/RequireHeaderDependency.js +7 -4
- package/lib/dependencies/RequireIncludeDependency.js +2 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +11 -12
- package/lib/dependencies/RequireIncludePlugin.js +2 -1
- package/lib/{RequireJsStuffPlugin.js → dependencies/RequireJsStuffPlugin.js} +9 -8
- package/lib/dependencies/RequireResolveContextDependency.js +10 -11
- package/lib/dependencies/RequireResolveDependency.js +2 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +8 -5
- package/lib/dependencies/RuntimeRequirementsDependency.js +11 -8
- package/lib/dependencies/StaticExportsDependency.js +13 -10
- package/lib/dependencies/SystemPlugin.js +9 -6
- package/lib/dependencies/SystemRuntimeModule.js +1 -0
- package/lib/dependencies/TopLevelAwaitDependency.js +93 -0
- package/lib/dependencies/URLContextDependency.js +8 -7
- package/lib/dependencies/URLDependency.js +157 -33
- package/lib/dependencies/URLPlugin.js +2 -0
- package/lib/dependencies/UnsupportedDependency.js +12 -13
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +15 -16
- package/lib/dependencies/WebAssemblyImportDependency.js +19 -18
- package/lib/dependencies/WebpackIsIncludedDependency.js +3 -0
- package/lib/dependencies/{WorkerPlugin.js → WorkerAndWorkletPlugin.js} +364 -114
- package/lib/dependencies/WorkerDependency.js +111 -27
- package/lib/dependencies/WorkletDependency.js +278 -0
- package/lib/dependencies/getFunctionExpression.js +1 -0
- package/lib/dependencies/processExportInfo.js +14 -11
- package/lib/{DelegatedModule.js → dll/DelegatedModule.js} +71 -44
- package/lib/{DelegatedModuleFactoryPlugin.js → dll/DelegatedModuleFactoryPlugin.js} +27 -4
- package/lib/{DelegatedPlugin.js → dll/DelegatedPlugin.js} +5 -3
- package/lib/{DllEntryPlugin.js → dll/DllEntryPlugin.js} +9 -5
- package/lib/{DllModule.js → dll/DllModule.js} +36 -24
- package/lib/{DllModuleFactory.js → dll/DllModuleFactory.js} +5 -4
- package/lib/{DllPlugin.js → dll/DllPlugin.js} +24 -6
- package/lib/{DllReferencePlugin.js → dll/DllReferencePlugin.js} +26 -18
- package/lib/{LibManifestPlugin.js → dll/LibManifestPlugin.js} +14 -10
- package/lib/electron/ElectronTargetPlugin.js +24 -5
- 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} +5 -2
- package/lib/{EnvironmentNotSupportAsyncWarning.js → errors/EnvironmentNotSupportAsyncWarning.js} +5 -5
- package/lib/{HookWebpackError.js → errors/HookWebpackError.js} +20 -16
- package/lib/{IgnoreErrorModuleFactory.js → errors/IgnoreErrorModuleFactory.js} +7 -4
- package/lib/{InvalidDependenciesModuleWarning.js → errors/InvalidDependenciesModuleWarning.js} +6 -3
- package/lib/errors/JSONParseError.js +115 -0
- package/lib/errors/LoaderLoadingError.js +20 -0
- package/lib/{ModuleBuildError.js → errors/ModuleBuildError.js} +22 -16
- package/lib/{ModuleDependencyError.js → errors/ModuleDependencyError.js} +10 -3
- package/lib/{ModuleDependencyWarning.js → errors/ModuleDependencyWarning.js} +13 -5
- package/lib/{ModuleError.js → errors/ModuleError.js} +10 -14
- package/lib/{ModuleHashingError.js → errors/ModuleHashingError.js} +5 -1
- package/lib/errors/ModuleNotFoundError.js +94 -0
- package/lib/errors/ModuleParseError.js +141 -0
- package/lib/{ModuleRestoreError.js → errors/ModuleRestoreError.js} +4 -1
- package/lib/{ModuleStoreError.js → errors/ModuleStoreError.js} +5 -1
- package/lib/{ModuleWarning.js → errors/ModuleWarning.js} +13 -14
- package/lib/{NodeStuffInWebError.js → errors/NodeStuffInWebError.js} +7 -5
- package/lib/errors/NonErrorEmittedError.js +30 -0
- package/lib/{UnhandledSchemeError.js → errors/UnhandledSchemeError.js} +9 -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 +52 -15
- package/lib/esm/ModuleChunkLoadingPlugin.js +11 -3
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +80 -52
- package/lib/hmr/HotModuleReplacement.runtime.js +175 -30
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +8 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +173 -26
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +154 -7
- package/lib/hmr/lazyCompilationBackend.js +53 -12
- package/lib/html/HtmlGenerator.js +1490 -0
- package/lib/html/HtmlModule.js +41 -0
- package/lib/html/HtmlModulesPlugin.js +1129 -0
- package/lib/html/HtmlParser.js +1970 -0
- package/lib/html/favicon.svg +1 -0
- package/lib/html/syntax.js +9106 -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 +49 -12
- 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 +66 -15
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +5 -6
- package/lib/javascript/BasicEvaluatedExpression.js +370 -49
- 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 +6 -1
- package/lib/javascript/JavascriptGenerator.js +213 -51
- package/lib/javascript/JavascriptModule.js +54 -0
- package/lib/javascript/JavascriptModulesPlugin.js +628 -198
- package/lib/javascript/JavascriptParser.js +1334 -471
- package/lib/javascript/JavascriptParserHelpers.js +10 -7
- package/lib/javascript/StartupHelpers.js +5 -0
- package/lib/javascript/syntax.js +5037 -0
- package/lib/json/JsonData.js +5 -0
- package/lib/json/JsonGenerator.js +21 -0
- package/lib/json/JsonModule.js +40 -0
- package/lib/json/JsonModulesPlugin.js +8 -1
- package/lib/json/JsonParser.js +18 -27
- package/lib/library/AbstractLibraryPlugin.js +17 -2
- package/lib/library/AmdLibraryPlugin.js +8 -0
- package/lib/library/AssignLibraryPlugin.js +21 -3
- package/lib/library/EnableLibraryPlugin.js +8 -2
- package/lib/library/ExportPropertyLibraryPlugin.js +10 -0
- package/lib/{FalseIIFEUmdWarning.js → library/FalseIIFEUmdWarning.js} +2 -1
- package/lib/library/JsonpLibraryPlugin.js +8 -0
- package/lib/library/ModuleLibraryPlugin.js +154 -7
- package/lib/library/SystemLibraryPlugin.js +11 -3
- package/lib/library/UmdLibraryPlugin.js +16 -0
- package/lib/loaders/LoaderRunner.js +714 -0
- package/lib/loaders/loadLoader.js +100 -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 +4 -63
- package/lib/node/NodeTemplatePlugin.js +3 -1
- package/lib/node/NodeWatchFileSystem.js +40 -22
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +13 -9
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +33 -3
- package/lib/node/ReadFileCompileWasmPlugin.js +28 -3
- package/lib/node/RequireChunkLoadingRuntimeModule.js +21 -16
- package/lib/node/nodeBuiltins.js +80 -0
- package/lib/node/nodeConsole.js +116 -64
- package/lib/optimize/AggressiveMergingPlugin.js +22 -16
- package/lib/optimize/AggressiveSplittingPlugin.js +6 -1
- package/lib/optimize/ConcatenatedModule.js +603 -130
- package/lib/optimize/ConstExportsPlugin.js +211 -0
- package/lib/optimize/EnsureChunkConditionsPlugin.js +2 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +15 -4
- package/lib/optimize/InlineExports.js +178 -0
- package/lib/optimize/InnerGraph.js +374 -262
- package/lib/optimize/InnerGraphPlugin.js +246 -117
- 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 +229 -55
- package/lib/optimize/RealContentHashPlugin.js +130 -52
- 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 +381 -55
- package/lib/optimize/SplitChunksPlugin.js +200 -50
- 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 +21 -0
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +1 -0
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +5 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +25 -13
- package/lib/prefetch/ResourceHintPlugin.js +687 -0
- package/lib/prefetch/ResourceHintRuntimeModule.js +149 -0
- package/lib/prefetch/StartupAssetHintRuntimeModule.js +210 -0
- package/lib/prefetch/parseResourceHintOptions.js +103 -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 +132 -0
- package/lib/rules/UseEffectRulePlugin.js +10 -3
- package/lib/runtime/AsyncModuleGeneratorRuntimeModule.js +56 -0
- package/lib/runtime/AsyncModuleRuntimeModule.js +52 -33
- package/lib/runtime/AutoPublicPathRuntimeModule.js +22 -9
- package/lib/runtime/BaseUriRuntimeModule.js +1 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
- package/lib/runtime/CommonJsWrapRuntimeModule.js +37 -0
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +2 -1
- package/lib/runtime/CompatRuntimeModule.js +2 -0
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +7 -4
- package/lib/runtime/CreateScriptRuntimeModule.js +1 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +1 -0
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +34 -4
- package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +88 -8
- package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -0
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +2 -1
- package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +59 -0
- package/lib/runtime/GlobalRuntimeModule.js +1 -0
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +2 -1
- package/lib/runtime/HelperRuntimeModule.js +5 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +28 -37
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +354 -37
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +2 -1
- package/lib/runtime/NonceRuntimeModule.js +1 -0
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +5 -4
- package/lib/runtime/PublicPathRuntimeModule.js +1 -0
- package/lib/runtime/RelativeUrlRuntimeModule.js +4 -2
- package/lib/runtime/RuntimeIdRuntimeModule.js +1 -0
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +38 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +13 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +2 -1
- package/lib/runtime/StartupEntrypointRuntimeModule.js +5 -3
- package/lib/runtime/SystemContextRuntimeModule.js +1 -0
- package/lib/runtime/ToBinaryRuntimeModule.js +1 -0
- package/lib/runtime/WorkerRuntimeModule.js +33 -0
- package/lib/schemes/DataUriPlugin.js +14 -2
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +86 -4
- package/lib/schemes/VirtualUrlPlugin.js +8 -4
- package/lib/serialization/AggregateErrorSerializer.js +9 -6
- package/lib/serialization/ArraySerializer.js +6 -8
- package/lib/serialization/BinaryMiddleware.js +427 -1006
- package/lib/serialization/DateObjectSerializer.js +4 -2
- package/lib/serialization/ErrorObjectSerializer.js +10 -6
- package/lib/serialization/FileMiddleware.js +345 -59
- package/lib/serialization/MapObjectSerializer.js +7 -9
- package/lib/serialization/NullPrototypeObjectSerializer.js +9 -9
- package/lib/serialization/ObjectMiddleware.js +73 -13
- package/lib/serialization/PlainObjectSerializer.js +16 -8
- package/lib/serialization/RegExpObjectSerializer.js +4 -2
- package/lib/serialization/Serializer.js +6 -0
- package/lib/serialization/SerializerMiddleware.js +14 -2
- package/lib/serialization/SetObjectSerializer.js +6 -8
- package/lib/serialization/SingleItemMiddleware.js +3 -0
- package/lib/sharing/ConsumeSharedFallbackDependency.js +1 -0
- package/lib/sharing/ConsumeSharedModule.js +21 -7
- package/lib/sharing/ConsumeSharedPlugin.js +11 -11
- package/lib/sharing/ConsumeSharedRuntimeModule.js +55 -45
- package/lib/sharing/ProvideForSharedDependency.js +1 -0
- package/lib/sharing/ProvideSharedDependency.js +34 -15
- package/lib/sharing/ProvideSharedModule.js +42 -12
- package/lib/sharing/ProvideSharedModuleFactory.js +1 -0
- package/lib/sharing/ProvideSharedPlugin.js +13 -8
- package/lib/sharing/SharePlugin.js +5 -1
- package/lib/sharing/ShareRuntimeModule.js +19 -16
- package/lib/sharing/resolveMatchedConfigs.js +6 -2
- package/lib/sharing/utils.js +9 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +289 -201
- package/lib/stats/DefaultStatsPresetPlugin.js +14 -2
- package/lib/stats/DefaultStatsPrinterPlugin.js +74 -170
- package/lib/stats/StatsFactory.js +70 -27
- package/lib/stats/StatsPrinter.js +16 -2
- package/lib/typescript/TypeScriptPlugin.js +210 -0
- package/lib/url/URLParserPlugin.js +111 -23
- package/lib/util/ArrayHelpers.js +1 -0
- package/lib/util/ArrayQueue.js +10 -5
- package/lib/util/AsyncQueue.js +154 -74
- package/lib/util/Hash.js +2 -2
- package/lib/util/IterableHelpers.js +3 -0
- package/lib/util/LazyBucketSortedSet.js +26 -0
- package/lib/util/LazySet.js +45 -4
- package/lib/util/LocConverter.js +64 -0
- package/lib/util/ParallelismFactorCalculator.js +1 -0
- package/lib/util/Queue.js +6 -3
- package/lib/util/Semaphore.js +15 -1
- package/lib/util/SetHelpers.js +4 -1
- package/lib/util/SortableSet.js +7 -1
- package/lib/util/SourceProcessor.js +119 -0
- package/lib/util/StackedCacheMap.js +20 -3
- package/lib/util/StackedMap.js +162 -43
- package/lib/util/StringXor.js +1 -1
- package/lib/util/TupleQueue.js +7 -3
- package/lib/util/TupleSet.js +14 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -0
- package/lib/util/WeakTupleMap.js +60 -1
- package/lib/util/binarySearchBounds.js +3 -2
- package/lib/util/chainedImports.js +3 -3
- package/lib/util/cleverMerge.js +19 -2
- package/lib/util/comparators.js +35 -4
- package/lib/util/compileBooleanMatcher.js +9 -0
- package/lib/util/concatenate.js +80 -24
- package/lib/util/conventions.js +46 -1
- package/lib/util/createHash.js +0 -1
- package/lib/util/createHooksRegistry.js +43 -0
- package/lib/util/createMappings.js +118 -0
- package/lib/util/dataURL.js +3 -2
- package/lib/util/deprecation.js +19 -0
- package/lib/util/deterministicGrouping.js +46 -17
- package/lib/util/extractSourceMap.js +2 -1
- package/lib/util/extractUrlAndGlobal.js +1 -0
- package/lib/util/findGraphRoots.js +7 -0
- package/lib/{formatLocation.js → util/formatLocation.js} +4 -2
- package/lib/{SizeFormatHelpers.js → util/formatSize.js} +10 -3
- package/lib/util/fs.js +87 -14
- package/lib/util/generateDebugId.js +1 -0
- package/lib/util/globUtils.js +710 -0
- package/lib/util/hash/BatchedHash.js +1 -0
- package/lib/util/hash/BulkUpdateHash.js +1 -0
- package/lib/util/hash/DebugHash.js +1 -0
- package/lib/util/hash/hash-digest.js +32 -15
- 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 +118 -7
- package/lib/util/implicitTypeLoaderFallback.js +62 -0
- package/lib/util/internalSerializables.js +102 -60
- package/lib/util/magicComment.js +149 -7
- package/lib/util/makeSerializable.js +7 -0
- package/lib/util/memoize.js +2 -0
- package/lib/util/mimeTypes.js +176 -0
- package/lib/util/nonNumericOnlyHash.js +31 -1
- package/lib/util/numberHash.js +2 -2
- package/lib/util/parseJson.js +41 -0
- package/lib/util/processAsyncTree.js +8 -0
- package/lib/util/property.js +9 -2
- package/lib/util/publicPathPlaceholder.js +64 -0
- package/lib/util/registerExternalSerializer.js +24 -4
- 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 +25 -18
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +34 -22
- package/lib/wasm-async/AsyncWasmModule.js +77 -0
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +6 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +22 -126
- package/lib/wasm-async/AsyncWebAssemblyParser.js +3 -2
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +13 -2
- package/lib/wasm-sync/SyncWasmModule.js +39 -0
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +7 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +86 -19
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +4 -3
- package/lib/wasm-sync/WebAssemblyGenerator.js +27 -1
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +9 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +4 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +20 -1
- package/lib/wasm-sync/WebAssemblyParser.js +9 -3
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -0
- package/lib/web/FetchCompileAsyncWasmPlugin.js +29 -1
- package/lib/web/FetchCompileWasmPlugin.js +27 -1
- package/lib/web/JsonpChunkLoadingPlugin.js +11 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +58 -64
- package/lib/web/JsonpTemplatePlugin.js +2 -1
- package/lib/webpack.js +78 -1
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +10 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +15 -10
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -1
- package/module.d.ts +21 -0
- package/package.json +79 -77
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +1173 -80
- 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/{DllReferencePlugin.check.d.ts → HtmlParserOptions.check.d.ts} +1 -1
- package/schemas/plugins/HtmlParserOptions.check.js +6 -0
- package/schemas/plugins/HtmlParserOptions.json +3 -0
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +38 -0
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +2 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +2 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.json +3 -0
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/dll/DllPlugin.check.d.ts +7 -0
- package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +7 -0
- package/types.d.ts +11053 -3019
- package/lib/CaseSensitiveModulesWarning.js +0 -72
- package/lib/GraphHelpers.js +0 -46
- package/lib/ModuleParseError.js +0 -125
- package/lib/NoModeWarning.js +0 -23
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +0 -56
- package/lib/css/walkCssTokens.js +0 -1843
- package/lib/util/AppendOnlyStackedSet.js +0 -78
- /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,20 +185,25 @@ 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
|
*/
|
|
186
203
|
constructor(snapshot, getMaps) {
|
|
204
|
+
/** @type {Snapshot} */
|
|
187
205
|
this.snapshot = snapshot;
|
|
206
|
+
/** @type {GetMapsFunction<T>} */
|
|
188
207
|
this.getMaps = getMaps;
|
|
189
208
|
}
|
|
190
209
|
|
|
@@ -214,7 +233,7 @@ class SnapshotIterable {
|
|
|
214
233
|
const map = maps.pop();
|
|
215
234
|
if (map !== undefined) {
|
|
216
235
|
it =
|
|
217
|
-
/** @type {Set<
|
|
236
|
+
/** @type {Set<string> | Map<string, EXPECTED_ANY>} */
|
|
218
237
|
(map).keys();
|
|
219
238
|
state = 2;
|
|
220
239
|
} else {
|
|
@@ -278,8 +297,25 @@ class SnapshotIterable {
|
|
|
278
297
|
/** @typedef {Set<string>} ManagedMissing */
|
|
279
298
|
/** @typedef {Set<Snapshot>} Children */
|
|
280
299
|
|
|
300
|
+
// `Snapshot._flags` bit for each optional field. Serialized as a whole integer,
|
|
301
|
+
// so these values are a persisted-cache format contract — never renumber them.
|
|
302
|
+
const SNAPSHOT_FLAG_START_TIME = 1;
|
|
303
|
+
const SNAPSHOT_FLAG_FILE_TIMESTAMPS = 2;
|
|
304
|
+
const SNAPSHOT_FLAG_FILE_HASHES = 4;
|
|
305
|
+
const SNAPSHOT_FLAG_FILE_TSHS = 8;
|
|
306
|
+
const SNAPSHOT_FLAG_CONTEXT_TIMESTAMPS = 0x10;
|
|
307
|
+
const SNAPSHOT_FLAG_CONTEXT_HASHES = 0x20;
|
|
308
|
+
const SNAPSHOT_FLAG_CONTEXT_TSHS = 0x40;
|
|
309
|
+
const SNAPSHOT_FLAG_MISSING_EXISTENCE = 0x80;
|
|
310
|
+
const SNAPSHOT_FLAG_MANAGED_ITEM_INFO = 0x100;
|
|
311
|
+
const SNAPSHOT_FLAG_MANAGED_FILES = 0x200;
|
|
312
|
+
const SNAPSHOT_FLAG_MANAGED_CONTEXTS = 0x400;
|
|
313
|
+
const SNAPSHOT_FLAG_MANAGED_MISSING = 0x800;
|
|
314
|
+
const SNAPSHOT_FLAG_CHILDREN = 0x1000;
|
|
315
|
+
|
|
281
316
|
class Snapshot {
|
|
282
317
|
constructor() {
|
|
318
|
+
/** @type {number} */
|
|
283
319
|
this._flags = 0;
|
|
284
320
|
/** @type {Iterable<string> | undefined} */
|
|
285
321
|
this._cachedFileIterable = undefined;
|
|
@@ -316,18 +352,20 @@ class Snapshot {
|
|
|
316
352
|
}
|
|
317
353
|
|
|
318
354
|
hasStartTime() {
|
|
319
|
-
return (this._flags &
|
|
355
|
+
return (this._flags & SNAPSHOT_FLAG_START_TIME) !== 0;
|
|
320
356
|
}
|
|
321
357
|
|
|
322
358
|
/**
|
|
359
|
+
* Updates start time using the provided value.
|
|
323
360
|
* @param {number} value start value
|
|
324
361
|
*/
|
|
325
362
|
setStartTime(value) {
|
|
326
|
-
this._flags |=
|
|
363
|
+
this._flags |= SNAPSHOT_FLAG_START_TIME;
|
|
327
364
|
this.startTime = value;
|
|
328
365
|
}
|
|
329
366
|
|
|
330
367
|
/**
|
|
368
|
+
* Sets merged start time.
|
|
331
369
|
* @param {number | undefined} value value
|
|
332
370
|
* @param {Snapshot} snapshot snapshot
|
|
333
371
|
*/
|
|
@@ -353,150 +391,163 @@ class Snapshot {
|
|
|
353
391
|
}
|
|
354
392
|
|
|
355
393
|
hasFileTimestamps() {
|
|
356
|
-
return (this._flags &
|
|
394
|
+
return (this._flags & SNAPSHOT_FLAG_FILE_TIMESTAMPS) !== 0;
|
|
357
395
|
}
|
|
358
396
|
|
|
359
397
|
/**
|
|
398
|
+
* Sets file timestamps.
|
|
360
399
|
* @param {FileTimestamps} value file timestamps
|
|
361
400
|
*/
|
|
362
401
|
setFileTimestamps(value) {
|
|
363
|
-
this._flags |=
|
|
402
|
+
this._flags |= SNAPSHOT_FLAG_FILE_TIMESTAMPS;
|
|
364
403
|
this.fileTimestamps = value;
|
|
365
404
|
}
|
|
366
405
|
|
|
367
406
|
hasFileHashes() {
|
|
368
|
-
return (this._flags &
|
|
407
|
+
return (this._flags & SNAPSHOT_FLAG_FILE_HASHES) !== 0;
|
|
369
408
|
}
|
|
370
409
|
|
|
371
410
|
/**
|
|
411
|
+
* Updates file hashes using the provided value.
|
|
372
412
|
* @param {FileHashes} value file hashes
|
|
373
413
|
*/
|
|
374
414
|
setFileHashes(value) {
|
|
375
|
-
this._flags |=
|
|
415
|
+
this._flags |= SNAPSHOT_FLAG_FILE_HASHES;
|
|
376
416
|
this.fileHashes = value;
|
|
377
417
|
}
|
|
378
418
|
|
|
379
419
|
hasFileTshs() {
|
|
380
|
-
return (this._flags &
|
|
420
|
+
return (this._flags & SNAPSHOT_FLAG_FILE_TSHS) !== 0;
|
|
381
421
|
}
|
|
382
422
|
|
|
383
423
|
/**
|
|
424
|
+
* Updates file tshs using the provided value.
|
|
384
425
|
* @param {FileTshs} value file tshs
|
|
385
426
|
*/
|
|
386
427
|
setFileTshs(value) {
|
|
387
|
-
this._flags |=
|
|
428
|
+
this._flags |= SNAPSHOT_FLAG_FILE_TSHS;
|
|
388
429
|
this.fileTshs = value;
|
|
389
430
|
}
|
|
390
431
|
|
|
391
432
|
hasContextTimestamps() {
|
|
392
|
-
return (this._flags &
|
|
433
|
+
return (this._flags & SNAPSHOT_FLAG_CONTEXT_TIMESTAMPS) !== 0;
|
|
393
434
|
}
|
|
394
435
|
|
|
395
436
|
/**
|
|
437
|
+
* Sets context timestamps.
|
|
396
438
|
* @param {ContextTimestamps} value context timestamps
|
|
397
439
|
*/
|
|
398
440
|
setContextTimestamps(value) {
|
|
399
|
-
this._flags |=
|
|
441
|
+
this._flags |= SNAPSHOT_FLAG_CONTEXT_TIMESTAMPS;
|
|
400
442
|
this.contextTimestamps = value;
|
|
401
443
|
}
|
|
402
444
|
|
|
403
445
|
hasContextHashes() {
|
|
404
|
-
return (this._flags &
|
|
446
|
+
return (this._flags & SNAPSHOT_FLAG_CONTEXT_HASHES) !== 0;
|
|
405
447
|
}
|
|
406
448
|
|
|
407
449
|
/**
|
|
450
|
+
* Sets context hashes.
|
|
408
451
|
* @param {ContextHashes} value context hashes
|
|
409
452
|
*/
|
|
410
453
|
setContextHashes(value) {
|
|
411
|
-
this._flags |=
|
|
454
|
+
this._flags |= SNAPSHOT_FLAG_CONTEXT_HASHES;
|
|
412
455
|
this.contextHashes = value;
|
|
413
456
|
}
|
|
414
457
|
|
|
415
458
|
hasContextTshs() {
|
|
416
|
-
return (this._flags &
|
|
459
|
+
return (this._flags & SNAPSHOT_FLAG_CONTEXT_TSHS) !== 0;
|
|
417
460
|
}
|
|
418
461
|
|
|
419
462
|
/**
|
|
463
|
+
* Updates context tshs using the provided value.
|
|
420
464
|
* @param {ContextTshs} value context tshs
|
|
421
465
|
*/
|
|
422
466
|
setContextTshs(value) {
|
|
423
|
-
this._flags |=
|
|
467
|
+
this._flags |= SNAPSHOT_FLAG_CONTEXT_TSHS;
|
|
424
468
|
this.contextTshs = value;
|
|
425
469
|
}
|
|
426
470
|
|
|
427
471
|
hasMissingExistence() {
|
|
428
|
-
return (this._flags &
|
|
472
|
+
return (this._flags & SNAPSHOT_FLAG_MISSING_EXISTENCE) !== 0;
|
|
429
473
|
}
|
|
430
474
|
|
|
431
475
|
/**
|
|
476
|
+
* Sets missing existence.
|
|
432
477
|
* @param {MissingExistence} value context tshs
|
|
433
478
|
*/
|
|
434
479
|
setMissingExistence(value) {
|
|
435
|
-
this._flags |=
|
|
480
|
+
this._flags |= SNAPSHOT_FLAG_MISSING_EXISTENCE;
|
|
436
481
|
this.missingExistence = value;
|
|
437
482
|
}
|
|
438
483
|
|
|
439
484
|
hasManagedItemInfo() {
|
|
440
|
-
return (this._flags &
|
|
485
|
+
return (this._flags & SNAPSHOT_FLAG_MANAGED_ITEM_INFO) !== 0;
|
|
441
486
|
}
|
|
442
487
|
|
|
443
488
|
/**
|
|
489
|
+
* Sets managed item info.
|
|
444
490
|
* @param {ManagedItemInfo} value managed item info
|
|
445
491
|
*/
|
|
446
492
|
setManagedItemInfo(value) {
|
|
447
|
-
this._flags |=
|
|
493
|
+
this._flags |= SNAPSHOT_FLAG_MANAGED_ITEM_INFO;
|
|
448
494
|
this.managedItemInfo = value;
|
|
449
495
|
}
|
|
450
496
|
|
|
451
497
|
hasManagedFiles() {
|
|
452
|
-
return (this._flags &
|
|
498
|
+
return (this._flags & SNAPSHOT_FLAG_MANAGED_FILES) !== 0;
|
|
453
499
|
}
|
|
454
500
|
|
|
455
501
|
/**
|
|
502
|
+
* Sets managed files.
|
|
456
503
|
* @param {ManagedFiles} value managed files
|
|
457
504
|
*/
|
|
458
505
|
setManagedFiles(value) {
|
|
459
|
-
this._flags |=
|
|
506
|
+
this._flags |= SNAPSHOT_FLAG_MANAGED_FILES;
|
|
460
507
|
this.managedFiles = value;
|
|
461
508
|
}
|
|
462
509
|
|
|
463
510
|
hasManagedContexts() {
|
|
464
|
-
return (this._flags &
|
|
511
|
+
return (this._flags & SNAPSHOT_FLAG_MANAGED_CONTEXTS) !== 0;
|
|
465
512
|
}
|
|
466
513
|
|
|
467
514
|
/**
|
|
515
|
+
* Sets managed contexts.
|
|
468
516
|
* @param {ManagedContexts} value managed contexts
|
|
469
517
|
*/
|
|
470
518
|
setManagedContexts(value) {
|
|
471
|
-
this._flags |=
|
|
519
|
+
this._flags |= SNAPSHOT_FLAG_MANAGED_CONTEXTS;
|
|
472
520
|
this.managedContexts = value;
|
|
473
521
|
}
|
|
474
522
|
|
|
475
523
|
hasManagedMissing() {
|
|
476
|
-
return (this._flags &
|
|
524
|
+
return (this._flags & SNAPSHOT_FLAG_MANAGED_MISSING) !== 0;
|
|
477
525
|
}
|
|
478
526
|
|
|
479
527
|
/**
|
|
528
|
+
* Sets managed missing.
|
|
480
529
|
* @param {ManagedMissing} value managed missing
|
|
481
530
|
*/
|
|
482
531
|
setManagedMissing(value) {
|
|
483
|
-
this._flags |=
|
|
532
|
+
this._flags |= SNAPSHOT_FLAG_MANAGED_MISSING;
|
|
484
533
|
this.managedMissing = value;
|
|
485
534
|
}
|
|
486
535
|
|
|
487
536
|
hasChildren() {
|
|
488
|
-
return (this._flags &
|
|
537
|
+
return (this._flags & SNAPSHOT_FLAG_CHILDREN) !== 0;
|
|
489
538
|
}
|
|
490
539
|
|
|
491
540
|
/**
|
|
541
|
+
* Updates children using the provided value.
|
|
492
542
|
* @param {Children} value children
|
|
493
543
|
*/
|
|
494
544
|
setChildren(value) {
|
|
495
|
-
this._flags |=
|
|
545
|
+
this._flags |= SNAPSHOT_FLAG_CHILDREN;
|
|
496
546
|
this.children = value;
|
|
497
547
|
}
|
|
498
548
|
|
|
499
549
|
/**
|
|
550
|
+
* Adds the provided child to the snapshot.
|
|
500
551
|
* @param {Snapshot} child children
|
|
501
552
|
*/
|
|
502
553
|
addChild(child) {
|
|
@@ -508,6 +559,7 @@ class Snapshot {
|
|
|
508
559
|
}
|
|
509
560
|
|
|
510
561
|
/**
|
|
562
|
+
* Serializes this instance into the provided serializer context.
|
|
511
563
|
* @param {ObjectSerializerContext} context context
|
|
512
564
|
*/
|
|
513
565
|
serialize({ write }) {
|
|
@@ -528,6 +580,7 @@ class Snapshot {
|
|
|
528
580
|
}
|
|
529
581
|
|
|
530
582
|
/**
|
|
583
|
+
* Restores this instance from the provided deserializer context.
|
|
531
584
|
* @param {ObjectDeserializerContext} context context
|
|
532
585
|
*/
|
|
533
586
|
deserialize({ read }) {
|
|
@@ -548,6 +601,7 @@ class Snapshot {
|
|
|
548
601
|
}
|
|
549
602
|
|
|
550
603
|
/**
|
|
604
|
+
* Creates an iterable from the provided get map.
|
|
551
605
|
* @template T
|
|
552
606
|
* @param {GetMapsFunction<T>} getMaps first
|
|
553
607
|
* @returns {SnapshotIterable<T>} iterable
|
|
@@ -557,6 +611,7 @@ class Snapshot {
|
|
|
557
611
|
}
|
|
558
612
|
|
|
559
613
|
/**
|
|
614
|
+
* Gets file iterable.
|
|
560
615
|
* @returns {Iterable<string>} iterable
|
|
561
616
|
*/
|
|
562
617
|
getFileIterable() {
|
|
@@ -572,6 +627,7 @@ class Snapshot {
|
|
|
572
627
|
}
|
|
573
628
|
|
|
574
629
|
/**
|
|
630
|
+
* Gets context iterable.
|
|
575
631
|
* @returns {Iterable<string>} iterable
|
|
576
632
|
*/
|
|
577
633
|
getContextIterable() {
|
|
@@ -587,6 +643,7 @@ class Snapshot {
|
|
|
587
643
|
}
|
|
588
644
|
|
|
589
645
|
/**
|
|
646
|
+
* Gets missing iterable.
|
|
590
647
|
* @returns {Iterable<string>} iterable
|
|
591
648
|
*/
|
|
592
649
|
getMissingIterable() {
|
|
@@ -605,16 +662,19 @@ makeSerializable(Snapshot, "webpack/lib/FileSystemInfo", "Snapshot");
|
|
|
605
662
|
const MIN_COMMON_SNAPSHOT_SIZE = 3;
|
|
606
663
|
|
|
607
664
|
/**
|
|
665
|
+
* Defines the snapshot optimization value type used by this module.
|
|
608
666
|
* @template U, T
|
|
609
667
|
* @typedef {U extends true ? Set<string> : Map<string, T>} SnapshotOptimizationValue
|
|
610
668
|
*/
|
|
611
669
|
|
|
612
670
|
/**
|
|
671
|
+
* Represents SnapshotOptimization.
|
|
613
672
|
* @template T
|
|
614
673
|
* @template {boolean} [U=false]
|
|
615
674
|
*/
|
|
616
675
|
class SnapshotOptimization {
|
|
617
676
|
/**
|
|
677
|
+
* Creates an instance of SnapshotOptimization.
|
|
618
678
|
* @param {(snapshot: Snapshot) => boolean} has has value
|
|
619
679
|
* @param {(snapshot: Snapshot) => SnapshotOptimizationValue<U, T> | undefined} get get value
|
|
620
680
|
* @param {(snapshot: Snapshot, value: SnapshotOptimizationValue<U, T>) => void} set set value
|
|
@@ -631,14 +691,19 @@ class SnapshotOptimization {
|
|
|
631
691
|
this._has = has;
|
|
632
692
|
this._get = get;
|
|
633
693
|
this._set = set;
|
|
694
|
+
/** @type {boolean} */
|
|
634
695
|
this._useStartTime = useStartTime;
|
|
635
696
|
/** @type {U} */
|
|
636
697
|
this._isSet = isSet;
|
|
637
698
|
/** @type {Map<string, SnapshotOptimizationEntry>} */
|
|
638
699
|
this._map = new Map();
|
|
700
|
+
/** @type {number} */
|
|
639
701
|
this._statItemsShared = 0;
|
|
702
|
+
/** @type {number} */
|
|
640
703
|
this._statItemsUnshared = 0;
|
|
704
|
+
/** @type {number} */
|
|
641
705
|
this._statSharedSnapshots = 0;
|
|
706
|
+
/** @type {number} */
|
|
642
707
|
this._statReusedSharedSnapshots = 0;
|
|
643
708
|
}
|
|
644
709
|
|
|
@@ -663,6 +728,7 @@ class SnapshotOptimization {
|
|
|
663
728
|
}
|
|
664
729
|
|
|
665
730
|
/**
|
|
731
|
+
* Processes the provided new snapshot.
|
|
666
732
|
* @param {Snapshot} newSnapshot snapshot
|
|
667
733
|
* @param {Set<string>} capturedFiles files to snapshot/share
|
|
668
734
|
* @returns {void}
|
|
@@ -672,6 +738,7 @@ class SnapshotOptimization {
|
|
|
672
738
|
return;
|
|
673
739
|
}
|
|
674
740
|
/**
|
|
741
|
+
* Increase shared and store optimization entry.
|
|
675
742
|
* @param {SnapshotOptimizationEntry} entry optimization entry
|
|
676
743
|
* @returns {void}
|
|
677
744
|
*/
|
|
@@ -685,6 +752,7 @@ class SnapshotOptimization {
|
|
|
685
752
|
storeOptimizationEntry(entry);
|
|
686
753
|
};
|
|
687
754
|
/**
|
|
755
|
+
* Stores optimization entry.
|
|
688
756
|
* @param {SnapshotOptimizationEntry} entry optimization entry
|
|
689
757
|
* @returns {void}
|
|
690
758
|
*/
|
|
@@ -885,19 +953,125 @@ class SnapshotOptimization {
|
|
|
885
953
|
}
|
|
886
954
|
}
|
|
887
955
|
|
|
956
|
+
/** @type {Record<string, string>} */
|
|
957
|
+
const ESCAPES = {
|
|
958
|
+
n: "\n",
|
|
959
|
+
r: "\r",
|
|
960
|
+
t: "\t",
|
|
961
|
+
b: "\b",
|
|
962
|
+
f: "\f",
|
|
963
|
+
v: "\v"
|
|
964
|
+
};
|
|
965
|
+
|
|
888
966
|
/**
|
|
889
|
-
*
|
|
890
|
-
*
|
|
967
|
+
* Cooks a JS string/template literal specifier into its evaluated value,
|
|
968
|
+
* matching ECMAScript escape semantics (sloppy-mode for string literals).
|
|
969
|
+
* @param {string} str input including the surrounding quotes
|
|
970
|
+
* @returns {string | null} result, or null when not a quoted literal
|
|
971
|
+
* @throws {Error} on a malformed escape sequence, like the JS parser would
|
|
891
972
|
*/
|
|
892
973
|
const parseString = (str) => {
|
|
893
|
-
|
|
894
|
-
|
|
974
|
+
const q = str[0];
|
|
975
|
+
|
|
976
|
+
if (q !== '"' && q !== "'" && q !== "`") {
|
|
977
|
+
return null;
|
|
895
978
|
}
|
|
896
|
-
|
|
979
|
+
|
|
980
|
+
const template = q === "`";
|
|
981
|
+
const inner = str.slice(1, -1);
|
|
982
|
+
const len = inner.length;
|
|
983
|
+
let result = "";
|
|
984
|
+
let i = 0;
|
|
985
|
+
|
|
986
|
+
while (i < len) {
|
|
987
|
+
const ch = inner[i];
|
|
988
|
+
if (ch !== "\\") {
|
|
989
|
+
// Template value normalizes raw <CR> and <CRLF> to <LF>
|
|
990
|
+
if (template && ch === "\r") {
|
|
991
|
+
result += "\n";
|
|
992
|
+
i += inner[i + 1] === "\n" ? 2 : 1;
|
|
993
|
+
} else {
|
|
994
|
+
result += ch;
|
|
995
|
+
i++;
|
|
996
|
+
}
|
|
997
|
+
continue;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
i++;
|
|
1001
|
+
if (i >= len) throw new Error("Unterminated escape sequence");
|
|
1002
|
+
const esc = inner[i];
|
|
1003
|
+
|
|
1004
|
+
if (esc === "x") {
|
|
1005
|
+
const hex = inner.slice(i + 1, i + 3);
|
|
1006
|
+
if (!/^[0-9a-fA-F]{2}$/.test(hex)) {
|
|
1007
|
+
throw new Error("Invalid hexadecimal escape sequence");
|
|
1008
|
+
}
|
|
1009
|
+
result += String.fromCharCode(Number.parseInt(hex, 16));
|
|
1010
|
+
i += 3;
|
|
1011
|
+
} else if (esc === "u") {
|
|
1012
|
+
if (inner[i + 1] === "{") {
|
|
1013
|
+
// \u{N...}
|
|
1014
|
+
const closeIdx = inner.indexOf("}", i + 2);
|
|
1015
|
+
const codeStr = closeIdx === -1 ? "" : inner.slice(i + 2, closeIdx);
|
|
1016
|
+
const code = Number.parseInt(codeStr, 16);
|
|
1017
|
+
if (!/^[0-9a-fA-F]+$/.test(codeStr) || code > 0x10ffff) {
|
|
1018
|
+
throw new Error("Invalid Unicode escape sequence");
|
|
1019
|
+
}
|
|
1020
|
+
result += String.fromCodePoint(code);
|
|
1021
|
+
i = closeIdx + 1;
|
|
1022
|
+
} else {
|
|
1023
|
+
// \uNNNN
|
|
1024
|
+
const hex = inner.slice(i + 1, i + 5);
|
|
1025
|
+
if (!/^[0-9a-fA-F]{4}$/.test(hex)) {
|
|
1026
|
+
throw new Error("Invalid Unicode escape sequence");
|
|
1027
|
+
}
|
|
1028
|
+
result += String.fromCharCode(Number.parseInt(hex, 16));
|
|
1029
|
+
i += 5;
|
|
1030
|
+
}
|
|
1031
|
+
} else if (esc === "\r") {
|
|
1032
|
+
// Line continuation: \<CR> or \<CRLF>
|
|
1033
|
+
i += inner[i + 1] === "\n" ? 2 : 1;
|
|
1034
|
+
} else if (esc === "\n" || esc === "\u2028" || esc === "\u2029") {
|
|
1035
|
+
// Line continuation: \<LF>, \<LS>, \<PS>
|
|
1036
|
+
i++;
|
|
1037
|
+
} else if (ESCAPES[esc] !== undefined) {
|
|
1038
|
+
result += ESCAPES[esc];
|
|
1039
|
+
i++;
|
|
1040
|
+
} else if (esc >= "0" && esc <= "7") {
|
|
1041
|
+
// \0 not followed by a digit is NUL, otherwise a legacy octal escape
|
|
1042
|
+
const next = inner[i + 1];
|
|
1043
|
+
if (esc === "0" && !(next >= "0" && next <= "9")) {
|
|
1044
|
+
result += "\0";
|
|
1045
|
+
i++;
|
|
1046
|
+
continue;
|
|
1047
|
+
}
|
|
1048
|
+
if (template) throw new Error("Octal escape not allowed in template");
|
|
1049
|
+
// Up to 3 octal digits, value capped at \377
|
|
1050
|
+
let oct = esc;
|
|
1051
|
+
i++;
|
|
1052
|
+
const max = esc <= "3" ? 3 : 2;
|
|
1053
|
+
while (oct.length < max && inner[i] >= "0" && inner[i] <= "7") {
|
|
1054
|
+
oct += inner[i];
|
|
1055
|
+
i++;
|
|
1056
|
+
}
|
|
1057
|
+
result += String.fromCharCode(Number.parseInt(oct, 8));
|
|
1058
|
+
} else if (esc === "8" || esc === "9") {
|
|
1059
|
+
if (template) throw new Error("\\8 and \\9 not allowed in template");
|
|
1060
|
+
result += esc;
|
|
1061
|
+
i++;
|
|
1062
|
+
} else {
|
|
1063
|
+
// \', \", \\, \`, and any other NonEscapeCharacter — the char itself
|
|
1064
|
+
result += esc;
|
|
1065
|
+
i++;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
return result;
|
|
897
1070
|
};
|
|
898
1071
|
|
|
899
1072
|
/* istanbul ignore next */
|
|
900
1073
|
/**
|
|
1074
|
+
* Processes the provided mtime.
|
|
901
1075
|
* @param {number} mtime mtime
|
|
902
1076
|
*/
|
|
903
1077
|
const applyMtime = (mtime) => {
|
|
@@ -908,6 +1082,7 @@ const applyMtime = (mtime) => {
|
|
|
908
1082
|
};
|
|
909
1083
|
|
|
910
1084
|
/**
|
|
1085
|
+
* Merges the provided values into a single result.
|
|
911
1086
|
* @template T
|
|
912
1087
|
* @template K
|
|
913
1088
|
* @param {Map<T, K> | undefined} a source map
|
|
@@ -926,6 +1101,7 @@ const mergeMaps = (a, b) => {
|
|
|
926
1101
|
};
|
|
927
1102
|
|
|
928
1103
|
/**
|
|
1104
|
+
* Merges the provided values into a single result.
|
|
929
1105
|
* @template T
|
|
930
1106
|
* @param {Set<T> | undefined} a source map
|
|
931
1107
|
* @param {Set<T> | undefined} b joining map
|
|
@@ -1027,6 +1203,7 @@ const getManagedItem = (managedPath, path) => {
|
|
|
1027
1203
|
};
|
|
1028
1204
|
|
|
1029
1205
|
/**
|
|
1206
|
+
* Gets resolved timestamp.
|
|
1030
1207
|
* @template {ContextFileSystemInfoEntry | ContextTimestampAndHash} T
|
|
1031
1208
|
* @param {T | null} entry entry
|
|
1032
1209
|
* @returns {T["resolved"] | null | undefined} the resolved entry
|
|
@@ -1038,6 +1215,7 @@ const getResolvedTimestamp = (entry) => {
|
|
|
1038
1215
|
};
|
|
1039
1216
|
|
|
1040
1217
|
/**
|
|
1218
|
+
* Gets resolved hash.
|
|
1041
1219
|
* @param {ContextHash | null} entry entry
|
|
1042
1220
|
* @returns {string | null | undefined} the resolved entry
|
|
1043
1221
|
*/
|
|
@@ -1048,6 +1226,7 @@ const getResolvedHash = (entry) => {
|
|
|
1048
1226
|
};
|
|
1049
1227
|
|
|
1050
1228
|
/**
|
|
1229
|
+
* Adds the provided source to the snapshot optimization.
|
|
1051
1230
|
* @template T
|
|
1052
1231
|
* @param {Set<T>} source source
|
|
1053
1232
|
* @param {Set<T>} target target
|
|
@@ -1058,12 +1237,91 @@ const addAll = (source, target) => {
|
|
|
1058
1237
|
|
|
1059
1238
|
const getEsModuleLexer = memoize(() => require("es-module-lexer"));
|
|
1060
1239
|
|
|
1240
|
+
const getAcorn = memoize(/* istanbul ignore next */ () => require("acorn"));
|
|
1241
|
+
|
|
1242
|
+
// Bun doesn't populate `require.cache` `module.children`, so the CJS build-dependency
|
|
1243
|
+
// walk needs a source-parsing fallback there. Node/Deno populate it — never pay for it.
|
|
1244
|
+
const IS_BUN = Boolean(process.versions.bun);
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* Collects static `require("literal")` specifiers from CommonJS source. Used as a
|
|
1248
|
+
* fallback where `require.cache` children aren't populated (e.g. Bun), so build
|
|
1249
|
+
* dependencies of a CJS file are still tracked. Dynamic requires can't be seen here.
|
|
1250
|
+
* @param {string} source source
|
|
1251
|
+
* @returns {Set<string>} required specifiers
|
|
1252
|
+
*/
|
|
1253
|
+
// Bun-only: exercised by BuildDependencies.longtest under the Bun CI job (no coverage upload).
|
|
1254
|
+
/* istanbul ignore next */
|
|
1255
|
+
const parseCjsRequires = (source) => {
|
|
1256
|
+
/** @type {Set<string>} */
|
|
1257
|
+
const requires = new Set();
|
|
1258
|
+
const ast = getAcorn().parse(source, {
|
|
1259
|
+
ecmaVersion: "latest",
|
|
1260
|
+
sourceType: "script",
|
|
1261
|
+
allowReturnOutsideFunction: true
|
|
1262
|
+
});
|
|
1263
|
+
/** @type {EXPECTED_ANY[]} */
|
|
1264
|
+
const stack = [ast];
|
|
1265
|
+
while (stack.length > 0) {
|
|
1266
|
+
const node = stack.pop();
|
|
1267
|
+
if (!node || typeof node.type !== "string") continue;
|
|
1268
|
+
if (
|
|
1269
|
+
node.type === "CallExpression" &&
|
|
1270
|
+
node.callee.type === "Identifier" &&
|
|
1271
|
+
node.callee.name === "require" &&
|
|
1272
|
+
node.arguments.length === 1 &&
|
|
1273
|
+
node.arguments[0].type === "Literal" &&
|
|
1274
|
+
typeof node.arguments[0].value === "string"
|
|
1275
|
+
) {
|
|
1276
|
+
requires.add(node.arguments[0].value);
|
|
1277
|
+
}
|
|
1278
|
+
for (const key of Object.keys(node)) {
|
|
1279
|
+
const value = node[key];
|
|
1280
|
+
if (Array.isArray(value)) {
|
|
1281
|
+
for (const item of value) {
|
|
1282
|
+
if (item && typeof item.type === "string") stack.push(item);
|
|
1283
|
+
}
|
|
1284
|
+
} else if (value && typeof value.type === "string") {
|
|
1285
|
+
stack.push(value);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
return requires;
|
|
1290
|
+
};
|
|
1291
|
+
|
|
1061
1292
|
/** @typedef {Set<string>} LoggedPaths */
|
|
1062
1293
|
|
|
1063
|
-
/** @typedef {FileSystemInfoEntry | "ignore" | null} FileTimestamp */
|
|
1064
|
-
/** @typedef {ContextFileSystemInfoEntry | "ignore" | null} ContextTimestamp */
|
|
1294
|
+
/** @typedef {FileSystemInfoEntry | ExistenceOnlyTimeEntry | "ignore" | null} FileTimestamp */
|
|
1295
|
+
/** @typedef {ContextFileSystemInfoEntry | ExistenceOnlyTimeEntry | "ignore" | null} ContextTimestamp */
|
|
1065
1296
|
/** @typedef {ResolvedContextFileSystemInfoEntry | "ignore" | null} ResolvedContextTimestamp */
|
|
1066
1297
|
|
|
1298
|
+
/**
|
|
1299
|
+
* `watchpack` may report `{}` (existence-only) for files and directories it
|
|
1300
|
+
* is watching but has no time information for. Such entries cannot be used
|
|
1301
|
+
* for snapshot comparison, so cache lookups treat them as "no cached value"
|
|
1302
|
+
* and fall back to a fresh on-disk read.
|
|
1303
|
+
* @param {FileTimestamp | ContextTimestamp | undefined} entry cache entry
|
|
1304
|
+
* @returns {entry is ExistenceOnlyTimeEntry} true if the entry exists but carries no time info
|
|
1305
|
+
*/
|
|
1306
|
+
const isExistenceOnly = (entry) => {
|
|
1307
|
+
if (entry === undefined || entry === null || entry === "ignore") return false;
|
|
1308
|
+
return (
|
|
1309
|
+
/** @type {Partial<FileSystemInfoEntry> & Partial<ContextFileSystemInfoEntry>} */
|
|
1310
|
+
(entry).safeTime === undefined
|
|
1311
|
+
);
|
|
1312
|
+
};
|
|
1313
|
+
|
|
1314
|
+
/**
|
|
1315
|
+
* Watchpack directory entries may carry `safeTime` / `timestamp` but never
|
|
1316
|
+
* `timestampHash`; such object caches cannot back snapshot checks or symlink walks.
|
|
1317
|
+
* @param {ContextFileSystemInfoEntry | null | "ignore" | undefined} entry cache entry
|
|
1318
|
+
* @returns {boolean} true when a non-null object entry lacks `timestampHash`
|
|
1319
|
+
*/
|
|
1320
|
+
const contextCacheEntryLacksTimestampHash = (entry) =>
|
|
1321
|
+
entry !== null &&
|
|
1322
|
+
typeof entry === "object" &&
|
|
1323
|
+
/** @type {ContextFileSystemInfoEntry} */ (entry).timestampHash === undefined;
|
|
1324
|
+
|
|
1067
1325
|
/** @typedef {(err?: WebpackError | null, result?: boolean) => void} CheckSnapshotValidCallback */
|
|
1068
1326
|
|
|
1069
1327
|
/**
|
|
@@ -1071,6 +1329,7 @@ const getEsModuleLexer = memoize(() => require("es-module-lexer"));
|
|
|
1071
1329
|
*/
|
|
1072
1330
|
class FileSystemInfo {
|
|
1073
1331
|
/**
|
|
1332
|
+
* Creates an instance of FileSystemInfo.
|
|
1074
1333
|
* @param {InputFileSystem} fs file system
|
|
1075
1334
|
* @param {object} options options
|
|
1076
1335
|
* @param {Iterable<string | RegExp>=} options.unmanagedPaths paths that are not managed by a package manager and the contents are subject to change
|
|
@@ -1089,52 +1348,63 @@ class FileSystemInfo {
|
|
|
1089
1348
|
hashFunction = DEFAULTS.HASH_FUNCTION
|
|
1090
1349
|
} = {}
|
|
1091
1350
|
) {
|
|
1351
|
+
/** @type {InputFileSystem} */
|
|
1092
1352
|
this.fs = fs;
|
|
1093
1353
|
this.logger = logger;
|
|
1354
|
+
/** @type {number} */
|
|
1094
1355
|
this._remainingLogs = logger ? 40 : 0;
|
|
1095
1356
|
/** @type {LoggedPaths | undefined} */
|
|
1096
1357
|
this._loggedPaths = logger ? new Set() : undefined;
|
|
1358
|
+
/** @type {HashFunction} */
|
|
1097
1359
|
this._hashFunction = hashFunction;
|
|
1098
1360
|
/** @type {WeakMap<Snapshot, boolean | CheckSnapshotValidCallback[]>} */
|
|
1099
1361
|
this._snapshotCache = new WeakMap();
|
|
1362
|
+
/** @type {SnapshotOptimization<FileSystemInfoEntry | null, false>} */
|
|
1100
1363
|
this._fileTimestampsOptimization = new SnapshotOptimization(
|
|
1101
1364
|
(s) => s.hasFileTimestamps(),
|
|
1102
1365
|
(s) => s.fileTimestamps,
|
|
1103
1366
|
(s, v) => s.setFileTimestamps(v)
|
|
1104
1367
|
);
|
|
1368
|
+
/** @type {SnapshotOptimization<string | null, false>} */
|
|
1105
1369
|
this._fileHashesOptimization = new SnapshotOptimization(
|
|
1106
1370
|
(s) => s.hasFileHashes(),
|
|
1107
1371
|
(s) => s.fileHashes,
|
|
1108
1372
|
(s, v) => s.setFileHashes(v),
|
|
1109
1373
|
false
|
|
1110
1374
|
);
|
|
1375
|
+
/** @type {SnapshotOptimization<string | TimestampAndHash | null, false>} */
|
|
1111
1376
|
this._fileTshsOptimization = new SnapshotOptimization(
|
|
1112
1377
|
(s) => s.hasFileTshs(),
|
|
1113
1378
|
(s) => s.fileTshs,
|
|
1114
1379
|
(s, v) => s.setFileTshs(v)
|
|
1115
1380
|
);
|
|
1381
|
+
/** @type {SnapshotOptimization<ResolvedContextFileSystemInfoEntry | null, false>} */
|
|
1116
1382
|
this._contextTimestampsOptimization = new SnapshotOptimization(
|
|
1117
1383
|
(s) => s.hasContextTimestamps(),
|
|
1118
1384
|
(s) => s.contextTimestamps,
|
|
1119
1385
|
(s, v) => s.setContextTimestamps(v)
|
|
1120
1386
|
);
|
|
1387
|
+
/** @type {SnapshotOptimization<string | null, false>} */
|
|
1121
1388
|
this._contextHashesOptimization = new SnapshotOptimization(
|
|
1122
1389
|
(s) => s.hasContextHashes(),
|
|
1123
1390
|
(s) => s.contextHashes,
|
|
1124
1391
|
(s, v) => s.setContextHashes(v),
|
|
1125
1392
|
false
|
|
1126
1393
|
);
|
|
1394
|
+
/** @type {SnapshotOptimization<ResolvedContextTimestampAndHash | null, false>} */
|
|
1127
1395
|
this._contextTshsOptimization = new SnapshotOptimization(
|
|
1128
1396
|
(s) => s.hasContextTshs(),
|
|
1129
1397
|
(s) => s.contextTshs,
|
|
1130
1398
|
(s, v) => s.setContextTshs(v)
|
|
1131
1399
|
);
|
|
1400
|
+
/** @type {SnapshotOptimization<boolean, false>} */
|
|
1132
1401
|
this._missingExistenceOptimization = new SnapshotOptimization(
|
|
1133
1402
|
(s) => s.hasMissingExistence(),
|
|
1134
1403
|
(s) => s.missingExistence,
|
|
1135
1404
|
(s, v) => s.setMissingExistence(v),
|
|
1136
1405
|
false
|
|
1137
1406
|
);
|
|
1407
|
+
/** @type {SnapshotOptimization<string, false>} */
|
|
1138
1408
|
this._managedItemInfoOptimization = new SnapshotOptimization(
|
|
1139
1409
|
(s) => s.hasManagedItemInfo(),
|
|
1140
1410
|
(s) => s.managedItemInfo,
|
|
@@ -1176,6 +1446,9 @@ class FileSystemInfo {
|
|
|
1176
1446
|
this._contextTshs = new Map();
|
|
1177
1447
|
/** @type {Map<string, string>} */
|
|
1178
1448
|
this._managedItems = new Map();
|
|
1449
|
+
// memoized checkManaged results: 0 = not managed, 1 = immutable, string = managed item
|
|
1450
|
+
/** @type {Map<string, 0 | 1 | string>} */
|
|
1451
|
+
this._pathClassificationCache = new Map();
|
|
1179
1452
|
/** @type {AsyncQueue<string, string, FileSystemInfoEntry>} */
|
|
1180
1453
|
this.fileTimestampQueue = new AsyncQueue({
|
|
1181
1454
|
name: "file timestamp",
|
|
@@ -1248,22 +1521,32 @@ class FileSystemInfo {
|
|
|
1248
1521
|
(p) => typeof p !== "string"
|
|
1249
1522
|
);
|
|
1250
1523
|
|
|
1524
|
+
/** @type {Map<string, number | null> | undefined} */
|
|
1251
1525
|
this._cachedDeprecatedFileTimestamps = undefined;
|
|
1526
|
+
/** @type {Map<string, number | null> | undefined} */
|
|
1252
1527
|
this._cachedDeprecatedContextTimestamps = undefined;
|
|
1253
1528
|
|
|
1529
|
+
/** @type {boolean} */
|
|
1254
1530
|
this._warnAboutExperimentalEsmTracking = false;
|
|
1255
1531
|
|
|
1532
|
+
/** @type {number} */
|
|
1256
1533
|
this._statCreatedSnapshots = 0;
|
|
1534
|
+
/** @type {number} */
|
|
1257
1535
|
this._statTestedSnapshotsCached = 0;
|
|
1536
|
+
/** @type {number} */
|
|
1258
1537
|
this._statTestedSnapshotsNotCached = 0;
|
|
1538
|
+
/** @type {number} */
|
|
1259
1539
|
this._statTestedChildrenCached = 0;
|
|
1540
|
+
/** @type {number} */
|
|
1260
1541
|
this._statTestedChildrenNotCached = 0;
|
|
1542
|
+
/** @type {number} */
|
|
1261
1543
|
this._statTestedEntries = 0;
|
|
1262
1544
|
}
|
|
1263
1545
|
|
|
1264
1546
|
logStatistics() {
|
|
1265
1547
|
const logger = /** @type {Logger} */ (this.logger);
|
|
1266
1548
|
/**
|
|
1549
|
+
* Processes the provided header.
|
|
1267
1550
|
* @param {string} header header
|
|
1268
1551
|
* @param {string | undefined} message message
|
|
1269
1552
|
*/
|
|
@@ -1351,6 +1634,7 @@ class FileSystemInfo {
|
|
|
1351
1634
|
}
|
|
1352
1635
|
|
|
1353
1636
|
/**
|
|
1637
|
+
* Processes the provided path.
|
|
1354
1638
|
* @private
|
|
1355
1639
|
* @param {string} path path
|
|
1356
1640
|
* @param {string} reason reason
|
|
@@ -1394,7 +1678,7 @@ class FileSystemInfo {
|
|
|
1394
1678
|
this._contextHashes.clear();
|
|
1395
1679
|
this._contextTshs.clear();
|
|
1396
1680
|
this._managedItems.clear();
|
|
1397
|
-
this.
|
|
1681
|
+
this._pathClassificationCache.clear();
|
|
1398
1682
|
|
|
1399
1683
|
this._cachedDeprecatedFileTimestamps = undefined;
|
|
1400
1684
|
this._cachedDeprecatedContextTimestamps = undefined;
|
|
@@ -1408,64 +1692,84 @@ class FileSystemInfo {
|
|
|
1408
1692
|
}
|
|
1409
1693
|
|
|
1410
1694
|
/**
|
|
1411
|
-
*
|
|
1695
|
+
* Adds file timestamps.
|
|
1696
|
+
* @param {ReadonlyMap<string, FileTimestamp>} map timestamps
|
|
1412
1697
|
* @param {boolean=} immutable if 'map' is immutable and FileSystemInfo can keep referencing it
|
|
1413
1698
|
* @returns {void}
|
|
1414
1699
|
*/
|
|
1415
1700
|
addFileTimestamps(map, immutable) {
|
|
1416
|
-
this._fileTimestamps.addAll(
|
|
1417
|
-
/** @type {ReadonlyMap<string, FileTimestamp>} */
|
|
1418
|
-
(map),
|
|
1419
|
-
immutable
|
|
1420
|
-
);
|
|
1701
|
+
this._fileTimestamps.addAll(map, immutable);
|
|
1421
1702
|
this._cachedDeprecatedFileTimestamps = undefined;
|
|
1422
1703
|
}
|
|
1423
1704
|
|
|
1424
1705
|
/**
|
|
1425
|
-
*
|
|
1706
|
+
* Adds context timestamps.
|
|
1707
|
+
* @param {ReadonlyMap<string, ContextTimestamp>} map timestamps
|
|
1426
1708
|
* @param {boolean=} immutable if 'map' is immutable and FileSystemInfo can keep referencing it
|
|
1427
1709
|
* @returns {void}
|
|
1428
1710
|
*/
|
|
1429
1711
|
addContextTimestamps(map, immutable) {
|
|
1430
|
-
this._contextTimestamps.addAll(
|
|
1431
|
-
/** @type {ReadonlyMap<string, ContextTimestamp>} */
|
|
1432
|
-
(map),
|
|
1433
|
-
immutable
|
|
1434
|
-
);
|
|
1712
|
+
this._contextTimestamps.addAll(map, immutable);
|
|
1435
1713
|
this._cachedDeprecatedContextTimestamps = undefined;
|
|
1436
1714
|
}
|
|
1437
1715
|
|
|
1438
1716
|
/**
|
|
1717
|
+
* Gets file timestamp.
|
|
1439
1718
|
* @param {string} path file path
|
|
1440
|
-
* @param {(err?: WebpackError | null, fileTimestamp?:
|
|
1719
|
+
* @param {(err?: WebpackError | null, fileTimestamp?: FileSystemInfoEntry | "ignore" | null) => void} callback callback function
|
|
1441
1720
|
* @returns {void}
|
|
1442
1721
|
*/
|
|
1443
1722
|
getFileTimestamp(path, callback) {
|
|
1444
1723
|
const cache = this._fileTimestamps.get(path);
|
|
1445
|
-
if (cache !== undefined
|
|
1724
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
1725
|
+
return callback(
|
|
1726
|
+
null,
|
|
1727
|
+
/** @type {FileSystemInfoEntry | "ignore" | null} */ (cache)
|
|
1728
|
+
);
|
|
1729
|
+
}
|
|
1446
1730
|
this.fileTimestampQueue.add(path, callback);
|
|
1447
1731
|
}
|
|
1448
1732
|
|
|
1449
1733
|
/**
|
|
1734
|
+
* Gets context timestamp.
|
|
1450
1735
|
* @param {string} path context path
|
|
1451
1736
|
* @param {(err?: WebpackError | null, resolvedContextTimestamp?: ResolvedContextTimestamp) => void} callback callback function
|
|
1452
1737
|
* @returns {void}
|
|
1453
1738
|
*/
|
|
1454
1739
|
getContextTimestamp(path, callback) {
|
|
1455
1740
|
const cache = this._contextTimestamps.get(path);
|
|
1456
|
-
if (cache !== undefined) {
|
|
1741
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
1457
1742
|
if (cache === "ignore") return callback(null, "ignore");
|
|
1458
|
-
const
|
|
1743
|
+
const fullEntry =
|
|
1744
|
+
/** @type {ContextFileSystemInfoEntry | null} */
|
|
1745
|
+
(cache);
|
|
1746
|
+
const resolved = getResolvedTimestamp(fullEntry);
|
|
1459
1747
|
if (resolved !== undefined) return callback(null, resolved);
|
|
1460
1748
|
return this._resolveContextTimestamp(
|
|
1461
|
-
/** @type {
|
|
1462
|
-
(
|
|
1749
|
+
/** @type {ContextFileSystemInfoEntry} */
|
|
1750
|
+
(fullEntry),
|
|
1463
1751
|
callback
|
|
1464
1752
|
);
|
|
1465
1753
|
}
|
|
1754
|
+
this._readFreshContextTimestamp(path, callback);
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
/**
|
|
1758
|
+
* Reads a context timestamp directly from disk, bypassing any cached
|
|
1759
|
+
* entry. Used by `getContextTimestamp` and the snapshot validity
|
|
1760
|
+
* checks when the cached entry is missing or is an `ExistenceOnlyTimeEntry`
|
|
1761
|
+
* (`{}`) supplied by watchpack — both cases require a fresh read to
|
|
1762
|
+
* obtain the `timestampHash`.
|
|
1763
|
+
* @private
|
|
1764
|
+
* @param {string} path context path
|
|
1765
|
+
* @param {(err?: WebpackError | null, resolvedContextTimestamp?: ResolvedContextTimestamp) => void} callback callback function
|
|
1766
|
+
* @returns {void}
|
|
1767
|
+
*/
|
|
1768
|
+
_readFreshContextTimestamp(path, callback) {
|
|
1466
1769
|
this.contextTimestampQueue.add(path, (err, _entry) => {
|
|
1467
1770
|
if (err) return callback(err);
|
|
1468
|
-
const entry = /** @type {ContextFileSystemInfoEntry} */ (_entry);
|
|
1771
|
+
const entry = /** @type {ContextFileSystemInfoEntry | null} */ (_entry);
|
|
1772
|
+
if (entry === null) return callback(null, null);
|
|
1469
1773
|
const resolved = getResolvedTimestamp(entry);
|
|
1470
1774
|
if (resolved !== undefined) return callback(null, resolved);
|
|
1471
1775
|
this._resolveContextTimestamp(entry, callback);
|
|
@@ -1473,18 +1777,33 @@ class FileSystemInfo {
|
|
|
1473
1777
|
}
|
|
1474
1778
|
|
|
1475
1779
|
/**
|
|
1780
|
+
* Get unresolved context timestamp. Existence-only cache entries (`{}`)
|
|
1781
|
+
* are bypassed so the callback always receives a complete entry, "ignore"
|
|
1782
|
+
* or null.
|
|
1476
1783
|
* @private
|
|
1477
1784
|
* @param {string} path context path
|
|
1478
|
-
* @param {(err?: WebpackError | null, contextTimestamp?:
|
|
1785
|
+
* @param {(err?: WebpackError | null, contextTimestamp?: ContextFileSystemInfoEntry | "ignore" | null) => void} callback callback function
|
|
1479
1786
|
* @returns {void}
|
|
1480
1787
|
*/
|
|
1481
1788
|
_getUnresolvedContextTimestamp(path, callback) {
|
|
1482
1789
|
const cache = this._contextTimestamps.get(path);
|
|
1483
|
-
if (
|
|
1790
|
+
if (
|
|
1791
|
+
cache !== undefined &&
|
|
1792
|
+
!isExistenceOnly(cache) &&
|
|
1793
|
+
!contextCacheEntryLacksTimestampHash(
|
|
1794
|
+
/** @type {ContextFileSystemInfoEntry | null | "ignore"} */ (cache)
|
|
1795
|
+
)
|
|
1796
|
+
) {
|
|
1797
|
+
return callback(
|
|
1798
|
+
null,
|
|
1799
|
+
/** @type {ContextFileSystemInfoEntry | "ignore" | null} */ (cache)
|
|
1800
|
+
);
|
|
1801
|
+
}
|
|
1484
1802
|
this.contextTimestampQueue.add(path, callback);
|
|
1485
1803
|
}
|
|
1486
1804
|
|
|
1487
1805
|
/**
|
|
1806
|
+
* Returns file hash.
|
|
1488
1807
|
* @param {string} path file path
|
|
1489
1808
|
* @param {(err?: WebpackError | null, hash?: string | null) => void} callback callback function
|
|
1490
1809
|
* @returns {void}
|
|
@@ -1496,6 +1815,7 @@ class FileSystemInfo {
|
|
|
1496
1815
|
}
|
|
1497
1816
|
|
|
1498
1817
|
/**
|
|
1818
|
+
* Returns context hash.
|
|
1499
1819
|
* @param {string} path context path
|
|
1500
1820
|
* @param {(err?: WebpackError | null, contextHash?: string) => void} callback callback function
|
|
1501
1821
|
* @returns {void}
|
|
@@ -1521,6 +1841,7 @@ class FileSystemInfo {
|
|
|
1521
1841
|
}
|
|
1522
1842
|
|
|
1523
1843
|
/**
|
|
1844
|
+
* Get unresolved context hash.
|
|
1524
1845
|
* @private
|
|
1525
1846
|
* @param {string} path context path
|
|
1526
1847
|
* @param {(err?: WebpackError | null, contextHash?: ContextHash | null) => void} callback callback function
|
|
@@ -1533,6 +1854,7 @@ class FileSystemInfo {
|
|
|
1533
1854
|
}
|
|
1534
1855
|
|
|
1535
1856
|
/**
|
|
1857
|
+
* Returns context tsh.
|
|
1536
1858
|
* @param {string} path context path
|
|
1537
1859
|
* @param {(err?: WebpackError | null, resolvedContextTimestampAndHash?: ResolvedContextTimestampAndHash | null) => void} callback callback function
|
|
1538
1860
|
* @returns {void}
|
|
@@ -1554,6 +1876,7 @@ class FileSystemInfo {
|
|
|
1554
1876
|
}
|
|
1555
1877
|
|
|
1556
1878
|
/**
|
|
1879
|
+
* Get unresolved context tsh.
|
|
1557
1880
|
* @private
|
|
1558
1881
|
* @param {string} path context path
|
|
1559
1882
|
* @param {(err?: WebpackError | null, contextTimestampAndHash?: ContextTimestampAndHash | null) => void} callback callback function
|
|
@@ -1573,20 +1896,20 @@ class FileSystemInfo {
|
|
|
1573
1896
|
});
|
|
1574
1897
|
const resolveCjs = createResolver({
|
|
1575
1898
|
extensions: [".js", ".json", ".node"],
|
|
1576
|
-
conditionNames: ["require", "node"],
|
|
1899
|
+
conditionNames: ["require", "module-sync", "node"],
|
|
1577
1900
|
exportsFields: ["exports"],
|
|
1578
1901
|
fileSystem: this.fs
|
|
1579
1902
|
});
|
|
1580
1903
|
const resolveCjsAsChild = createResolver({
|
|
1581
1904
|
extensions: [".js", ".json", ".node"],
|
|
1582
|
-
conditionNames: ["require", "node"],
|
|
1905
|
+
conditionNames: ["require", "module-sync", "node"],
|
|
1583
1906
|
exportsFields: [],
|
|
1584
1907
|
fileSystem: this.fs
|
|
1585
1908
|
});
|
|
1586
1909
|
const resolveEsm = createResolver({
|
|
1587
1910
|
extensions: [".js", ".json", ".node"],
|
|
1588
1911
|
fullySpecified: true,
|
|
1589
|
-
conditionNames: ["import", "node"],
|
|
1912
|
+
conditionNames: ["import", "module-sync", "node"],
|
|
1590
1913
|
exportsFields: ["exports"],
|
|
1591
1914
|
fileSystem: this.fs
|
|
1592
1915
|
});
|
|
@@ -1594,6 +1917,7 @@ class FileSystemInfo {
|
|
|
1594
1917
|
}
|
|
1595
1918
|
|
|
1596
1919
|
/**
|
|
1920
|
+
* Resolves build dependencies.
|
|
1597
1921
|
* @param {string} context context directory
|
|
1598
1922
|
* @param {Iterable<string>} deps dependencies
|
|
1599
1923
|
* @param {(err?: Error | null, resolveBuildDependenciesResult?: ResolveBuildDependenciesResult) => void} callback callback function
|
|
@@ -1629,6 +1953,7 @@ class FileSystemInfo {
|
|
|
1629
1953
|
missingDependencies: resolveMissing
|
|
1630
1954
|
};
|
|
1631
1955
|
/**
|
|
1956
|
+
* Expected to string.
|
|
1632
1957
|
* @param {undefined | boolean | string} expected expected result
|
|
1633
1958
|
* @returns {string} expected result
|
|
1634
1959
|
*/
|
|
@@ -1637,6 +1962,7 @@ class FileSystemInfo {
|
|
|
1637
1962
|
/** @typedef {{ type: JobType, context: string | undefined, path: string, issuer: Job | undefined, expected: undefined | boolean | string }} Job */
|
|
1638
1963
|
|
|
1639
1964
|
/**
|
|
1965
|
+
* Returns result.
|
|
1640
1966
|
* @param {Job} job job
|
|
1641
1967
|
* @returns {string} result
|
|
1642
1968
|
*/
|
|
@@ -1666,6 +1992,7 @@ class FileSystemInfo {
|
|
|
1666
1992
|
return `unknown ${job.type} ${job.path}`;
|
|
1667
1993
|
};
|
|
1668
1994
|
/**
|
|
1995
|
+
* Returns string value.
|
|
1669
1996
|
* @param {Job} job job
|
|
1670
1997
|
* @returns {string} string value
|
|
1671
1998
|
*/
|
|
@@ -1696,6 +2023,7 @@ class FileSystemInfo {
|
|
|
1696
2023
|
(job, push, callback) => {
|
|
1697
2024
|
const { type, context, path, expected } = job;
|
|
1698
2025
|
/**
|
|
2026
|
+
* Resolves directory.
|
|
1699
2027
|
* @param {string} path path
|
|
1700
2028
|
* @returns {void}
|
|
1701
2029
|
*/
|
|
@@ -1733,6 +2061,7 @@ class FileSystemInfo {
|
|
|
1733
2061
|
);
|
|
1734
2062
|
};
|
|
1735
2063
|
/**
|
|
2064
|
+
* Processes the provided path.
|
|
1736
2065
|
* @param {string} path path
|
|
1737
2066
|
* @param {("f" | "c" | "e")=} symbol symbol
|
|
1738
2067
|
* @param {(ResolveFunctionAsync)=} resolve resolve fn
|
|
@@ -1952,6 +2281,38 @@ class FileSystemInfo {
|
|
|
1952
2281
|
});
|
|
1953
2282
|
}
|
|
1954
2283
|
}
|
|
2284
|
+
// On Bun the children array is empty (unpopulated), so recover the
|
|
2285
|
+
// static require() specifiers by parsing the source; Node/Deno don't.
|
|
2286
|
+
/* istanbul ignore next */
|
|
2287
|
+
if (IS_BUN && module.children.length === 0) {
|
|
2288
|
+
this.fs.readFile(path, (err, content) => {
|
|
2289
|
+
if (err) return callback(err);
|
|
2290
|
+
try {
|
|
2291
|
+
const context = dirname(this.fs, path);
|
|
2292
|
+
const source = /** @type {Buffer} */ (content).toString();
|
|
2293
|
+
/** @type {Set<string>} */
|
|
2294
|
+
const added = new Set();
|
|
2295
|
+
for (const dependency of parseCjsRequires(source)) {
|
|
2296
|
+
if (dependency.startsWith("node:")) continue;
|
|
2297
|
+
if (builtinModules.has(dependency)) continue;
|
|
2298
|
+
if (added.has(dependency)) continue;
|
|
2299
|
+
push({
|
|
2300
|
+
type: RBDT_RESOLVE_CJS_FILE,
|
|
2301
|
+
context,
|
|
2302
|
+
path: dependency,
|
|
2303
|
+
// Best effort: tolerate specifiers that don't resolve.
|
|
2304
|
+
expected: false,
|
|
2305
|
+
issuer: job
|
|
2306
|
+
});
|
|
2307
|
+
added.add(dependency);
|
|
2308
|
+
}
|
|
2309
|
+
} catch (_err) {
|
|
2310
|
+
// Source we can't parse as CommonJS — ignore its dependencies.
|
|
2311
|
+
}
|
|
2312
|
+
process.nextTick(callback);
|
|
2313
|
+
});
|
|
2314
|
+
break;
|
|
2315
|
+
}
|
|
1955
2316
|
} else if (supportsEsm && /\.m?js$/.test(path)) {
|
|
1956
2317
|
if (!this._warnAboutExperimentalEsmTracking) {
|
|
1957
2318
|
logger.log(
|
|
@@ -1975,19 +2336,17 @@ class FileSystemInfo {
|
|
|
1975
2336
|
const added = new Set();
|
|
1976
2337
|
for (const imp of imports) {
|
|
1977
2338
|
try {
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
} else {
|
|
1990
|
-
// e.g. import.meta
|
|
2339
|
+
// import.meta
|
|
2340
|
+
if (imp.d === -2) {
|
|
2341
|
+
continue;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
/** @type {string | null} */
|
|
2345
|
+
const dependency =
|
|
2346
|
+
imp.n ||
|
|
2347
|
+
parseString(source.slice(imp.s, imp.e).trim());
|
|
2348
|
+
|
|
2349
|
+
if (!dependency) {
|
|
1991
2350
|
continue;
|
|
1992
2351
|
}
|
|
1993
2352
|
|
|
@@ -2128,6 +2487,7 @@ class FileSystemInfo {
|
|
|
2128
2487
|
}
|
|
2129
2488
|
|
|
2130
2489
|
/**
|
|
2490
|
+
* Checks resolve results valid.
|
|
2131
2491
|
* @param {ResolveResults} resolveResults results from resolving
|
|
2132
2492
|
* @param {(err?: Error | null, result?: boolean) => void} callback callback with true when resolveResults resolve the same way
|
|
2133
2493
|
* @returns {void}
|
|
@@ -2191,6 +2551,7 @@ class FileSystemInfo {
|
|
|
2191
2551
|
}
|
|
2192
2552
|
},
|
|
2193
2553
|
/**
|
|
2554
|
+
* Processes the provided err.
|
|
2194
2555
|
* @param {Error | typeof INVALID=} err error or invalid flag
|
|
2195
2556
|
* @returns {void}
|
|
2196
2557
|
*/
|
|
@@ -2209,6 +2570,7 @@ class FileSystemInfo {
|
|
|
2209
2570
|
}
|
|
2210
2571
|
|
|
2211
2572
|
/**
|
|
2573
|
+
* Creates a snapshot.
|
|
2212
2574
|
* @param {number | null | undefined} startTime when processing the files has started
|
|
2213
2575
|
* @param {Iterable<string> | null | undefined} files all files
|
|
2214
2576
|
* @param {Iterable<string> | null | undefined} directories all directories
|
|
@@ -2218,30 +2580,29 @@ class FileSystemInfo {
|
|
|
2218
2580
|
* @returns {void}
|
|
2219
2581
|
*/
|
|
2220
2582
|
createSnapshot(startTime, files, directories, missing, options, callback) {
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2583
|
+
// collections are allocated lazily to avoid per-snapshot garbage for unused modes
|
|
2584
|
+
/** @type {FileTimestamps | undefined} */
|
|
2585
|
+
let fileTimestamps;
|
|
2586
|
+
/** @type {FileHashes | undefined} */
|
|
2587
|
+
let fileHashes;
|
|
2588
|
+
/** @type {FileTshs | undefined} */
|
|
2589
|
+
let fileTshs;
|
|
2590
|
+
/** @type {ContextTimestamps | undefined} */
|
|
2591
|
+
let contextTimestamps;
|
|
2592
|
+
/** @type {ContextHashes | undefined} */
|
|
2593
|
+
let contextHashes;
|
|
2594
|
+
/** @type {ContextTshs | undefined} */
|
|
2595
|
+
let contextTshs;
|
|
2596
|
+
/** @type {MissingExistence | undefined} */
|
|
2597
|
+
let missingExistence;
|
|
2598
|
+
/** @type {ManagedItemInfo | undefined} */
|
|
2599
|
+
let managedItemInfo;
|
|
2237
2600
|
/** @type {ManagedFiles} */
|
|
2238
2601
|
const managedFiles = new Set();
|
|
2239
2602
|
/** @type {ManagedContexts} */
|
|
2240
2603
|
const managedContexts = new Set();
|
|
2241
2604
|
/** @type {ManagedMissing} */
|
|
2242
2605
|
const managedMissing = new Set();
|
|
2243
|
-
/** @type {Children} */
|
|
2244
|
-
const children = new Set();
|
|
2245
2606
|
|
|
2246
2607
|
const snapshot = new Snapshot();
|
|
2247
2608
|
if (startTime) snapshot.setStartTime(startTime);
|
|
@@ -2255,28 +2616,28 @@ class FileSystemInfo {
|
|
|
2255
2616
|
let jobs = 1;
|
|
2256
2617
|
const jobDone = () => {
|
|
2257
2618
|
if (--jobs === 0) {
|
|
2258
|
-
if (fileTimestamps.size !== 0) {
|
|
2619
|
+
if (fileTimestamps !== undefined && fileTimestamps.size !== 0) {
|
|
2259
2620
|
snapshot.setFileTimestamps(fileTimestamps);
|
|
2260
2621
|
}
|
|
2261
|
-
if (fileHashes.size !== 0) {
|
|
2622
|
+
if (fileHashes !== undefined && fileHashes.size !== 0) {
|
|
2262
2623
|
snapshot.setFileHashes(fileHashes);
|
|
2263
2624
|
}
|
|
2264
|
-
if (fileTshs.size !== 0) {
|
|
2625
|
+
if (fileTshs !== undefined && fileTshs.size !== 0) {
|
|
2265
2626
|
snapshot.setFileTshs(fileTshs);
|
|
2266
2627
|
}
|
|
2267
|
-
if (contextTimestamps.size !== 0) {
|
|
2628
|
+
if (contextTimestamps !== undefined && contextTimestamps.size !== 0) {
|
|
2268
2629
|
snapshot.setContextTimestamps(contextTimestamps);
|
|
2269
2630
|
}
|
|
2270
|
-
if (contextHashes.size !== 0) {
|
|
2631
|
+
if (contextHashes !== undefined && contextHashes.size !== 0) {
|
|
2271
2632
|
snapshot.setContextHashes(contextHashes);
|
|
2272
2633
|
}
|
|
2273
|
-
if (contextTshs.size !== 0) {
|
|
2634
|
+
if (contextTshs !== undefined && contextTshs.size !== 0) {
|
|
2274
2635
|
snapshot.setContextTshs(contextTshs);
|
|
2275
2636
|
}
|
|
2276
|
-
if (missingExistence.size !== 0) {
|
|
2637
|
+
if (missingExistence !== undefined && missingExistence.size !== 0) {
|
|
2277
2638
|
snapshot.setMissingExistence(missingExistence);
|
|
2278
2639
|
}
|
|
2279
|
-
if (managedItemInfo.size !== 0) {
|
|
2640
|
+
if (managedItemInfo !== undefined && managedItemInfo.size !== 0) {
|
|
2280
2641
|
snapshot.setManagedItemInfo(managedItemInfo);
|
|
2281
2642
|
}
|
|
2282
2643
|
this._managedFilesOptimization.optimize(snapshot, managedFiles);
|
|
@@ -2291,9 +2652,6 @@ class FileSystemInfo {
|
|
|
2291
2652
|
if (managedMissing.size !== 0) {
|
|
2292
2653
|
snapshot.setManagedMissing(managedMissing);
|
|
2293
2654
|
}
|
|
2294
|
-
if (children.size !== 0) {
|
|
2295
|
-
snapshot.setChildren(children);
|
|
2296
|
-
}
|
|
2297
2655
|
this._snapshotCache.set(snapshot, true);
|
|
2298
2656
|
this._statCreatedSnapshots++;
|
|
2299
2657
|
|
|
@@ -2307,26 +2665,44 @@ class FileSystemInfo {
|
|
|
2307
2665
|
callback(null, null);
|
|
2308
2666
|
}
|
|
2309
2667
|
};
|
|
2668
|
+
const classificationCache = this._pathClassificationCache;
|
|
2310
2669
|
/**
|
|
2670
|
+
* Checks true when managed.
|
|
2311
2671
|
* @param {string} path path
|
|
2312
2672
|
* @param {ManagedFiles} managedSet managed set
|
|
2313
2673
|
* @returns {boolean} true when managed
|
|
2314
2674
|
*/
|
|
2315
2675
|
const checkManaged = (path, managedSet) => {
|
|
2676
|
+
// classification is a pure function of the path, so it's shared across snapshots
|
|
2677
|
+
const cached = classificationCache.get(path);
|
|
2678
|
+
if (cached !== undefined) {
|
|
2679
|
+
if (cached === 0) return false;
|
|
2680
|
+
if (cached !== 1) managedItems.add(cached);
|
|
2681
|
+
managedSet.add(path);
|
|
2682
|
+
return true;
|
|
2683
|
+
}
|
|
2316
2684
|
for (const unmanagedPath of this.unmanagedPathsRegExps) {
|
|
2317
|
-
if (unmanagedPath.test(path))
|
|
2685
|
+
if (unmanagedPath.test(path)) {
|
|
2686
|
+
classificationCache.set(path, 0);
|
|
2687
|
+
return false;
|
|
2688
|
+
}
|
|
2318
2689
|
}
|
|
2319
2690
|
for (const unmanagedPath of this.unmanagedPathsWithSlash) {
|
|
2320
|
-
if (path.startsWith(unmanagedPath))
|
|
2691
|
+
if (path.startsWith(unmanagedPath)) {
|
|
2692
|
+
classificationCache.set(path, 0);
|
|
2693
|
+
return false;
|
|
2694
|
+
}
|
|
2321
2695
|
}
|
|
2322
2696
|
for (const immutablePath of this.immutablePathsRegExps) {
|
|
2323
2697
|
if (immutablePath.test(path)) {
|
|
2698
|
+
classificationCache.set(path, 1);
|
|
2324
2699
|
managedSet.add(path);
|
|
2325
2700
|
return true;
|
|
2326
2701
|
}
|
|
2327
2702
|
}
|
|
2328
2703
|
for (const immutablePath of this.immutablePathsWithSlash) {
|
|
2329
2704
|
if (path.startsWith(immutablePath)) {
|
|
2705
|
+
classificationCache.set(path, 1);
|
|
2330
2706
|
managedSet.add(path);
|
|
2331
2707
|
return true;
|
|
2332
2708
|
}
|
|
@@ -2336,6 +2712,7 @@ class FileSystemInfo {
|
|
|
2336
2712
|
if (match) {
|
|
2337
2713
|
const managedItem = getManagedItem(match[1], path);
|
|
2338
2714
|
if (managedItem) {
|
|
2715
|
+
classificationCache.set(path, managedItem);
|
|
2339
2716
|
managedItems.add(managedItem);
|
|
2340
2717
|
managedSet.add(path);
|
|
2341
2718
|
return true;
|
|
@@ -2346,15 +2723,18 @@ class FileSystemInfo {
|
|
|
2346
2723
|
if (path.startsWith(managedPath)) {
|
|
2347
2724
|
const managedItem = getManagedItem(managedPath, path);
|
|
2348
2725
|
if (managedItem) {
|
|
2726
|
+
classificationCache.set(path, managedItem);
|
|
2349
2727
|
managedItems.add(managedItem);
|
|
2350
2728
|
managedSet.add(path);
|
|
2351
2729
|
return true;
|
|
2352
2730
|
}
|
|
2353
2731
|
}
|
|
2354
2732
|
}
|
|
2733
|
+
classificationCache.set(path, 0);
|
|
2355
2734
|
return false;
|
|
2356
2735
|
};
|
|
2357
2736
|
/**
|
|
2737
|
+
* Capture non managed.
|
|
2358
2738
|
* @param {Iterable<string>} items items
|
|
2359
2739
|
* @param {Set<string>} managedSet managed set
|
|
2360
2740
|
* @returns {Set<string>} result
|
|
@@ -2368,6 +2748,7 @@ class FileSystemInfo {
|
|
|
2368
2748
|
return capturedItems;
|
|
2369
2749
|
};
|
|
2370
2750
|
/**
|
|
2751
|
+
* Process captured files.
|
|
2371
2752
|
* @param {ManagedFiles} capturedFiles captured files
|
|
2372
2753
|
*/
|
|
2373
2754
|
const processCapturedFiles = (capturedFiles) => {
|
|
@@ -2375,12 +2756,14 @@ class FileSystemInfo {
|
|
|
2375
2756
|
return;
|
|
2376
2757
|
}
|
|
2377
2758
|
switch (mode) {
|
|
2378
|
-
case 3:
|
|
2759
|
+
case 3: {
|
|
2379
2760
|
this._fileTshsOptimization.optimize(snapshot, capturedFiles);
|
|
2761
|
+
if (fileTshs === undefined) fileTshs = new Map();
|
|
2762
|
+
const fileTshsMap = fileTshs;
|
|
2380
2763
|
for (const path of capturedFiles) {
|
|
2381
2764
|
const cache = this._fileTshs.get(path);
|
|
2382
2765
|
if (cache !== undefined) {
|
|
2383
|
-
|
|
2766
|
+
fileTshsMap.set(path, cache);
|
|
2384
2767
|
} else {
|
|
2385
2768
|
jobs++;
|
|
2386
2769
|
this._getFileTimestampAndHash(path, (err, entry) => {
|
|
@@ -2392,19 +2775,25 @@ class FileSystemInfo {
|
|
|
2392
2775
|
}
|
|
2393
2776
|
jobError();
|
|
2394
2777
|
} else {
|
|
2395
|
-
|
|
2778
|
+
fileTshsMap.set(
|
|
2779
|
+
path,
|
|
2780
|
+
/** @type {TimestampAndHash} */ (entry)
|
|
2781
|
+
);
|
|
2396
2782
|
jobDone();
|
|
2397
2783
|
}
|
|
2398
2784
|
});
|
|
2399
2785
|
}
|
|
2400
2786
|
}
|
|
2401
2787
|
break;
|
|
2402
|
-
|
|
2788
|
+
}
|
|
2789
|
+
case 2: {
|
|
2403
2790
|
this._fileHashesOptimization.optimize(snapshot, capturedFiles);
|
|
2791
|
+
if (fileHashes === undefined) fileHashes = new Map();
|
|
2792
|
+
const fileHashesMap = fileHashes;
|
|
2404
2793
|
for (const path of capturedFiles) {
|
|
2405
2794
|
const cache = this._fileHashes.get(path);
|
|
2406
2795
|
if (cache !== undefined) {
|
|
2407
|
-
|
|
2796
|
+
fileHashesMap.set(path, cache);
|
|
2408
2797
|
} else {
|
|
2409
2798
|
jobs++;
|
|
2410
2799
|
this.fileHashQueue.add(path, (err, entry) => {
|
|
@@ -2416,20 +2805,26 @@ class FileSystemInfo {
|
|
|
2416
2805
|
}
|
|
2417
2806
|
jobError();
|
|
2418
2807
|
} else {
|
|
2419
|
-
|
|
2808
|
+
fileHashesMap.set(path, /** @type {string} */ (entry));
|
|
2420
2809
|
jobDone();
|
|
2421
2810
|
}
|
|
2422
2811
|
});
|
|
2423
2812
|
}
|
|
2424
2813
|
}
|
|
2425
2814
|
break;
|
|
2426
|
-
|
|
2815
|
+
}
|
|
2816
|
+
case 1: {
|
|
2427
2817
|
this._fileTimestampsOptimization.optimize(snapshot, capturedFiles);
|
|
2818
|
+
if (fileTimestamps === undefined) fileTimestamps = new Map();
|
|
2819
|
+
const fileTimestampsMap = fileTimestamps;
|
|
2428
2820
|
for (const path of capturedFiles) {
|
|
2429
2821
|
const cache = this._fileTimestamps.get(path);
|
|
2430
|
-
if (cache !== undefined) {
|
|
2822
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
2431
2823
|
if (cache !== "ignore") {
|
|
2432
|
-
|
|
2824
|
+
fileTimestampsMap.set(
|
|
2825
|
+
path,
|
|
2826
|
+
/** @type {FileSystemInfoEntry | null} */ (cache)
|
|
2827
|
+
);
|
|
2433
2828
|
}
|
|
2434
2829
|
} else {
|
|
2435
2830
|
jobs++;
|
|
@@ -2442,7 +2837,7 @@ class FileSystemInfo {
|
|
|
2442
2837
|
}
|
|
2443
2838
|
jobError();
|
|
2444
2839
|
} else {
|
|
2445
|
-
|
|
2840
|
+
fileTimestampsMap.set(
|
|
2446
2841
|
path,
|
|
2447
2842
|
/** @type {FileSystemInfoEntry} */
|
|
2448
2843
|
(entry)
|
|
@@ -2453,12 +2848,14 @@ class FileSystemInfo {
|
|
|
2453
2848
|
}
|
|
2454
2849
|
}
|
|
2455
2850
|
break;
|
|
2851
|
+
}
|
|
2456
2852
|
}
|
|
2457
2853
|
};
|
|
2458
2854
|
if (files) {
|
|
2459
2855
|
processCapturedFiles(captureNonManaged(files, managedFiles));
|
|
2460
2856
|
}
|
|
2461
2857
|
/**
|
|
2858
|
+
* Process captured directories.
|
|
2462
2859
|
* @param {ManagedContexts} capturedDirectories captured directories
|
|
2463
2860
|
*/
|
|
2464
2861
|
const processCapturedDirectories = (capturedDirectories) => {
|
|
@@ -2466,8 +2863,10 @@ class FileSystemInfo {
|
|
|
2466
2863
|
return;
|
|
2467
2864
|
}
|
|
2468
2865
|
switch (mode) {
|
|
2469
|
-
case 3:
|
|
2866
|
+
case 3: {
|
|
2470
2867
|
this._contextTshsOptimization.optimize(snapshot, capturedDirectories);
|
|
2868
|
+
if (contextTshs === undefined) contextTshs = new Map();
|
|
2869
|
+
const contextTshsMap = contextTshs;
|
|
2471
2870
|
for (const path of capturedDirectories) {
|
|
2472
2871
|
const cache = this._contextTshs.get(path);
|
|
2473
2872
|
/** @type {ResolvedContextTimestampAndHash | null | undefined} */
|
|
@@ -2476,10 +2875,11 @@ class FileSystemInfo {
|
|
|
2476
2875
|
cache !== undefined &&
|
|
2477
2876
|
(resolved = getResolvedTimestamp(cache)) !== undefined
|
|
2478
2877
|
) {
|
|
2479
|
-
|
|
2878
|
+
contextTshsMap.set(path, resolved);
|
|
2480
2879
|
} else {
|
|
2481
2880
|
jobs++;
|
|
2482
2881
|
/**
|
|
2882
|
+
* Processes the provided err.
|
|
2483
2883
|
* @param {(WebpackError | null)=} err error
|
|
2484
2884
|
* @param {(ResolvedContextTimestampAndHash | null)=} entry entry
|
|
2485
2885
|
* @returns {void}
|
|
@@ -2493,7 +2893,7 @@ class FileSystemInfo {
|
|
|
2493
2893
|
}
|
|
2494
2894
|
jobError();
|
|
2495
2895
|
} else {
|
|
2496
|
-
|
|
2896
|
+
contextTshsMap.set(
|
|
2497
2897
|
path,
|
|
2498
2898
|
/** @type {ResolvedContextTimestampAndHash | null} */
|
|
2499
2899
|
(entry)
|
|
@@ -2509,11 +2909,14 @@ class FileSystemInfo {
|
|
|
2509
2909
|
}
|
|
2510
2910
|
}
|
|
2511
2911
|
break;
|
|
2512
|
-
|
|
2912
|
+
}
|
|
2913
|
+
case 2: {
|
|
2513
2914
|
this._contextHashesOptimization.optimize(
|
|
2514
2915
|
snapshot,
|
|
2515
2916
|
capturedDirectories
|
|
2516
2917
|
);
|
|
2918
|
+
if (contextHashes === undefined) contextHashes = new Map();
|
|
2919
|
+
const contextHashesMap = contextHashes;
|
|
2517
2920
|
for (const path of capturedDirectories) {
|
|
2518
2921
|
const cache = this._contextHashes.get(path);
|
|
2519
2922
|
/** @type {undefined | null | string} */
|
|
@@ -2522,10 +2925,11 @@ class FileSystemInfo {
|
|
|
2522
2925
|
cache !== undefined &&
|
|
2523
2926
|
(resolved = getResolvedHash(cache)) !== undefined
|
|
2524
2927
|
) {
|
|
2525
|
-
|
|
2928
|
+
contextHashesMap.set(path, resolved);
|
|
2526
2929
|
} else {
|
|
2527
2930
|
jobs++;
|
|
2528
2931
|
/**
|
|
2932
|
+
* Processes the provided err.
|
|
2529
2933
|
* @param {(WebpackError | null)=} err err
|
|
2530
2934
|
* @param {string=} entry entry
|
|
2531
2935
|
*/
|
|
@@ -2538,7 +2942,7 @@ class FileSystemInfo {
|
|
|
2538
2942
|
}
|
|
2539
2943
|
jobError();
|
|
2540
2944
|
} else {
|
|
2541
|
-
|
|
2945
|
+
contextHashesMap.set(path, /** @type {string} */ (entry));
|
|
2542
2946
|
jobDone();
|
|
2543
2947
|
}
|
|
2544
2948
|
};
|
|
@@ -2550,26 +2954,38 @@ class FileSystemInfo {
|
|
|
2550
2954
|
}
|
|
2551
2955
|
}
|
|
2552
2956
|
break;
|
|
2553
|
-
|
|
2957
|
+
}
|
|
2958
|
+
case 1: {
|
|
2554
2959
|
this._contextTimestampsOptimization.optimize(
|
|
2555
2960
|
snapshot,
|
|
2556
2961
|
capturedDirectories
|
|
2557
2962
|
);
|
|
2963
|
+
if (contextTimestamps === undefined) contextTimestamps = new Map();
|
|
2964
|
+
const contextTimestampsMap = contextTimestamps;
|
|
2558
2965
|
for (const path of capturedDirectories) {
|
|
2559
2966
|
const cache = this._contextTimestamps.get(path);
|
|
2560
2967
|
if (cache === "ignore") continue;
|
|
2968
|
+
/** @type {ContextFileSystemInfoEntry | null | undefined} */
|
|
2969
|
+
const usableCache =
|
|
2970
|
+
cache === undefined || isExistenceOnly(cache)
|
|
2971
|
+
? undefined
|
|
2972
|
+
: /** @type {ContextFileSystemInfoEntry | null} */ (cache);
|
|
2973
|
+
const cacheLacksHash =
|
|
2974
|
+
contextCacheEntryLacksTimestampHash(usableCache);
|
|
2561
2975
|
/** @type {undefined | null | ResolvedContextFileSystemInfoEntry} */
|
|
2562
2976
|
let resolved;
|
|
2563
2977
|
if (
|
|
2564
|
-
|
|
2565
|
-
|
|
2978
|
+
usableCache !== undefined &&
|
|
2979
|
+
!cacheLacksHash &&
|
|
2980
|
+
(resolved = getResolvedTimestamp(usableCache)) !== undefined
|
|
2566
2981
|
) {
|
|
2567
|
-
|
|
2982
|
+
contextTimestampsMap.set(path, resolved);
|
|
2568
2983
|
} else {
|
|
2569
2984
|
jobs++;
|
|
2570
2985
|
/**
|
|
2571
|
-
*
|
|
2572
|
-
* @param {
|
|
2986
|
+
* Processes the provided err.
|
|
2987
|
+
* @param {(WebpackError | null)=} err error
|
|
2988
|
+
* @param {ResolvedContextTimestamp=} entry entry
|
|
2573
2989
|
* @returns {void}
|
|
2574
2990
|
*/
|
|
2575
2991
|
const callback = (err, entry) => {
|
|
@@ -2581,26 +2997,27 @@ class FileSystemInfo {
|
|
|
2581
2997
|
}
|
|
2582
2998
|
jobError();
|
|
2583
2999
|
} else {
|
|
2584
|
-
|
|
3000
|
+
contextTimestampsMap.set(
|
|
2585
3001
|
path,
|
|
2586
|
-
/** @type {
|
|
3002
|
+
/** @type {ResolvedContextFileSystemInfoEntry | null} */
|
|
2587
3003
|
(entry)
|
|
2588
3004
|
);
|
|
2589
3005
|
jobDone();
|
|
2590
3006
|
}
|
|
2591
3007
|
};
|
|
2592
|
-
if (
|
|
2593
|
-
this.
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
callback
|
|
2597
|
-
);
|
|
3008
|
+
if (cacheLacksHash) {
|
|
3009
|
+
this._readFreshContextTimestamp(path, callback);
|
|
3010
|
+
} else if (usableCache !== undefined && usableCache !== null) {
|
|
3011
|
+
this._resolveContextTimestamp(usableCache, callback);
|
|
2598
3012
|
} else {
|
|
2599
|
-
|
|
3013
|
+
// Force a fresh on-disk read so the snapshot stores a
|
|
3014
|
+
// complete entry (with `timestampHash`).
|
|
3015
|
+
this._readFreshContextTimestamp(path, callback);
|
|
2600
3016
|
}
|
|
2601
3017
|
}
|
|
2602
3018
|
}
|
|
2603
3019
|
break;
|
|
3020
|
+
}
|
|
2604
3021
|
}
|
|
2605
3022
|
};
|
|
2606
3023
|
if (directories) {
|
|
@@ -2609,6 +3026,7 @@ class FileSystemInfo {
|
|
|
2609
3026
|
);
|
|
2610
3027
|
}
|
|
2611
3028
|
/**
|
|
3029
|
+
* Process captured missing.
|
|
2612
3030
|
* @param {ManagedMissing} capturedMissing captured missing
|
|
2613
3031
|
*/
|
|
2614
3032
|
const processCapturedMissing = (capturedMissing) => {
|
|
@@ -2616,11 +3034,13 @@ class FileSystemInfo {
|
|
|
2616
3034
|
return;
|
|
2617
3035
|
}
|
|
2618
3036
|
this._missingExistenceOptimization.optimize(snapshot, capturedMissing);
|
|
3037
|
+
if (missingExistence === undefined) missingExistence = new Map();
|
|
3038
|
+
const missingExistenceMap = missingExistence;
|
|
2619
3039
|
for (const path of capturedMissing) {
|
|
2620
3040
|
const cache = this._fileTimestamps.get(path);
|
|
2621
|
-
if (cache !== undefined) {
|
|
3041
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
2622
3042
|
if (cache !== "ignore") {
|
|
2623
|
-
|
|
3043
|
+
missingExistenceMap.set(path, Boolean(cache));
|
|
2624
3044
|
}
|
|
2625
3045
|
} else {
|
|
2626
3046
|
jobs++;
|
|
@@ -2633,7 +3053,7 @@ class FileSystemInfo {
|
|
|
2633
3053
|
}
|
|
2634
3054
|
jobError();
|
|
2635
3055
|
} else {
|
|
2636
|
-
|
|
3056
|
+
missingExistenceMap.set(path, Boolean(entry));
|
|
2637
3057
|
jobDone();
|
|
2638
3058
|
}
|
|
2639
3059
|
});
|
|
@@ -2644,6 +3064,10 @@ class FileSystemInfo {
|
|
|
2644
3064
|
processCapturedMissing(captureNonManaged(missing, managedMissing));
|
|
2645
3065
|
}
|
|
2646
3066
|
this._managedItemInfoOptimization.optimize(snapshot, managedItems);
|
|
3067
|
+
if (managedItems.size !== 0 && managedItemInfo === undefined) {
|
|
3068
|
+
managedItemInfo = new Map();
|
|
3069
|
+
}
|
|
3070
|
+
const managedItemInfoMap = managedItemInfo;
|
|
2647
3071
|
for (const path of managedItems) {
|
|
2648
3072
|
const cache = this._managedItems.get(path);
|
|
2649
3073
|
if (cache !== undefined) {
|
|
@@ -2652,7 +3076,7 @@ class FileSystemInfo {
|
|
|
2652
3076
|
} else if (cache === "*nested") {
|
|
2653
3077
|
managedMissing.add(join(this.fs, path, "package.json"));
|
|
2654
3078
|
}
|
|
2655
|
-
|
|
3079
|
+
/** @type {ManagedItemInfo} */ (managedItemInfoMap).set(path, cache);
|
|
2656
3080
|
} else {
|
|
2657
3081
|
jobs++;
|
|
2658
3082
|
this.managedItemQueue.add(path, (err, entry) => {
|
|
@@ -2669,11 +3093,15 @@ class FileSystemInfo {
|
|
|
2669
3093
|
} else if (cache === "*nested") {
|
|
2670
3094
|
managedMissing.add(join(this.fs, path, "package.json"));
|
|
2671
3095
|
}
|
|
2672
|
-
|
|
3096
|
+
/** @type {ManagedItemInfo} */ (managedItemInfoMap).set(
|
|
3097
|
+
path,
|
|
3098
|
+
entry
|
|
3099
|
+
);
|
|
2673
3100
|
jobDone();
|
|
2674
3101
|
} else {
|
|
2675
3102
|
// Fallback to normal snapshotting
|
|
2676
3103
|
/**
|
|
3104
|
+
* Processes the provided set.
|
|
2677
3105
|
* @param {Set<string>} set set
|
|
2678
3106
|
* @param {(set: Set<string>) => void} fn fn
|
|
2679
3107
|
*/
|
|
@@ -2698,6 +3126,7 @@ class FileSystemInfo {
|
|
|
2698
3126
|
}
|
|
2699
3127
|
|
|
2700
3128
|
/**
|
|
3129
|
+
* Merges the provided values into a single result.
|
|
2701
3130
|
* @param {Snapshot} snapshot1 a snapshot
|
|
2702
3131
|
* @param {Snapshot} snapshot2 a snapshot
|
|
2703
3132
|
* @returns {Snapshot} merged snapshot
|
|
@@ -2784,6 +3213,7 @@ class FileSystemInfo {
|
|
|
2784
3213
|
}
|
|
2785
3214
|
|
|
2786
3215
|
/**
|
|
3216
|
+
* Checks snapshot valid.
|
|
2787
3217
|
* @param {Snapshot} snapshot the snapshot made
|
|
2788
3218
|
* @param {CheckSnapshotValidCallback} callback callback function
|
|
2789
3219
|
* @returns {void}
|
|
@@ -2804,6 +3234,7 @@ class FileSystemInfo {
|
|
|
2804
3234
|
}
|
|
2805
3235
|
|
|
2806
3236
|
/**
|
|
3237
|
+
* Check snapshot valid no cache.
|
|
2807
3238
|
* @private
|
|
2808
3239
|
* @param {Snapshot} snapshot the snapshot made
|
|
2809
3240
|
* @param {CheckSnapshotValidCallback} callback callback function
|
|
@@ -2831,6 +3262,7 @@ class FileSystemInfo {
|
|
|
2831
3262
|
}
|
|
2832
3263
|
};
|
|
2833
3264
|
/**
|
|
3265
|
+
* Invalid with error.
|
|
2834
3266
|
* @param {string} path path
|
|
2835
3267
|
* @param {WebpackError} err err
|
|
2836
3268
|
*/
|
|
@@ -2841,6 +3273,7 @@ class FileSystemInfo {
|
|
|
2841
3273
|
invalid();
|
|
2842
3274
|
};
|
|
2843
3275
|
/**
|
|
3276
|
+
* Checks true, if ok.
|
|
2844
3277
|
* @param {string} path file path
|
|
2845
3278
|
* @param {string | null} current current hash
|
|
2846
3279
|
* @param {string | null} snap snapshot hash
|
|
@@ -2857,6 +3290,7 @@ class FileSystemInfo {
|
|
|
2857
3290
|
return true;
|
|
2858
3291
|
};
|
|
2859
3292
|
/**
|
|
3293
|
+
* Checks true, if ok.
|
|
2860
3294
|
* @param {string} path file path
|
|
2861
3295
|
* @param {boolean} current current entry
|
|
2862
3296
|
* @param {boolean} snap entry from snapshot
|
|
@@ -2877,6 +3311,7 @@ class FileSystemInfo {
|
|
|
2877
3311
|
return true;
|
|
2878
3312
|
};
|
|
2879
3313
|
/**
|
|
3314
|
+
* Checks true, if ok.
|
|
2880
3315
|
* @param {string} path file path
|
|
2881
3316
|
* @param {FileSystemInfoEntry | null} c current entry
|
|
2882
3317
|
* @param {FileSystemInfoEntry | null} s entry from snapshot
|
|
@@ -2919,6 +3354,7 @@ class FileSystemInfo {
|
|
|
2919
3354
|
return true;
|
|
2920
3355
|
};
|
|
2921
3356
|
/**
|
|
3357
|
+
* Checks true, if ok.
|
|
2922
3358
|
* @param {string} path file path
|
|
2923
3359
|
* @param {ResolvedContextFileSystemInfoEntry | null} c current entry
|
|
2924
3360
|
* @param {ResolvedContextFileSystemInfoEntry | null} s entry from snapshot
|
|
@@ -2965,6 +3401,7 @@ class FileSystemInfo {
|
|
|
2965
3401
|
};
|
|
2966
3402
|
if (snapshot.hasChildren()) {
|
|
2967
3403
|
/**
|
|
3404
|
+
* Processes the provided err.
|
|
2968
3405
|
* @param {(WebpackError | null)=} err err
|
|
2969
3406
|
* @param {boolean=} result result
|
|
2970
3407
|
* @returns {void}
|
|
@@ -3001,8 +3438,15 @@ class FileSystemInfo {
|
|
|
3001
3438
|
this._statTestedEntries += fileTimestamps.size;
|
|
3002
3439
|
for (const [path, ts] of fileTimestamps) {
|
|
3003
3440
|
const cache = this._fileTimestamps.get(path);
|
|
3004
|
-
if (cache !== undefined) {
|
|
3005
|
-
if (
|
|
3441
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
3442
|
+
if (
|
|
3443
|
+
cache !== "ignore" &&
|
|
3444
|
+
!checkFile(
|
|
3445
|
+
path,
|
|
3446
|
+
/** @type {FileSystemInfoEntry | null} */ (cache),
|
|
3447
|
+
ts
|
|
3448
|
+
)
|
|
3449
|
+
) {
|
|
3006
3450
|
invalid();
|
|
3007
3451
|
return;
|
|
3008
3452
|
}
|
|
@@ -3026,6 +3470,7 @@ class FileSystemInfo {
|
|
|
3026
3470
|
}
|
|
3027
3471
|
}
|
|
3028
3472
|
/**
|
|
3473
|
+
* Process file hash snapshot.
|
|
3029
3474
|
* @param {string} path file path
|
|
3030
3475
|
* @param {string | null} hash hash
|
|
3031
3476
|
*/
|
|
@@ -3062,8 +3507,16 @@ class FileSystemInfo {
|
|
|
3062
3507
|
processFileHashSnapshot(path, tsh);
|
|
3063
3508
|
} else {
|
|
3064
3509
|
const cache = this._fileTimestamps.get(path);
|
|
3065
|
-
if (cache !== undefined) {
|
|
3066
|
-
if (
|
|
3510
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
3511
|
+
if (
|
|
3512
|
+
cache === "ignore" ||
|
|
3513
|
+
!checkFile(
|
|
3514
|
+
path,
|
|
3515
|
+
/** @type {FileSystemInfoEntry | null} */ (cache),
|
|
3516
|
+
tsh,
|
|
3517
|
+
false
|
|
3518
|
+
)
|
|
3519
|
+
) {
|
|
3067
3520
|
processFileHashSnapshot(path, tsh && tsh.hash);
|
|
3068
3521
|
}
|
|
3069
3522
|
} else {
|
|
@@ -3095,11 +3548,24 @@ class FileSystemInfo {
|
|
|
3095
3548
|
for (const [path, ts] of contextTimestamps) {
|
|
3096
3549
|
const cache = this._contextTimestamps.get(path);
|
|
3097
3550
|
if (cache === "ignore") continue;
|
|
3551
|
+
// Treat existence-only entries (`{}` from watchpack) as a cache
|
|
3552
|
+
// miss — they carry no time info, so we cannot compare them to
|
|
3553
|
+
// the snapshot.
|
|
3554
|
+
/** @type {ContextFileSystemInfoEntry | null | undefined} */
|
|
3555
|
+
const usableCache =
|
|
3556
|
+
cache === undefined || isExistenceOnly(cache)
|
|
3557
|
+
? undefined
|
|
3558
|
+
: /** @type {ContextFileSystemInfoEntry | null} */ (cache);
|
|
3559
|
+
const cacheLacksHash =
|
|
3560
|
+
contextCacheEntryLacksTimestampHash(usableCache) &&
|
|
3561
|
+
ts !== null &&
|
|
3562
|
+
ts.timestampHash !== undefined;
|
|
3098
3563
|
/** @type {undefined | null | ResolvedContextFileSystemInfoEntry} */
|
|
3099
3564
|
let resolved;
|
|
3100
3565
|
if (
|
|
3101
|
-
|
|
3102
|
-
|
|
3566
|
+
usableCache !== undefined &&
|
|
3567
|
+
!cacheLacksHash &&
|
|
3568
|
+
(resolved = getResolvedTimestamp(usableCache)) !== undefined
|
|
3103
3569
|
) {
|
|
3104
3570
|
if (!checkContext(path, resolved, ts)) {
|
|
3105
3571
|
invalid();
|
|
@@ -3108,6 +3574,7 @@ class FileSystemInfo {
|
|
|
3108
3574
|
} else {
|
|
3109
3575
|
jobs++;
|
|
3110
3576
|
/**
|
|
3577
|
+
* Processes the provided err.
|
|
3111
3578
|
* @param {(WebpackError | null)=} err error
|
|
3112
3579
|
* @param {ResolvedContextTimestamp=} entry entry
|
|
3113
3580
|
* @returns {void}
|
|
@@ -3127,12 +3594,10 @@ class FileSystemInfo {
|
|
|
3127
3594
|
jobDone();
|
|
3128
3595
|
}
|
|
3129
3596
|
};
|
|
3130
|
-
if (
|
|
3131
|
-
this.
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
callback
|
|
3135
|
-
);
|
|
3597
|
+
if (cacheLacksHash) {
|
|
3598
|
+
this._readFreshContextTimestamp(path, callback);
|
|
3599
|
+
} else if (usableCache !== undefined && usableCache !== null) {
|
|
3600
|
+
this._resolveContextTimestamp(usableCache, callback);
|
|
3136
3601
|
} else {
|
|
3137
3602
|
this.getContextTimestamp(path, callback);
|
|
3138
3603
|
}
|
|
@@ -3140,6 +3605,7 @@ class FileSystemInfo {
|
|
|
3140
3605
|
}
|
|
3141
3606
|
}
|
|
3142
3607
|
/**
|
|
3608
|
+
* Process context hash snapshot.
|
|
3143
3609
|
* @param {string} path path
|
|
3144
3610
|
* @param {string | null} hash hash
|
|
3145
3611
|
*/
|
|
@@ -3157,6 +3623,7 @@ class FileSystemInfo {
|
|
|
3157
3623
|
} else {
|
|
3158
3624
|
jobs++;
|
|
3159
3625
|
/**
|
|
3626
|
+
* Processes the provided err.
|
|
3160
3627
|
* @param {(WebpackError | null)=} err err
|
|
3161
3628
|
* @param {string=} entry entry
|
|
3162
3629
|
* @returns {void}
|
|
@@ -3194,11 +3661,22 @@ class FileSystemInfo {
|
|
|
3194
3661
|
} else {
|
|
3195
3662
|
const cache = this._contextTimestamps.get(path);
|
|
3196
3663
|
if (cache === "ignore") continue;
|
|
3664
|
+
// See the matching block in `hasContextTimestamps` above.
|
|
3665
|
+
/** @type {ContextFileSystemInfoEntry | null | undefined} */
|
|
3666
|
+
const usableCache =
|
|
3667
|
+
cache === undefined || isExistenceOnly(cache)
|
|
3668
|
+
? undefined
|
|
3669
|
+
: /** @type {ContextFileSystemInfoEntry | null} */ (cache);
|
|
3670
|
+
const cacheLacksHash =
|
|
3671
|
+
contextCacheEntryLacksTimestampHash(usableCache) &&
|
|
3672
|
+
tsh !== null &&
|
|
3673
|
+
tsh.timestampHash !== undefined;
|
|
3197
3674
|
/** @type {undefined | null | ResolvedContextFileSystemInfoEntry} */
|
|
3198
3675
|
let resolved;
|
|
3199
3676
|
if (
|
|
3200
|
-
|
|
3201
|
-
|
|
3677
|
+
usableCache !== undefined &&
|
|
3678
|
+
!cacheLacksHash &&
|
|
3679
|
+
(resolved = getResolvedTimestamp(usableCache)) !== undefined
|
|
3202
3680
|
) {
|
|
3203
3681
|
if (!checkContext(path, resolved, tsh, false)) {
|
|
3204
3682
|
processContextHashSnapshot(path, tsh && tsh.hash);
|
|
@@ -3206,6 +3684,7 @@ class FileSystemInfo {
|
|
|
3206
3684
|
} else {
|
|
3207
3685
|
jobs++;
|
|
3208
3686
|
/**
|
|
3687
|
+
* Processes the provided err.
|
|
3209
3688
|
* @param {(WebpackError | null)=} err error
|
|
3210
3689
|
* @param {ResolvedContextTimestamp=} entry entry
|
|
3211
3690
|
* @returns {void}
|
|
@@ -3215,7 +3694,6 @@ class FileSystemInfo {
|
|
|
3215
3694
|
if (
|
|
3216
3695
|
!checkContext(
|
|
3217
3696
|
path,
|
|
3218
|
-
// TODO: test with `"ignore"`
|
|
3219
3697
|
/** @type {ResolvedContextFileSystemInfoEntry | null} */
|
|
3220
3698
|
(entry),
|
|
3221
3699
|
tsh,
|
|
@@ -3226,12 +3704,10 @@ class FileSystemInfo {
|
|
|
3226
3704
|
}
|
|
3227
3705
|
jobDone();
|
|
3228
3706
|
};
|
|
3229
|
-
if (
|
|
3230
|
-
this.
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
callback
|
|
3234
|
-
);
|
|
3707
|
+
if (cacheLacksHash) {
|
|
3708
|
+
this._readFreshContextTimestamp(path, callback);
|
|
3709
|
+
} else if (usableCache !== undefined && usableCache !== null) {
|
|
3710
|
+
this._resolveContextTimestamp(usableCache, callback);
|
|
3235
3711
|
} else {
|
|
3236
3712
|
this.getContextTimestamp(path, callback);
|
|
3237
3713
|
}
|
|
@@ -3246,7 +3722,7 @@ class FileSystemInfo {
|
|
|
3246
3722
|
this._statTestedEntries += missingExistence.size;
|
|
3247
3723
|
for (const [path, existence] of missingExistence) {
|
|
3248
3724
|
const cache = this._fileTimestamps.get(path);
|
|
3249
|
-
if (cache !== undefined) {
|
|
3725
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
3250
3726
|
if (
|
|
3251
3727
|
cache !== "ignore" &&
|
|
3252
3728
|
!checkExistence(path, Boolean(cache), Boolean(existence))
|
|
@@ -3382,12 +3858,14 @@ class FileSystemInfo {
|
|
|
3382
3858
|
}
|
|
3383
3859
|
|
|
3384
3860
|
/**
|
|
3861
|
+
* Get file timestamp and hash.
|
|
3385
3862
|
* @private
|
|
3386
3863
|
* @param {string} path path
|
|
3387
3864
|
* @param {(err: WebpackError | null, timestampAndHash?: TimestampAndHash | string) => void} callback callback
|
|
3388
3865
|
*/
|
|
3389
3866
|
_getFileTimestampAndHash(path, callback) {
|
|
3390
3867
|
/**
|
|
3868
|
+
* Continue with hash.
|
|
3391
3869
|
* @param {string} hash hash
|
|
3392
3870
|
* @returns {void}
|
|
3393
3871
|
*/
|
|
@@ -3434,6 +3912,7 @@ class FileSystemInfo {
|
|
|
3434
3912
|
}
|
|
3435
3913
|
|
|
3436
3914
|
/**
|
|
3915
|
+
* Processes the provided object.
|
|
3437
3916
|
* @private
|
|
3438
3917
|
* @template T
|
|
3439
3918
|
* @template ItemType
|
|
@@ -3573,8 +4052,13 @@ class FileSystemInfo {
|
|
|
3573
4052
|
fromFile: (file, stat, callback) => {
|
|
3574
4053
|
// Prefer the cached value over our new stat to report consistent results
|
|
3575
4054
|
const cache = this._fileTimestamps.get(file);
|
|
3576
|
-
if (cache !== undefined) {
|
|
3577
|
-
return callback(
|
|
4055
|
+
if (cache !== undefined && !isExistenceOnly(cache)) {
|
|
4056
|
+
return callback(
|
|
4057
|
+
null,
|
|
4058
|
+
cache === "ignore"
|
|
4059
|
+
? null
|
|
4060
|
+
: /** @type {FileSystemInfoEntry | null} */ (cache)
|
|
4061
|
+
);
|
|
3578
4062
|
}
|
|
3579
4063
|
|
|
3580
4064
|
const mtime = Number(stat.mtime);
|
|
@@ -3663,6 +4147,7 @@ class FileSystemInfo {
|
|
|
3663
4147
|
}
|
|
3664
4148
|
|
|
3665
4149
|
/**
|
|
4150
|
+
* Resolve context timestamp.
|
|
3666
4151
|
* @private
|
|
3667
4152
|
* @param {ContextFileSystemInfoEntry} entry entry
|
|
3668
4153
|
* @param {(err?: WebpackError | null, resolvedContextTimestamp?: ResolvedContextTimestamp) => void} callback callback
|
|
@@ -3672,6 +4157,8 @@ class FileSystemInfo {
|
|
|
3672
4157
|
/** @type {string[]} */
|
|
3673
4158
|
const hashes = [];
|
|
3674
4159
|
let safeTime = 0;
|
|
4160
|
+
// Skip already-visited symlink targets so cyclic pnpm/peer-variant graphs terminate (#21084).
|
|
4161
|
+
const seen = new Set(entry.symlinks);
|
|
3675
4162
|
processAsyncTree(
|
|
3676
4163
|
/** @type {NonNullable<ContextHash["symlinks"]>} */ (entry.symlinks),
|
|
3677
4164
|
10,
|
|
@@ -3684,7 +4171,12 @@ class FileSystemInfo {
|
|
|
3684
4171
|
safeTime = Math.max(safeTime, entry.safeTime);
|
|
3685
4172
|
}
|
|
3686
4173
|
if (entry.symlinks !== undefined) {
|
|
3687
|
-
for (const target of entry.symlinks)
|
|
4174
|
+
for (const target of entry.symlinks) {
|
|
4175
|
+
if (!seen.has(target)) {
|
|
4176
|
+
seen.add(target);
|
|
4177
|
+
push(target);
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
3688
4180
|
}
|
|
3689
4181
|
}
|
|
3690
4182
|
callback();
|
|
@@ -3744,8 +4236,9 @@ class FileSystemInfo {
|
|
|
3744
4236
|
});
|
|
3745
4237
|
},
|
|
3746
4238
|
/**
|
|
4239
|
+
* Returns reduced hash.
|
|
3747
4240
|
* @param {string[]} files files
|
|
3748
|
-
* @param {(string | ContextHash)[]} fileHashes hashes
|
|
4241
|
+
* @param {(string | ContextHash | null)[]} fileHashes hashes
|
|
3749
4242
|
* @returns {ContextHash} reduced hash
|
|
3750
4243
|
*/
|
|
3751
4244
|
reduce: (files, fileHashes) => {
|
|
@@ -3755,10 +4248,13 @@ class FileSystemInfo {
|
|
|
3755
4248
|
|
|
3756
4249
|
for (const file of files) hash.update(file);
|
|
3757
4250
|
for (const entry of fileHashes) {
|
|
3758
|
-
|
|
4251
|
+
// null for unsupported entry kinds (FIFO, socket); skip like the tsh reduce
|
|
4252
|
+
if (!entry) {
|
|
4253
|
+
continue;
|
|
4254
|
+
} else if (typeof entry === "string") {
|
|
3759
4255
|
hash.update(entry);
|
|
3760
4256
|
} else {
|
|
3761
|
-
hash.update(entry.hash);
|
|
4257
|
+
if (entry.hash) hash.update(entry.hash);
|
|
3762
4258
|
if (entry.symlinks) {
|
|
3763
4259
|
if (symlinks === undefined) symlinks = new Set();
|
|
3764
4260
|
addAll(entry.symlinks, symlinks);
|
|
@@ -3784,6 +4280,7 @@ class FileSystemInfo {
|
|
|
3784
4280
|
}
|
|
3785
4281
|
|
|
3786
4282
|
/**
|
|
4283
|
+
* Resolve context hash.
|
|
3787
4284
|
* @private
|
|
3788
4285
|
* @param {ContextHash} entry context hash
|
|
3789
4286
|
* @param {(err: WebpackError | null, contextHash?: string) => void} callback callback
|
|
@@ -3792,6 +4289,8 @@ class FileSystemInfo {
|
|
|
3792
4289
|
_resolveContextHash(entry, callback) {
|
|
3793
4290
|
/** @type {string[]} */
|
|
3794
4291
|
const hashes = [];
|
|
4292
|
+
// Skip already-visited symlink targets so cyclic pnpm/peer-variant graphs terminate (#21084).
|
|
4293
|
+
const seen = new Set(entry.symlinks);
|
|
3795
4294
|
processAsyncTree(
|
|
3796
4295
|
/** @type {NonNullable<ContextHash["symlinks"]>} */ (entry.symlinks),
|
|
3797
4296
|
10,
|
|
@@ -3801,7 +4300,12 @@ class FileSystemInfo {
|
|
|
3801
4300
|
if (hash) {
|
|
3802
4301
|
hashes.push(hash.hash);
|
|
3803
4302
|
if (hash.symlinks !== undefined) {
|
|
3804
|
-
for (const target of hash.symlinks)
|
|
4303
|
+
for (const target of hash.symlinks) {
|
|
4304
|
+
if (!seen.has(target)) {
|
|
4305
|
+
seen.add(target);
|
|
4306
|
+
push(target);
|
|
4307
|
+
}
|
|
4308
|
+
}
|
|
3805
4309
|
}
|
|
3806
4310
|
}
|
|
3807
4311
|
callback();
|
|
@@ -3826,6 +4330,7 @@ class FileSystemInfo {
|
|
|
3826
4330
|
*/
|
|
3827
4331
|
_readContextTimestampAndHash(path, callback) {
|
|
3828
4332
|
/**
|
|
4333
|
+
* Processes the provided timestamp.
|
|
3829
4334
|
* @param {ContextTimestamp} timestamp timestamp
|
|
3830
4335
|
* @param {ContextHash} hash hash
|
|
3831
4336
|
*/
|
|
@@ -3887,6 +4392,7 @@ class FileSystemInfo {
|
|
|
3887
4392
|
});
|
|
3888
4393
|
},
|
|
3889
4394
|
/**
|
|
4395
|
+
* Returns tsh.
|
|
3890
4396
|
* @param {string[]} files files
|
|
3891
4397
|
* @param {(Partial<TimestampAndHash> & Partial<ContextTimestampAndHash> | string | null)[]} results results
|
|
3892
4398
|
* @returns {ContextTimestampAndHash} tsh
|
|
@@ -3951,6 +4457,7 @@ class FileSystemInfo {
|
|
|
3951
4457
|
}
|
|
3952
4458
|
|
|
3953
4459
|
/**
|
|
4460
|
+
* Resolve context tsh.
|
|
3954
4461
|
* @private
|
|
3955
4462
|
* @param {ContextTimestampAndHash} entry entry
|
|
3956
4463
|
* @param {ProcessorCallback<ResolvedContextTimestampAndHash>} callback callback
|
|
@@ -3962,6 +4469,8 @@ class FileSystemInfo {
|
|
|
3962
4469
|
/** @type {string[]} */
|
|
3963
4470
|
const tsHashes = [];
|
|
3964
4471
|
let safeTime = 0;
|
|
4472
|
+
// Skip already-visited symlink targets so cyclic pnpm/peer-variant graphs terminate (#21084).
|
|
4473
|
+
const seen = new Set(entry.symlinks);
|
|
3965
4474
|
processAsyncTree(
|
|
3966
4475
|
/** @type {NonNullable<ContextHash["symlinks"]>} */ (entry.symlinks),
|
|
3967
4476
|
10,
|
|
@@ -3975,7 +4484,12 @@ class FileSystemInfo {
|
|
|
3975
4484
|
safeTime = Math.max(safeTime, entry.safeTime);
|
|
3976
4485
|
}
|
|
3977
4486
|
if (entry.symlinks !== undefined) {
|
|
3978
|
-
for (const target of entry.symlinks)
|
|
4487
|
+
for (const target of entry.symlinks) {
|
|
4488
|
+
if (!seen.has(target)) {
|
|
4489
|
+
seen.add(target);
|
|
4490
|
+
push(target);
|
|
4491
|
+
}
|
|
4492
|
+
}
|
|
3979
4493
|
}
|
|
3980
4494
|
}
|
|
3981
4495
|
callback();
|
|
@@ -4111,7 +4625,13 @@ class FileSystemInfo {
|
|
|
4111
4625
|
/** @type {Map<string, number | null>} */
|
|
4112
4626
|
const map = new Map();
|
|
4113
4627
|
for (const [path, info] of this._fileTimestamps) {
|
|
4114
|
-
if (info)
|
|
4628
|
+
if (info) {
|
|
4629
|
+
const safeTime =
|
|
4630
|
+
typeof info === "object"
|
|
4631
|
+
? /** @type {Partial<FileSystemInfoEntry>} */ (info).safeTime
|
|
4632
|
+
: undefined;
|
|
4633
|
+
map.set(path, safeTime === undefined ? null : safeTime);
|
|
4634
|
+
}
|
|
4115
4635
|
}
|
|
4116
4636
|
return (this._cachedDeprecatedFileTimestamps = map);
|
|
4117
4637
|
}
|
|
@@ -4123,7 +4643,13 @@ class FileSystemInfo {
|
|
|
4123
4643
|
/** @type {Map<string, number | null>} */
|
|
4124
4644
|
const map = new Map();
|
|
4125
4645
|
for (const [path, info] of this._contextTimestamps) {
|
|
4126
|
-
if (info)
|
|
4646
|
+
if (info) {
|
|
4647
|
+
const safeTime =
|
|
4648
|
+
typeof info === "object"
|
|
4649
|
+
? /** @type {Partial<ContextFileSystemInfoEntry>} */ (info).safeTime
|
|
4650
|
+
: undefined;
|
|
4651
|
+
map.set(path, safeTime === undefined ? null : safeTime);
|
|
4652
|
+
}
|
|
4127
4653
|
}
|
|
4128
4654
|
return (this._cachedDeprecatedContextTimestamps = map);
|
|
4129
4655
|
}
|