xhs-mp-pack 1.1.0-beta.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 +1 -0
- package/dist/Compilation.d.ts +239 -0
- package/dist/Compilation.js +3513 -0
- package/dist/Compiler.d.ts +76 -0
- package/dist/Compiler.js +845 -0
- package/dist/ConcatenationScope.d.ts +37 -0
- package/dist/ConcatenationScope.js +69 -0
- package/dist/FileSystemInfo.d.ts +183 -0
- package/dist/FileSystemInfo.js +2896 -0
- package/dist/MPPack.d.ts +33 -0
- package/dist/MPPack.js +163 -0
- package/dist/MPPackSetting.d.ts +52 -0
- package/dist/MPPackSetting.js +85 -0
- package/dist/MultiCompiler.d.ts +25 -0
- package/dist/MultiCompiler.js +387 -0
- package/dist/MultiWatching.d.ts +11 -0
- package/dist/MultiWatching.js +54 -0
- package/dist/PluginManager.d.ts +9 -0
- package/dist/PluginManager.js +359 -0
- package/dist/ResolverFactory.d.ts +7 -0
- package/dist/ResolverFactory.js +84 -0
- package/dist/Watching.d.ts +41 -0
- package/dist/Watching.js +359 -0
- package/dist/base/ArrayHelpers.d.ts +6 -0
- package/dist/base/ArrayHelpers.js +21 -0
- package/dist/base/ArrayQueue.d.ts +29 -0
- package/dist/base/ArrayQueue.js +87 -0
- package/dist/base/AsyncQueue.d.ts +37 -0
- package/dist/base/AsyncQueue.js +263 -0
- package/dist/base/ChunkHelpers.d.ts +3 -0
- package/dist/base/ChunkHelpers.js +26 -0
- package/dist/base/ConditionalInitFragment.d.ts +9 -0
- package/dist/base/ConditionalInitFragment.js +64 -0
- package/dist/base/GraphHelpers.d.ts +6 -0
- package/dist/base/GraphHelpers.js +32 -0
- package/dist/base/Hash.d.ts +6 -0
- package/dist/base/Hash.js +13 -0
- package/dist/base/InitFragment.d.ts +22 -0
- package/dist/base/InitFragment.js +113 -0
- package/dist/base/IterableHelpers.d.ts +4 -0
- package/dist/base/IterableHelpers.js +26 -0
- package/dist/base/LazyBucketSortedSet.d.ts +34 -0
- package/dist/base/LazyBucketSortedSet.js +188 -0
- package/dist/base/LazySet.d.ts +35 -0
- package/dist/base/LazySet.js +155 -0
- package/dist/base/MapHelpers.d.ts +14 -0
- package/dist/base/MapHelpers.js +27 -0
- package/dist/base/ModuleFilenameHelpers.d.ts +95 -0
- package/dist/base/ModuleFilenameHelpers.js +314 -0
- package/dist/base/NodeWatchFileSystem.d.ts +23 -0
- package/dist/base/NodeWatchFileSystem.js +135 -0
- package/dist/base/ParallelismFactorCalculator.d.ts +8 -0
- package/dist/base/ParallelismFactorCalculator.js +52 -0
- package/dist/base/Queue.d.ts +12 -0
- package/dist/base/Queue.js +25 -0
- package/dist/base/RequestShortener.d.ts +6 -0
- package/dist/base/RequestShortener.js +15 -0
- package/dist/base/Semaphore.d.ts +12 -0
- package/dist/base/Semaphore.js +37 -0
- package/dist/base/SetHelpers.d.ts +36 -0
- package/dist/base/SetHelpers.js +94 -0
- package/dist/base/SizeFormatHelpers.d.ts +2 -0
- package/dist/base/SizeFormatHelpers.js +15 -0
- package/dist/base/SizeOnlySource.d.ts +14 -0
- package/dist/base/SizeOnlySource.js +34 -0
- package/dist/base/SortableSet.d.ts +18 -0
- package/dist/base/SortableSet.js +90 -0
- package/dist/base/StackedCacheMap.d.ts +20 -0
- package/dist/base/StackedCacheMap.js +73 -0
- package/dist/base/StackedMap.d.ts +17 -0
- package/dist/base/StackedMap.js +103 -0
- package/dist/base/StartupHelpers.d.ts +4 -0
- package/dist/base/StartupHelpers.js +94 -0
- package/dist/base/StringXor.d.ts +53 -0
- package/dist/base/StringXor.js +94 -0
- package/dist/base/TupleQueue.d.ts +10 -0
- package/dist/base/TupleQueue.js +33 -0
- package/dist/base/TupleSet.d.ts +18 -0
- package/dist/base/TupleSet.js +115 -0
- package/dist/base/URLAbsoluteSpecifier.d.ts +3 -0
- package/dist/base/URLAbsoluteSpecifier.js +57 -0
- package/dist/base/WeakTupleMap.d.ts +20 -0
- package/dist/base/WeakTupleMap.js +124 -0
- package/dist/base/binarySearchBounds.d.ts +23 -0
- package/dist/base/binarySearchBounds.js +105 -0
- package/dist/base/cleverMerge.d.ts +27 -0
- package/dist/base/cleverMerge.js +450 -0
- package/dist/base/common.d.ts +7 -0
- package/dist/base/common.js +25 -0
- package/dist/base/commonjs.d.ts +1 -0
- package/dist/base/commonjs.js +48 -0
- package/dist/base/comparators.d.ts +22 -0
- package/dist/base/comparators.js +279 -0
- package/dist/base/compileBooleanMatcher.d.ts +6 -0
- package/dist/base/compileBooleanMatcher.js +162 -0
- package/dist/base/const.d.ts +29 -0
- package/dist/base/const.js +49 -0
- package/dist/base/copyPatterns.d.ts +14 -0
- package/dist/base/copyPatterns.js +501 -0
- package/dist/base/createHash.d.ts +3 -0
- package/dist/base/createHash.js +131 -0
- package/dist/base/defaults.d.ts +3 -0
- package/dist/base/defaults.js +671 -0
- package/dist/base/deprecation.d.ts +21 -0
- package/dist/base/deprecation.js +165 -0
- package/dist/base/deterministicGrouping.d.ts +8 -0
- package/dist/base/deterministicGrouping.js +395 -0
- package/dist/base/errors/AbstractMethodError.d.ts +5 -0
- package/dist/base/errors/AbstractMethodError.js +23 -0
- package/dist/base/errors/AsyncDependencyToInitialChunkError.d.ts +8 -0
- package/dist/base/errors/AsyncDependencyToInitialChunkError.js +18 -0
- package/dist/base/errors/BaseError.d.ts +17 -0
- package/dist/base/errors/BaseError.js +39 -0
- package/dist/base/errors/BuildCycleError.d.ts +8 -0
- package/dist/base/errors/BuildCycleError.js +17 -0
- package/dist/base/errors/CaseSensitiveModulesWarning.d.ts +5 -0
- package/dist/base/errors/CaseSensitiveModulesWarning.js +42 -0
- package/dist/base/errors/ChunkRenderError.d.ts +6 -0
- package/dist/base/errors/ChunkRenderError.js +18 -0
- package/dist/base/errors/CodeGenerationError.d.ts +8 -0
- package/dist/base/errors/CodeGenerationError.js +20 -0
- package/dist/base/errors/CommentCompilationWarning.d.ts +5 -0
- package/dist/base/errors/CommentCompilationWarning.js +16 -0
- package/dist/base/errors/ConcurrentCompilationError.d.ts +4 -0
- package/dist/base/errors/ConcurrentCompilationError.js +15 -0
- package/dist/base/errors/CriticalDependencyWarning.d.ts +5 -0
- package/dist/base/errors/CriticalDependencyWarning.js +16 -0
- package/dist/base/errors/ErrorHelpers.d.ts +8 -0
- package/dist/base/errors/ErrorHelpers.js +51 -0
- package/dist/base/errors/HarmonyLinkingError.d.ts +4 -0
- package/dist/base/errors/HarmonyLinkingError.js +14 -0
- package/dist/base/errors/HookBaseError.d.ts +10 -0
- package/dist/base/errors/HookBaseError.js +51 -0
- package/dist/base/errors/InvalidDependenciesModuleWarning.d.ts +5 -0
- package/dist/base/errors/InvalidDependenciesModuleWarning.js +26 -0
- package/dist/base/errors/MinMaxSizeWarning.d.ts +5 -0
- package/dist/base/errors/MinMaxSizeWarning.js +45 -0
- package/dist/base/errors/ModuleBuildError.d.ts +9 -0
- package/dist/base/errors/ModuleBuildError.js +62 -0
- package/dist/base/errors/ModuleDependencyError.d.ts +8 -0
- package/dist/base/errors/ModuleDependencyError.js +24 -0
- package/dist/base/errors/ModuleDependencyWarning.d.ts +6 -0
- package/dist/base/errors/ModuleDependencyWarning.js +23 -0
- package/dist/base/errors/ModuleError.d.ts +10 -0
- package/dist/base/errors/ModuleError.js +42 -0
- package/dist/base/errors/ModuleHashingError.d.ts +5 -0
- package/dist/base/errors/ModuleHashingError.js +17 -0
- package/dist/base/errors/ModuleNotFoundError.d.ts +5 -0
- package/dist/base/errors/ModuleNotFoundError.js +69 -0
- package/dist/base/errors/ModuleParseError.d.ts +8 -0
- package/dist/base/errors/ModuleParseError.js +77 -0
- package/dist/base/errors/ModuleRestoreError.d.ts +5 -0
- package/dist/base/errors/ModuleRestoreError.js +33 -0
- package/dist/base/errors/ModuleStoreError.d.ts +5 -0
- package/dist/base/errors/ModuleStoreError.js +33 -0
- package/dist/base/errors/ModuleWarning.d.ts +10 -0
- package/dist/base/errors/ModuleWarning.js +44 -0
- package/dist/base/errors/NodeStuffInWebError.d.ts +5 -0
- package/dist/base/errors/NodeStuffInWebError.js +17 -0
- package/dist/base/errors/UnhandledSchemeError.d.ts +5 -0
- package/dist/base/errors/UnhandledSchemeError.js +18 -0
- package/dist/base/errors/UnsupportedFeatureWarning.d.ts +5 -0
- package/dist/base/errors/UnsupportedFeatureWarning.js +17 -0
- package/dist/base/extractUrlAndGlobal.d.ts +1 -0
- package/dist/base/extractUrlAndGlobal.js +10 -0
- package/dist/base/findGraphRoots.d.ts +2 -0
- package/dist/base/findGraphRoots.js +183 -0
- package/dist/base/formatLocation.d.ts +2 -0
- package/dist/base/formatLocation.js +47 -0
- package/dist/base/fs.d.ts +94 -0
- package/dist/base/fs.js +218 -0
- package/dist/base/hash/BatchedHash.d.ts +11 -0
- package/dist/base/hash/BatchedHash.js +47 -0
- package/dist/base/hash/md4.d.ts +2 -0
- package/dist/base/hash/md4.js +10 -0
- package/dist/base/hash/wasm-hash.d.ts +3 -0
- package/dist/base/hash/wasm-hash.js +138 -0
- package/dist/base/hash/xxhash64.d.ts +2 -0
- package/dist/base/hash/xxhash64.js +10 -0
- package/dist/base/identifier.d.ts +30 -0
- package/dist/base/identifier.js +237 -0
- package/dist/base/logging/Logger.d.ts +40 -0
- package/dist/base/logging/Logger.js +128 -0
- package/dist/base/logging/createConsoleLogger.d.ts +6 -0
- package/dist/base/logging/createConsoleLogger.js +161 -0
- package/dist/base/logging/nodeConsole.d.ts +21 -0
- package/dist/base/logging/nodeConsole.js +109 -0
- package/dist/base/logging/runtime.d.ts +8 -0
- package/dist/base/logging/runtime.js +30 -0
- package/dist/base/logging/truncateArgs.d.ts +2 -0
- package/dist/base/logging/truncateArgs.js +66 -0
- package/dist/base/memoize.d.ts +2 -0
- package/dist/base/memoize.js +18 -0
- package/dist/base/missingModule.d.ts +4 -0
- package/dist/base/missingModule.js +16 -0
- package/dist/base/moduleAlias.d.ts +1 -0
- package/dist/base/moduleAlias.js +8 -0
- package/dist/base/nonNumericOnlyHash.d.ts +7 -0
- package/dist/base/nonNumericOnlyHash.js +16 -0
- package/dist/base/normalization.d.ts +32 -0
- package/dist/base/normalization.js +320 -0
- package/dist/base/numberHash.d.ts +17 -0
- package/dist/base/numberHash.js +72 -0
- package/dist/base/objectToMap.d.ts +1 -0
- package/dist/base/objectToMap.js +6 -0
- package/dist/base/processAsyncTree.d.ts +2 -0
- package/dist/base/processAsyncTree.js +45 -0
- package/dist/base/propertyAccess.d.ts +2 -0
- package/dist/base/propertyAccess.js +20 -0
- package/dist/base/propertyName.d.ts +9 -0
- package/dist/base/propertyName.js +71 -0
- package/dist/base/semver.d.ts +25 -0
- package/dist/base/semver.js +425 -0
- package/dist/base/singletontask.d.ts +27 -0
- package/dist/base/singletontask.js +124 -0
- package/dist/base/smartGrouping.d.ts +2 -0
- package/dist/base/smartGrouping.js +138 -0
- package/dist/base/source.d.ts +2 -0
- package/dist/base/source.js +48 -0
- package/dist/base/stats/MultiStats.d.ts +19 -0
- package/dist/base/stats/MultiStats.js +142 -0
- package/dist/base/stats/Stats.d.ts +13 -0
- package/dist/base/stats/Stats.js +49 -0
- package/dist/base/stats/StatsFactory.d.ts +26 -0
- package/dist/base/stats/StatsFactory.js +163 -0
- package/dist/base/stats/StatsPrinter.d.ts +12 -0
- package/dist/base/stats/StatsPrinter.js +104 -0
- package/dist/base/utils.d.ts +5 -0
- package/dist/base/utils.js +35 -0
- package/dist/cache/AddBuildDependenciesPlugin.d.ts +6 -0
- package/dist/cache/AddBuildDependenciesPlugin.js +13 -0
- package/dist/cache/AddManagedPathsPlugin.d.ts +7 -0
- package/dist/cache/AddManagedPathsPlugin.js +17 -0
- package/dist/cache/Cache.d.ts +15 -0
- package/dist/cache/Cache.js +69 -0
- package/dist/cache/CacheFacade.d.ts +37 -0
- package/dist/cache/CacheFacade.js +187 -0
- package/dist/cache/IdleFileCachePlugin.d.ts +9 -0
- package/dist/cache/IdleFileCachePlugin.js +165 -0
- package/dist/cache/MemoryCachePlugin.d.ts +4 -0
- package/dist/cache/MemoryCachePlugin.js +36 -0
- package/dist/cache/MemoryWithGcCachePlugin.d.ts +8 -0
- package/dist/cache/MemoryWithGcCachePlugin.js +104 -0
- package/dist/cache/PackFileCacheStrategy.d.ts +47 -0
- package/dist/cache/PackFileCacheStrategy.js +1085 -0
- package/dist/cache/ResolverCachePlugin.d.ts +4 -0
- package/dist/cache/ResolverCachePlugin.js +248 -0
- package/dist/cache/getLazyHashedEtag.d.ts +2 -0
- package/dist/cache/getLazyHashedEtag.js +53 -0
- package/dist/cache/mergeEtags.d.ts +2 -0
- package/dist/cache/mergeEtags.js +50 -0
- package/dist/chunk/Chunk.d.ts +75 -0
- package/dist/chunk/Chunk.js +445 -0
- package/dist/chunk/ChunkGraph.d.ts +102 -0
- package/dist/chunk/ChunkGraph.js +1037 -0
- package/dist/chunk/ChunkGroup.d.ts +62 -0
- package/dist/chunk/ChunkGroup.js +341 -0
- package/dist/chunk/CodeGenerationResults.d.ts +13 -0
- package/dist/chunk/CodeGenerationResults.js +82 -0
- package/dist/chunk/Entrypoint.d.ts +22 -0
- package/dist/chunk/Entrypoint.js +56 -0
- package/dist/chunk/GraphHelpers.d.ts +3 -0
- package/dist/chunk/GraphHelpers.js +15 -0
- package/dist/chunk/buildChunkGraph.d.ts +2 -0
- package/dist/chunk/buildChunkGraph.js +1067 -0
- package/dist/chunk/chunkFormat/ArrayPushCallbackChunkFormatPlugin.d.ts +4 -0
- package/dist/chunk/chunkFormat/ArrayPushCallbackChunkFormatPlugin.js +101 -0
- package/dist/chunk/chunkLoading/JsonpChunkLoadingPlugin.d.ts +4 -0
- package/dist/chunk/chunkLoading/JsonpChunkLoadingPlugin.js +98 -0
- package/dist/chunk/chunkLoading/JsonpChunkLoadingRuntimeModule.d.ts +15 -0
- package/dist/chunk/chunkLoading/JsonpChunkLoadingRuntimeModule.js +272 -0
- package/dist/dependencies/AsyncDependenciesBlock.d.ts +14 -0
- package/dist/dependencies/AsyncDependenciesBlock.js +64 -0
- package/dist/dependencies/CreateScriptUrlDependency.d.ts +9 -0
- package/dist/dependencies/CreateScriptUrlDependency.js +60 -0
- package/dist/dependencies/DelegatedSourceDependency.d.ts +7 -0
- package/dist/dependencies/DelegatedSourceDependency.js +20 -0
- package/dist/dependencies/DependenciesBlock.d.ts +29 -0
- package/dist/dependencies/DependenciesBlock.js +66 -0
- package/dist/dependencies/Dependency.d.ts +44 -0
- package/dist/dependencies/Dependency.js +171 -0
- package/dist/dependencies/DependencyTemplate.d.ts +4 -0
- package/dist/dependencies/DependencyTemplate.js +9 -0
- package/dist/dependencies/DependencyTemplates.d.ts +12 -0
- package/dist/dependencies/DependencyTemplates.js +34 -0
- package/dist/dependencies/DynamicExports.d.ts +6 -0
- package/dist/dependencies/DynamicExports.js +48 -0
- package/dist/dependencies/ExportsInfoDependency.d.ts +10 -0
- package/dist/dependencies/ExportsInfoDependency.js +80 -0
- package/dist/dependencies/LocalModule.d.ts +11 -0
- package/dist/dependencies/LocalModule.js +33 -0
- package/dist/dependencies/LocalModuleDependency.d.ts +10 -0
- package/dist/dependencies/LocalModuleDependency.js +42 -0
- package/dist/dependencies/LocalModulesHelpers.d.ts +4 -0
- package/dist/dependencies/LocalModulesHelpers.js +48 -0
- package/dist/dependencies/ModuleDecoratorDependency.d.ts +15 -0
- package/dist/dependencies/ModuleDecoratorDependency.js +85 -0
- package/dist/dependencies/ModuleDependency.d.ts +16 -0
- package/dist/dependencies/ModuleDependency.js +53 -0
- package/dist/dependencies/ModuleDependencyTemplateAsId.d.ts +9 -0
- package/dist/dependencies/ModuleDependencyTemplateAsId.js +21 -0
- package/dist/dependencies/ModuleDependencyTemplateAsRequireId.d.ts +10 -0
- package/dist/dependencies/ModuleDependencyTemplateAsRequireId.js +22 -0
- package/dist/dependencies/NullDependency.d.ts +7 -0
- package/dist/dependencies/NullDependency.js +19 -0
- package/dist/dependencies/PureExpressionDependency.d.ts +12 -0
- package/dist/dependencies/PureExpressionDependency.js +73 -0
- package/dist/dependencies/RequireHeaderDependency.d.ts +8 -0
- package/dist/dependencies/RequireHeaderDependency.js +58 -0
- package/dist/dependencies/RequireResolveContextDependency.d.ts +8 -0
- package/dist/dependencies/RequireResolveContextDependency.js +33 -0
- package/dist/dependencies/RequireResolveDependency.d.ts +10 -0
- package/dist/dependencies/RequireResolveDependency.js +29 -0
- package/dist/dependencies/RequireResolveHeaderDependency.d.ts +8 -0
- package/dist/dependencies/RequireResolveHeaderDependency.js +36 -0
- package/dist/dependencies/RuntimeRequirementsDependency.d.ts +10 -0
- package/dist/dependencies/RuntimeRequirementsDependency.js +40 -0
- package/dist/dependencies/StaticExportsDependency.d.ts +15 -0
- package/dist/dependencies/StaticExportsDependency.js +38 -0
- package/dist/dependencies/URLDependency.d.ts +16 -0
- package/dist/dependencies/URLDependency.js +103 -0
- package/dist/dependencies/URLPlugin.d.ts +4 -0
- package/dist/dependencies/URLPlugin.js +107 -0
- package/dist/dependencies/UnsupportedDependency.d.ts +9 -0
- package/dist/dependencies/UnsupportedDependency.js +36 -0
- package/dist/dependencies/commonjs/CommonJsDependencyHelpers.d.ts +2 -0
- package/dist/dependencies/commonjs/CommonJsDependencyHelpers.js +67 -0
- package/dist/dependencies/commonjs/CommonJsExportRequireDependency.d.ts +46 -0
- package/dist/dependencies/commonjs/CommonJsExportRequireDependency.js +260 -0
- package/dist/dependencies/commonjs/CommonJsExportsDependency.d.ts +19 -0
- package/dist/dependencies/commonjs/CommonJsExportsDependency.js +82 -0
- package/dist/dependencies/commonjs/CommonJsExportsParserPlugin.d.ts +6 -0
- package/dist/dependencies/commonjs/CommonJsExportsParserPlugin.js +314 -0
- package/dist/dependencies/commonjs/CommonJsFullRequireDependency.d.ts +13 -0
- package/dist/dependencies/commonjs/CommonJsFullRequireDependency.js +77 -0
- package/dist/dependencies/commonjs/CommonJsImportsParserPlugin.d.ts +6 -0
- package/dist/dependencies/commonjs/CommonJsImportsParserPlugin.js +500 -0
- package/dist/dependencies/commonjs/CommonJsPlugin.d.ts +4 -0
- package/dist/dependencies/commonjs/CommonJsPlugin.js +170 -0
- package/dist/dependencies/commonjs/CommonJsRequireContextDependency.d.ts +8 -0
- package/dist/dependencies/commonjs/CommonJsRequireContextDependency.js +37 -0
- package/dist/dependencies/commonjs/CommonJsRequireDependency.d.ts +7 -0
- package/dist/dependencies/commonjs/CommonJsRequireDependency.js +24 -0
- package/dist/dependencies/commonjs/CommonJsSelfReferenceDependency.d.ts +15 -0
- package/dist/dependencies/commonjs/CommonJsSelfReferenceDependency.js +112 -0
- package/dist/dependencies/const/CachedConstDependency.d.ts +12 -0
- package/dist/dependencies/const/CachedConstDependency.js +50 -0
- package/dist/dependencies/const/ConstDependency.d.ts +13 -0
- package/dist/dependencies/const/ConstDependency.js +63 -0
- package/dist/dependencies/context/ContextDependency.d.ts +26 -0
- package/dist/dependencies/context/ContextDependency.js +91 -0
- package/dist/dependencies/context/ContextDependencyHelpers.d.ts +2 -0
- package/dist/dependencies/context/ContextDependencyHelpers.js +128 -0
- package/dist/dependencies/context/ContextDependencyTemplateAsId.d.ts +10 -0
- package/dist/dependencies/context/ContextDependencyTemplateAsId.js +37 -0
- package/dist/dependencies/context/ContextDependencyTemplateAsRequireCall.d.ts +10 -0
- package/dist/dependencies/context/ContextDependencyTemplateAsRequireCall.js +39 -0
- package/dist/dependencies/context/ContextElementDependency.d.ts +13 -0
- package/dist/dependencies/context/ContextElementDependency.js +53 -0
- package/dist/dependencies/css/CssExportDependency.d.ts +17 -0
- package/dist/dependencies/css/CssExportDependency.js +49 -0
- package/dist/dependencies/css/CssImportDependency.d.ts +14 -0
- package/dist/dependencies/css/CssImportDependency.js +60 -0
- package/dist/dependencies/css/CssLocalIdentifierDependency.d.ts +12 -0
- package/dist/dependencies/css/CssLocalIdentifierDependency.js +69 -0
- package/dist/dependencies/css/CssSelfLocalIdentifierDependency.d.ts +13 -0
- package/dist/dependencies/css/CssSelfLocalIdentifierDependency.js +53 -0
- package/dist/dependencies/css/CssUrlDependency.d.ts +12 -0
- package/dist/dependencies/css/CssUrlDependency.js +89 -0
- package/dist/dependencies/entry/DynamicEntryPlugin.d.ts +22 -0
- package/dist/dependencies/entry/DynamicEntryPlugin.js +62 -0
- package/dist/dependencies/entry/EntryDependency.d.ts +7 -0
- package/dist/dependencies/entry/EntryDependency.js +20 -0
- package/dist/dependencies/getFunctionExpression.d.ts +10 -0
- package/dist/dependencies/getFunctionExpression.js +42 -0
- package/dist/dependencies/harmony/HarmonyAcceptDependency.d.ts +11 -0
- package/dist/dependencies/harmony/HarmonyAcceptDependency.js +81 -0
- package/dist/dependencies/harmony/HarmonyAcceptImportDependency.d.ts +6 -0
- package/dist/dependencies/harmony/HarmonyAcceptImportDependency.js +20 -0
- package/dist/dependencies/harmony/HarmonyCompatibilityDependency.d.ts +5 -0
- package/dist/dependencies/harmony/HarmonyCompatibilityDependency.js +61 -0
- package/dist/dependencies/harmony/HarmonyDetectionParserPlugin.d.ts +5 -0
- package/dist/dependencies/harmony/HarmonyDetectionParserPlugin.js +102 -0
- package/dist/dependencies/harmony/HarmonyEvaluatedImportSpecifierDependency.d.ts +16 -0
- package/dist/dependencies/harmony/HarmonyEvaluatedImportSpecifierDependency.js +84 -0
- package/dist/dependencies/harmony/HarmonyExportDependencyParserPlugin.d.ts +5 -0
- package/dist/dependencies/harmony/HarmonyExportDependencyParserPlugin.js +143 -0
- package/dist/dependencies/harmony/HarmonyExportExpressionDependency.d.ts +23 -0
- package/dist/dependencies/harmony/HarmonyExportExpressionDependency.js +148 -0
- package/dist/dependencies/harmony/HarmonyExportHeaderDependency.d.ts +10 -0
- package/dist/dependencies/harmony/HarmonyExportHeaderDependency.js +39 -0
- package/dist/dependencies/harmony/HarmonyExportImportedSpecifierDependency.d.ts +140 -0
- package/dist/dependencies/harmony/HarmonyExportImportedSpecifierDependency.js +763 -0
- package/dist/dependencies/harmony/HarmonyExportInitFragment.d.ts +14 -0
- package/dist/dependencies/harmony/HarmonyExportInitFragment.js +147 -0
- package/dist/dependencies/harmony/HarmonyExportSpecifierDependency.d.ts +17 -0
- package/dist/dependencies/harmony/HarmonyExportSpecifierDependency.js +62 -0
- package/dist/dependencies/harmony/HarmonyExports.d.ts +3 -0
- package/dist/dependencies/harmony/HarmonyExports.js +51 -0
- package/dist/dependencies/harmony/HarmonyImportDependency.d.ts +30 -0
- package/dist/dependencies/harmony/HarmonyImportDependency.js +217 -0
- package/dist/dependencies/harmony/HarmonyImportDependencyParserPlugin.d.ts +9 -0
- package/dist/dependencies/harmony/HarmonyImportDependencyParserPlugin.js +202 -0
- package/dist/dependencies/harmony/HarmonyImportSideEffectDependency.d.ts +8 -0
- package/dist/dependencies/harmony/HarmonyImportSideEffectDependency.js +43 -0
- package/dist/dependencies/harmony/HarmonyImportSpecifierDependency.d.ts +33 -0
- package/dist/dependencies/harmony/HarmonyImportSpecifierDependency.js +272 -0
- package/dist/dependencies/harmony/HarmonyModulesPlugin.d.ts +6 -0
- package/dist/dependencies/harmony/HarmonyModulesPlugin.js +57 -0
- package/dist/dependencies/harmony/HarmonyTopLevelThisParserPlugin.d.ts +4 -0
- package/dist/dependencies/harmony/HarmonyTopLevelThisParserPlugin.js +45 -0
- package/dist/dependencies/import/ImportContextDependency.d.ts +9 -0
- package/dist/dependencies/import/ImportContextDependency.js +34 -0
- package/dist/dependencies/import/ImportDependency.d.ts +11 -0
- package/dist/dependencies/import/ImportDependency.js +57 -0
- package/dist/dependencies/import/ImportEagerDependency.d.ts +7 -0
- package/dist/dependencies/import/ImportEagerDependency.js +34 -0
- package/dist/dependencies/import/ImportMetaContextDependency.d.ts +7 -0
- package/dist/dependencies/import/ImportMetaContextDependency.js +23 -0
- package/dist/dependencies/import/ImportMetaContextDependencyParserPlugin.d.ts +3 -0
- package/dist/dependencies/import/ImportMetaContextDependencyParserPlugin.js +207 -0
- package/dist/dependencies/import/ImportMetaContextPlugin.d.ts +4 -0
- package/dist/dependencies/import/ImportMetaContextPlugin.js +27 -0
- package/dist/dependencies/import/ImportMetaHotAcceptDependency.d.ts +7 -0
- package/dist/dependencies/import/ImportMetaHotAcceptDependency.js +24 -0
- package/dist/dependencies/import/ImportMetaHotDeclineDependency.d.ts +7 -0
- package/dist/dependencies/import/ImportMetaHotDeclineDependency.js +24 -0
- package/dist/dependencies/import/ImportMetaPlugin.d.ts +4 -0
- package/dist/dependencies/import/ImportMetaPlugin.js +129 -0
- package/dist/dependencies/import/ImportParserPlugin.d.ts +6 -0
- package/dist/dependencies/import/ImportParserPlugin.js +207 -0
- package/dist/dependencies/import/ImportPlugin.d.ts +4 -0
- package/dist/dependencies/import/ImportPlugin.js +37 -0
- package/dist/dependencies/import/ImportWeakDependency.d.ts +6 -0
- package/dist/dependencies/import/ImportWeakDependency.js +33 -0
- package/dist/dependencies/json/JsonExportsDependency.d.ts +14 -0
- package/dist/dependencies/json/JsonExportsDependency.js +61 -0
- package/dist/dependencies/loader/LoaderDependency.d.ts +8 -0
- package/dist/dependencies/loader/LoaderDependency.js +21 -0
- package/dist/dependencies/loader/LoaderImportDependency.d.ts +8 -0
- package/dist/dependencies/loader/LoaderImportDependency.js +22 -0
- package/dist/dependencies/loader/LoaderPlugin.d.ts +5 -0
- package/dist/dependencies/loader/LoaderPlugin.js +164 -0
- package/dist/dependencies/processExportInfo.d.ts +2 -0
- package/dist/dependencies/processExportInfo.js +32 -0
- package/dist/ids/DeterministicChunkIdsPlugin.d.ts +10 -0
- package/dist/ids/DeterministicChunkIdsPlugin.js +30 -0
- package/dist/ids/DeterministicModuleIdsPlugin.d.ts +6 -0
- package/dist/ids/DeterministicModuleIdsPlugin.js +38 -0
- package/dist/ids/IdHelpers.d.ts +16 -0
- package/dist/ids/IdHelpers.js +259 -0
- package/dist/ids/NamedChunkIdsPlugin.d.ts +11 -0
- package/dist/ids/NamedChunkIdsPlugin.js +34 -0
- package/dist/ids/NamedModuleIdsPlugin.d.ts +6 -0
- package/dist/ids/NamedModuleIdsPlugin.js +25 -0
- package/dist/ids/NaturalChunkIdsPlugin.d.ts +4 -0
- package/dist/ids/NaturalChunkIdsPlugin.js +17 -0
- package/dist/ids/NaturalModuleIdsPlugin.d.ts +4 -0
- package/dist/ids/NaturalModuleIdsPlugin.js +16 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +58 -0
- package/dist/library/AbstractLibraryPlugin.d.ts +21 -0
- package/dist/library/AbstractLibraryPlugin.js +177 -0
- package/dist/library/AssignLibraryPlugin.d.ts +53 -0
- package/dist/library/AssignLibraryPlugin.js +201 -0
- package/dist/library/EnableLibraryPlugin.d.ts +8 -0
- package/dist/library/EnableLibraryPlugin.js +174 -0
- package/dist/library/ExportPropertyLibraryPlugin.d.ts +22 -0
- package/dist/library/ExportPropertyLibraryPlugin.js +74 -0
- package/dist/library/JsonpLibraryPlugin.d.ts +19 -0
- package/dist/library/JsonpLibraryPlugin.js +35 -0
- package/dist/library/ModuleLibraryPlugin.d.ts +16 -0
- package/dist/library/ModuleLibraryPlugin.js +73 -0
- package/dist/library/UmdLibraryPlugin.d.ts +22 -0
- package/dist/library/UmdLibraryPlugin.js +161 -0
- package/dist/module/ContextExclusionPlugin.d.ts +6 -0
- package/dist/module/ContextExclusionPlugin.js +13 -0
- package/dist/module/ContextModule.d.ts +75 -0
- package/dist/module/ContextModule.js +844 -0
- package/dist/module/ContextModuleFactory.d.ts +8 -0
- package/dist/module/ContextModuleFactory.js +292 -0
- package/dist/module/ContextReplacementPlugin.d.ts +11 -0
- package/dist/module/ContextReplacementPlugin.js +128 -0
- package/dist/module/CssModule.d.ts +20 -0
- package/dist/module/CssModule.js +105 -0
- package/dist/module/ExportsInfo.d.ts +135 -0
- package/dist/module/ExportsInfo.js +1171 -0
- package/dist/module/ExportsInfoApiPlugin.d.ts +4 -0
- package/dist/module/ExportsInfoApiPlugin.js +38 -0
- package/dist/module/ExternalModule.d.ts +47 -0
- package/dist/module/ExternalModule.js +458 -0
- package/dist/module/ExternalModuleFactoryPlugin.d.ts +7 -0
- package/dist/module/ExternalModuleFactoryPlugin.js +176 -0
- package/dist/module/ExternalsPlugin.d.ts +7 -0
- package/dist/module/ExternalsPlugin.js +18 -0
- package/dist/module/Generator.d.ts +40 -0
- package/dist/module/Generator.js +49 -0
- package/dist/module/IgnoreErrorModuleFactory.d.ts +7 -0
- package/dist/module/IgnoreErrorModuleFactory.js +16 -0
- package/dist/module/JavascriptMetaInfoPlugin.d.ts +4 -0
- package/dist/module/JavascriptMetaInfoPlugin.js +65 -0
- package/dist/module/LazyModuleFactoryPlugin.d.ts +6 -0
- package/dist/module/LazyModuleFactoryPlugin.js +171 -0
- package/dist/module/Module.d.ts +175 -0
- package/dist/module/Module.js +550 -0
- package/dist/module/ModuleFactory.d.ts +25 -0
- package/dist/module/ModuleFactory.js +10 -0
- package/dist/module/ModuleGraph.d.ts +74 -0
- package/dist/module/ModuleGraph.js +470 -0
- package/dist/module/ModuleGraphConnection.d.ts +33 -0
- package/dist/module/ModuleGraphConnection.js +113 -0
- package/dist/module/ModuleProfile.d.ts +40 -0
- package/dist/module/ModuleProfile.js +77 -0
- package/dist/module/ModuleTypeConstants.d.ts +22 -0
- package/dist/module/ModuleTypeConstants.js +45 -0
- package/dist/module/NormalModule.d.ts +104 -0
- package/dist/module/NormalModule.js +904 -0
- package/dist/module/NormalModuleFactory.d.ts +36 -0
- package/dist/module/NormalModuleFactory.js +761 -0
- package/dist/module/Parser.d.ts +4 -0
- package/dist/module/Parser.js +9 -0
- package/dist/module/RawModule.d.ts +29 -0
- package/dist/module/RawModule.js +74 -0
- package/dist/module/RuntimeGlobals.d.ts +310 -0
- package/dist/module/RuntimeGlobals.js +316 -0
- package/dist/module/RuntimeHelpers.d.ts +43 -0
- package/dist/module/RuntimeHelpers.js +548 -0
- package/dist/module/RuntimeModule.d.ts +39 -0
- package/dist/module/RuntimeModule.js +114 -0
- package/dist/module/RuntimePlugin.d.ts +4 -0
- package/dist/module/RuntimePlugin.js +332 -0
- package/dist/module/SelfModuleFactory.d.ts +6 -0
- package/dist/module/SelfModuleFactory.js +14 -0
- package/dist/module/asset/AssetGenerator.d.ts +30 -0
- package/dist/module/asset/AssetGenerator.js +364 -0
- package/dist/module/asset/AssetModulesPlugin.d.ts +4 -0
- package/dist/module/asset/AssetModulesPlugin.js +98 -0
- package/dist/module/asset/AssetParser.d.ts +12 -0
- package/dist/module/asset/AssetParser.js +44 -0
- package/dist/module/asset/AssetSourceGenerator.d.ts +14 -0
- package/dist/module/asset/AssetSourceGenerator.js +74 -0
- package/dist/module/asset/AssetSourceParser.d.ts +5 -0
- package/dist/module/asset/AssetSourceParser.js +19 -0
- package/dist/module/asset/RawDataUrlModule.d.ts +27 -0
- package/dist/module/asset/RawDataUrlModule.js +102 -0
- package/dist/module/async-modules/AwaitDependenciesInitFragment.d.ts +10 -0
- package/dist/module/async-modules/AwaitDependenciesInitFragment.js +68 -0
- package/dist/module/async-modules/InferAsyncModulesPlugin.d.ts +4 -0
- package/dist/module/async-modules/InferAsyncModulesPlugin.js +28 -0
- package/dist/module/javascript/BasicEvaluatedExpression.d.ts +139 -0
- package/dist/module/javascript/BasicEvaluatedExpression.js +481 -0
- package/dist/module/javascript/JavascriptGenerator.d.ts +11 -0
- package/dist/module/javascript/JavascriptGenerator.js +103 -0
- package/dist/module/javascript/JavascriptModulesPlugin.d.ts +17 -0
- package/dist/module/javascript/JavascriptModulesPlugin.js +821 -0
- package/dist/module/javascript/JavascriptParser.d.ts +598 -0
- package/dist/module/javascript/JavascriptParser.js +3579 -0
- package/dist/module/javascript/JavascriptParserHelpers.d.ts +10 -0
- package/dist/module/javascript/JavascriptParserHelpers.js +61 -0
- package/dist/module/json/JsonData.d.ts +9 -0
- package/dist/module/json/JsonData.js +43 -0
- package/dist/module/json/JsonGenerator.d.ts +15 -0
- package/dist/module/json/JsonGenerator.js +137 -0
- package/dist/module/json/JsonModulesPlugin.d.ts +4 -0
- package/dist/module/json/JsonModulesPlugin.js +20 -0
- package/dist/module/json/JsonParser.d.ts +7 -0
- package/dist/module/json/JsonParser.js +41 -0
- package/dist/module/runtime/AsyncModuleRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/AsyncModuleRuntimeModule.js +115 -0
- package/dist/module/runtime/AutoPublicPathRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/AutoPublicPathRuntimeModule.js +81 -0
- package/dist/module/runtime/BaseUriRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/BaseUriRuntimeModule.js +41 -0
- package/dist/module/runtime/ChunkNameRuntimeModule.d.ts +7 -0
- package/dist/module/runtime/ChunkNameRuntimeModule.js +40 -0
- package/dist/module/runtime/CompatGetDefaultExportRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/CompatGetDefaultExportRuntimeModule.js +54 -0
- package/dist/module/runtime/CompatRuntimeModule.d.ts +7 -0
- package/dist/module/runtime/CompatRuntimeModule.js +59 -0
- package/dist/module/runtime/CreateFakeNamespaceObjectRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/CreateFakeNamespaceObjectRuntimeModule.js +77 -0
- package/dist/module/runtime/CreateScriptRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/CreateScriptRuntimeModule.js +44 -0
- package/dist/module/runtime/CreateScriptUrlRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/CreateScriptUrlRuntimeModule.js +44 -0
- package/dist/module/runtime/DefinePropertyGettersRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/DefinePropertyGettersRuntimeModule.js +56 -0
- package/dist/module/runtime/EnsureChunkRuntimeModule.d.ts +7 -0
- package/dist/module/runtime/EnsureChunkRuntimeModule.js +66 -0
- package/dist/module/runtime/GetChunkFilenameRuntimeModule.d.ts +10 -0
- package/dist/module/runtime/GetChunkFilenameRuntimeModule.js +220 -0
- package/dist/module/runtime/GetFullHashRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/GetFullHashRuntimeModule.js +42 -0
- package/dist/module/runtime/GetMainFilenameRuntimeModule.d.ts +8 -0
- package/dist/module/runtime/GetMainFilenameRuntimeModule.js +52 -0
- package/dist/module/runtime/GetTrustedTypesPolicyRuntimeModule.d.ts +7 -0
- package/dist/module/runtime/GetTrustedTypesPolicyRuntimeModule.js +89 -0
- package/dist/module/runtime/GlobalRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/GlobalRuntimeModule.js +61 -0
- package/dist/module/runtime/HasOwnPropertyRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/HasOwnPropertyRuntimeModule.js +44 -0
- package/dist/module/runtime/HelperRuntimeModule.d.ts +5 -0
- package/dist/module/runtime/HelperRuntimeModule.js +12 -0
- package/dist/module/runtime/LoadScriptRuntimeModule.d.ts +9 -0
- package/dist/module/runtime/LoadScriptRuntimeModule.js +129 -0
- package/dist/module/runtime/MakeNamespaceObjectRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/MakeNamespaceObjectRuntimeModule.js +53 -0
- package/dist/module/runtime/NonceRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/NonceRuntimeModule.js +39 -0
- package/dist/module/runtime/OnChunksLoadedRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/OnChunksLoadedRuntimeModule.js +81 -0
- package/dist/module/runtime/PublicPathRuntimeModule.d.ts +7 -0
- package/dist/module/runtime/PublicPathRuntimeModule.js +44 -0
- package/dist/module/runtime/RelativeUrlRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/RelativeUrlRuntimeModule.js +56 -0
- package/dist/module/runtime/RuntimeIdRuntimeModule.d.ts +6 -0
- package/dist/module/runtime/RuntimeIdRuntimeModule.js +45 -0
- package/dist/module/runtime/StartupChunkDependenciesPlugin.d.ts +11 -0
- package/dist/module/runtime/StartupChunkDependenciesPlugin.js +69 -0
- package/dist/module/runtime/StartupChunkDependenciesRuntimeModule.d.ts +7 -0
- package/dist/module/runtime/StartupChunkDependenciesRuntimeModule.js +67 -0
- package/dist/module/runtime/StartupEntrypointRuntimeModule.d.ts +7 -0
- package/dist/module/runtime/StartupEntrypointRuntimeModule.js +58 -0
- package/dist/module/uri/DataUriPlugin.d.ts +4 -0
- package/dist/module/uri/DataUriPlugin.js +46 -0
- package/dist/module/uri/FileUriPlugin.d.ts +4 -0
- package/dist/module/uri/FileUriPlugin.js +31 -0
- package/dist/plugins/APIPlugin.d.ts +9 -0
- package/dist/plugins/APIPlugin.js +230 -0
- package/dist/plugins/CleanPlugin.d.ts +7 -0
- package/dist/plugins/CleanPlugin.js +295 -0
- package/dist/plugins/CompatibilityPlugin.d.ts +4 -0
- package/dist/plugins/CompatibilityPlugin.js +142 -0
- package/dist/plugins/ConstPlugin.d.ts +4 -0
- package/dist/plugins/ConstPlugin.js +409 -0
- package/dist/plugins/DefaultStatsFactoryPlugin.d.ts +4 -0
- package/dist/plugins/DefaultStatsFactoryPlugin.js +1552 -0
- package/dist/plugins/DefaultStatsPresetPlugin.d.ts +4 -0
- package/dist/plugins/DefaultStatsPresetPlugin.js +306 -0
- package/dist/plugins/DefaultStatsPrinterPlugin.d.ts +4 -0
- package/dist/plugins/DefaultStatsPrinterPlugin.js +986 -0
- package/dist/plugins/DefinePlugin.d.ts +15 -0
- package/dist/plugins/DefinePlugin.js +400 -0
- package/dist/plugins/NodeStuffPlugin.d.ts +6 -0
- package/dist/plugins/NodeStuffPlugin.js +134 -0
- package/dist/plugins/ProgressPlugin.d.ts +20 -0
- package/dist/plugins/ProgressPlugin.js +494 -0
- package/dist/plugins/RecordIdsPlugin.d.ts +9 -0
- package/dist/plugins/RecordIdsPlugin.js +175 -0
- package/dist/plugins/UseStrictPlugin.d.ts +4 -0
- package/dist/plugins/UseStrictPlugin.js +35 -0
- package/dist/plugins/WarnCaseSensitiveModulesPlugin.d.ts +4 -0
- package/dist/plugins/WarnCaseSensitiveModulesPlugin.js +37 -0
- package/dist/plugins/WarnDeprecatedOptionPlugin.d.ts +8 -0
- package/dist/plugins/WarnDeprecatedOptionPlugin.js +29 -0
- package/dist/plugins/cssMinimizer/CssMinimizerMinify.js +73 -0
- package/dist/plugins/cssMinimizer/CssMinimizerPlugin.d.ts +11 -0
- package/dist/plugins/cssMinimizer/CssMinimizerPlugin.js +329 -0
- package/dist/plugins/cssMinimizer/CssMinimizerUtils.js +147 -0
- package/dist/plugins/miniCssExtractPlugin/MiniCssExtractLoader.d.ts +1 -0
- package/dist/plugins/miniCssExtractPlugin/MiniCssExtractLoader.js +177 -0
- package/dist/plugins/miniCssExtractPlugin/MiniCssExtractPlugin.d.ts +22 -0
- package/dist/plugins/miniCssExtractPlugin/MiniCssExtractPlugin.js +780 -0
- package/dist/plugins/miniCssExtractPlugin/MiniCssUtils.d.ts +14 -0
- package/dist/plugins/miniCssExtractPlugin/MiniCssUtils.js +132 -0
- package/dist/plugins/optimize/AggressiveMergingPlugin.d.ts +6 -0
- package/dist/plugins/optimize/AggressiveMergingPlugin.js +62 -0
- package/dist/plugins/optimize/AggressiveSplittingPlugin.d.ts +7 -0
- package/dist/plugins/optimize/AggressiveSplittingPlugin.js +247 -0
- package/dist/plugins/optimize/ConcatenatedModule.d.ts +47 -0
- package/dist/plugins/optimize/ConcatenatedModule.js +1221 -0
- package/dist/plugins/optimize/EnsureChunkConditionsPlugin.d.ts +4 -0
- package/dist/plugins/optimize/EnsureChunkConditionsPlugin.js +61 -0
- package/dist/plugins/optimize/FlagAllModulesAsUsedPlugin.d.ts +6 -0
- package/dist/plugins/optimize/FlagAllModulesAsUsedPlugin.js +30 -0
- package/dist/plugins/optimize/FlagDependencyExportsPlugin.d.ts +4 -0
- package/dist/plugins/optimize/FlagDependencyExportsPlugin.js +275 -0
- package/dist/plugins/optimize/FlagDependencyUsagePlugin.d.ts +6 -0
- package/dist/plugins/optimize/FlagDependencyUsagePlugin.js +243 -0
- package/dist/plugins/optimize/FlagEntryExportAsUsedPlugin.d.ts +7 -0
- package/dist/plugins/optimize/FlagEntryExportAsUsedPlugin.js +34 -0
- package/dist/plugins/optimize/FlagIncludedChunksPlugin.d.ts +4 -0
- package/dist/plugins/optimize/FlagIncludedChunksPlugin.js +85 -0
- package/dist/plugins/optimize/InnerGraph.d.ts +20 -0
- package/dist/plugins/optimize/InnerGraph.js +234 -0
- package/dist/plugins/optimize/InnerGraphPlugin.d.ts +4 -0
- package/dist/plugins/optimize/InnerGraphPlugin.js +289 -0
- package/dist/plugins/optimize/LimitChunkCountPlugin.d.ts +6 -0
- package/dist/plugins/optimize/LimitChunkCountPlugin.js +200 -0
- package/dist/plugins/optimize/MangleExportsPlugin.d.ts +6 -0
- package/dist/plugins/optimize/MangleExportsPlugin.js +124 -0
- package/dist/plugins/optimize/MergeDuplicateChunksPlugin.d.ts +4 -0
- package/dist/plugins/optimize/MergeDuplicateChunksPlugin.js +84 -0
- package/dist/plugins/optimize/MinChunkSizePlugin.d.ts +6 -0
- package/dist/plugins/optimize/MinChunkSizePlugin.js +71 -0
- package/dist/plugins/optimize/ModuleConcatenationPlugin.d.ts +8 -0
- package/dist/plugins/optimize/ModuleConcatenationPlugin.js +525 -0
- package/dist/plugins/optimize/ModuleInfoHeaderPlugin.d.ts +6 -0
- package/dist/plugins/optimize/ModuleInfoHeaderPlugin.js +145 -0
- package/dist/plugins/optimize/NoEmitOnErrorsPlugin.d.ts +4 -0
- package/dist/plugins/optimize/NoEmitOnErrorsPlugin.js +17 -0
- package/dist/plugins/optimize/OptimizationStages.d.ts +4 -0
- package/dist/plugins/optimize/OptimizationStages.js +9 -0
- package/dist/plugins/optimize/RealContentHashPlugin.d.ts +11 -0
- package/dist/plugins/optimize/RealContentHashPlugin.js +295 -0
- package/dist/plugins/optimize/RemoveEmptyChunksPlugin.d.ts +4 -0
- package/dist/plugins/optimize/RemoveEmptyChunksPlugin.js +30 -0
- package/dist/plugins/optimize/RemoveParentModulesPlugin.d.ts +4 -0
- package/dist/plugins/optimize/RemoveParentModulesPlugin.js +103 -0
- package/dist/plugins/optimize/RuntimeChunkPlugin.d.ts +6 -0
- package/dist/plugins/optimize/RuntimeChunkPlugin.js +25 -0
- package/dist/plugins/optimize/SideEffectsFlagPlugin.d.ts +7 -0
- package/dist/plugins/optimize/SideEffectsFlagPlugin.js +211 -0
- package/dist/plugins/optimize/SplitChunksPlugin.d.ts +7 -0
- package/dist/plugins/optimize/SplitChunksPlugin.js +1113 -0
- package/dist/rules/BasicEffectRulePlugin.d.ts +7 -0
- package/dist/rules/BasicEffectRulePlugin.js +21 -0
- package/dist/rules/BasicMatcherRulePlugin.d.ts +8 -0
- package/dist/rules/BasicMatcherRulePlugin.js +25 -0
- package/dist/rules/ObjectMatcherRulePlugin.d.ts +7 -0
- package/dist/rules/ObjectMatcherRulePlugin.js +27 -0
- package/dist/rules/RuleSetCompiler.d.ts +20 -0
- package/dist/rules/RuleSetCompiler.js +242 -0
- package/dist/rules/UseEffectRulePlugin.d.ts +5 -0
- package/dist/rules/UseEffectRulePlugin.js +117 -0
- package/dist/serialization/Serialization.d.ts +11 -0
- package/dist/serialization/Serialization.js +95 -0
- package/dist/serialization/Serializer.d.ts +9 -0
- package/dist/serialization/Serializer.js +43 -0
- package/dist/serialization/SerializerMiddleware.d.ts +13 -0
- package/dist/serialization/SerializerMiddleware.js +86 -0
- package/dist/serialization/internalSerializables.d.ts +82 -0
- package/dist/serialization/internalSerializables.js +94 -0
- package/dist/serialization/makeSerializable.d.ts +2 -0
- package/dist/serialization/makeSerializable.js +25 -0
- package/dist/serialization/middlewares/BinaryMiddleware.d.ts +12 -0
- package/dist/serialization/middlewares/BinaryMiddleware.js +955 -0
- package/dist/serialization/middlewares/FileMiddleware.d.ts +9 -0
- package/dist/serialization/middlewares/FileMiddleware.js +546 -0
- package/dist/serialization/middlewares/ObjectMiddleware.d.ts +15 -0
- package/dist/serialization/middlewares/ObjectMiddleware.js +602 -0
- package/dist/serialization/middlewares/SingleItemMiddleware.d.ts +6 -0
- package/dist/serialization/middlewares/SingleItemMiddleware.js +15 -0
- package/dist/serialization/registerExternalSerializer.d.ts +1 -0
- package/dist/serialization/registerExternalSerializer.js +154 -0
- package/dist/serialization/serializers/ArraySerializer.d.ts +5 -0
- package/dist/serialization/serializers/ArraySerializer.js +18 -0
- package/dist/serialization/serializers/DateObjectSerializer.d.ts +5 -0
- package/dist/serialization/serializers/DateObjectSerializer.js +11 -0
- package/dist/serialization/serializers/ErrorObjectSerializer.d.ts +7 -0
- package/dist/serialization/serializers/ErrorObjectSerializer.js +20 -0
- package/dist/serialization/serializers/MapObjectSerializer.d.ts +5 -0
- package/dist/serialization/serializers/MapObjectSerializer.js +26 -0
- package/dist/serialization/serializers/NullPrototypeObjectSerializer.d.ts +5 -0
- package/dist/serialization/serializers/NullPrototypeObjectSerializer.js +28 -0
- package/dist/serialization/serializers/PlainObjectSerializer.d.ts +5 -0
- package/dist/serialization/serializers/PlainObjectSerializer.js +77 -0
- package/dist/serialization/serializers/RegExpObjectSerializer.d.ts +5 -0
- package/dist/serialization/serializers/RegExpObjectSerializer.js +12 -0
- package/dist/serialization/serializers/SetObjectSerializer.d.ts +5 -0
- package/dist/serialization/serializers/SetObjectSerializer.js +19 -0
- package/dist/sourcemap/EvalDevToolModulePlugin.d.ts +8 -0
- package/dist/sourcemap/EvalDevToolModulePlugin.js +97 -0
- package/dist/sourcemap/EvalSourceMapDevToolPlugin.d.ts +9 -0
- package/dist/sourcemap/EvalSourceMapDevToolPlugin.js +167 -0
- package/dist/sourcemap/SourceMapDevToolModuleOptionsPlugin.d.ts +6 -0
- package/dist/sourcemap/SourceMapDevToolModuleOptionsPlugin.js +29 -0
- package/dist/sourcemap/SourceMapDevToolPlugin.d.ts +11 -0
- package/dist/sourcemap/SourceMapDevToolPlugin.js +364 -0
- package/dist/template/ChunkTemplate.d.ts +6 -0
- package/dist/template/ChunkTemplate.js +69 -0
- package/dist/template/LibraryTemplatePlugin.d.ts +6 -0
- package/dist/template/LibraryTemplatePlugin.js +23 -0
- package/dist/template/MainTemplate.d.ts +10 -0
- package/dist/template/MainTemplate.js +177 -0
- package/dist/template/ModuleTemplate.d.ts +7 -0
- package/dist/template/ModuleTemplate.js +46 -0
- package/dist/template/RuntimeTemplate.d.ts +158 -0
- package/dist/template/RuntimeTemplate.js +663 -0
- package/dist/template/Template.d.ts +25 -0
- package/dist/template/Template.js +269 -0
- package/dist/template/TemplatedPathPlugin.d.ts +4 -0
- package/dist/template/TemplatedPathPlugin.js +228 -0
- package/dist/thread/WorkerError.d.ts +4 -0
- package/dist/thread/WorkerError.js +21 -0
- package/dist/thread/WorkerPool.d.ts +52 -0
- package/dist/thread/WorkerPool.js +370 -0
- package/dist/thread/readBuffer.d.ts +1 -0
- package/dist/thread/readBuffer.js +37 -0
- package/dist/thread/serializer.d.ts +2 -0
- package/dist/thread/serializer.js +24 -0
- package/dist/thread/worker.d.ts +1 -0
- package/dist/thread/worker.js +185 -0
- package/dist/thread/workerPools.d.ts +2 -0
- package/dist/thread/workerPools.js +31 -0
- package/dist/types/index.d.ts +58 -0
- package/dist/types/index.js +8 -0
- package/package.json +96 -0
|
@@ -0,0 +1,2896 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Snapshot = exports.FileSystemInfo = void 0;
|
|
7
|
+
const enhanced_resolve_1 = require("enhanced-resolve");
|
|
8
|
+
const module_1 = __importDefault(require("module"));
|
|
9
|
+
const neo_async_1 = __importDefault(require("neo-async"));
|
|
10
|
+
const path_1 = require("path");
|
|
11
|
+
const AsyncQueue_1 = __importDefault(require("@/base/AsyncQueue"));
|
|
12
|
+
const StackedCacheMap_1 = __importDefault(require("@/base/StackedCacheMap"));
|
|
13
|
+
const createHash_1 = __importDefault(require("@/base/createHash"));
|
|
14
|
+
const fs_1 = require("@/base/fs");
|
|
15
|
+
const makeSerializable_1 = __importDefault(require("@/serialization/makeSerializable"));
|
|
16
|
+
const processAsyncTree_1 = __importDefault(require("@/base/processAsyncTree"));
|
|
17
|
+
const es_module_lexer_1 = __importDefault(require("es-module-lexer"));
|
|
18
|
+
const supportsEsm = +process.versions.modules >= 83;
|
|
19
|
+
const builtinModules = new Set(module_1.default.builtinModules);
|
|
20
|
+
let FS_ACCURACY = 2000;
|
|
21
|
+
const EMPTY_SET = new Set();
|
|
22
|
+
const RBDT_RESOLVE_CJS = 0;
|
|
23
|
+
const RBDT_RESOLVE_ESM = 1;
|
|
24
|
+
const RBDT_RESOLVE_DIRECTORY = 2;
|
|
25
|
+
const RBDT_RESOLVE_CJS_FILE = 3;
|
|
26
|
+
const RBDT_RESOLVE_CJS_FILE_AS_CHILD = 4;
|
|
27
|
+
const RBDT_RESOLVE_ESM_FILE = 5;
|
|
28
|
+
const RBDT_DIRECTORY = 6;
|
|
29
|
+
const RBDT_FILE = 7;
|
|
30
|
+
const RBDT_DIRECTORY_DEPENDENCIES = 8;
|
|
31
|
+
const RBDT_FILE_DEPENDENCIES = 9;
|
|
32
|
+
const INVALID = Symbol('invalid');
|
|
33
|
+
const DONE_ITERATOR_RESULT = new Set().keys().next();
|
|
34
|
+
class SnapshotIterator {
|
|
35
|
+
constructor(next) {
|
|
36
|
+
this.next = next;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
class SnapshotIterable {
|
|
40
|
+
constructor(snapshot, getMaps) {
|
|
41
|
+
this.snapshot = snapshot;
|
|
42
|
+
this.getMaps = getMaps;
|
|
43
|
+
}
|
|
44
|
+
[Symbol.iterator]() {
|
|
45
|
+
let state = 0;
|
|
46
|
+
let it;
|
|
47
|
+
let getMaps;
|
|
48
|
+
let maps;
|
|
49
|
+
let snapshot;
|
|
50
|
+
let queue;
|
|
51
|
+
return new SnapshotIterator(() => {
|
|
52
|
+
for (;;) {
|
|
53
|
+
switch (state) {
|
|
54
|
+
case 0:
|
|
55
|
+
snapshot = this.snapshot;
|
|
56
|
+
getMaps = this.getMaps;
|
|
57
|
+
maps = getMaps(snapshot);
|
|
58
|
+
state = 1;
|
|
59
|
+
/* falls through */
|
|
60
|
+
case 1:
|
|
61
|
+
if (maps.length > 0) {
|
|
62
|
+
const map = maps.pop();
|
|
63
|
+
if (map !== undefined) {
|
|
64
|
+
it = map.keys();
|
|
65
|
+
state = 2;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
state = 3;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
/* falls through */
|
|
76
|
+
case 2: {
|
|
77
|
+
const result = it.next();
|
|
78
|
+
if (!result.done)
|
|
79
|
+
return result;
|
|
80
|
+
state = 1;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case 3: {
|
|
84
|
+
const children = snapshot.children;
|
|
85
|
+
if (children !== undefined) {
|
|
86
|
+
if (children.size === 1) {
|
|
87
|
+
// shortcut for a single child
|
|
88
|
+
// avoids allocation of queue
|
|
89
|
+
for (const child of children)
|
|
90
|
+
snapshot = child;
|
|
91
|
+
maps = getMaps(snapshot);
|
|
92
|
+
state = 1;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (queue === undefined)
|
|
96
|
+
queue = [];
|
|
97
|
+
for (const child of children) {
|
|
98
|
+
queue.push(child);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (queue !== undefined && queue.length > 0) {
|
|
102
|
+
snapshot = queue.pop();
|
|
103
|
+
maps = getMaps(snapshot);
|
|
104
|
+
state = 1;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
state = 4;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/* falls through */
|
|
112
|
+
case 4:
|
|
113
|
+
return DONE_ITERATOR_RESULT;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
class Snapshot {
|
|
120
|
+
constructor() {
|
|
121
|
+
this._flags = 0;
|
|
122
|
+
}
|
|
123
|
+
hasStartTime() {
|
|
124
|
+
return (this._flags & 1) !== 0;
|
|
125
|
+
}
|
|
126
|
+
setStartTime(value) {
|
|
127
|
+
this._flags |= 1;
|
|
128
|
+
this.startTime = value;
|
|
129
|
+
}
|
|
130
|
+
setMergedStartTime(value, snapshot) {
|
|
131
|
+
if (value) {
|
|
132
|
+
if (snapshot.hasStartTime()) {
|
|
133
|
+
this.setStartTime(Math.min(value, snapshot.startTime));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
this.setStartTime(value);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else if (snapshot.hasStartTime())
|
|
140
|
+
this.setStartTime(snapshot.startTime);
|
|
141
|
+
}
|
|
142
|
+
hasFileTimestamps() {
|
|
143
|
+
return (this._flags & 2) !== 0;
|
|
144
|
+
}
|
|
145
|
+
setFileTimestamps(value) {
|
|
146
|
+
this._flags |= 2;
|
|
147
|
+
this.fileTimestamps = value;
|
|
148
|
+
}
|
|
149
|
+
hasFileHashes() {
|
|
150
|
+
return (this._flags & 4) !== 0;
|
|
151
|
+
}
|
|
152
|
+
setFileHashes(value) {
|
|
153
|
+
this._flags |= 4;
|
|
154
|
+
this.fileHashes = value;
|
|
155
|
+
}
|
|
156
|
+
hasFileTshs() {
|
|
157
|
+
return (this._flags & 8) !== 0;
|
|
158
|
+
}
|
|
159
|
+
setFileTshs(value) {
|
|
160
|
+
this._flags |= 8;
|
|
161
|
+
this.fileTshs = value;
|
|
162
|
+
}
|
|
163
|
+
hasContextTimestamps() {
|
|
164
|
+
return (this._flags & 0x10) !== 0;
|
|
165
|
+
}
|
|
166
|
+
setContextTimestamps(value) {
|
|
167
|
+
this._flags |= 0x10;
|
|
168
|
+
this.contextTimestamps = value;
|
|
169
|
+
}
|
|
170
|
+
hasContextHashes() {
|
|
171
|
+
return (this._flags & 0x20) !== 0;
|
|
172
|
+
}
|
|
173
|
+
setContextHashes(value) {
|
|
174
|
+
this._flags |= 0x20;
|
|
175
|
+
this.contextHashes = value;
|
|
176
|
+
}
|
|
177
|
+
hasContextTshs() {
|
|
178
|
+
return (this._flags & 0x40) !== 0;
|
|
179
|
+
}
|
|
180
|
+
setContextTshs(value) {
|
|
181
|
+
this._flags |= 0x40;
|
|
182
|
+
this.contextTshs = value;
|
|
183
|
+
}
|
|
184
|
+
hasMissingExistence() {
|
|
185
|
+
return (this._flags & 0x80) !== 0;
|
|
186
|
+
}
|
|
187
|
+
setMissingExistence(value) {
|
|
188
|
+
this._flags |= 0x80;
|
|
189
|
+
this.missingExistence = value;
|
|
190
|
+
}
|
|
191
|
+
hasManagedItemInfo() {
|
|
192
|
+
return (this._flags & 0x100) !== 0;
|
|
193
|
+
}
|
|
194
|
+
setManagedItemInfo(value) {
|
|
195
|
+
this._flags |= 0x100;
|
|
196
|
+
this.managedItemInfo = value;
|
|
197
|
+
}
|
|
198
|
+
hasManagedFiles() {
|
|
199
|
+
return (this._flags & 0x200) !== 0;
|
|
200
|
+
}
|
|
201
|
+
setManagedFiles(value) {
|
|
202
|
+
this._flags |= 0x200;
|
|
203
|
+
this.managedFiles = value;
|
|
204
|
+
}
|
|
205
|
+
hasManagedContexts() {
|
|
206
|
+
return (this._flags & 0x400) !== 0;
|
|
207
|
+
}
|
|
208
|
+
setManagedContexts(value) {
|
|
209
|
+
this._flags |= 0x400;
|
|
210
|
+
this.managedContexts = value;
|
|
211
|
+
}
|
|
212
|
+
hasManagedMissing() {
|
|
213
|
+
return (this._flags & 0x800) !== 0;
|
|
214
|
+
}
|
|
215
|
+
setManagedMissing(value) {
|
|
216
|
+
this._flags |= 0x800;
|
|
217
|
+
this.managedMissing = value;
|
|
218
|
+
}
|
|
219
|
+
hasChildren() {
|
|
220
|
+
return (this._flags & 0x1000) !== 0;
|
|
221
|
+
}
|
|
222
|
+
setChildren(value) {
|
|
223
|
+
this._flags |= 0x1000;
|
|
224
|
+
this.children = value;
|
|
225
|
+
}
|
|
226
|
+
addChild(child) {
|
|
227
|
+
if (!this.hasChildren()) {
|
|
228
|
+
this.setChildren(new Set());
|
|
229
|
+
}
|
|
230
|
+
this.children.add(child);
|
|
231
|
+
}
|
|
232
|
+
serialize({ write }) {
|
|
233
|
+
write(this._flags);
|
|
234
|
+
if (this.hasStartTime())
|
|
235
|
+
write(this.startTime);
|
|
236
|
+
if (this.hasFileTimestamps())
|
|
237
|
+
write(this.fileTimestamps);
|
|
238
|
+
if (this.hasFileHashes())
|
|
239
|
+
write(this.fileHashes);
|
|
240
|
+
if (this.hasFileTshs())
|
|
241
|
+
write(this.fileTshs);
|
|
242
|
+
if (this.hasContextTimestamps())
|
|
243
|
+
write(this.contextTimestamps);
|
|
244
|
+
if (this.hasContextHashes())
|
|
245
|
+
write(this.contextHashes);
|
|
246
|
+
if (this.hasContextTshs())
|
|
247
|
+
write(this.contextTshs);
|
|
248
|
+
if (this.hasMissingExistence())
|
|
249
|
+
write(this.missingExistence);
|
|
250
|
+
if (this.hasManagedItemInfo())
|
|
251
|
+
write(this.managedItemInfo);
|
|
252
|
+
if (this.hasManagedFiles())
|
|
253
|
+
write(this.managedFiles);
|
|
254
|
+
if (this.hasManagedContexts())
|
|
255
|
+
write(this.managedContexts);
|
|
256
|
+
if (this.hasManagedMissing())
|
|
257
|
+
write(this.managedMissing);
|
|
258
|
+
if (this.hasChildren())
|
|
259
|
+
write(this.children);
|
|
260
|
+
}
|
|
261
|
+
deserialize({ read }) {
|
|
262
|
+
this._flags = read();
|
|
263
|
+
if (this.hasStartTime())
|
|
264
|
+
this.startTime = read();
|
|
265
|
+
if (this.hasFileTimestamps())
|
|
266
|
+
this.fileTimestamps = read();
|
|
267
|
+
if (this.hasFileHashes())
|
|
268
|
+
this.fileHashes = read();
|
|
269
|
+
if (this.hasFileTshs())
|
|
270
|
+
this.fileTshs = read();
|
|
271
|
+
if (this.hasContextTimestamps())
|
|
272
|
+
this.contextTimestamps = read();
|
|
273
|
+
if (this.hasContextHashes())
|
|
274
|
+
this.contextHashes = read();
|
|
275
|
+
if (this.hasContextTshs())
|
|
276
|
+
this.contextTshs = read();
|
|
277
|
+
if (this.hasMissingExistence())
|
|
278
|
+
this.missingExistence = read();
|
|
279
|
+
if (this.hasManagedItemInfo())
|
|
280
|
+
this.managedItemInfo = read();
|
|
281
|
+
if (this.hasManagedFiles())
|
|
282
|
+
this.managedFiles = read();
|
|
283
|
+
if (this.hasManagedContexts())
|
|
284
|
+
this.managedContexts = read();
|
|
285
|
+
if (this.hasManagedMissing())
|
|
286
|
+
this.managedMissing = read();
|
|
287
|
+
if (this.hasChildren())
|
|
288
|
+
this.children = read();
|
|
289
|
+
}
|
|
290
|
+
_createIterable(getMaps) {
|
|
291
|
+
return new SnapshotIterable(this, getMaps);
|
|
292
|
+
}
|
|
293
|
+
getFileIterable() {
|
|
294
|
+
if (this._cachedFileIterable === undefined) {
|
|
295
|
+
this._cachedFileIterable = this._createIterable(s => [
|
|
296
|
+
s.fileTimestamps,
|
|
297
|
+
s.fileHashes,
|
|
298
|
+
s.fileTshs,
|
|
299
|
+
s.managedFiles,
|
|
300
|
+
]);
|
|
301
|
+
}
|
|
302
|
+
return this._cachedFileIterable;
|
|
303
|
+
}
|
|
304
|
+
getContextIterable() {
|
|
305
|
+
if (this._cachedContextIterable === undefined) {
|
|
306
|
+
this._cachedContextIterable = this._createIterable(s => [
|
|
307
|
+
s.contextTimestamps,
|
|
308
|
+
s.contextHashes,
|
|
309
|
+
s.contextTshs,
|
|
310
|
+
s.managedContexts,
|
|
311
|
+
]);
|
|
312
|
+
}
|
|
313
|
+
return this._cachedContextIterable;
|
|
314
|
+
}
|
|
315
|
+
getMissingIterable() {
|
|
316
|
+
if (this._cachedMissingIterable === undefined) {
|
|
317
|
+
this._cachedMissingIterable = this._createIterable(s => [
|
|
318
|
+
s.missingExistence,
|
|
319
|
+
s.managedMissing,
|
|
320
|
+
]);
|
|
321
|
+
}
|
|
322
|
+
return this._cachedMissingIterable;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
exports.Snapshot = Snapshot;
|
|
326
|
+
(0, makeSerializable_1.default)(Snapshot, 'mp-compiler/core/FileSystemInfo', 'Snapshot');
|
|
327
|
+
const MIN_COMMON_SNAPSHOT_SIZE = 3;
|
|
328
|
+
class SnapshotOptimization {
|
|
329
|
+
constructor(has, get, set, useStartTime = true, isSet = false) {
|
|
330
|
+
this._has = has;
|
|
331
|
+
this._get = get;
|
|
332
|
+
this._set = set;
|
|
333
|
+
this._useStartTime = useStartTime;
|
|
334
|
+
this._isSet = isSet;
|
|
335
|
+
this._map = new Map();
|
|
336
|
+
this._statItemsShared = 0;
|
|
337
|
+
this._statItemsUnshared = 0;
|
|
338
|
+
this._statSharedSnapshots = 0;
|
|
339
|
+
this._statReusedSharedSnapshots = 0;
|
|
340
|
+
}
|
|
341
|
+
getStatisticMessage() {
|
|
342
|
+
const total = this._statItemsShared + this._statItemsUnshared;
|
|
343
|
+
if (total === 0)
|
|
344
|
+
return undefined;
|
|
345
|
+
return `${this._statItemsShared && Math.round((this._statItemsShared * 100) / total)}% (${this._statItemsShared}/${total}) entries shared via ${this._statSharedSnapshots} shared snapshots (${this._statReusedSharedSnapshots + this._statSharedSnapshots} times referenced)`;
|
|
346
|
+
}
|
|
347
|
+
clear() {
|
|
348
|
+
this._map.clear();
|
|
349
|
+
this._statItemsShared = 0;
|
|
350
|
+
this._statItemsUnshared = 0;
|
|
351
|
+
this._statSharedSnapshots = 0;
|
|
352
|
+
this._statReusedSharedSnapshots = 0;
|
|
353
|
+
}
|
|
354
|
+
optimize(newSnapshot, capturedFiles) {
|
|
355
|
+
const increaseSharedAndStoreOptimizationEntry = entry => {
|
|
356
|
+
if (entry.children !== undefined) {
|
|
357
|
+
entry.children.forEach(increaseSharedAndStoreOptimizationEntry);
|
|
358
|
+
}
|
|
359
|
+
entry.shared++;
|
|
360
|
+
storeOptimizationEntry(entry);
|
|
361
|
+
};
|
|
362
|
+
const storeOptimizationEntry = entry => {
|
|
363
|
+
for (const path of entry.snapshotContent) {
|
|
364
|
+
const old = this._map.get(path);
|
|
365
|
+
if (old.shared < entry.shared) {
|
|
366
|
+
this._map.set(path, entry);
|
|
367
|
+
}
|
|
368
|
+
capturedFiles.delete(path);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
let newOptimizationEntry;
|
|
372
|
+
const capturedFilesSize = capturedFiles.size;
|
|
373
|
+
const optimizationEntries = new Set();
|
|
374
|
+
for (const path of capturedFiles) {
|
|
375
|
+
const optimizationEntry = this._map.get(path);
|
|
376
|
+
if (optimizationEntry === undefined) {
|
|
377
|
+
if (newOptimizationEntry === undefined) {
|
|
378
|
+
newOptimizationEntry = {
|
|
379
|
+
snapshot: newSnapshot,
|
|
380
|
+
shared: 0,
|
|
381
|
+
snapshotContent: undefined,
|
|
382
|
+
children: undefined,
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
this._map.set(path, newOptimizationEntry);
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
optimizationEntries.add(optimizationEntry);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
// eslint-disable-next-line no-label-var
|
|
393
|
+
optimizationEntries: for (const optimizationEntry of optimizationEntries) {
|
|
394
|
+
const snapshot = optimizationEntry.snapshot;
|
|
395
|
+
if (optimizationEntry.shared > 0) {
|
|
396
|
+
// It's a shared snapshot
|
|
397
|
+
// We can't change it, so we can only use it when all files match
|
|
398
|
+
// and startTime is compatible
|
|
399
|
+
if (this._useStartTime &&
|
|
400
|
+
newSnapshot.startTime &&
|
|
401
|
+
(!snapshot.startTime || snapshot.startTime > newSnapshot.startTime)) {
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
const nonSharedFiles = new Set();
|
|
405
|
+
const snapshotContent = optimizationEntry.snapshotContent;
|
|
406
|
+
const snapshotEntries = this._get(snapshot);
|
|
407
|
+
for (const path of snapshotContent) {
|
|
408
|
+
if (!capturedFiles.has(path)) {
|
|
409
|
+
if (!snapshotEntries.has(path)) {
|
|
410
|
+
// File is not shared and can't be removed from the snapshot
|
|
411
|
+
// because it's in a child of the snapshot
|
|
412
|
+
continue optimizationEntries;
|
|
413
|
+
}
|
|
414
|
+
nonSharedFiles.add(path);
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
if (nonSharedFiles.size === 0) {
|
|
419
|
+
// The complete snapshot is shared
|
|
420
|
+
// add it as child
|
|
421
|
+
newSnapshot.addChild(snapshot);
|
|
422
|
+
increaseSharedAndStoreOptimizationEntry(optimizationEntry);
|
|
423
|
+
this._statReusedSharedSnapshots++;
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
// Only a part of the snapshot is shared
|
|
427
|
+
const sharedCount = snapshotContent.size - nonSharedFiles.size;
|
|
428
|
+
if (sharedCount < MIN_COMMON_SNAPSHOT_SIZE) {
|
|
429
|
+
// Common part it too small
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
// Extract common timestamps from both snapshots
|
|
433
|
+
let commonMap;
|
|
434
|
+
if (this._isSet) {
|
|
435
|
+
commonMap = new Set();
|
|
436
|
+
for (const path of snapshotEntries) {
|
|
437
|
+
if (nonSharedFiles.has(path))
|
|
438
|
+
continue;
|
|
439
|
+
commonMap.add(path);
|
|
440
|
+
snapshotEntries.delete(path);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
commonMap = new Map();
|
|
445
|
+
const map = snapshotEntries;
|
|
446
|
+
for (const [path, value] of map) {
|
|
447
|
+
if (nonSharedFiles.has(path))
|
|
448
|
+
continue;
|
|
449
|
+
commonMap.set(path, value);
|
|
450
|
+
snapshotEntries.delete(path);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
// Create and attach snapshot
|
|
454
|
+
const commonSnapshot = new Snapshot();
|
|
455
|
+
if (this._useStartTime) {
|
|
456
|
+
commonSnapshot.setMergedStartTime(newSnapshot.startTime, snapshot);
|
|
457
|
+
}
|
|
458
|
+
this._set(commonSnapshot, commonMap);
|
|
459
|
+
newSnapshot.addChild(commonSnapshot);
|
|
460
|
+
snapshot.addChild(commonSnapshot);
|
|
461
|
+
// Create optimization entry
|
|
462
|
+
const newEntry = {
|
|
463
|
+
snapshot: commonSnapshot,
|
|
464
|
+
shared: optimizationEntry.shared + 1,
|
|
465
|
+
snapshotContent: new Set(commonMap.keys()),
|
|
466
|
+
children: undefined,
|
|
467
|
+
};
|
|
468
|
+
if (optimizationEntry.children === undefined)
|
|
469
|
+
optimizationEntry.children = new Set();
|
|
470
|
+
optimizationEntry.children.add(newEntry);
|
|
471
|
+
storeOptimizationEntry(newEntry);
|
|
472
|
+
this._statSharedSnapshots++;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
// It's a unshared snapshot
|
|
477
|
+
// We can extract a common shared snapshot
|
|
478
|
+
// with all common files
|
|
479
|
+
const snapshotEntries = this._get(snapshot);
|
|
480
|
+
if (snapshotEntries === undefined) {
|
|
481
|
+
// Incomplete snapshot, that can't be used
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
let commonMap;
|
|
485
|
+
if (this._isSet) {
|
|
486
|
+
commonMap = new Set();
|
|
487
|
+
const set = snapshotEntries;
|
|
488
|
+
if (capturedFiles.size < set.size) {
|
|
489
|
+
for (const path of capturedFiles) {
|
|
490
|
+
if (set.has(path))
|
|
491
|
+
commonMap.add(path);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
for (const path of set) {
|
|
496
|
+
if (capturedFiles.has(path))
|
|
497
|
+
commonMap.add(path);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
commonMap = new Map();
|
|
503
|
+
const map = snapshotEntries;
|
|
504
|
+
for (const path of capturedFiles) {
|
|
505
|
+
const ts = map.get(path);
|
|
506
|
+
if (ts === undefined)
|
|
507
|
+
continue;
|
|
508
|
+
commonMap.set(path, ts);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
if (commonMap.size < MIN_COMMON_SNAPSHOT_SIZE) {
|
|
512
|
+
// Common part it too small
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
// Create and attach snapshot
|
|
516
|
+
const commonSnapshot = new Snapshot();
|
|
517
|
+
if (this._useStartTime) {
|
|
518
|
+
commonSnapshot.setMergedStartTime(newSnapshot.startTime, snapshot);
|
|
519
|
+
}
|
|
520
|
+
this._set(commonSnapshot, commonMap);
|
|
521
|
+
newSnapshot.addChild(commonSnapshot);
|
|
522
|
+
snapshot.addChild(commonSnapshot);
|
|
523
|
+
// Remove files from snapshot
|
|
524
|
+
for (const path of commonMap.keys())
|
|
525
|
+
snapshotEntries.delete(path);
|
|
526
|
+
const sharedCount = commonMap.size;
|
|
527
|
+
this._statItemsUnshared -= sharedCount;
|
|
528
|
+
this._statItemsShared += sharedCount;
|
|
529
|
+
// Create optimization entry
|
|
530
|
+
storeOptimizationEntry({
|
|
531
|
+
snapshot: commonSnapshot,
|
|
532
|
+
shared: 2,
|
|
533
|
+
snapshotContent: new Set(commonMap.keys()),
|
|
534
|
+
children: undefined,
|
|
535
|
+
});
|
|
536
|
+
this._statSharedSnapshots++;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
const unshared = capturedFiles.size;
|
|
540
|
+
this._statItemsUnshared += unshared;
|
|
541
|
+
this._statItemsShared += capturedFilesSize - unshared;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
const parseString = str => {
|
|
545
|
+
if (str[0] === "'")
|
|
546
|
+
str = `"${str.slice(1, -1).replace(/"/g, '\\"')}"`;
|
|
547
|
+
return JSON.parse(str);
|
|
548
|
+
};
|
|
549
|
+
const applyMtime = mtime => {
|
|
550
|
+
if (FS_ACCURACY > 1 && mtime % 2 !== 0)
|
|
551
|
+
FS_ACCURACY = 1;
|
|
552
|
+
else if (FS_ACCURACY > 10 && mtime % 20 !== 0)
|
|
553
|
+
FS_ACCURACY = 10;
|
|
554
|
+
else if (FS_ACCURACY > 100 && mtime % 200 !== 0)
|
|
555
|
+
FS_ACCURACY = 100;
|
|
556
|
+
else if (FS_ACCURACY > 1000 && mtime % 2000 !== 0)
|
|
557
|
+
FS_ACCURACY = 1000;
|
|
558
|
+
};
|
|
559
|
+
const mergeMaps = (a, b) => {
|
|
560
|
+
if (!b || b.size === 0)
|
|
561
|
+
return a;
|
|
562
|
+
if (!a || a.size === 0)
|
|
563
|
+
return b;
|
|
564
|
+
const map = new Map(a);
|
|
565
|
+
for (const [key, value] of b) {
|
|
566
|
+
map.set(key, value);
|
|
567
|
+
}
|
|
568
|
+
return map;
|
|
569
|
+
};
|
|
570
|
+
const mergeSets = (a, b) => {
|
|
571
|
+
if (!b || b.size === 0)
|
|
572
|
+
return a;
|
|
573
|
+
if (!a || a.size === 0)
|
|
574
|
+
return b;
|
|
575
|
+
const map = new Set(a);
|
|
576
|
+
for (const item of b) {
|
|
577
|
+
map.add(item);
|
|
578
|
+
}
|
|
579
|
+
return map;
|
|
580
|
+
};
|
|
581
|
+
/**
|
|
582
|
+
* Finding file or directory to manage
|
|
583
|
+
* getManagedItem(
|
|
584
|
+
* '/Users/user/my-project/node_modules/',
|
|
585
|
+
* '/Users/user/my-project/node_modules/package/index.js'
|
|
586
|
+
* ) === '/Users/user/my-project/node_modules/package'
|
|
587
|
+
* getManagedItem(
|
|
588
|
+
* '/Users/user/my-project/node_modules/',
|
|
589
|
+
* '/Users/user/my-project/node_modules/package1/node_modules/package2'
|
|
590
|
+
* ) === '/Users/user/my-project/node_modules/package1/node_modules/package2'
|
|
591
|
+
* getManagedItem(
|
|
592
|
+
* '/Users/user/my-project/node_modules/',
|
|
593
|
+
* '/Users/user/my-project/node_modules/.bin/script.js'
|
|
594
|
+
* ) === null // hidden files are disallowed as managed items
|
|
595
|
+
* getManagedItem(
|
|
596
|
+
* '/Users/user/my-project/node_modules/',
|
|
597
|
+
* '/Users/user/my-project/node_modules/package'
|
|
598
|
+
* ) === '/Users/user/my-project/node_modules/package'
|
|
599
|
+
*/
|
|
600
|
+
const getManagedItem = (managedPath, path) => {
|
|
601
|
+
let i = managedPath.length;
|
|
602
|
+
let slashes = 1;
|
|
603
|
+
let startingPosition = true;
|
|
604
|
+
loop: while (i < path.length) {
|
|
605
|
+
switch (path.charCodeAt(i)) {
|
|
606
|
+
case 47: // slash
|
|
607
|
+
case 92: // backslash
|
|
608
|
+
if (--slashes === 0)
|
|
609
|
+
break loop;
|
|
610
|
+
startingPosition = true;
|
|
611
|
+
break;
|
|
612
|
+
case 46: // .
|
|
613
|
+
// hidden files are disallowed as managed items
|
|
614
|
+
// it's probably .yarn-integrity or .cache
|
|
615
|
+
if (startingPosition)
|
|
616
|
+
return null;
|
|
617
|
+
break;
|
|
618
|
+
case 64: // @
|
|
619
|
+
if (!startingPosition)
|
|
620
|
+
return null;
|
|
621
|
+
slashes++;
|
|
622
|
+
break;
|
|
623
|
+
default:
|
|
624
|
+
startingPosition = false;
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
i++;
|
|
628
|
+
}
|
|
629
|
+
if (i === path.length)
|
|
630
|
+
slashes--;
|
|
631
|
+
// return null when path is incomplete
|
|
632
|
+
if (slashes !== 0)
|
|
633
|
+
return null;
|
|
634
|
+
// if (path.slice(i + 1, i + 13) === "node_modules")
|
|
635
|
+
if (path.length >= i + 13 &&
|
|
636
|
+
path.charCodeAt(i + 1) === 110 &&
|
|
637
|
+
path.charCodeAt(i + 2) === 111 &&
|
|
638
|
+
path.charCodeAt(i + 3) === 100 &&
|
|
639
|
+
path.charCodeAt(i + 4) === 101 &&
|
|
640
|
+
path.charCodeAt(i + 5) === 95 &&
|
|
641
|
+
path.charCodeAt(i + 6) === 109 &&
|
|
642
|
+
path.charCodeAt(i + 7) === 111 &&
|
|
643
|
+
path.charCodeAt(i + 8) === 100 &&
|
|
644
|
+
path.charCodeAt(i + 9) === 117 &&
|
|
645
|
+
path.charCodeAt(i + 10) === 108 &&
|
|
646
|
+
path.charCodeAt(i + 11) === 101 &&
|
|
647
|
+
path.charCodeAt(i + 12) === 115) {
|
|
648
|
+
// if this is the end of the path
|
|
649
|
+
if (path.length === i + 13) {
|
|
650
|
+
// return the node_modules directory
|
|
651
|
+
// it's special
|
|
652
|
+
return path;
|
|
653
|
+
}
|
|
654
|
+
const c = path.charCodeAt(i + 13);
|
|
655
|
+
// if next symbol is slash or backslash
|
|
656
|
+
if (c === 47 || c === 92) {
|
|
657
|
+
// Managed subpath
|
|
658
|
+
return getManagedItem(path.slice(0, i + 14), path);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
return path.slice(0, i);
|
|
662
|
+
};
|
|
663
|
+
const getResolvedTimestamp = entry => {
|
|
664
|
+
if (entry === null)
|
|
665
|
+
return null;
|
|
666
|
+
if (entry.resolved !== undefined)
|
|
667
|
+
return entry.resolved;
|
|
668
|
+
return entry.symlinks === undefined ? entry : undefined;
|
|
669
|
+
};
|
|
670
|
+
const getResolvedHash = entry => {
|
|
671
|
+
if (entry === null)
|
|
672
|
+
return null;
|
|
673
|
+
if (entry.resolved !== undefined)
|
|
674
|
+
return entry.resolved;
|
|
675
|
+
return entry.symlinks === undefined ? entry.hash : undefined;
|
|
676
|
+
};
|
|
677
|
+
const addAll = (source, target) => {
|
|
678
|
+
for (const key of source)
|
|
679
|
+
target.add(key);
|
|
680
|
+
};
|
|
681
|
+
class FileSystemInfo {
|
|
682
|
+
constructor(fs, { managedPaths = [], immutablePaths = [], logger = undefined, hashFunction = 'md4' } = {}) {
|
|
683
|
+
this.fs = fs;
|
|
684
|
+
this.logger = logger;
|
|
685
|
+
this._remainingLogs = logger ? 40 : 0;
|
|
686
|
+
// @ts-ignore
|
|
687
|
+
this._loggedPaths = logger ? new Set() : undefined;
|
|
688
|
+
this._hashFunction = hashFunction;
|
|
689
|
+
this._snapshotCache = new WeakMap();
|
|
690
|
+
this._fileTimestampsOptimization = new SnapshotOptimization(s => s.hasFileTimestamps(), s => s.fileTimestamps, (s, v) => s.setFileTimestamps(v));
|
|
691
|
+
this._fileHashesOptimization = new SnapshotOptimization(s => s.hasFileHashes(), s => s.fileHashes, (s, v) => s.setFileHashes(v), false);
|
|
692
|
+
this._fileTshsOptimization = new SnapshotOptimization(s => s.hasFileTshs(), s => s.fileTshs, (s, v) => s.setFileTshs(v));
|
|
693
|
+
this._contextTimestampsOptimization = new SnapshotOptimization(s => s.hasContextTimestamps(), s => s.contextTimestamps, (s, v) => s.setContextTimestamps(v));
|
|
694
|
+
this._contextHashesOptimization = new SnapshotOptimization(s => s.hasContextHashes(), s => s.contextHashes, (s, v) => s.setContextHashes(v), false);
|
|
695
|
+
this._contextTshsOptimization = new SnapshotOptimization(s => s.hasContextTshs(), s => s.contextTshs, (s, v) => s.setContextTshs(v));
|
|
696
|
+
this._missingExistenceOptimization = new SnapshotOptimization(s => s.hasMissingExistence(), s => s.missingExistence, (s, v) => s.setMissingExistence(v), false);
|
|
697
|
+
this._managedItemInfoOptimization = new SnapshotOptimization(s => s.hasManagedItemInfo(), s => s.managedItemInfo, (s, v) => s.setManagedItemInfo(v), false);
|
|
698
|
+
this._managedFilesOptimization = new SnapshotOptimization(s => s.hasManagedFiles(), s => s.managedFiles, (s, v) => s.setManagedFiles(v), false, true);
|
|
699
|
+
this._managedContextsOptimization = new SnapshotOptimization(s => s.hasManagedContexts(), s => s.managedContexts, (s, v) => s.setManagedContexts(v), false, true);
|
|
700
|
+
this._managedMissingOptimization = new SnapshotOptimization(s => s.hasManagedMissing(), s => s.managedMissing, (s, v) => s.setManagedMissing(v), false, true);
|
|
701
|
+
this._fileTimestamps = new StackedCacheMap_1.default();
|
|
702
|
+
this._fileHashes = new Map();
|
|
703
|
+
this._fileTshs = new Map();
|
|
704
|
+
this._contextTimestamps = new StackedCacheMap_1.default();
|
|
705
|
+
this._contextHashes = new Map();
|
|
706
|
+
this._contextTshs = new Map();
|
|
707
|
+
this._managedItems = new Map();
|
|
708
|
+
this.fileTimestampQueue = new AsyncQueue_1.default({
|
|
709
|
+
name: 'file timestamp',
|
|
710
|
+
parallelism: 30,
|
|
711
|
+
processor: this._readFileTimestamp.bind(this),
|
|
712
|
+
});
|
|
713
|
+
this.fileHashQueue = new AsyncQueue_1.default({
|
|
714
|
+
name: 'file hash',
|
|
715
|
+
parallelism: 10,
|
|
716
|
+
processor: this._readFileHash.bind(this),
|
|
717
|
+
});
|
|
718
|
+
this.contextTimestampQueue = new AsyncQueue_1.default({
|
|
719
|
+
name: 'context timestamp',
|
|
720
|
+
parallelism: 2,
|
|
721
|
+
processor: this._readContextTimestamp.bind(this),
|
|
722
|
+
});
|
|
723
|
+
this.contextHashQueue = new AsyncQueue_1.default({
|
|
724
|
+
name: 'context hash',
|
|
725
|
+
parallelism: 2,
|
|
726
|
+
processor: this._readContextHash.bind(this),
|
|
727
|
+
});
|
|
728
|
+
this.contextTshQueue = new AsyncQueue_1.default({
|
|
729
|
+
name: 'context hash and timestamp',
|
|
730
|
+
parallelism: 2,
|
|
731
|
+
processor: this._readContextTimestampAndHash.bind(this),
|
|
732
|
+
});
|
|
733
|
+
this.managedItemQueue = new AsyncQueue_1.default({
|
|
734
|
+
name: 'managed item info',
|
|
735
|
+
parallelism: 10,
|
|
736
|
+
processor: this._getManagedItemInfo.bind(this),
|
|
737
|
+
});
|
|
738
|
+
this.managedItemDirectoryQueue = new AsyncQueue_1.default({
|
|
739
|
+
name: 'managed item directory info',
|
|
740
|
+
parallelism: 10,
|
|
741
|
+
processor: this._getManagedItemDirectoryInfo.bind(this),
|
|
742
|
+
});
|
|
743
|
+
this.managedPaths = Array.from(managedPaths);
|
|
744
|
+
this.managedPathsWithSlash = this.managedPaths
|
|
745
|
+
.filter(p => typeof p === 'string')
|
|
746
|
+
.map(p => (0, fs_1.join)(fs, p, '_').slice(0, -1));
|
|
747
|
+
this.managedPathsRegExps = this.managedPaths.filter(p => typeof p !== 'string');
|
|
748
|
+
this.immutablePaths = Array.from(immutablePaths);
|
|
749
|
+
this.immutablePathsWithSlash = this.immutablePaths
|
|
750
|
+
.filter(p => typeof p === 'string')
|
|
751
|
+
.map(p => (0, fs_1.join)(fs, p, '_').slice(0, -1));
|
|
752
|
+
this.immutablePathsRegExps = this.immutablePaths.filter(p => typeof p !== 'string');
|
|
753
|
+
this._cachedDeprecatedFileTimestamps = undefined;
|
|
754
|
+
this._cachedDeprecatedContextTimestamps = undefined;
|
|
755
|
+
this._warnAboutExperimentalEsmTracking = false;
|
|
756
|
+
this._statCreatedSnapshots = 0;
|
|
757
|
+
this._statTestedSnapshotsCached = 0;
|
|
758
|
+
this._statTestedSnapshotsNotCached = 0;
|
|
759
|
+
this._statTestedChildrenCached = 0;
|
|
760
|
+
this._statTestedChildrenNotCached = 0;
|
|
761
|
+
this._statTestedEntries = 0;
|
|
762
|
+
}
|
|
763
|
+
logStatistics() {
|
|
764
|
+
const logWhenMessage = (header, message) => {
|
|
765
|
+
if (message) {
|
|
766
|
+
this.logger.log(`${header}: ${message}`);
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
this.logger.log(`${this._statCreatedSnapshots} new snapshots created`);
|
|
770
|
+
this.logger.log(`${this._statTestedSnapshotsNotCached &&
|
|
771
|
+
Math.round((this._statTestedSnapshotsNotCached * 100) /
|
|
772
|
+
(this._statTestedSnapshotsCached + this._statTestedSnapshotsNotCached))}% root snapshot uncached (${this._statTestedSnapshotsNotCached} / ${this._statTestedSnapshotsCached + this._statTestedSnapshotsNotCached})`);
|
|
773
|
+
this.logger.log(`${this._statTestedChildrenNotCached &&
|
|
774
|
+
Math.round((this._statTestedChildrenNotCached * 100) /
|
|
775
|
+
(this._statTestedChildrenCached + this._statTestedChildrenNotCached))}% children snapshot uncached (${this._statTestedChildrenNotCached} / ${this._statTestedChildrenCached + this._statTestedChildrenNotCached})`);
|
|
776
|
+
this.logger.log(`${this._statTestedEntries} entries tested`);
|
|
777
|
+
this.logger.log(`File info in cache: ${this._fileTimestamps.size} timestamps ${this._fileHashes.size} hashes ${this._fileTshs.size} timestamp hash combinations`);
|
|
778
|
+
logWhenMessage(`File timestamp snapshot optimization`, this._fileTimestampsOptimization.getStatisticMessage());
|
|
779
|
+
logWhenMessage(`File hash snapshot optimization`, this._fileHashesOptimization.getStatisticMessage());
|
|
780
|
+
logWhenMessage(`File timestamp hash combination snapshot optimization`, this._fileTshsOptimization.getStatisticMessage());
|
|
781
|
+
this.logger.log(`Directory info in cache: ${this._contextTimestamps.size} timestamps ${this._contextHashes.size} hashes ${this._contextTshs.size} timestamp hash combinations`);
|
|
782
|
+
logWhenMessage(`Directory timestamp snapshot optimization`, this._contextTimestampsOptimization.getStatisticMessage());
|
|
783
|
+
logWhenMessage(`Directory hash snapshot optimization`, this._contextHashesOptimization.getStatisticMessage());
|
|
784
|
+
logWhenMessage(`Directory timestamp hash combination snapshot optimization`, this._contextTshsOptimization.getStatisticMessage());
|
|
785
|
+
logWhenMessage(`Missing items snapshot optimization`, this._missingExistenceOptimization.getStatisticMessage());
|
|
786
|
+
this.logger.log(`Managed items info in cache: ${this._managedItems.size} items`);
|
|
787
|
+
logWhenMessage(`Managed items snapshot optimization`, this._managedItemInfoOptimization.getStatisticMessage());
|
|
788
|
+
logWhenMessage(`Managed files snapshot optimization`, this._managedFilesOptimization.getStatisticMessage());
|
|
789
|
+
logWhenMessage(`Managed contexts snapshot optimization`, this._managedContextsOptimization.getStatisticMessage());
|
|
790
|
+
logWhenMessage(`Managed missing snapshot optimization`, this._managedMissingOptimization.getStatisticMessage());
|
|
791
|
+
}
|
|
792
|
+
_log(path, reason, ...args) {
|
|
793
|
+
const key = path + reason;
|
|
794
|
+
if (this._loggedPaths.has(key))
|
|
795
|
+
return;
|
|
796
|
+
this._loggedPaths.add(key);
|
|
797
|
+
this.logger.debug(`${path} invalidated because ${reason}`, ...args);
|
|
798
|
+
if (--this._remainingLogs === 0) {
|
|
799
|
+
this.logger.debug('Logging limit has been reached and no further logging will be emitted by FileSystemInfo');
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
clear() {
|
|
803
|
+
this._remainingLogs = this.logger ? 40 : 0;
|
|
804
|
+
if (this._loggedPaths !== undefined)
|
|
805
|
+
this._loggedPaths.clear();
|
|
806
|
+
this._snapshotCache = new WeakMap();
|
|
807
|
+
this._fileTimestampsOptimization.clear();
|
|
808
|
+
this._fileHashesOptimization.clear();
|
|
809
|
+
this._fileTshsOptimization.clear();
|
|
810
|
+
this._contextTimestampsOptimization.clear();
|
|
811
|
+
this._contextHashesOptimization.clear();
|
|
812
|
+
this._contextTshsOptimization.clear();
|
|
813
|
+
this._missingExistenceOptimization.clear();
|
|
814
|
+
this._managedItemInfoOptimization.clear();
|
|
815
|
+
this._managedFilesOptimization.clear();
|
|
816
|
+
this._managedContextsOptimization.clear();
|
|
817
|
+
this._managedMissingOptimization.clear();
|
|
818
|
+
this._fileTimestamps.clear();
|
|
819
|
+
this._fileHashes.clear();
|
|
820
|
+
this._fileTshs.clear();
|
|
821
|
+
this._contextTimestamps.clear();
|
|
822
|
+
this._contextHashes.clear();
|
|
823
|
+
this._contextTshs.clear();
|
|
824
|
+
this._managedItems.clear();
|
|
825
|
+
this._managedItems.clear();
|
|
826
|
+
this._cachedDeprecatedFileTimestamps = undefined;
|
|
827
|
+
this._cachedDeprecatedContextTimestamps = undefined;
|
|
828
|
+
this._statCreatedSnapshots = 0;
|
|
829
|
+
this._statTestedSnapshotsCached = 0;
|
|
830
|
+
this._statTestedSnapshotsNotCached = 0;
|
|
831
|
+
this._statTestedChildrenCached = 0;
|
|
832
|
+
this._statTestedChildrenNotCached = 0;
|
|
833
|
+
this._statTestedEntries = 0;
|
|
834
|
+
}
|
|
835
|
+
addFileTimestamps(map, immutable) {
|
|
836
|
+
this._fileTimestamps.addAll(map, immutable);
|
|
837
|
+
this._cachedDeprecatedFileTimestamps = undefined;
|
|
838
|
+
}
|
|
839
|
+
addContextTimestamps(map, immutable) {
|
|
840
|
+
this._contextTimestamps.addAll(map, immutable);
|
|
841
|
+
this._cachedDeprecatedContextTimestamps = undefined;
|
|
842
|
+
}
|
|
843
|
+
getFileTimestamp(path, callback) {
|
|
844
|
+
const cache = this._fileTimestamps.get(path);
|
|
845
|
+
if (cache !== undefined)
|
|
846
|
+
return callback(null, cache);
|
|
847
|
+
this.fileTimestampQueue.add(path, callback);
|
|
848
|
+
}
|
|
849
|
+
getContextTimestamp(path, callback) {
|
|
850
|
+
const cache = this._contextTimestamps.get(path);
|
|
851
|
+
if (cache !== undefined) {
|
|
852
|
+
if (cache === 'ignore')
|
|
853
|
+
return callback(null, 'ignore');
|
|
854
|
+
const resolved = getResolvedTimestamp(cache);
|
|
855
|
+
if (resolved !== undefined)
|
|
856
|
+
return callback(null, resolved);
|
|
857
|
+
return this._resolveContextTimestamp(cache, callback);
|
|
858
|
+
}
|
|
859
|
+
this.contextTimestampQueue.add(path, (err, entry) => {
|
|
860
|
+
if (err)
|
|
861
|
+
return callback(err);
|
|
862
|
+
const resolved = getResolvedTimestamp(entry);
|
|
863
|
+
if (resolved !== undefined)
|
|
864
|
+
return callback(null, resolved);
|
|
865
|
+
this._resolveContextTimestamp(entry, callback);
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
_getUnresolvedContextTimestamp(path, callback) {
|
|
869
|
+
const cache = this._contextTimestamps.get(path);
|
|
870
|
+
if (cache !== undefined)
|
|
871
|
+
return callback(null, cache);
|
|
872
|
+
this.contextTimestampQueue.add(path, callback);
|
|
873
|
+
}
|
|
874
|
+
getFileHash(path, callback) {
|
|
875
|
+
const cache = this._fileHashes.get(path);
|
|
876
|
+
if (cache !== undefined)
|
|
877
|
+
return callback(null, cache);
|
|
878
|
+
this.fileHashQueue.add(path, callback);
|
|
879
|
+
}
|
|
880
|
+
getContextHash(path, callback) {
|
|
881
|
+
const cache = this._contextHashes.get(path);
|
|
882
|
+
if (cache !== undefined) {
|
|
883
|
+
const resolved = getResolvedHash(cache);
|
|
884
|
+
if (resolved !== undefined)
|
|
885
|
+
return callback(null, resolved);
|
|
886
|
+
return this._resolveContextHash(cache, callback);
|
|
887
|
+
}
|
|
888
|
+
this.contextHashQueue.add(path, (err, entry) => {
|
|
889
|
+
if (err)
|
|
890
|
+
return callback(err);
|
|
891
|
+
const resolved = getResolvedHash(entry);
|
|
892
|
+
if (resolved !== undefined)
|
|
893
|
+
return callback(null, resolved);
|
|
894
|
+
this._resolveContextHash(entry, callback);
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
_getUnresolvedContextHash(path, callback) {
|
|
898
|
+
const cache = this._contextHashes.get(path);
|
|
899
|
+
if (cache !== undefined)
|
|
900
|
+
return callback(null, cache);
|
|
901
|
+
this.contextHashQueue.add(path, callback);
|
|
902
|
+
}
|
|
903
|
+
getContextTsh(path, callback) {
|
|
904
|
+
const cache = this._contextTshs.get(path);
|
|
905
|
+
if (cache !== undefined) {
|
|
906
|
+
const resolved = getResolvedTimestamp(cache);
|
|
907
|
+
if (resolved !== undefined)
|
|
908
|
+
return callback(null, resolved);
|
|
909
|
+
return this._resolveContextTsh(cache, callback);
|
|
910
|
+
}
|
|
911
|
+
this.contextTshQueue.add(path, (err, entry) => {
|
|
912
|
+
if (err)
|
|
913
|
+
return callback(err);
|
|
914
|
+
const resolved = getResolvedTimestamp(entry);
|
|
915
|
+
if (resolved !== undefined)
|
|
916
|
+
return callback(null, resolved);
|
|
917
|
+
this._resolveContextTsh(entry, callback);
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
_getUnresolvedContextTsh(path, callback) {
|
|
921
|
+
const cache = this._contextTshs.get(path);
|
|
922
|
+
if (cache !== undefined)
|
|
923
|
+
return callback(null, cache);
|
|
924
|
+
this.contextTshQueue.add(path, callback);
|
|
925
|
+
}
|
|
926
|
+
_createBuildDependenciesResolvers() {
|
|
927
|
+
const resolveContext = (0, enhanced_resolve_1.create)({
|
|
928
|
+
resolveToContext: true,
|
|
929
|
+
exportsFields: [],
|
|
930
|
+
fileSystem: this.fs,
|
|
931
|
+
});
|
|
932
|
+
const resolveCjs = (0, enhanced_resolve_1.create)({
|
|
933
|
+
extensions: ['.js', '.json', '.node'],
|
|
934
|
+
conditionNames: ['require', 'node'],
|
|
935
|
+
exportsFields: ['exports'],
|
|
936
|
+
fileSystem: this.fs,
|
|
937
|
+
});
|
|
938
|
+
const resolveCjsAsChild = (0, enhanced_resolve_1.create)({
|
|
939
|
+
extensions: ['.js', '.json', '.node'],
|
|
940
|
+
conditionNames: ['require', 'node'],
|
|
941
|
+
exportsFields: [],
|
|
942
|
+
fileSystem: this.fs,
|
|
943
|
+
});
|
|
944
|
+
const resolveEsm = (0, enhanced_resolve_1.create)({
|
|
945
|
+
extensions: ['.js', '.json', '.node'],
|
|
946
|
+
fullySpecified: true,
|
|
947
|
+
conditionNames: ['import', 'node'],
|
|
948
|
+
exportsFields: ['exports'],
|
|
949
|
+
fileSystem: this.fs,
|
|
950
|
+
});
|
|
951
|
+
return { resolveContext, resolveEsm, resolveCjs, resolveCjsAsChild };
|
|
952
|
+
}
|
|
953
|
+
resolveBuildDependencies(context, deps, callback) {
|
|
954
|
+
const { resolveContext, resolveEsm, resolveCjs, resolveCjsAsChild } = this._createBuildDependenciesResolvers();
|
|
955
|
+
const files = new Set();
|
|
956
|
+
const fileSymlinks = new Set();
|
|
957
|
+
const directories = new Set();
|
|
958
|
+
const directorySymlinks = new Set();
|
|
959
|
+
const missing = new Set();
|
|
960
|
+
const resolveFiles = new Set();
|
|
961
|
+
const resolveDirectories = new Set();
|
|
962
|
+
const resolveMissing = new Set();
|
|
963
|
+
const resolveResults = new Map();
|
|
964
|
+
const invalidResolveResults = new Set();
|
|
965
|
+
const resolverContext = {
|
|
966
|
+
fileDependencies: resolveFiles,
|
|
967
|
+
contextDependencies: resolveDirectories,
|
|
968
|
+
missingDependencies: resolveMissing,
|
|
969
|
+
};
|
|
970
|
+
const expectedToString = (expected) => expected ? ` (expected ${expected})` : '';
|
|
971
|
+
const jobToString = job => {
|
|
972
|
+
switch (job.type) {
|
|
973
|
+
case RBDT_RESOLVE_CJS:
|
|
974
|
+
return `resolve commonjs ${job.path}${expectedToString(job.expected)}`;
|
|
975
|
+
case RBDT_RESOLVE_ESM:
|
|
976
|
+
return `resolve esm ${job.path}${expectedToString(job.expected)}`;
|
|
977
|
+
case RBDT_RESOLVE_DIRECTORY:
|
|
978
|
+
return `resolve directory ${job.path}`;
|
|
979
|
+
case RBDT_RESOLVE_CJS_FILE:
|
|
980
|
+
return `resolve commonjs file ${job.path}${expectedToString(job.expected)}`;
|
|
981
|
+
case RBDT_RESOLVE_ESM_FILE:
|
|
982
|
+
return `resolve esm file ${job.path}${expectedToString(job.expected)}`;
|
|
983
|
+
case RBDT_DIRECTORY:
|
|
984
|
+
return `directory ${job.path}`;
|
|
985
|
+
case RBDT_FILE:
|
|
986
|
+
return `file ${job.path}`;
|
|
987
|
+
case RBDT_DIRECTORY_DEPENDENCIES:
|
|
988
|
+
return `directory dependencies ${job.path}`;
|
|
989
|
+
case RBDT_FILE_DEPENDENCIES:
|
|
990
|
+
return `file dependencies ${job.path}`;
|
|
991
|
+
}
|
|
992
|
+
return `unknown ${job.type} ${job.path}`;
|
|
993
|
+
};
|
|
994
|
+
const pathToString = job => {
|
|
995
|
+
let result = ` at ${jobToString(job)}`;
|
|
996
|
+
job = job.issuer;
|
|
997
|
+
while (job !== undefined) {
|
|
998
|
+
result += `\n at ${jobToString(job)}`;
|
|
999
|
+
job = job.issuer;
|
|
1000
|
+
}
|
|
1001
|
+
return result;
|
|
1002
|
+
};
|
|
1003
|
+
(0, processAsyncTree_1.default)(Array.from(deps, dep => ({
|
|
1004
|
+
type: RBDT_RESOLVE_CJS,
|
|
1005
|
+
context,
|
|
1006
|
+
path: dep,
|
|
1007
|
+
expected: undefined,
|
|
1008
|
+
issuer: undefined,
|
|
1009
|
+
})), 20, (job, push, callback) => {
|
|
1010
|
+
const { type, context, path, expected } = job;
|
|
1011
|
+
const resolveDirectory = path => {
|
|
1012
|
+
const key = `d\n${context}\n${path}`;
|
|
1013
|
+
if (resolveResults.has(key)) {
|
|
1014
|
+
return callback();
|
|
1015
|
+
}
|
|
1016
|
+
resolveResults.set(key, undefined);
|
|
1017
|
+
resolveContext(context, path, resolverContext, (err, _, result) => {
|
|
1018
|
+
if (err) {
|
|
1019
|
+
if (expected === false) {
|
|
1020
|
+
resolveResults.set(key, false);
|
|
1021
|
+
return callback();
|
|
1022
|
+
}
|
|
1023
|
+
invalidResolveResults.add(key);
|
|
1024
|
+
err.message += `\nwhile resolving '${path}' in ${context} to a directory`;
|
|
1025
|
+
return callback(err);
|
|
1026
|
+
}
|
|
1027
|
+
const resultPath = result.path;
|
|
1028
|
+
resolveResults.set(key, resultPath);
|
|
1029
|
+
push({
|
|
1030
|
+
type: RBDT_DIRECTORY,
|
|
1031
|
+
context: undefined,
|
|
1032
|
+
path: resultPath,
|
|
1033
|
+
expected: undefined,
|
|
1034
|
+
issuer: job,
|
|
1035
|
+
});
|
|
1036
|
+
callback();
|
|
1037
|
+
});
|
|
1038
|
+
};
|
|
1039
|
+
const resolveFile = (path, symbol, resolve) => {
|
|
1040
|
+
const key = `${symbol}\n${context}\n${path}`;
|
|
1041
|
+
if (resolveResults.has(key)) {
|
|
1042
|
+
return callback();
|
|
1043
|
+
}
|
|
1044
|
+
resolveResults.set(key, undefined);
|
|
1045
|
+
resolve(context, path, resolverContext, (err, _, result) => {
|
|
1046
|
+
if (typeof expected === 'string') {
|
|
1047
|
+
if (!err && result && result.path === expected) {
|
|
1048
|
+
resolveResults.set(key, result.path);
|
|
1049
|
+
}
|
|
1050
|
+
else {
|
|
1051
|
+
invalidResolveResults.add(key);
|
|
1052
|
+
this.logger.warn(`Resolving '${path}' in ${context} for build dependencies doesn't lead to expected result '${expected}', but to '${err || (result === null || result === void 0 ? void 0 : result.path)}' instead. Resolving dependencies are ignored for this path.\n${pathToString(job)}`);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
else {
|
|
1056
|
+
if (err) {
|
|
1057
|
+
if (expected === false) {
|
|
1058
|
+
resolveResults.set(key, false);
|
|
1059
|
+
return callback();
|
|
1060
|
+
}
|
|
1061
|
+
invalidResolveResults.add(key);
|
|
1062
|
+
err.message += `\nwhile resolving '${path}' in ${context} as file\n${pathToString(job)}`;
|
|
1063
|
+
return callback(err);
|
|
1064
|
+
}
|
|
1065
|
+
const resultPath = result.path;
|
|
1066
|
+
resolveResults.set(key, resultPath);
|
|
1067
|
+
push({
|
|
1068
|
+
type: RBDT_FILE,
|
|
1069
|
+
context: undefined,
|
|
1070
|
+
path: resultPath,
|
|
1071
|
+
expected: undefined,
|
|
1072
|
+
issuer: job,
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
callback();
|
|
1076
|
+
});
|
|
1077
|
+
};
|
|
1078
|
+
switch (type) {
|
|
1079
|
+
case RBDT_RESOLVE_CJS: {
|
|
1080
|
+
const isDirectory = /[\\/]$/.test(path);
|
|
1081
|
+
if (isDirectory) {
|
|
1082
|
+
resolveDirectory(path.slice(0, path.length - 1));
|
|
1083
|
+
}
|
|
1084
|
+
else {
|
|
1085
|
+
resolveFile(path, 'f', resolveCjs);
|
|
1086
|
+
}
|
|
1087
|
+
break;
|
|
1088
|
+
}
|
|
1089
|
+
case RBDT_RESOLVE_ESM: {
|
|
1090
|
+
const isDirectory = /[\\/]$/.test(path);
|
|
1091
|
+
if (isDirectory) {
|
|
1092
|
+
resolveDirectory(path.slice(0, path.length - 1));
|
|
1093
|
+
}
|
|
1094
|
+
else {
|
|
1095
|
+
resolveFile(path);
|
|
1096
|
+
}
|
|
1097
|
+
break;
|
|
1098
|
+
}
|
|
1099
|
+
case RBDT_RESOLVE_DIRECTORY: {
|
|
1100
|
+
resolveDirectory(path);
|
|
1101
|
+
break;
|
|
1102
|
+
}
|
|
1103
|
+
case RBDT_RESOLVE_CJS_FILE: {
|
|
1104
|
+
resolveFile(path, 'f', resolveCjs);
|
|
1105
|
+
break;
|
|
1106
|
+
}
|
|
1107
|
+
case RBDT_RESOLVE_CJS_FILE_AS_CHILD: {
|
|
1108
|
+
resolveFile(path, 'c', resolveCjsAsChild);
|
|
1109
|
+
break;
|
|
1110
|
+
}
|
|
1111
|
+
case RBDT_RESOLVE_ESM_FILE: {
|
|
1112
|
+
resolveFile(path, 'e', resolveEsm);
|
|
1113
|
+
break;
|
|
1114
|
+
}
|
|
1115
|
+
case RBDT_FILE: {
|
|
1116
|
+
if (files.has(path)) {
|
|
1117
|
+
callback();
|
|
1118
|
+
break;
|
|
1119
|
+
}
|
|
1120
|
+
files.add(path);
|
|
1121
|
+
this.fs.realpath(path, (err, _realPath) => {
|
|
1122
|
+
if (err)
|
|
1123
|
+
return callback(err);
|
|
1124
|
+
const realPath = _realPath;
|
|
1125
|
+
if (realPath !== path) {
|
|
1126
|
+
fileSymlinks.add(path);
|
|
1127
|
+
resolveFiles.add(path);
|
|
1128
|
+
if (files.has(realPath))
|
|
1129
|
+
return callback();
|
|
1130
|
+
files.add(realPath);
|
|
1131
|
+
}
|
|
1132
|
+
push({
|
|
1133
|
+
type: RBDT_FILE_DEPENDENCIES,
|
|
1134
|
+
context: undefined,
|
|
1135
|
+
path: realPath,
|
|
1136
|
+
expected: undefined,
|
|
1137
|
+
issuer: job,
|
|
1138
|
+
});
|
|
1139
|
+
callback();
|
|
1140
|
+
});
|
|
1141
|
+
break;
|
|
1142
|
+
}
|
|
1143
|
+
case RBDT_DIRECTORY: {
|
|
1144
|
+
if (directories.has(path)) {
|
|
1145
|
+
callback();
|
|
1146
|
+
break;
|
|
1147
|
+
}
|
|
1148
|
+
directories.add(path);
|
|
1149
|
+
this.fs.realpath(path, (err, _realPath) => {
|
|
1150
|
+
if (err)
|
|
1151
|
+
return callback(err);
|
|
1152
|
+
const realPath = _realPath;
|
|
1153
|
+
if (realPath !== path) {
|
|
1154
|
+
directorySymlinks.add(path);
|
|
1155
|
+
resolveFiles.add(path);
|
|
1156
|
+
if (directories.has(realPath))
|
|
1157
|
+
return callback();
|
|
1158
|
+
directories.add(realPath);
|
|
1159
|
+
}
|
|
1160
|
+
push({
|
|
1161
|
+
type: RBDT_DIRECTORY_DEPENDENCIES,
|
|
1162
|
+
context: undefined,
|
|
1163
|
+
path: realPath,
|
|
1164
|
+
expected: undefined,
|
|
1165
|
+
issuer: job,
|
|
1166
|
+
});
|
|
1167
|
+
callback();
|
|
1168
|
+
});
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
case RBDT_FILE_DEPENDENCIES: {
|
|
1172
|
+
// Check for known files without dependencies
|
|
1173
|
+
if (/\.json5?$|\.yarn-integrity$|yarn\.lock$|\.ya?ml/.test(path)) {
|
|
1174
|
+
process.nextTick(callback);
|
|
1175
|
+
break;
|
|
1176
|
+
}
|
|
1177
|
+
// Check commonjs cache for the module
|
|
1178
|
+
const module = require.cache[path];
|
|
1179
|
+
if (module && Array.isArray(module.children)) {
|
|
1180
|
+
children: for (const child of module.children) {
|
|
1181
|
+
const childPath = child.filename;
|
|
1182
|
+
if (childPath) {
|
|
1183
|
+
push({
|
|
1184
|
+
type: RBDT_FILE,
|
|
1185
|
+
context: undefined,
|
|
1186
|
+
path: childPath,
|
|
1187
|
+
expected: undefined,
|
|
1188
|
+
issuer: job,
|
|
1189
|
+
});
|
|
1190
|
+
const context = (0, fs_1.dirname)(this.fs, path);
|
|
1191
|
+
for (const modulePath of module.paths) {
|
|
1192
|
+
if (childPath.startsWith(modulePath)) {
|
|
1193
|
+
const subPath = childPath.slice(modulePath.length + 1);
|
|
1194
|
+
const packageMatch = /^(@[^\\/]+[\\/])[^\\/]+/.exec(subPath);
|
|
1195
|
+
if (packageMatch) {
|
|
1196
|
+
push({
|
|
1197
|
+
type: RBDT_FILE,
|
|
1198
|
+
context: undefined,
|
|
1199
|
+
path: `${modulePath +
|
|
1200
|
+
childPath[modulePath.length] +
|
|
1201
|
+
packageMatch[0] +
|
|
1202
|
+
childPath[modulePath.length]}package.json`,
|
|
1203
|
+
expected: false,
|
|
1204
|
+
issuer: job,
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
let request = subPath.replace(/\\/g, '/');
|
|
1208
|
+
if (request.endsWith('.js'))
|
|
1209
|
+
request = request.slice(0, -3);
|
|
1210
|
+
push({
|
|
1211
|
+
type: RBDT_RESOLVE_CJS_FILE_AS_CHILD,
|
|
1212
|
+
context,
|
|
1213
|
+
path: request,
|
|
1214
|
+
expected: child.filename,
|
|
1215
|
+
issuer: job,
|
|
1216
|
+
});
|
|
1217
|
+
continue children;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
let request = (0, fs_1.relative)(this.fs, context, childPath);
|
|
1221
|
+
if (request.endsWith('.js'))
|
|
1222
|
+
request = request.slice(0, -3);
|
|
1223
|
+
request = request.replace(/\\/g, '/');
|
|
1224
|
+
if (!request.startsWith('../') && !(0, path_1.isAbsolute)(request)) {
|
|
1225
|
+
request = `./${request}`;
|
|
1226
|
+
}
|
|
1227
|
+
push({
|
|
1228
|
+
type: RBDT_RESOLVE_CJS_FILE,
|
|
1229
|
+
context,
|
|
1230
|
+
path: request,
|
|
1231
|
+
expected: child.filename,
|
|
1232
|
+
issuer: job,
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
else if (supportsEsm && /\.m?js$/.test(path)) {
|
|
1238
|
+
if (!this._warnAboutExperimentalEsmTracking) {
|
|
1239
|
+
this.logger.log("Node.js doesn't offer a (nice) way to introspect the ESM dependency graph yet.\n" +
|
|
1240
|
+
'Until a full solution is available webpack uses an experimental ESM tracking based on parsing.\n' +
|
|
1241
|
+
'As best effort webpack parses the ESM files to guess dependencies. But this can lead to expensive and incorrect tracking.');
|
|
1242
|
+
this._warnAboutExperimentalEsmTracking = true;
|
|
1243
|
+
}
|
|
1244
|
+
es_module_lexer_1.default.init.then(() => {
|
|
1245
|
+
this.fs.readFile(path, (err, content) => {
|
|
1246
|
+
if (err)
|
|
1247
|
+
return callback(err);
|
|
1248
|
+
try {
|
|
1249
|
+
const context = (0, fs_1.dirname)(this.fs, path);
|
|
1250
|
+
const source = content.toString();
|
|
1251
|
+
const [imports] = es_module_lexer_1.default.parse(source);
|
|
1252
|
+
for (const imp of imports) {
|
|
1253
|
+
try {
|
|
1254
|
+
let dependency;
|
|
1255
|
+
if (imp.d === -1) {
|
|
1256
|
+
// import ... from "..."
|
|
1257
|
+
dependency = parseString(source.substring(imp.s - 1, imp.e + 1));
|
|
1258
|
+
}
|
|
1259
|
+
else if (imp.d > -1) {
|
|
1260
|
+
// import()
|
|
1261
|
+
const expr = source.substring(imp.s, imp.e).trim();
|
|
1262
|
+
dependency = parseString(expr);
|
|
1263
|
+
}
|
|
1264
|
+
else {
|
|
1265
|
+
// e.g. import.meta
|
|
1266
|
+
continue;
|
|
1267
|
+
}
|
|
1268
|
+
// we should not track Node.js build dependencies
|
|
1269
|
+
if (dependency.startsWith('node:'))
|
|
1270
|
+
continue;
|
|
1271
|
+
if (builtinModules.has(dependency))
|
|
1272
|
+
continue;
|
|
1273
|
+
push({
|
|
1274
|
+
type: RBDT_RESOLVE_ESM_FILE,
|
|
1275
|
+
context,
|
|
1276
|
+
path: dependency,
|
|
1277
|
+
expected: undefined,
|
|
1278
|
+
issuer: job,
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
catch (e) {
|
|
1282
|
+
this.logger.warn(`Parsing of ${path} for build dependencies failed at 'import(${source.substring(imp.s, imp.e)})'.\n` +
|
|
1283
|
+
'Build dependencies behind this expression are ignored and might cause incorrect cache invalidation.');
|
|
1284
|
+
this.logger.debug(pathToString(job));
|
|
1285
|
+
this.logger.debug(e.stack);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
catch (e) {
|
|
1290
|
+
this.logger.warn(`Parsing of ${path} for build dependencies failed and all dependencies of this file are ignored, which might cause incorrect cache invalidation..`);
|
|
1291
|
+
this.logger.debug(pathToString(job));
|
|
1292
|
+
this.logger.debug(e.stack);
|
|
1293
|
+
}
|
|
1294
|
+
process.nextTick(callback);
|
|
1295
|
+
});
|
|
1296
|
+
}, callback);
|
|
1297
|
+
break;
|
|
1298
|
+
}
|
|
1299
|
+
else {
|
|
1300
|
+
this.logger.log(`Assuming ${path} has no dependencies as we were unable to assign it to any module system.`);
|
|
1301
|
+
this.logger.debug(pathToString(job));
|
|
1302
|
+
}
|
|
1303
|
+
process.nextTick(callback);
|
|
1304
|
+
break;
|
|
1305
|
+
}
|
|
1306
|
+
case RBDT_DIRECTORY_DEPENDENCIES: {
|
|
1307
|
+
const match = /(^.+[\\/]node_modules[\\/](?:@[^\\/]+[\\/])?[^\\/]+)/.exec(path);
|
|
1308
|
+
const packagePath = match ? match[1] : path;
|
|
1309
|
+
const packageJson = (0, fs_1.join)(this.fs, packagePath, 'package.json');
|
|
1310
|
+
this.fs.readFile(packageJson, (err, content) => {
|
|
1311
|
+
if (err) {
|
|
1312
|
+
if (err.code === 'ENOENT') {
|
|
1313
|
+
resolveMissing.add(packageJson);
|
|
1314
|
+
const parent = (0, fs_1.dirname)(this.fs, packagePath);
|
|
1315
|
+
if (parent !== packagePath) {
|
|
1316
|
+
push({
|
|
1317
|
+
type: RBDT_DIRECTORY_DEPENDENCIES,
|
|
1318
|
+
context: undefined,
|
|
1319
|
+
path: parent,
|
|
1320
|
+
expected: undefined,
|
|
1321
|
+
issuer: job,
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
callback();
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
return callback(err);
|
|
1328
|
+
}
|
|
1329
|
+
resolveFiles.add(packageJson);
|
|
1330
|
+
let packageData;
|
|
1331
|
+
try {
|
|
1332
|
+
packageData = JSON.parse(content.toString('utf-8'));
|
|
1333
|
+
}
|
|
1334
|
+
catch (e) {
|
|
1335
|
+
return callback(e);
|
|
1336
|
+
}
|
|
1337
|
+
const depsObject = packageData.dependencies;
|
|
1338
|
+
const optionalDepsObject = packageData.optionalDependencies;
|
|
1339
|
+
const allDeps = new Set();
|
|
1340
|
+
const optionalDeps = new Set();
|
|
1341
|
+
if (typeof depsObject === 'object' && depsObject) {
|
|
1342
|
+
for (const dep of Object.keys(depsObject)) {
|
|
1343
|
+
allDeps.add(dep);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
if (typeof optionalDepsObject === 'object' && optionalDepsObject) {
|
|
1347
|
+
for (const dep of Object.keys(optionalDepsObject)) {
|
|
1348
|
+
allDeps.add(dep);
|
|
1349
|
+
optionalDeps.add(dep);
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
for (const dep of allDeps) {
|
|
1353
|
+
push({
|
|
1354
|
+
type: RBDT_RESOLVE_DIRECTORY,
|
|
1355
|
+
context: packagePath,
|
|
1356
|
+
path: dep,
|
|
1357
|
+
expected: !optionalDeps.has(dep),
|
|
1358
|
+
issuer: job,
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
callback();
|
|
1362
|
+
});
|
|
1363
|
+
break;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
}, err => {
|
|
1367
|
+
if (err)
|
|
1368
|
+
return callback(err);
|
|
1369
|
+
for (const l of fileSymlinks)
|
|
1370
|
+
files.delete(l);
|
|
1371
|
+
for (const l of directorySymlinks)
|
|
1372
|
+
directories.delete(l);
|
|
1373
|
+
for (const k of invalidResolveResults)
|
|
1374
|
+
resolveResults.delete(k);
|
|
1375
|
+
callback(null, {
|
|
1376
|
+
files,
|
|
1377
|
+
directories,
|
|
1378
|
+
missing,
|
|
1379
|
+
resolveResults,
|
|
1380
|
+
resolveDependencies: {
|
|
1381
|
+
files: resolveFiles,
|
|
1382
|
+
directories: resolveDirectories,
|
|
1383
|
+
missing: resolveMissing,
|
|
1384
|
+
},
|
|
1385
|
+
});
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
checkResolveResultsValid(resolveResults, callback) {
|
|
1389
|
+
const { resolveCjs, resolveCjsAsChild, resolveEsm, resolveContext } = this._createBuildDependenciesResolvers();
|
|
1390
|
+
neo_async_1.default.eachLimit(resolveResults, 20, ([key, expectedResult], callback) => {
|
|
1391
|
+
const [type, context, path] = key.split('\n');
|
|
1392
|
+
switch (type) {
|
|
1393
|
+
case 'd':
|
|
1394
|
+
resolveContext(context, path, {}, (err, _, result) => {
|
|
1395
|
+
if (expectedResult === false)
|
|
1396
|
+
return callback(err ? undefined : INVALID);
|
|
1397
|
+
if (err)
|
|
1398
|
+
return callback(err);
|
|
1399
|
+
const resultPath = result.path;
|
|
1400
|
+
if (resultPath !== expectedResult)
|
|
1401
|
+
return callback(INVALID);
|
|
1402
|
+
callback();
|
|
1403
|
+
});
|
|
1404
|
+
break;
|
|
1405
|
+
case 'f':
|
|
1406
|
+
resolveCjs(context, path, {}, (err, _, result) => {
|
|
1407
|
+
if (expectedResult === false)
|
|
1408
|
+
return callback(err ? undefined : INVALID);
|
|
1409
|
+
if (err)
|
|
1410
|
+
return callback(err);
|
|
1411
|
+
const resultPath = result.path;
|
|
1412
|
+
if (resultPath !== expectedResult)
|
|
1413
|
+
return callback(INVALID);
|
|
1414
|
+
callback();
|
|
1415
|
+
});
|
|
1416
|
+
break;
|
|
1417
|
+
case 'c':
|
|
1418
|
+
resolveCjsAsChild(context, path, {}, (err, _, result) => {
|
|
1419
|
+
if (expectedResult === false)
|
|
1420
|
+
return callback(err ? undefined : INVALID);
|
|
1421
|
+
if (err)
|
|
1422
|
+
return callback(err);
|
|
1423
|
+
const resultPath = result.path;
|
|
1424
|
+
if (resultPath !== expectedResult)
|
|
1425
|
+
return callback(INVALID);
|
|
1426
|
+
callback();
|
|
1427
|
+
});
|
|
1428
|
+
break;
|
|
1429
|
+
case 'e':
|
|
1430
|
+
resolveEsm(context, path, {}, (err, _, result) => {
|
|
1431
|
+
if (expectedResult === false)
|
|
1432
|
+
return callback(err ? undefined : INVALID);
|
|
1433
|
+
if (err)
|
|
1434
|
+
return callback(err);
|
|
1435
|
+
const resultPath = result.path;
|
|
1436
|
+
if (resultPath !== expectedResult)
|
|
1437
|
+
return callback(INVALID);
|
|
1438
|
+
callback();
|
|
1439
|
+
});
|
|
1440
|
+
break;
|
|
1441
|
+
default:
|
|
1442
|
+
callback(new Error('Unexpected type in resolve result key'));
|
|
1443
|
+
break;
|
|
1444
|
+
}
|
|
1445
|
+
}, err => {
|
|
1446
|
+
if (err === INVALID) {
|
|
1447
|
+
return callback(null, false);
|
|
1448
|
+
}
|
|
1449
|
+
if (err) {
|
|
1450
|
+
return callback(err);
|
|
1451
|
+
}
|
|
1452
|
+
return callback(null, true);
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
createSnapshot(startTime, files, directories, missing, options, callback) {
|
|
1456
|
+
const fileTimestamps = new Map();
|
|
1457
|
+
const fileHashes = new Map();
|
|
1458
|
+
const fileTshs = new Map();
|
|
1459
|
+
const contextTimestamps = new Map();
|
|
1460
|
+
const contextHashes = new Map();
|
|
1461
|
+
const contextTshs = new Map();
|
|
1462
|
+
const missingExistence = new Map();
|
|
1463
|
+
const managedItemInfo = new Map();
|
|
1464
|
+
const managedFiles = new Set();
|
|
1465
|
+
const managedContexts = new Set();
|
|
1466
|
+
const managedMissing = new Set();
|
|
1467
|
+
const children = new Set();
|
|
1468
|
+
const snapshot = new Snapshot();
|
|
1469
|
+
if (startTime)
|
|
1470
|
+
snapshot.setStartTime(startTime);
|
|
1471
|
+
const managedItems = new Set();
|
|
1472
|
+
/** 1 = timestamp, 2 = hash, 3 = timestamp + hash */
|
|
1473
|
+
const mode = (options === null || options === void 0 ? void 0 : options.hash) ? (options.timestamp ? 3 : 2) : 1;
|
|
1474
|
+
let jobs = 1;
|
|
1475
|
+
const jobDone = () => {
|
|
1476
|
+
if (--jobs === 0) {
|
|
1477
|
+
if (fileTimestamps.size !== 0) {
|
|
1478
|
+
snapshot.setFileTimestamps(fileTimestamps);
|
|
1479
|
+
}
|
|
1480
|
+
if (fileHashes.size !== 0) {
|
|
1481
|
+
snapshot.setFileHashes(fileHashes);
|
|
1482
|
+
}
|
|
1483
|
+
if (fileTshs.size !== 0) {
|
|
1484
|
+
snapshot.setFileTshs(fileTshs);
|
|
1485
|
+
}
|
|
1486
|
+
if (contextTimestamps.size !== 0) {
|
|
1487
|
+
snapshot.setContextTimestamps(contextTimestamps);
|
|
1488
|
+
}
|
|
1489
|
+
if (contextHashes.size !== 0) {
|
|
1490
|
+
snapshot.setContextHashes(contextHashes);
|
|
1491
|
+
}
|
|
1492
|
+
if (contextTshs.size !== 0) {
|
|
1493
|
+
snapshot.setContextTshs(contextTshs);
|
|
1494
|
+
}
|
|
1495
|
+
if (missingExistence.size !== 0) {
|
|
1496
|
+
snapshot.setMissingExistence(missingExistence);
|
|
1497
|
+
}
|
|
1498
|
+
if (managedItemInfo.size !== 0) {
|
|
1499
|
+
snapshot.setManagedItemInfo(managedItemInfo);
|
|
1500
|
+
}
|
|
1501
|
+
this._managedFilesOptimization.optimize(snapshot, managedFiles);
|
|
1502
|
+
if (managedFiles.size !== 0) {
|
|
1503
|
+
snapshot.setManagedFiles(managedFiles);
|
|
1504
|
+
}
|
|
1505
|
+
this._managedContextsOptimization.optimize(snapshot, managedContexts);
|
|
1506
|
+
if (managedContexts.size !== 0) {
|
|
1507
|
+
snapshot.setManagedContexts(managedContexts);
|
|
1508
|
+
}
|
|
1509
|
+
this._managedMissingOptimization.optimize(snapshot, managedMissing);
|
|
1510
|
+
if (managedMissing.size !== 0) {
|
|
1511
|
+
snapshot.setManagedMissing(managedMissing);
|
|
1512
|
+
}
|
|
1513
|
+
if (children.size !== 0) {
|
|
1514
|
+
snapshot.setChildren(children);
|
|
1515
|
+
}
|
|
1516
|
+
this._snapshotCache.set(snapshot, true);
|
|
1517
|
+
this._statCreatedSnapshots++;
|
|
1518
|
+
callback(null, snapshot);
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1521
|
+
const jobError = () => {
|
|
1522
|
+
if (jobs > 0) {
|
|
1523
|
+
// large negative number instead of NaN or something else to keep jobs to stay a SMI (v8)
|
|
1524
|
+
jobs = -100000000;
|
|
1525
|
+
callback(null, null);
|
|
1526
|
+
}
|
|
1527
|
+
};
|
|
1528
|
+
const checkManaged = (path, managedSet) => {
|
|
1529
|
+
for (const immutablePath of this.immutablePathsRegExps) {
|
|
1530
|
+
if (immutablePath.test(path)) {
|
|
1531
|
+
managedSet.add(path);
|
|
1532
|
+
return true;
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
for (const immutablePath of this.immutablePathsWithSlash) {
|
|
1536
|
+
if (path.startsWith(immutablePath)) {
|
|
1537
|
+
managedSet.add(path);
|
|
1538
|
+
return true;
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
for (const managedPath of this.managedPathsRegExps) {
|
|
1542
|
+
const match = managedPath.exec(path);
|
|
1543
|
+
if (match) {
|
|
1544
|
+
const managedItem = getManagedItem(match[1], path);
|
|
1545
|
+
if (managedItem) {
|
|
1546
|
+
managedItems.add(managedItem);
|
|
1547
|
+
managedSet.add(path);
|
|
1548
|
+
return true;
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
for (const managedPath of this.managedPathsWithSlash) {
|
|
1553
|
+
if (path.startsWith(managedPath)) {
|
|
1554
|
+
const managedItem = getManagedItem(managedPath, path);
|
|
1555
|
+
if (managedItem) {
|
|
1556
|
+
managedItems.add(managedItem);
|
|
1557
|
+
managedSet.add(path);
|
|
1558
|
+
return true;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
return false;
|
|
1563
|
+
};
|
|
1564
|
+
const captureNonManaged = (items, managedSet) => {
|
|
1565
|
+
const capturedItems = new Set();
|
|
1566
|
+
for (const path of items) {
|
|
1567
|
+
if (!checkManaged(path, managedSet))
|
|
1568
|
+
capturedItems.add(path);
|
|
1569
|
+
}
|
|
1570
|
+
return capturedItems;
|
|
1571
|
+
};
|
|
1572
|
+
const processCapturedFiles = capturedFiles => {
|
|
1573
|
+
switch (mode) {
|
|
1574
|
+
case 3:
|
|
1575
|
+
this._fileTshsOptimization.optimize(snapshot, capturedFiles);
|
|
1576
|
+
for (const path of capturedFiles) {
|
|
1577
|
+
const cache = this._fileTshs.get(path);
|
|
1578
|
+
if (cache !== undefined) {
|
|
1579
|
+
fileTshs.set(path, cache);
|
|
1580
|
+
}
|
|
1581
|
+
else {
|
|
1582
|
+
jobs++;
|
|
1583
|
+
this._getFileTimestampAndHash(path, (err, entry) => {
|
|
1584
|
+
if (err) {
|
|
1585
|
+
if (this.logger) {
|
|
1586
|
+
this.logger.debug(`Error snapshotting file timestamp hash combination of ${path}: ${err.stack}`);
|
|
1587
|
+
}
|
|
1588
|
+
jobError();
|
|
1589
|
+
}
|
|
1590
|
+
else {
|
|
1591
|
+
fileTshs.set(path, entry);
|
|
1592
|
+
jobDone();
|
|
1593
|
+
}
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
break;
|
|
1598
|
+
case 2:
|
|
1599
|
+
this._fileHashesOptimization.optimize(snapshot, capturedFiles);
|
|
1600
|
+
for (const path of capturedFiles) {
|
|
1601
|
+
const cache = this._fileHashes.get(path);
|
|
1602
|
+
if (cache !== undefined) {
|
|
1603
|
+
fileHashes.set(path, cache);
|
|
1604
|
+
}
|
|
1605
|
+
else {
|
|
1606
|
+
jobs++;
|
|
1607
|
+
this.fileHashQueue.add(path, (err, entry) => {
|
|
1608
|
+
if (err) {
|
|
1609
|
+
if (this.logger) {
|
|
1610
|
+
this.logger.debug(`Error snapshotting file hash of ${path}: ${err.stack}`);
|
|
1611
|
+
}
|
|
1612
|
+
jobError();
|
|
1613
|
+
}
|
|
1614
|
+
else {
|
|
1615
|
+
fileHashes.set(path, entry);
|
|
1616
|
+
jobDone();
|
|
1617
|
+
}
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
break;
|
|
1622
|
+
case 1:
|
|
1623
|
+
this._fileTimestampsOptimization.optimize(snapshot, capturedFiles);
|
|
1624
|
+
for (const path of capturedFiles) {
|
|
1625
|
+
const cache = this._fileTimestamps.get(path);
|
|
1626
|
+
if (cache !== undefined) {
|
|
1627
|
+
if (cache !== 'ignore') {
|
|
1628
|
+
fileTimestamps.set(path, cache);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
else {
|
|
1632
|
+
jobs++;
|
|
1633
|
+
this.fileTimestampQueue.add(path, (err, entry) => {
|
|
1634
|
+
if (err) {
|
|
1635
|
+
if (this.logger) {
|
|
1636
|
+
this.logger.debug(`Error snapshotting file timestamp of ${path}: ${err.stack}`);
|
|
1637
|
+
}
|
|
1638
|
+
jobError();
|
|
1639
|
+
}
|
|
1640
|
+
else {
|
|
1641
|
+
fileTimestamps.set(path, entry);
|
|
1642
|
+
jobDone();
|
|
1643
|
+
}
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
break;
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1650
|
+
if (files) {
|
|
1651
|
+
processCapturedFiles(captureNonManaged(files, managedFiles));
|
|
1652
|
+
}
|
|
1653
|
+
const processCapturedDirectories = capturedDirectories => {
|
|
1654
|
+
switch (mode) {
|
|
1655
|
+
case 3:
|
|
1656
|
+
this._contextTshsOptimization.optimize(snapshot, capturedDirectories);
|
|
1657
|
+
for (const path of capturedDirectories) {
|
|
1658
|
+
const cache = this._contextTshs.get(path);
|
|
1659
|
+
let resolved;
|
|
1660
|
+
if (cache !== undefined && (resolved = getResolvedTimestamp(cache)) !== undefined) {
|
|
1661
|
+
contextTshs.set(path, resolved);
|
|
1662
|
+
}
|
|
1663
|
+
else {
|
|
1664
|
+
jobs++;
|
|
1665
|
+
const callback = (err, entry) => {
|
|
1666
|
+
if (err) {
|
|
1667
|
+
if (this.logger) {
|
|
1668
|
+
this.logger.debug(`Error snapshotting context timestamp hash combination of ${path}: ${err.stack}`);
|
|
1669
|
+
}
|
|
1670
|
+
jobError();
|
|
1671
|
+
}
|
|
1672
|
+
else {
|
|
1673
|
+
contextTshs.set(path, entry);
|
|
1674
|
+
jobDone();
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
if (cache !== undefined) {
|
|
1678
|
+
this._resolveContextTsh(cache, callback);
|
|
1679
|
+
}
|
|
1680
|
+
else {
|
|
1681
|
+
this.getContextTsh(path, callback);
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
break;
|
|
1686
|
+
case 2:
|
|
1687
|
+
this._contextHashesOptimization.optimize(snapshot, capturedDirectories);
|
|
1688
|
+
for (const path of capturedDirectories) {
|
|
1689
|
+
const cache = this._contextHashes.get(path);
|
|
1690
|
+
let resolved;
|
|
1691
|
+
if (cache !== undefined && (resolved = getResolvedHash(cache)) !== undefined) {
|
|
1692
|
+
contextHashes.set(path, resolved);
|
|
1693
|
+
}
|
|
1694
|
+
else {
|
|
1695
|
+
jobs++;
|
|
1696
|
+
const callback = (err, entry) => {
|
|
1697
|
+
if (err) {
|
|
1698
|
+
if (this.logger) {
|
|
1699
|
+
this.logger.debug(`Error snapshotting context hash of ${path}: ${err.stack}`);
|
|
1700
|
+
}
|
|
1701
|
+
jobError();
|
|
1702
|
+
}
|
|
1703
|
+
else {
|
|
1704
|
+
contextHashes.set(path, entry);
|
|
1705
|
+
jobDone();
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
if (cache !== undefined) {
|
|
1709
|
+
this._resolveContextHash(cache, callback);
|
|
1710
|
+
}
|
|
1711
|
+
else {
|
|
1712
|
+
this.getContextHash(path, callback);
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
break;
|
|
1717
|
+
case 1:
|
|
1718
|
+
this._contextTimestampsOptimization.optimize(snapshot, capturedDirectories);
|
|
1719
|
+
for (const path of capturedDirectories) {
|
|
1720
|
+
const cache = this._contextTimestamps.get(path);
|
|
1721
|
+
if (cache === 'ignore')
|
|
1722
|
+
continue;
|
|
1723
|
+
let resolved;
|
|
1724
|
+
if (cache !== undefined && (resolved = getResolvedTimestamp(cache)) !== undefined) {
|
|
1725
|
+
contextTimestamps.set(path, resolved);
|
|
1726
|
+
}
|
|
1727
|
+
else {
|
|
1728
|
+
jobs++;
|
|
1729
|
+
const callback = (err, entry) => {
|
|
1730
|
+
if (err) {
|
|
1731
|
+
if (this.logger) {
|
|
1732
|
+
this.logger.debug(`Error snapshotting context timestamp of ${path}: ${err.stack}`);
|
|
1733
|
+
}
|
|
1734
|
+
jobError();
|
|
1735
|
+
}
|
|
1736
|
+
else {
|
|
1737
|
+
contextTimestamps.set(path, entry);
|
|
1738
|
+
jobDone();
|
|
1739
|
+
}
|
|
1740
|
+
};
|
|
1741
|
+
if (cache !== undefined) {
|
|
1742
|
+
this._resolveContextTimestamp(cache, callback);
|
|
1743
|
+
}
|
|
1744
|
+
else {
|
|
1745
|
+
this.getContextTimestamp(path, callback);
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
break;
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
if (directories) {
|
|
1753
|
+
processCapturedDirectories(captureNonManaged(directories, managedContexts));
|
|
1754
|
+
}
|
|
1755
|
+
const processCapturedMissing = capturedMissing => {
|
|
1756
|
+
this._missingExistenceOptimization.optimize(snapshot, capturedMissing);
|
|
1757
|
+
for (const path of capturedMissing) {
|
|
1758
|
+
const cache = this._fileTimestamps.get(path);
|
|
1759
|
+
if (cache !== undefined) {
|
|
1760
|
+
if (cache !== 'ignore') {
|
|
1761
|
+
missingExistence.set(path, Boolean(cache));
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
else {
|
|
1765
|
+
jobs++;
|
|
1766
|
+
this.fileTimestampQueue.add(path, (err, entry) => {
|
|
1767
|
+
if (err) {
|
|
1768
|
+
if (this.logger) {
|
|
1769
|
+
this.logger.debug(`Error snapshotting missing timestamp of ${path}: ${err.stack}`);
|
|
1770
|
+
}
|
|
1771
|
+
jobError();
|
|
1772
|
+
}
|
|
1773
|
+
else {
|
|
1774
|
+
missingExistence.set(path, Boolean(entry));
|
|
1775
|
+
jobDone();
|
|
1776
|
+
}
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
};
|
|
1781
|
+
if (missing) {
|
|
1782
|
+
processCapturedMissing(captureNonManaged(missing, managedMissing));
|
|
1783
|
+
}
|
|
1784
|
+
this._managedItemInfoOptimization.optimize(snapshot, managedItems);
|
|
1785
|
+
for (const path of managedItems) {
|
|
1786
|
+
const cache = this._managedItems.get(path);
|
|
1787
|
+
if (cache !== undefined) {
|
|
1788
|
+
if (!cache.startsWith('*')) {
|
|
1789
|
+
managedFiles.add((0, fs_1.join)(this.fs, path, 'package.json'));
|
|
1790
|
+
}
|
|
1791
|
+
else if (cache === '*nested') {
|
|
1792
|
+
managedMissing.add((0, fs_1.join)(this.fs, path, 'package.json'));
|
|
1793
|
+
}
|
|
1794
|
+
managedItemInfo.set(path, cache);
|
|
1795
|
+
}
|
|
1796
|
+
else {
|
|
1797
|
+
jobs++;
|
|
1798
|
+
this.managedItemQueue.add(path, (err, entry) => {
|
|
1799
|
+
if (err) {
|
|
1800
|
+
if (this.logger) {
|
|
1801
|
+
this.logger.debug(`Error snapshotting managed item ${path}: ${err.stack}`);
|
|
1802
|
+
}
|
|
1803
|
+
jobError();
|
|
1804
|
+
}
|
|
1805
|
+
else if (entry) {
|
|
1806
|
+
if (!entry.startsWith('*')) {
|
|
1807
|
+
managedFiles.add((0, fs_1.join)(this.fs, path, 'package.json'));
|
|
1808
|
+
}
|
|
1809
|
+
else if (cache === '*nested') {
|
|
1810
|
+
managedMissing.add((0, fs_1.join)(this.fs, path, 'package.json'));
|
|
1811
|
+
}
|
|
1812
|
+
managedItemInfo.set(path, entry);
|
|
1813
|
+
jobDone();
|
|
1814
|
+
}
|
|
1815
|
+
else {
|
|
1816
|
+
// Fallback to normal snapshotting
|
|
1817
|
+
const process = (set, fn) => {
|
|
1818
|
+
if (set.size === 0)
|
|
1819
|
+
return;
|
|
1820
|
+
const captured = new Set();
|
|
1821
|
+
for (const file of set) {
|
|
1822
|
+
if (file.startsWith(path))
|
|
1823
|
+
captured.add(file);
|
|
1824
|
+
}
|
|
1825
|
+
if (captured.size > 0)
|
|
1826
|
+
fn(captured);
|
|
1827
|
+
};
|
|
1828
|
+
process(managedFiles, processCapturedFiles);
|
|
1829
|
+
process(managedContexts, processCapturedDirectories);
|
|
1830
|
+
process(managedMissing, processCapturedMissing);
|
|
1831
|
+
jobDone();
|
|
1832
|
+
}
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
jobDone();
|
|
1837
|
+
}
|
|
1838
|
+
mergeSnapshots(snapshot1, snapshot2) {
|
|
1839
|
+
const snapshot = new Snapshot();
|
|
1840
|
+
if (snapshot1.hasStartTime() && snapshot2.hasStartTime())
|
|
1841
|
+
snapshot.setStartTime(Math.min(snapshot1.startTime, snapshot2.startTime));
|
|
1842
|
+
else if (snapshot2.hasStartTime())
|
|
1843
|
+
snapshot.startTime = snapshot2.startTime;
|
|
1844
|
+
else if (snapshot1.hasStartTime())
|
|
1845
|
+
snapshot.startTime = snapshot1.startTime;
|
|
1846
|
+
if (snapshot1.hasFileTimestamps() || snapshot2.hasFileTimestamps()) {
|
|
1847
|
+
snapshot.setFileTimestamps(mergeMaps(snapshot1.fileTimestamps, snapshot2.fileTimestamps));
|
|
1848
|
+
}
|
|
1849
|
+
if (snapshot1.hasFileHashes() || snapshot2.hasFileHashes()) {
|
|
1850
|
+
snapshot.setFileHashes(mergeMaps(snapshot1.fileHashes, snapshot2.fileHashes));
|
|
1851
|
+
}
|
|
1852
|
+
if (snapshot1.hasFileTshs() || snapshot2.hasFileTshs()) {
|
|
1853
|
+
snapshot.setFileTshs(mergeMaps(snapshot1.fileTshs, snapshot2.fileTshs));
|
|
1854
|
+
}
|
|
1855
|
+
if (snapshot1.hasContextTimestamps() || snapshot2.hasContextTimestamps()) {
|
|
1856
|
+
snapshot.setContextTimestamps(mergeMaps(snapshot1.contextTimestamps, snapshot2.contextTimestamps));
|
|
1857
|
+
}
|
|
1858
|
+
if (snapshot1.hasContextHashes() || snapshot2.hasContextHashes()) {
|
|
1859
|
+
snapshot.setContextHashes(mergeMaps(snapshot1.contextHashes, snapshot2.contextHashes));
|
|
1860
|
+
}
|
|
1861
|
+
if (snapshot1.hasContextTshs() || snapshot2.hasContextTshs()) {
|
|
1862
|
+
snapshot.setContextTshs(mergeMaps(snapshot1.contextTshs, snapshot2.contextTshs));
|
|
1863
|
+
}
|
|
1864
|
+
if (snapshot1.hasMissingExistence() || snapshot2.hasMissingExistence()) {
|
|
1865
|
+
snapshot.setMissingExistence(mergeMaps(snapshot1.missingExistence, snapshot2.missingExistence));
|
|
1866
|
+
}
|
|
1867
|
+
if (snapshot1.hasManagedItemInfo() || snapshot2.hasManagedItemInfo()) {
|
|
1868
|
+
snapshot.setManagedItemInfo(mergeMaps(snapshot1.managedItemInfo, snapshot2.managedItemInfo));
|
|
1869
|
+
}
|
|
1870
|
+
if (snapshot1.hasManagedFiles() || snapshot2.hasManagedFiles()) {
|
|
1871
|
+
snapshot.setManagedFiles(mergeSets(snapshot1.managedFiles, snapshot2.managedFiles));
|
|
1872
|
+
}
|
|
1873
|
+
if (snapshot1.hasManagedContexts() || snapshot2.hasManagedContexts()) {
|
|
1874
|
+
snapshot.setManagedContexts(mergeSets(snapshot1.managedContexts, snapshot2.managedContexts));
|
|
1875
|
+
}
|
|
1876
|
+
if (snapshot1.hasManagedMissing() || snapshot2.hasManagedMissing()) {
|
|
1877
|
+
snapshot.setManagedMissing(mergeSets(snapshot1.managedMissing, snapshot2.managedMissing));
|
|
1878
|
+
}
|
|
1879
|
+
if (snapshot1.hasChildren() || snapshot2.hasChildren()) {
|
|
1880
|
+
snapshot.setChildren(mergeSets(snapshot1.children, snapshot2.children));
|
|
1881
|
+
}
|
|
1882
|
+
if (this._snapshotCache.get(snapshot1) === true &&
|
|
1883
|
+
this._snapshotCache.get(snapshot2) === true) {
|
|
1884
|
+
this._snapshotCache.set(snapshot, true);
|
|
1885
|
+
}
|
|
1886
|
+
return snapshot;
|
|
1887
|
+
}
|
|
1888
|
+
checkSnapshotValid(snapshot, callback) {
|
|
1889
|
+
const cachedResult = this._snapshotCache.get(snapshot);
|
|
1890
|
+
if (cachedResult !== undefined) {
|
|
1891
|
+
this._statTestedSnapshotsCached++;
|
|
1892
|
+
if (typeof cachedResult === 'boolean') {
|
|
1893
|
+
callback(null, cachedResult);
|
|
1894
|
+
}
|
|
1895
|
+
else {
|
|
1896
|
+
cachedResult.push(callback);
|
|
1897
|
+
}
|
|
1898
|
+
return;
|
|
1899
|
+
}
|
|
1900
|
+
this._statTestedSnapshotsNotCached++;
|
|
1901
|
+
this._checkSnapshotValidNoCache(snapshot, callback);
|
|
1902
|
+
}
|
|
1903
|
+
_checkSnapshotValidNoCache(snapshot, callback) {
|
|
1904
|
+
let startTime;
|
|
1905
|
+
if (snapshot.hasStartTime()) {
|
|
1906
|
+
startTime = snapshot.startTime;
|
|
1907
|
+
}
|
|
1908
|
+
let jobs = 1;
|
|
1909
|
+
const jobDone = () => {
|
|
1910
|
+
if (--jobs === 0) {
|
|
1911
|
+
this._snapshotCache.set(snapshot, true);
|
|
1912
|
+
callback(null, true);
|
|
1913
|
+
}
|
|
1914
|
+
};
|
|
1915
|
+
const invalid = () => {
|
|
1916
|
+
if (jobs > 0) {
|
|
1917
|
+
// large negative number instead of NaN or something else to keep jobs to stay a SMI (v8)
|
|
1918
|
+
jobs = -100000000;
|
|
1919
|
+
this._snapshotCache.set(snapshot, false);
|
|
1920
|
+
callback(null, false);
|
|
1921
|
+
}
|
|
1922
|
+
};
|
|
1923
|
+
const invalidWithError = (path, err) => {
|
|
1924
|
+
if (this._remainingLogs > 0) {
|
|
1925
|
+
this._log(path, `error occurred: %s`, err);
|
|
1926
|
+
}
|
|
1927
|
+
invalid();
|
|
1928
|
+
};
|
|
1929
|
+
const checkHash = (path, current, snap) => {
|
|
1930
|
+
if (current !== snap) {
|
|
1931
|
+
// If hash differ it's invalid
|
|
1932
|
+
if (this._remainingLogs > 0) {
|
|
1933
|
+
this._log(path, `hashes differ (%s != %s)`, current, snap);
|
|
1934
|
+
}
|
|
1935
|
+
return false;
|
|
1936
|
+
}
|
|
1937
|
+
return true;
|
|
1938
|
+
};
|
|
1939
|
+
const checkExistence = (path, current, snap) => {
|
|
1940
|
+
if (!current !== !snap) {
|
|
1941
|
+
// If existence of item differs
|
|
1942
|
+
// it's invalid
|
|
1943
|
+
if (this._remainingLogs > 0) {
|
|
1944
|
+
this._log(path, current ? "it didn't exist before" : 'it does no longer exist');
|
|
1945
|
+
}
|
|
1946
|
+
return false;
|
|
1947
|
+
}
|
|
1948
|
+
return true;
|
|
1949
|
+
};
|
|
1950
|
+
const checkFile = (path, current, snap, log = true) => {
|
|
1951
|
+
if (current === snap)
|
|
1952
|
+
return true;
|
|
1953
|
+
if (!checkExistence(path, Boolean(current), Boolean(snap)))
|
|
1954
|
+
return false;
|
|
1955
|
+
if (current) {
|
|
1956
|
+
// For existing items only
|
|
1957
|
+
if (typeof startTime === 'number' && current.safeTime > startTime) {
|
|
1958
|
+
// If a change happened after starting reading the item
|
|
1959
|
+
// this may no longer be valid
|
|
1960
|
+
if (log && this._remainingLogs > 0) {
|
|
1961
|
+
this._log(path, `it may have changed (%d) after the start time of the snapshot (%d)`, current.safeTime, startTime);
|
|
1962
|
+
}
|
|
1963
|
+
return false;
|
|
1964
|
+
}
|
|
1965
|
+
if (snap.timestamp !== undefined && current.timestamp !== snap.timestamp) {
|
|
1966
|
+
// If we have a timestamp (it was a file or symlink) and it differs from current timestamp
|
|
1967
|
+
// it's invalid
|
|
1968
|
+
if (log && this._remainingLogs > 0) {
|
|
1969
|
+
this._log(path, `timestamps differ (%d != %d)`, current.timestamp, snap.timestamp);
|
|
1970
|
+
}
|
|
1971
|
+
return false;
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
return true;
|
|
1975
|
+
};
|
|
1976
|
+
const checkContext = (path, current, snap, log = true) => {
|
|
1977
|
+
if (current === snap)
|
|
1978
|
+
return true;
|
|
1979
|
+
if (!checkExistence(path, Boolean(current), Boolean(snap)))
|
|
1980
|
+
return false;
|
|
1981
|
+
if (current) {
|
|
1982
|
+
// For existing items only
|
|
1983
|
+
if (typeof startTime === 'number' && current.safeTime > startTime) {
|
|
1984
|
+
// If a change happened after starting reading the item
|
|
1985
|
+
// this may no longer be valid
|
|
1986
|
+
if (log && this._remainingLogs > 0) {
|
|
1987
|
+
this._log(path, `it may have changed (%d) after the start time of the snapshot (%d)`, current.safeTime, startTime);
|
|
1988
|
+
}
|
|
1989
|
+
return false;
|
|
1990
|
+
}
|
|
1991
|
+
if (snap.timestampHash !== undefined && current.timestampHash !== snap.timestampHash) {
|
|
1992
|
+
// If we have a timestampHash (it was a directory) and it differs from current timestampHash
|
|
1993
|
+
// it's invalid
|
|
1994
|
+
if (log && this._remainingLogs > 0) {
|
|
1995
|
+
this._log(path, `timestamps hashes differ (%s != %s)`, current.timestampHash, snap.timestampHash);
|
|
1996
|
+
}
|
|
1997
|
+
return false;
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
return true;
|
|
2001
|
+
};
|
|
2002
|
+
if (snapshot.hasChildren()) {
|
|
2003
|
+
const childCallback = (err, result) => {
|
|
2004
|
+
if (err || !result)
|
|
2005
|
+
return invalid();
|
|
2006
|
+
jobDone();
|
|
2007
|
+
};
|
|
2008
|
+
for (const child of snapshot.children) {
|
|
2009
|
+
const cache = this._snapshotCache.get(child);
|
|
2010
|
+
if (cache !== undefined) {
|
|
2011
|
+
this._statTestedChildrenCached++;
|
|
2012
|
+
/* istanbul ignore else */
|
|
2013
|
+
if (typeof cache === 'boolean') {
|
|
2014
|
+
if (cache === false) {
|
|
2015
|
+
invalid();
|
|
2016
|
+
return;
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
else {
|
|
2020
|
+
jobs++;
|
|
2021
|
+
cache.push(childCallback);
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
else {
|
|
2025
|
+
this._statTestedChildrenNotCached++;
|
|
2026
|
+
jobs++;
|
|
2027
|
+
this._checkSnapshotValidNoCache(child, childCallback);
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
if (snapshot.hasFileTimestamps()) {
|
|
2032
|
+
const { fileTimestamps } = snapshot;
|
|
2033
|
+
this._statTestedEntries += fileTimestamps.size;
|
|
2034
|
+
for (const [path, ts] of fileTimestamps) {
|
|
2035
|
+
const cache = this._fileTimestamps.get(path);
|
|
2036
|
+
if (cache !== undefined) {
|
|
2037
|
+
if (cache !== 'ignore' && !checkFile(path, cache, ts)) {
|
|
2038
|
+
invalid();
|
|
2039
|
+
return;
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
else {
|
|
2043
|
+
jobs++;
|
|
2044
|
+
this.fileTimestampQueue.add(path, (err, entry) => {
|
|
2045
|
+
if (err)
|
|
2046
|
+
return invalidWithError(path, err);
|
|
2047
|
+
if (!checkFile(path, entry, ts)) {
|
|
2048
|
+
invalid();
|
|
2049
|
+
}
|
|
2050
|
+
else {
|
|
2051
|
+
jobDone();
|
|
2052
|
+
}
|
|
2053
|
+
});
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
const processFileHashSnapshot = (path, hash) => {
|
|
2058
|
+
const cache = this._fileHashes.get(path);
|
|
2059
|
+
if (cache !== undefined) {
|
|
2060
|
+
if (cache !== 'ignore' && !checkHash(path, cache, hash)) {
|
|
2061
|
+
invalid();
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
else {
|
|
2065
|
+
jobs++;
|
|
2066
|
+
this.fileHashQueue.add(path, (err, entry) => {
|
|
2067
|
+
if (err)
|
|
2068
|
+
return invalidWithError(path, err);
|
|
2069
|
+
if (!checkHash(path, entry, hash)) {
|
|
2070
|
+
invalid();
|
|
2071
|
+
}
|
|
2072
|
+
else {
|
|
2073
|
+
jobDone();
|
|
2074
|
+
}
|
|
2075
|
+
});
|
|
2076
|
+
}
|
|
2077
|
+
};
|
|
2078
|
+
if (snapshot.hasFileHashes()) {
|
|
2079
|
+
const { fileHashes } = snapshot;
|
|
2080
|
+
this._statTestedEntries += fileHashes.size;
|
|
2081
|
+
for (const [path, hash] of fileHashes) {
|
|
2082
|
+
processFileHashSnapshot(path, hash);
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
if (snapshot.hasFileTshs()) {
|
|
2086
|
+
const { fileTshs } = snapshot;
|
|
2087
|
+
this._statTestedEntries += fileTshs.size;
|
|
2088
|
+
for (const [path, tsh] of fileTshs) {
|
|
2089
|
+
if (typeof tsh === 'string') {
|
|
2090
|
+
processFileHashSnapshot(path, tsh);
|
|
2091
|
+
}
|
|
2092
|
+
else {
|
|
2093
|
+
const cache = this._fileTimestamps.get(path);
|
|
2094
|
+
if (cache !== undefined) {
|
|
2095
|
+
if (cache === 'ignore' || !checkFile(path, cache, tsh, false)) {
|
|
2096
|
+
processFileHashSnapshot(path, tsh === null || tsh === void 0 ? void 0 : tsh.hash);
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
else {
|
|
2100
|
+
jobs++;
|
|
2101
|
+
this.fileTimestampQueue.add(path, (err, entry) => {
|
|
2102
|
+
if (err)
|
|
2103
|
+
return invalidWithError(path, err);
|
|
2104
|
+
if (!checkFile(path, entry, tsh, false)) {
|
|
2105
|
+
processFileHashSnapshot(path, tsh === null || tsh === void 0 ? void 0 : tsh.hash);
|
|
2106
|
+
}
|
|
2107
|
+
jobDone();
|
|
2108
|
+
});
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
if (snapshot.hasContextTimestamps()) {
|
|
2114
|
+
const { contextTimestamps } = snapshot;
|
|
2115
|
+
this._statTestedEntries += contextTimestamps.size;
|
|
2116
|
+
for (const [path, ts] of contextTimestamps) {
|
|
2117
|
+
const cache = this._contextTimestamps.get(path);
|
|
2118
|
+
if (cache === 'ignore')
|
|
2119
|
+
continue;
|
|
2120
|
+
let resolved;
|
|
2121
|
+
if (cache !== undefined && (resolved = getResolvedTimestamp(cache)) !== undefined) {
|
|
2122
|
+
if (!checkContext(path, resolved, ts)) {
|
|
2123
|
+
invalid();
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
else {
|
|
2128
|
+
jobs++;
|
|
2129
|
+
const callback = (err, entry) => {
|
|
2130
|
+
if (err)
|
|
2131
|
+
return invalidWithError(path, err);
|
|
2132
|
+
if (!checkContext(path, entry, ts)) {
|
|
2133
|
+
invalid();
|
|
2134
|
+
}
|
|
2135
|
+
else {
|
|
2136
|
+
jobDone();
|
|
2137
|
+
}
|
|
2138
|
+
};
|
|
2139
|
+
if (cache !== undefined) {
|
|
2140
|
+
this._resolveContextTimestamp(cache, callback);
|
|
2141
|
+
}
|
|
2142
|
+
else {
|
|
2143
|
+
this.getContextTimestamp(path, callback);
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
const processContextHashSnapshot = (path, hash) => {
|
|
2149
|
+
const cache = this._contextHashes.get(path);
|
|
2150
|
+
let resolved;
|
|
2151
|
+
if (cache !== undefined && (resolved = getResolvedHash(cache)) !== undefined) {
|
|
2152
|
+
if (!checkHash(path, resolved, hash)) {
|
|
2153
|
+
invalid();
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
else {
|
|
2157
|
+
jobs++;
|
|
2158
|
+
const callback = (err, entry) => {
|
|
2159
|
+
if (err)
|
|
2160
|
+
return invalidWithError(path, err);
|
|
2161
|
+
if (!checkHash(path, entry, hash)) {
|
|
2162
|
+
invalid();
|
|
2163
|
+
}
|
|
2164
|
+
else {
|
|
2165
|
+
jobDone();
|
|
2166
|
+
}
|
|
2167
|
+
};
|
|
2168
|
+
if (cache !== undefined) {
|
|
2169
|
+
this._resolveContextHash(cache, callback);
|
|
2170
|
+
}
|
|
2171
|
+
else {
|
|
2172
|
+
this.getContextHash(path, callback);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
};
|
|
2176
|
+
if (snapshot.hasContextHashes()) {
|
|
2177
|
+
const { contextHashes } = snapshot;
|
|
2178
|
+
this._statTestedEntries += contextHashes.size;
|
|
2179
|
+
for (const [path, hash] of contextHashes) {
|
|
2180
|
+
processContextHashSnapshot(path, hash);
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
if (snapshot.hasContextTshs()) {
|
|
2184
|
+
const { contextTshs } = snapshot;
|
|
2185
|
+
this._statTestedEntries += contextTshs.size;
|
|
2186
|
+
for (const [path, tsh] of contextTshs) {
|
|
2187
|
+
if (typeof tsh === 'string') {
|
|
2188
|
+
processContextHashSnapshot(path, tsh);
|
|
2189
|
+
}
|
|
2190
|
+
else {
|
|
2191
|
+
const cache = this._contextTimestamps.get(path);
|
|
2192
|
+
if (cache === 'ignore')
|
|
2193
|
+
continue;
|
|
2194
|
+
let resolved;
|
|
2195
|
+
if (cache !== undefined && (resolved = getResolvedTimestamp(cache)) !== undefined) {
|
|
2196
|
+
if (!checkContext(path, resolved, tsh, false)) {
|
|
2197
|
+
processContextHashSnapshot(path, tsh === null || tsh === void 0 ? void 0 : tsh.hash);
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
else {
|
|
2201
|
+
jobs++;
|
|
2202
|
+
const callback = (err, entry) => {
|
|
2203
|
+
if (err)
|
|
2204
|
+
return invalidWithError(path, err);
|
|
2205
|
+
if (!checkContext(path, entry, tsh, false)) {
|
|
2206
|
+
processContextHashSnapshot(path, tsh === null || tsh === void 0 ? void 0 : tsh.hash);
|
|
2207
|
+
}
|
|
2208
|
+
jobDone();
|
|
2209
|
+
};
|
|
2210
|
+
if (cache !== undefined) {
|
|
2211
|
+
this._resolveContextTimestamp(cache, callback);
|
|
2212
|
+
}
|
|
2213
|
+
else {
|
|
2214
|
+
this.getContextTimestamp(path, callback);
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
if (snapshot.hasMissingExistence()) {
|
|
2221
|
+
const { missingExistence } = snapshot;
|
|
2222
|
+
this._statTestedEntries += missingExistence.size;
|
|
2223
|
+
for (const [path, existence] of missingExistence) {
|
|
2224
|
+
const cache = this._fileTimestamps.get(path);
|
|
2225
|
+
if (cache !== undefined) {
|
|
2226
|
+
if (cache !== 'ignore' && !checkExistence(path, Boolean(cache), Boolean(existence))) {
|
|
2227
|
+
invalid();
|
|
2228
|
+
return;
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
else {
|
|
2232
|
+
jobs++;
|
|
2233
|
+
this.fileTimestampQueue.add(path, (err, entry) => {
|
|
2234
|
+
if (err)
|
|
2235
|
+
return invalidWithError(path, err);
|
|
2236
|
+
if (!checkExistence(path, Boolean(entry), Boolean(existence))) {
|
|
2237
|
+
invalid();
|
|
2238
|
+
}
|
|
2239
|
+
else {
|
|
2240
|
+
jobDone();
|
|
2241
|
+
}
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
if (snapshot.hasManagedItemInfo()) {
|
|
2247
|
+
const { managedItemInfo } = snapshot;
|
|
2248
|
+
this._statTestedEntries += managedItemInfo.size;
|
|
2249
|
+
for (const [path, info] of managedItemInfo) {
|
|
2250
|
+
const cache = this._managedItems.get(path);
|
|
2251
|
+
if (cache !== undefined) {
|
|
2252
|
+
if (!checkHash(path, cache, info)) {
|
|
2253
|
+
invalid();
|
|
2254
|
+
return;
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
else {
|
|
2258
|
+
jobs++;
|
|
2259
|
+
this.managedItemQueue.add(path, (err, entry) => {
|
|
2260
|
+
if (err)
|
|
2261
|
+
return invalidWithError(path, err);
|
|
2262
|
+
if (!checkHash(path, entry, info)) {
|
|
2263
|
+
invalid();
|
|
2264
|
+
}
|
|
2265
|
+
else {
|
|
2266
|
+
jobDone();
|
|
2267
|
+
}
|
|
2268
|
+
});
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
jobDone();
|
|
2273
|
+
// if there was an async action
|
|
2274
|
+
// try to join multiple concurrent request for this snapshot
|
|
2275
|
+
if (jobs > 0) {
|
|
2276
|
+
const callbacks = [callback];
|
|
2277
|
+
callback = (err, result) => {
|
|
2278
|
+
for (const callback of callbacks)
|
|
2279
|
+
callback(err, result);
|
|
2280
|
+
};
|
|
2281
|
+
this._snapshotCache.set(snapshot, callbacks);
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
_readFileTimestamp(path, callback) {
|
|
2285
|
+
this.fs.stat(path, (err, stat) => {
|
|
2286
|
+
if (err) {
|
|
2287
|
+
if (err.code === 'ENOENT') {
|
|
2288
|
+
this._fileTimestamps.set(path, null);
|
|
2289
|
+
this._cachedDeprecatedFileTimestamps = undefined;
|
|
2290
|
+
return callback(null, null);
|
|
2291
|
+
}
|
|
2292
|
+
return callback(err);
|
|
2293
|
+
}
|
|
2294
|
+
let ts;
|
|
2295
|
+
if (stat.isDirectory()) {
|
|
2296
|
+
ts = {
|
|
2297
|
+
safeTime: 0,
|
|
2298
|
+
timestamp: undefined,
|
|
2299
|
+
};
|
|
2300
|
+
}
|
|
2301
|
+
else {
|
|
2302
|
+
const mtime = +stat.mtime;
|
|
2303
|
+
if (mtime)
|
|
2304
|
+
applyMtime(mtime);
|
|
2305
|
+
ts = {
|
|
2306
|
+
safeTime: mtime ? mtime + FS_ACCURACY : Infinity,
|
|
2307
|
+
timestamp: mtime,
|
|
2308
|
+
};
|
|
2309
|
+
}
|
|
2310
|
+
this._fileTimestamps.set(path, ts);
|
|
2311
|
+
this._cachedDeprecatedFileTimestamps = undefined;
|
|
2312
|
+
callback(null, ts);
|
|
2313
|
+
});
|
|
2314
|
+
}
|
|
2315
|
+
_readFileHash(path, callback) {
|
|
2316
|
+
this.fs.readFile(path, (err, content) => {
|
|
2317
|
+
if (err) {
|
|
2318
|
+
if (err.code === 'EISDIR') {
|
|
2319
|
+
this._fileHashes.set(path, 'directory');
|
|
2320
|
+
return callback(null, 'directory');
|
|
2321
|
+
}
|
|
2322
|
+
if (err.code === 'ENOENT') {
|
|
2323
|
+
this._fileHashes.set(path, null);
|
|
2324
|
+
return callback(null, null);
|
|
2325
|
+
}
|
|
2326
|
+
if (err.code === 'ERR_FS_FILE_TOO_LARGE') {
|
|
2327
|
+
this.logger.warn(`Ignoring ${path} for hashing as it's very large`);
|
|
2328
|
+
this._fileHashes.set(path, 'too large');
|
|
2329
|
+
return callback(null, 'too large');
|
|
2330
|
+
}
|
|
2331
|
+
return callback(err);
|
|
2332
|
+
}
|
|
2333
|
+
const hash = (0, createHash_1.default)(this._hashFunction);
|
|
2334
|
+
hash.update(content);
|
|
2335
|
+
const digest = hash.digest('hex');
|
|
2336
|
+
this._fileHashes.set(path, digest);
|
|
2337
|
+
callback(null, digest);
|
|
2338
|
+
});
|
|
2339
|
+
}
|
|
2340
|
+
_getFileTimestampAndHash(path, callback) {
|
|
2341
|
+
const continueWithHash = hash => {
|
|
2342
|
+
const cache = this._fileTimestamps.get(path);
|
|
2343
|
+
if (cache !== undefined) {
|
|
2344
|
+
if (cache !== 'ignore') {
|
|
2345
|
+
const result = Object.assign(Object.assign({}, cache), { hash });
|
|
2346
|
+
this._fileTshs.set(path, result);
|
|
2347
|
+
return callback(null, result);
|
|
2348
|
+
}
|
|
2349
|
+
this._fileTshs.set(path, hash);
|
|
2350
|
+
return callback(null, hash);
|
|
2351
|
+
}
|
|
2352
|
+
this.fileTimestampQueue.add(path, (err, entry) => {
|
|
2353
|
+
if (err) {
|
|
2354
|
+
return callback(err);
|
|
2355
|
+
}
|
|
2356
|
+
const result = Object.assign(Object.assign({}, entry), { hash });
|
|
2357
|
+
this._fileTshs.set(path, result);
|
|
2358
|
+
return callback(null, result);
|
|
2359
|
+
});
|
|
2360
|
+
};
|
|
2361
|
+
const cache = this._fileHashes.get(path);
|
|
2362
|
+
if (cache !== undefined) {
|
|
2363
|
+
continueWithHash(cache);
|
|
2364
|
+
}
|
|
2365
|
+
else {
|
|
2366
|
+
this.fileHashQueue.add(path, (err, entry) => {
|
|
2367
|
+
if (err) {
|
|
2368
|
+
return callback(err);
|
|
2369
|
+
}
|
|
2370
|
+
continueWithHash(entry);
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
_readContext({ path, fromImmutablePath, fromManagedItem, fromSymlink, fromFile, fromDirectory, reduce }, callback) {
|
|
2375
|
+
this.fs.readdir(path, (err, _files) => {
|
|
2376
|
+
if (err) {
|
|
2377
|
+
if (err.code === 'ENOENT') {
|
|
2378
|
+
return callback(null, null);
|
|
2379
|
+
}
|
|
2380
|
+
return callback(err);
|
|
2381
|
+
}
|
|
2382
|
+
const files = _files
|
|
2383
|
+
.map(file => file.normalize('NFC'))
|
|
2384
|
+
.filter(file => !/^\./.test(file))
|
|
2385
|
+
.sort();
|
|
2386
|
+
neo_async_1.default.map(files, (file, callback) => {
|
|
2387
|
+
const child = (0, fs_1.join)(this.fs, path, file);
|
|
2388
|
+
for (const immutablePath of this.immutablePathsRegExps) {
|
|
2389
|
+
if (immutablePath.test(path)) {
|
|
2390
|
+
// ignore any immutable path for timestamping
|
|
2391
|
+
return callback(null, fromImmutablePath(path));
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
for (const immutablePath of this.immutablePathsWithSlash) {
|
|
2395
|
+
if (path.startsWith(immutablePath)) {
|
|
2396
|
+
// ignore any immutable path for timestamping
|
|
2397
|
+
return callback(null, fromImmutablePath(path));
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
for (const managedPath of this.managedPathsRegExps) {
|
|
2401
|
+
const match = managedPath.exec(path);
|
|
2402
|
+
if (match) {
|
|
2403
|
+
const managedItem = getManagedItem(match[1], path);
|
|
2404
|
+
if (managedItem) {
|
|
2405
|
+
// construct timestampHash from managed info
|
|
2406
|
+
return this.managedItemQueue.add(managedItem, (err, info) => {
|
|
2407
|
+
if (err)
|
|
2408
|
+
return callback(err);
|
|
2409
|
+
return callback(null, fromManagedItem(info));
|
|
2410
|
+
});
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
for (const managedPath of this.managedPathsWithSlash) {
|
|
2415
|
+
if (path.startsWith(managedPath)) {
|
|
2416
|
+
const managedItem = getManagedItem(managedPath, child);
|
|
2417
|
+
if (managedItem) {
|
|
2418
|
+
// construct timestampHash from managed info
|
|
2419
|
+
return this.managedItemQueue.add(managedItem, (err, info) => {
|
|
2420
|
+
if (err)
|
|
2421
|
+
return callback(err);
|
|
2422
|
+
return callback(null, fromManagedItem(info));
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
(0, fs_1.lstatReadlinkAbsolute)(this.fs, child, (err, stat) => {
|
|
2428
|
+
if (err)
|
|
2429
|
+
return callback(err);
|
|
2430
|
+
if (typeof stat === 'string') {
|
|
2431
|
+
return fromSymlink(child, stat, callback);
|
|
2432
|
+
}
|
|
2433
|
+
if (stat.isFile()) {
|
|
2434
|
+
return fromFile(child, stat, callback);
|
|
2435
|
+
}
|
|
2436
|
+
if (stat.isDirectory()) {
|
|
2437
|
+
return fromDirectory(child, stat, callback);
|
|
2438
|
+
}
|
|
2439
|
+
callback(null, null);
|
|
2440
|
+
});
|
|
2441
|
+
}, (err, results) => {
|
|
2442
|
+
if (err)
|
|
2443
|
+
return callback(err);
|
|
2444
|
+
const result = reduce(files, results);
|
|
2445
|
+
callback(null, result);
|
|
2446
|
+
});
|
|
2447
|
+
});
|
|
2448
|
+
}
|
|
2449
|
+
_readContextTimestamp(path, callback) {
|
|
2450
|
+
this._readContext({
|
|
2451
|
+
path,
|
|
2452
|
+
fromImmutablePath: () => null,
|
|
2453
|
+
fromManagedItem: info => ({
|
|
2454
|
+
safeTime: 0,
|
|
2455
|
+
timestampHash: info,
|
|
2456
|
+
}),
|
|
2457
|
+
fromSymlink: (file, target, callback) => {
|
|
2458
|
+
callback(null, {
|
|
2459
|
+
timestampHash: target,
|
|
2460
|
+
symlinks: new Set([target]),
|
|
2461
|
+
});
|
|
2462
|
+
},
|
|
2463
|
+
fromFile: (file, stat, callback) => {
|
|
2464
|
+
// Prefer the cached value over our new stat to report consistent results
|
|
2465
|
+
const cache = this._fileTimestamps.get(file);
|
|
2466
|
+
if (cache !== undefined)
|
|
2467
|
+
return callback(null, cache === 'ignore' ? null : cache);
|
|
2468
|
+
const mtime = +stat.mtime;
|
|
2469
|
+
if (mtime)
|
|
2470
|
+
applyMtime(mtime);
|
|
2471
|
+
const ts = {
|
|
2472
|
+
safeTime: mtime ? mtime + FS_ACCURACY : Infinity,
|
|
2473
|
+
timestamp: mtime,
|
|
2474
|
+
};
|
|
2475
|
+
this._fileTimestamps.set(file, ts);
|
|
2476
|
+
this._cachedDeprecatedFileTimestamps = undefined;
|
|
2477
|
+
callback(null, ts);
|
|
2478
|
+
},
|
|
2479
|
+
fromDirectory: (directory, stat, callback) => {
|
|
2480
|
+
this.contextTimestampQueue.increaseParallelism();
|
|
2481
|
+
this._getUnresolvedContextTimestamp(directory, (err, tsEntry) => {
|
|
2482
|
+
this.contextTimestampQueue.decreaseParallelism();
|
|
2483
|
+
callback(err, tsEntry);
|
|
2484
|
+
});
|
|
2485
|
+
},
|
|
2486
|
+
reduce: (files, tsEntries) => {
|
|
2487
|
+
let symlinks;
|
|
2488
|
+
const hash = (0, createHash_1.default)(this._hashFunction);
|
|
2489
|
+
for (const file of files)
|
|
2490
|
+
hash.update(file);
|
|
2491
|
+
let safeTime = 0;
|
|
2492
|
+
for (const entry of tsEntries) {
|
|
2493
|
+
if (!entry) {
|
|
2494
|
+
hash.update('n');
|
|
2495
|
+
continue;
|
|
2496
|
+
}
|
|
2497
|
+
if (entry.timestamp) {
|
|
2498
|
+
hash.update('f');
|
|
2499
|
+
hash.update(`${entry.timestamp}`);
|
|
2500
|
+
}
|
|
2501
|
+
else if (entry.timestampHash) {
|
|
2502
|
+
hash.update('d');
|
|
2503
|
+
hash.update(`${entry.timestampHash}`);
|
|
2504
|
+
}
|
|
2505
|
+
if (entry.symlinks !== undefined) {
|
|
2506
|
+
if (symlinks === undefined)
|
|
2507
|
+
symlinks = new Set();
|
|
2508
|
+
addAll(entry.symlinks, symlinks);
|
|
2509
|
+
}
|
|
2510
|
+
if (entry.safeTime) {
|
|
2511
|
+
safeTime = Math.max(safeTime, entry.safeTime);
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
const digest = hash.digest('hex');
|
|
2515
|
+
const result = {
|
|
2516
|
+
safeTime,
|
|
2517
|
+
timestampHash: digest,
|
|
2518
|
+
};
|
|
2519
|
+
if (symlinks)
|
|
2520
|
+
result.symlinks = symlinks;
|
|
2521
|
+
return result;
|
|
2522
|
+
},
|
|
2523
|
+
}, (err, result) => {
|
|
2524
|
+
if (err)
|
|
2525
|
+
return callback(err);
|
|
2526
|
+
this._contextTimestamps.set(path, result);
|
|
2527
|
+
this._cachedDeprecatedContextTimestamps = undefined;
|
|
2528
|
+
callback(null, result);
|
|
2529
|
+
});
|
|
2530
|
+
}
|
|
2531
|
+
_resolveContextTimestamp(entry, callback) {
|
|
2532
|
+
const hashes = [];
|
|
2533
|
+
let safeTime = 0;
|
|
2534
|
+
(0, processAsyncTree_1.default)(entry.symlinks, 10, (target, push, callback) => {
|
|
2535
|
+
this._getUnresolvedContextTimestamp(target, (err, entry) => {
|
|
2536
|
+
if (err)
|
|
2537
|
+
return callback(err);
|
|
2538
|
+
if (entry && entry !== 'ignore') {
|
|
2539
|
+
hashes.push(entry.timestampHash);
|
|
2540
|
+
if (entry.safeTime) {
|
|
2541
|
+
safeTime = Math.max(safeTime, entry.safeTime);
|
|
2542
|
+
}
|
|
2543
|
+
if (entry.symlinks !== undefined) {
|
|
2544
|
+
for (const target of entry.symlinks)
|
|
2545
|
+
push(target);
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
callback();
|
|
2549
|
+
});
|
|
2550
|
+
}, err => {
|
|
2551
|
+
if (err)
|
|
2552
|
+
return callback(err);
|
|
2553
|
+
const hash = (0, createHash_1.default)(this._hashFunction);
|
|
2554
|
+
hash.update(entry.timestampHash);
|
|
2555
|
+
if (entry.safeTime) {
|
|
2556
|
+
safeTime = Math.max(safeTime, entry.safeTime);
|
|
2557
|
+
}
|
|
2558
|
+
hashes.sort();
|
|
2559
|
+
for (const h of hashes) {
|
|
2560
|
+
hash.update(h);
|
|
2561
|
+
}
|
|
2562
|
+
callback(null, (entry.resolved = {
|
|
2563
|
+
safeTime,
|
|
2564
|
+
timestampHash: hash.digest('hex'),
|
|
2565
|
+
}));
|
|
2566
|
+
});
|
|
2567
|
+
}
|
|
2568
|
+
_readContextHash(path, callback) {
|
|
2569
|
+
this._readContext({
|
|
2570
|
+
path,
|
|
2571
|
+
fromImmutablePath: () => '',
|
|
2572
|
+
fromManagedItem: info => info || '',
|
|
2573
|
+
fromSymlink: (file, target, callback) => {
|
|
2574
|
+
callback(null, {
|
|
2575
|
+
hash: target,
|
|
2576
|
+
symlinks: new Set([target]),
|
|
2577
|
+
});
|
|
2578
|
+
},
|
|
2579
|
+
fromFile: (file, stat, callback) => this.getFileHash(file, (err, hash) => {
|
|
2580
|
+
callback(err, hash || '');
|
|
2581
|
+
}),
|
|
2582
|
+
fromDirectory: (directory, stat, callback) => {
|
|
2583
|
+
this.contextHashQueue.increaseParallelism();
|
|
2584
|
+
this._getUnresolvedContextHash(directory, (err, hash) => {
|
|
2585
|
+
this.contextHashQueue.decreaseParallelism();
|
|
2586
|
+
callback(err, hash || '');
|
|
2587
|
+
});
|
|
2588
|
+
},
|
|
2589
|
+
reduce: (files, fileHashes) => {
|
|
2590
|
+
let symlinks;
|
|
2591
|
+
const hash = (0, createHash_1.default)(this._hashFunction);
|
|
2592
|
+
for (const file of files)
|
|
2593
|
+
hash.update(file);
|
|
2594
|
+
for (const entry of fileHashes) {
|
|
2595
|
+
if (typeof entry === 'string') {
|
|
2596
|
+
hash.update(entry);
|
|
2597
|
+
}
|
|
2598
|
+
else {
|
|
2599
|
+
hash.update(entry.hash);
|
|
2600
|
+
if (entry.symlinks) {
|
|
2601
|
+
if (symlinks === undefined)
|
|
2602
|
+
symlinks = new Set();
|
|
2603
|
+
addAll(entry.symlinks, symlinks);
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
const result = {
|
|
2608
|
+
hash: hash.digest('hex'),
|
|
2609
|
+
};
|
|
2610
|
+
if (symlinks)
|
|
2611
|
+
result.symlinks = symlinks;
|
|
2612
|
+
return result;
|
|
2613
|
+
},
|
|
2614
|
+
}, (err, result) => {
|
|
2615
|
+
if (err)
|
|
2616
|
+
return callback(err);
|
|
2617
|
+
this._contextHashes.set(path, result);
|
|
2618
|
+
return callback(null, result);
|
|
2619
|
+
});
|
|
2620
|
+
}
|
|
2621
|
+
_resolveContextHash(entry, callback) {
|
|
2622
|
+
const hashes = [];
|
|
2623
|
+
(0, processAsyncTree_1.default)(entry.symlinks, 10, (target, push, callback) => {
|
|
2624
|
+
this._getUnresolvedContextHash(target, (err, hash) => {
|
|
2625
|
+
if (err)
|
|
2626
|
+
return callback(err);
|
|
2627
|
+
if (hash) {
|
|
2628
|
+
hashes.push(hash.hash);
|
|
2629
|
+
if (hash.symlinks !== undefined) {
|
|
2630
|
+
for (const target of hash.symlinks)
|
|
2631
|
+
push(target);
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
callback();
|
|
2635
|
+
});
|
|
2636
|
+
}, err => {
|
|
2637
|
+
if (err)
|
|
2638
|
+
return callback(err);
|
|
2639
|
+
const hash = (0, createHash_1.default)(this._hashFunction);
|
|
2640
|
+
hash.update(entry.hash);
|
|
2641
|
+
hashes.sort();
|
|
2642
|
+
for (const h of hashes) {
|
|
2643
|
+
hash.update(h);
|
|
2644
|
+
}
|
|
2645
|
+
callback(null, (entry.resolved = hash.digest('hex')));
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
_readContextTimestampAndHash(path, callback) {
|
|
2649
|
+
const finalize = (timestamp, hash) => {
|
|
2650
|
+
const result = timestamp === 'ignore'
|
|
2651
|
+
? hash
|
|
2652
|
+
: Object.assign(Object.assign({}, timestamp), hash);
|
|
2653
|
+
this._contextTshs.set(path, result);
|
|
2654
|
+
callback(null, result);
|
|
2655
|
+
};
|
|
2656
|
+
const cachedHash = this._contextHashes.get(path);
|
|
2657
|
+
const cachedTimestamp = this._contextTimestamps.get(path);
|
|
2658
|
+
if (cachedHash !== undefined) {
|
|
2659
|
+
if (cachedTimestamp !== undefined) {
|
|
2660
|
+
finalize(cachedTimestamp, cachedHash);
|
|
2661
|
+
}
|
|
2662
|
+
else {
|
|
2663
|
+
this.contextTimestampQueue.add(path, (err, entry) => {
|
|
2664
|
+
if (err)
|
|
2665
|
+
return callback(err);
|
|
2666
|
+
finalize(entry, cachedHash);
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
else if (cachedTimestamp !== undefined) {
|
|
2671
|
+
this.contextHashQueue.add(path, (err, entry) => {
|
|
2672
|
+
if (err)
|
|
2673
|
+
return callback(err);
|
|
2674
|
+
finalize(cachedTimestamp, entry);
|
|
2675
|
+
});
|
|
2676
|
+
}
|
|
2677
|
+
else {
|
|
2678
|
+
this._readContext({
|
|
2679
|
+
path,
|
|
2680
|
+
fromImmutablePath: () => null,
|
|
2681
|
+
fromManagedItem: info => ({
|
|
2682
|
+
safeTime: 0,
|
|
2683
|
+
timestampHash: info,
|
|
2684
|
+
hash: info || '',
|
|
2685
|
+
}),
|
|
2686
|
+
fromSymlink: (fle, target, callback) => {
|
|
2687
|
+
callback(null, {
|
|
2688
|
+
timestampHash: target,
|
|
2689
|
+
hash: target,
|
|
2690
|
+
symlinks: new Set([target]),
|
|
2691
|
+
});
|
|
2692
|
+
},
|
|
2693
|
+
fromFile: (file, stat, callback) => {
|
|
2694
|
+
this._getFileTimestampAndHash(file, callback);
|
|
2695
|
+
},
|
|
2696
|
+
fromDirectory: (directory, stat, callback) => {
|
|
2697
|
+
this.contextTshQueue.increaseParallelism();
|
|
2698
|
+
this.contextTshQueue.add(directory, (err, result) => {
|
|
2699
|
+
this.contextTshQueue.decreaseParallelism();
|
|
2700
|
+
callback(err, result);
|
|
2701
|
+
});
|
|
2702
|
+
},
|
|
2703
|
+
reduce: (files, results) => {
|
|
2704
|
+
let symlinks;
|
|
2705
|
+
const tsHash = (0, createHash_1.default)(this._hashFunction);
|
|
2706
|
+
const hash = (0, createHash_1.default)(this._hashFunction);
|
|
2707
|
+
for (const file of files) {
|
|
2708
|
+
tsHash.update(file);
|
|
2709
|
+
hash.update(file);
|
|
2710
|
+
}
|
|
2711
|
+
let safeTime = 0;
|
|
2712
|
+
for (const entry of results) {
|
|
2713
|
+
if (!entry) {
|
|
2714
|
+
tsHash.update('n');
|
|
2715
|
+
continue;
|
|
2716
|
+
}
|
|
2717
|
+
if (typeof entry === 'string') {
|
|
2718
|
+
tsHash.update('n');
|
|
2719
|
+
hash.update(entry);
|
|
2720
|
+
continue;
|
|
2721
|
+
}
|
|
2722
|
+
if (entry.timestamp) {
|
|
2723
|
+
tsHash.update('f');
|
|
2724
|
+
tsHash.update(`${entry.timestamp}`);
|
|
2725
|
+
}
|
|
2726
|
+
else if (entry.timestampHash) {
|
|
2727
|
+
tsHash.update('d');
|
|
2728
|
+
tsHash.update(`${entry.timestampHash}`);
|
|
2729
|
+
}
|
|
2730
|
+
if (entry.symlinks !== undefined) {
|
|
2731
|
+
if (symlinks === undefined)
|
|
2732
|
+
symlinks = new Set();
|
|
2733
|
+
addAll(entry.symlinks, symlinks);
|
|
2734
|
+
}
|
|
2735
|
+
if (entry.safeTime) {
|
|
2736
|
+
safeTime = Math.max(safeTime, entry.safeTime);
|
|
2737
|
+
}
|
|
2738
|
+
hash.update(entry.hash);
|
|
2739
|
+
}
|
|
2740
|
+
const result = {
|
|
2741
|
+
safeTime,
|
|
2742
|
+
timestampHash: tsHash.digest('hex'),
|
|
2743
|
+
hash: hash.digest('hex'),
|
|
2744
|
+
};
|
|
2745
|
+
if (symlinks)
|
|
2746
|
+
result.symlinks = symlinks;
|
|
2747
|
+
return result;
|
|
2748
|
+
},
|
|
2749
|
+
}, (err, result) => {
|
|
2750
|
+
if (err)
|
|
2751
|
+
return callback(err);
|
|
2752
|
+
this._contextTshs.set(path, result);
|
|
2753
|
+
return callback(null, result);
|
|
2754
|
+
});
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
_resolveContextTsh(entry, callback) {
|
|
2758
|
+
const hashes = [];
|
|
2759
|
+
const tsHashes = [];
|
|
2760
|
+
let safeTime = 0;
|
|
2761
|
+
(0, processAsyncTree_1.default)(entry.symlinks, 10, (target, push, callback) => {
|
|
2762
|
+
this._getUnresolvedContextTsh(target, (err, entry) => {
|
|
2763
|
+
if (err)
|
|
2764
|
+
return callback(err);
|
|
2765
|
+
if (entry) {
|
|
2766
|
+
hashes.push(entry.hash);
|
|
2767
|
+
if (entry.timestampHash)
|
|
2768
|
+
tsHashes.push(entry.timestampHash);
|
|
2769
|
+
if (entry.safeTime) {
|
|
2770
|
+
safeTime = Math.max(safeTime, entry.safeTime);
|
|
2771
|
+
}
|
|
2772
|
+
if (entry.symlinks !== undefined) {
|
|
2773
|
+
for (const target of entry.symlinks)
|
|
2774
|
+
push(target);
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
callback();
|
|
2778
|
+
});
|
|
2779
|
+
}, err => {
|
|
2780
|
+
if (err)
|
|
2781
|
+
return callback(err);
|
|
2782
|
+
const hash = (0, createHash_1.default)(this._hashFunction);
|
|
2783
|
+
const tsHash = (0, createHash_1.default)(this._hashFunction);
|
|
2784
|
+
hash.update(entry.hash);
|
|
2785
|
+
if (entry.timestampHash)
|
|
2786
|
+
tsHash.update(entry.timestampHash);
|
|
2787
|
+
if (entry.safeTime) {
|
|
2788
|
+
safeTime = Math.max(safeTime, entry.safeTime);
|
|
2789
|
+
}
|
|
2790
|
+
hashes.sort();
|
|
2791
|
+
for (const h of hashes) {
|
|
2792
|
+
hash.update(h);
|
|
2793
|
+
}
|
|
2794
|
+
tsHashes.sort();
|
|
2795
|
+
for (const h of tsHashes) {
|
|
2796
|
+
tsHash.update(h);
|
|
2797
|
+
}
|
|
2798
|
+
callback(null, (entry.resolved = {
|
|
2799
|
+
safeTime,
|
|
2800
|
+
timestampHash: tsHash.digest('hex'),
|
|
2801
|
+
hash: hash.digest('hex'),
|
|
2802
|
+
}));
|
|
2803
|
+
});
|
|
2804
|
+
}
|
|
2805
|
+
_getManagedItemDirectoryInfo(path, callback) {
|
|
2806
|
+
this.fs.readdir(path, (err, elements) => {
|
|
2807
|
+
if (err) {
|
|
2808
|
+
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') {
|
|
2809
|
+
return callback(null, EMPTY_SET);
|
|
2810
|
+
}
|
|
2811
|
+
return callback(err);
|
|
2812
|
+
}
|
|
2813
|
+
const set = new Set(elements.map(element => (0, fs_1.join)(this.fs, path, element)));
|
|
2814
|
+
callback(null, set);
|
|
2815
|
+
});
|
|
2816
|
+
}
|
|
2817
|
+
_getManagedItemInfo(path, callback) {
|
|
2818
|
+
const dir = (0, fs_1.dirname)(this.fs, path);
|
|
2819
|
+
this.managedItemDirectoryQueue.add(dir, (err, elements) => {
|
|
2820
|
+
if (err) {
|
|
2821
|
+
return callback(err);
|
|
2822
|
+
}
|
|
2823
|
+
if (!elements.has(path)) {
|
|
2824
|
+
// file or directory doesn't exist
|
|
2825
|
+
this._managedItems.set(path, '*missing');
|
|
2826
|
+
return callback(null, '*missing');
|
|
2827
|
+
}
|
|
2828
|
+
// something exists
|
|
2829
|
+
// it may be a file or directory
|
|
2830
|
+
if (path.endsWith('node_modules') &&
|
|
2831
|
+
(path.endsWith('/node_modules') || path.endsWith('\\node_modules'))) {
|
|
2832
|
+
// we are only interested in existence of this special directory
|
|
2833
|
+
this._managedItems.set(path, '*node_modules');
|
|
2834
|
+
return callback(null, '*node_modules');
|
|
2835
|
+
}
|
|
2836
|
+
// we assume it's a directory, as files shouldn't occur in managed paths
|
|
2837
|
+
const packageJsonPath = (0, fs_1.join)(this.fs, path, 'package.json');
|
|
2838
|
+
this.fs.readFile(packageJsonPath, (err, content) => {
|
|
2839
|
+
if (err) {
|
|
2840
|
+
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') {
|
|
2841
|
+
// no package.json or path is not a directory
|
|
2842
|
+
this.fs.readdir(path, (err, elements) => {
|
|
2843
|
+
if (!err && elements.length === 1 && elements[0] === 'node_modules') {
|
|
2844
|
+
// This is only a grouping folder e. g. used by yarn
|
|
2845
|
+
// we are only interested in existence of this special directory
|
|
2846
|
+
this._managedItems.set(path, '*nested');
|
|
2847
|
+
return callback(null, '*nested');
|
|
2848
|
+
}
|
|
2849
|
+
this.logger.warn(`Managed item ${path} isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)`);
|
|
2850
|
+
return callback();
|
|
2851
|
+
});
|
|
2852
|
+
return;
|
|
2853
|
+
}
|
|
2854
|
+
return callback(err);
|
|
2855
|
+
}
|
|
2856
|
+
let data;
|
|
2857
|
+
try {
|
|
2858
|
+
data = JSON.parse(content.toString('utf-8'));
|
|
2859
|
+
}
|
|
2860
|
+
catch (e) {
|
|
2861
|
+
return callback(e);
|
|
2862
|
+
}
|
|
2863
|
+
if (!data.name) {
|
|
2864
|
+
this.logger.warn(`${packageJsonPath} doesn't contain a "name" property (see snapshot.managedPaths option)`);
|
|
2865
|
+
return callback();
|
|
2866
|
+
}
|
|
2867
|
+
const info = `${data.name || ''}@${data.version || ''}`;
|
|
2868
|
+
this._managedItems.set(path, info);
|
|
2869
|
+
callback(null, info);
|
|
2870
|
+
});
|
|
2871
|
+
});
|
|
2872
|
+
}
|
|
2873
|
+
getDeprecatedFileTimestamps() {
|
|
2874
|
+
if (this._cachedDeprecatedFileTimestamps !== undefined)
|
|
2875
|
+
return this._cachedDeprecatedFileTimestamps;
|
|
2876
|
+
const map = new Map();
|
|
2877
|
+
for (const [path, info] of this._fileTimestamps) {
|
|
2878
|
+
if (info)
|
|
2879
|
+
map.set(path, typeof info === 'object' ? info.safeTime : null);
|
|
2880
|
+
}
|
|
2881
|
+
this._cachedDeprecatedFileTimestamps = map;
|
|
2882
|
+
return this._cachedDeprecatedFileTimestamps;
|
|
2883
|
+
}
|
|
2884
|
+
getDeprecatedContextTimestamps() {
|
|
2885
|
+
if (this._cachedDeprecatedContextTimestamps !== undefined)
|
|
2886
|
+
return this._cachedDeprecatedContextTimestamps;
|
|
2887
|
+
const map = new Map();
|
|
2888
|
+
for (const [path, info] of this._contextTimestamps) {
|
|
2889
|
+
if (info)
|
|
2890
|
+
map.set(path, typeof info === 'object' ? info.safeTime : null);
|
|
2891
|
+
}
|
|
2892
|
+
this._cachedDeprecatedContextTimestamps = map;
|
|
2893
|
+
return this._cachedDeprecatedContextTimestamps;
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
exports.FileSystemInfo = FileSystemInfo;
|