webpack 5.97.1 → 5.104.1
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 +368 -434
- package/bin/webpack.js +15 -9
- package/hot/dev-server.js +18 -3
- package/hot/emitter-event-target.js +7 -0
- package/hot/lazy-compilation-node.js +45 -29
- package/hot/lazy-compilation-universal.js +18 -0
- package/hot/lazy-compilation-web.js +15 -5
- package/hot/load-http.js +7 -0
- package/hot/log.js +15 -15
- package/hot/only-dev-server.js +19 -4
- package/hot/poll.js +1 -0
- package/lib/APIPlugin.js +48 -50
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AsyncDependenciesBlock.js +4 -5
- package/lib/AutomaticPrefetchPlugin.js +22 -22
- package/lib/BannerPlugin.js +35 -40
- package/lib/Cache.js +12 -9
- package/lib/CacheFacade.js +13 -13
- package/lib/CaseSensitiveModulesWarning.js +6 -6
- package/lib/Chunk.js +68 -47
- package/lib/ChunkGraph.js +174 -95
- package/lib/ChunkGroup.js +32 -24
- package/lib/ChunkTemplate.js +8 -8
- package/lib/CleanPlugin.js +90 -42
- package/lib/CodeGenerationResults.js +12 -9
- package/lib/CompatibilityPlugin.js +70 -21
- package/lib/Compilation.js +827 -550
- package/lib/Compiler.js +137 -109
- package/lib/ConcatenationScope.js +45 -8
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +89 -59
- package/lib/ContextExclusionPlugin.js +5 -4
- package/lib/ContextModule.js +66 -51
- package/lib/ContextModuleFactory.js +51 -30
- package/lib/ContextReplacementPlugin.js +89 -34
- package/lib/CssModule.js +8 -4
- package/lib/DefinePlugin.js +209 -57
- package/lib/DelegatedModule.js +34 -23
- package/lib/DelegatedModuleFactoryPlugin.js +27 -24
- package/lib/DelegatedPlugin.js +4 -2
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +37 -19
- package/lib/DependencyTemplate.js +2 -0
- package/lib/DependencyTemplates.js +5 -6
- package/lib/DllEntryPlugin.js +8 -4
- package/lib/DllModule.js +11 -12
- package/lib/DllModuleFactory.js +2 -2
- package/lib/DllPlugin.js +9 -6
- package/lib/DllReferencePlugin.js +60 -65
- package/lib/DotenvPlugin.js +462 -0
- package/lib/DynamicEntryPlugin.js +8 -8
- package/lib/EntryOptionPlugin.js +8 -6
- package/lib/EntryPlugin.js +5 -3
- package/lib/Entrypoint.js +19 -0
- package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
- package/lib/EnvironmentPlugin.js +26 -19
- package/lib/ErrorHelpers.js +6 -6
- package/lib/EvalDevToolModulePlugin.js +17 -14
- package/lib/EvalSourceMapDevToolPlugin.js +156 -142
- package/lib/ExportsInfo.js +180 -115
- package/lib/ExportsInfoApiPlugin.js +2 -2
- package/lib/ExternalModule.js +256 -102
- package/lib/ExternalModuleFactoryPlugin.js +66 -29
- package/lib/ExternalsPlugin.js +57 -2
- package/lib/FileSystemInfo.js +313 -247
- package/lib/FlagAllModulesAsUsedPlugin.js +2 -2
- package/lib/FlagDependencyExportsPlugin.js +29 -19
- package/lib/FlagDependencyUsagePlugin.js +9 -10
- package/lib/FlagEntryExportAsUsedPlugin.js +1 -1
- package/lib/Generator.js +43 -10
- package/lib/GraphHelpers.js +11 -3
- package/lib/HookWebpackError.js +35 -7
- package/lib/HotModuleReplacementPlugin.js +149 -108
- package/lib/HotUpdateChunk.js +0 -3
- package/lib/IgnoreErrorModuleFactory.js +2 -2
- package/lib/IgnorePlugin.js +16 -13
- package/lib/IgnoreWarningsPlugin.js +6 -4
- package/lib/InitFragment.js +41 -23
- package/lib/InvalidDependenciesModuleWarning.js +2 -3
- package/lib/JavascriptMetaInfoPlugin.js +2 -4
- package/lib/LibManifestPlugin.js +12 -13
- package/lib/LoaderOptionsPlugin.js +12 -14
- package/lib/LoaderTargetPlugin.js +5 -3
- package/lib/MainTemplate.js +18 -29
- package/lib/ManifestPlugin.js +235 -0
- package/lib/Module.js +138 -60
- package/lib/ModuleBuildError.js +4 -2
- package/lib/ModuleDependencyError.js +4 -3
- package/lib/ModuleDependencyWarning.js +4 -3
- package/lib/ModuleError.js +1 -1
- package/lib/ModuleFactory.js +10 -3
- package/lib/ModuleFilenameHelpers.js +63 -60
- package/lib/ModuleGraph.js +195 -70
- package/lib/ModuleGraphConnection.js +14 -20
- package/lib/ModuleInfoHeaderPlugin.js +15 -16
- package/lib/ModuleNotFoundError.js +1 -1
- package/lib/ModuleParseError.js +8 -4
- package/lib/ModuleSourceTypeConstants.js +189 -0
- package/lib/ModuleTemplate.js +7 -8
- package/lib/ModuleTypeConstants.js +37 -15
- package/lib/ModuleWarning.js +1 -1
- package/lib/MultiCompiler.js +64 -49
- package/lib/MultiStats.js +19 -14
- package/lib/MultiWatching.js +7 -11
- package/lib/NoEmitOnErrorsPlugin.js +5 -3
- package/lib/NodeStuffPlugin.js +438 -126
- package/lib/NormalModule.js +322 -201
- package/lib/NormalModuleFactory.js +230 -117
- package/lib/NormalModuleReplacementPlugin.js +37 -39
- package/lib/NullFactory.js +3 -2
- package/lib/OptimizationStages.js +1 -1
- package/lib/OptionsApply.js +1 -1
- package/lib/Parser.js +5 -3
- package/lib/PlatformPlugin.js +3 -1
- package/lib/PrefetchPlugin.js +6 -4
- package/lib/ProgressPlugin.js +48 -49
- package/lib/ProvidePlugin.js +7 -5
- package/lib/RawModule.js +26 -12
- package/lib/RecordIdsPlugin.js +88 -110
- package/lib/RequestShortener.js +3 -1
- package/lib/ResolverFactory.js +15 -14
- package/lib/RuntimeGlobals.js +216 -153
- package/lib/RuntimeModule.js +7 -6
- package/lib/RuntimePlugin.js +115 -62
- package/lib/RuntimeTemplate.js +248 -76
- package/lib/SelfModuleFactory.js +2 -2
- package/lib/SizeFormatHelpers.js +2 -2
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +17 -27
- package/lib/SourceMapDevToolPlugin.js +72 -59
- package/lib/Stats.js +2 -3
- package/lib/Template.js +31 -24
- package/lib/TemplatedPathPlugin.js +24 -21
- package/lib/UseStrictPlugin.js +1 -1
- package/lib/WarnCaseSensitiveModulesPlugin.js +36 -37
- package/lib/WarnDeprecatedOptionPlugin.js +7 -8
- package/lib/WarnNoModeSetPlugin.js +3 -1
- package/lib/WatchIgnorePlugin.js +11 -9
- package/lib/Watching.js +27 -29
- package/lib/WebpackError.js +10 -3
- package/lib/WebpackIsIncludedPlugin.js +4 -5
- package/lib/WebpackOptionsApply.js +263 -135
- package/lib/asset/AssetBytesGenerator.js +171 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +285 -223
- package/lib/asset/AssetModulesPlugin.js +103 -41
- package/lib/asset/AssetParser.js +7 -3
- package/lib/asset/AssetSourceGenerator.js +41 -17
- package/lib/asset/RawDataUrlModule.js +17 -9
- package/lib/async-modules/AsyncModuleHelpers.js +52 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +39 -24
- package/lib/async-modules/InferAsyncModulesPlugin.js +25 -26
- package/lib/buildChunkGraph.js +36 -17
- package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
- package/lib/cache/IdleFileCachePlugin.js +22 -20
- package/lib/cache/MemoryCachePlugin.js +3 -3
- package/lib/cache/MemoryWithGcCachePlugin.js +17 -11
- package/lib/cache/PackFileCacheStrategy.js +198 -170
- package/lib/cache/ResolverCachePlugin.js +58 -48
- package/lib/cache/getLazyHashedEtag.js +5 -4
- package/lib/cli.js +197 -39
- package/lib/config/browserslistTargetHandler.js +110 -85
- package/lib/config/defaults.js +514 -113
- package/lib/config/normalization.js +91 -64
- package/lib/config/target.js +30 -18
- package/lib/container/ContainerEntryDependency.js +0 -1
- package/lib/container/ContainerEntryModule.js +16 -15
- package/lib/container/ContainerEntryModuleFactory.js +2 -2
- package/lib/container/ContainerPlugin.js +5 -6
- package/lib/container/ContainerReferencePlugin.js +27 -30
- package/lib/container/FallbackDependency.js +2 -1
- package/lib/container/FallbackModule.js +19 -14
- package/lib/container/FallbackModuleFactory.js +2 -2
- package/lib/container/HoistContainerReferencesPlugin.js +7 -7
- package/lib/container/ModuleFederationPlugin.js +4 -4
- package/lib/container/RemoteModule.js +14 -14
- package/lib/container/RemoteRuntimeModule.js +2 -2
- package/lib/container/options.js +9 -9
- package/lib/css/CssGenerator.js +366 -74
- package/lib/css/CssLoadingRuntimeModule.js +26 -16
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +56 -0
- package/lib/css/CssModulesPlugin.js +191 -142
- package/lib/css/CssParser.js +1756 -740
- package/lib/css/walkCssTokens.js +180 -67
- package/lib/debug/ProfilingPlugin.js +135 -51
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +29 -28
- package/lib/dependencies/AMDPlugin.js +18 -11
- package/lib/dependencies/AMDRequireArrayDependency.js +5 -4
- package/lib/dependencies/AMDRequireContextDependency.js +2 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +35 -26
- package/lib/dependencies/AMDRuntimeModules.js +3 -1
- package/lib/dependencies/CachedConstDependency.js +24 -18
- package/lib/dependencies/CommonJsExportRequireDependency.js +31 -24
- package/lib/dependencies/CommonJsExportsDependency.js +2 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +50 -36
- package/lib/dependencies/CommonJsFullRequireDependency.js +7 -13
- package/lib/dependencies/CommonJsImportsParserPlugin.js +146 -127
- package/lib/dependencies/CommonJsPlugin.js +29 -18
- package/lib/dependencies/CommonJsRequireContextDependency.js +4 -3
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +10 -5
- package/lib/dependencies/ContextDependencyHelpers.js +21 -13
- package/lib/dependencies/ContextDependencyTemplateAsId.js +10 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +13 -10
- package/lib/dependencies/ContextElementDependency.js +23 -12
- package/lib/dependencies/CssIcssExportDependency.js +402 -22
- package/lib/dependencies/CssIcssImportDependency.js +116 -51
- package/lib/dependencies/CssIcssSymbolDependency.js +33 -35
- package/lib/dependencies/CssImportDependency.js +17 -14
- package/lib/dependencies/CssUrlDependency.js +8 -13
- package/lib/dependencies/DynamicExports.js +19 -19
- package/lib/dependencies/ExportsInfoDependency.js +13 -10
- package/lib/dependencies/ExternalModuleDependency.js +7 -7
- package/lib/dependencies/ExternalModuleInitFragment.js +3 -2
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +96 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +96 -5
- package/lib/dependencies/HarmonyAcceptImportDependency.js +2 -5
- package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +10 -30
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +19 -8
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +136 -99
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +152 -61
- package/lib/dependencies/HarmonyExportInitFragment.js +2 -2
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +2 -2
- package/lib/dependencies/HarmonyExports.js +5 -5
- package/lib/dependencies/HarmonyImportDependency.js +92 -45
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +201 -163
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +5 -6
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +69 -42
- package/lib/dependencies/HarmonyModulesPlugin.js +16 -11
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -15
- package/lib/dependencies/ImportContextDependency.js +15 -1
- package/lib/dependencies/ImportDependency.js +25 -7
- package/lib/dependencies/ImportEagerDependency.js +7 -5
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +23 -13
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -2
- package/lib/dependencies/ImportMetaPlugin.js +172 -20
- package/lib/dependencies/ImportParserPlugin.js +327 -49
- package/lib/dependencies/ImportPhase.js +121 -0
- package/lib/dependencies/ImportPlugin.js +3 -1
- package/lib/dependencies/ImportWeakDependency.js +7 -5
- package/lib/dependencies/JsonExportsDependency.js +54 -28
- package/lib/dependencies/LoaderDependency.js +0 -3
- package/lib/dependencies/LoaderImportDependency.js +0 -3
- package/lib/dependencies/LoaderPlugin.js +24 -25
- package/lib/dependencies/LocalModulesHelpers.js +4 -4
- package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
- package/lib/dependencies/ModuleDependency.js +14 -13
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -1
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/ProvidedDependency.js +8 -10
- package/lib/dependencies/PureExpressionDependency.js +1 -2
- package/lib/dependencies/RequireContextDependency.js +2 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +47 -44
- package/lib/dependencies/RequireContextPlugin.js +5 -2
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +3 -3
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +101 -99
- package/lib/dependencies/RequireEnsurePlugin.js +6 -6
- package/lib/dependencies/RequireIncludeDependency.js +2 -2
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
- package/lib/dependencies/RequireIncludePlugin.js +1 -0
- package/lib/dependencies/RequireResolveContextDependency.js +1 -1
- package/lib/dependencies/RequireResolveDependency.js +3 -3
- package/lib/dependencies/RuntimeRequirementsDependency.js +3 -4
- package/lib/dependencies/StaticExportsDependency.js +3 -5
- package/lib/dependencies/SystemPlugin.js +4 -4
- package/lib/dependencies/URLContextDependency.js +65 -0
- package/lib/dependencies/URLDependency.js +3 -8
- package/lib/dependencies/URLPlugin.js +18 -159
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +3 -3
- package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
- package/lib/dependencies/WorkerDependency.js +8 -6
- package/lib/dependencies/WorkerPlugin.js +131 -67
- package/lib/dependencies/getFunctionExpression.js +2 -2
- package/lib/dependencies/processExportInfo.js +4 -4
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +232 -179
- package/lib/esm/ModuleChunkLoadingPlugin.js +112 -57
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +102 -28
- package/lib/formatLocation.js +2 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +41 -29
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +43 -33
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
- package/lib/hmr/LazyCompilationPlugin.js +67 -54
- package/lib/hmr/lazyCompilationBackend.js +23 -18
- package/lib/ids/ChunkModuleIdRangePlugin.js +14 -11
- package/lib/ids/DeterministicChunkIdsPlugin.js +32 -37
- package/lib/ids/DeterministicModuleIdsPlugin.js +52 -52
- package/lib/ids/HashedModuleIdsPlugin.js +15 -13
- package/lib/ids/IdHelpers.js +66 -49
- package/lib/ids/NamedChunkIdsPlugin.js +14 -17
- package/lib/ids/NamedModuleIdsPlugin.js +12 -14
- package/lib/ids/NaturalChunkIdsPlugin.js +6 -4
- package/lib/ids/NaturalModuleIdsPlugin.js +4 -3
- package/lib/ids/OccurrenceChunkIdsPlugin.js +7 -5
- package/lib/ids/OccurrenceModuleIdsPlugin.js +8 -7
- package/lib/ids/SyncModuleIdsPlugin.js +18 -13
- package/lib/index.js +54 -14
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +116 -119
- package/lib/javascript/BasicEvaluatedExpression.js +26 -18
- package/lib/javascript/ChunkFormatHelpers.js +70 -0
- package/lib/javascript/ChunkHelpers.js +17 -5
- package/lib/javascript/CommonJsChunkFormatPlugin.js +114 -141
- package/lib/javascript/EnableChunkLoadingPlugin.js +7 -4
- package/lib/javascript/JavascriptGenerator.js +122 -100
- package/lib/javascript/JavascriptModulesPlugin.js +332 -152
- package/lib/javascript/JavascriptParser.js +1488 -1052
- package/lib/javascript/JavascriptParserHelpers.js +48 -47
- package/lib/javascript/StartupHelpers.js +23 -22
- package/lib/json/JsonData.js +4 -4
- package/lib/json/JsonGenerator.js +66 -32
- package/lib/json/JsonModulesPlugin.js +16 -6
- package/lib/json/JsonParser.js +23 -8
- package/lib/library/AbstractLibraryPlugin.js +45 -10
- package/lib/library/AmdLibraryPlugin.js +7 -5
- package/lib/library/AssignLibraryPlugin.js +71 -17
- package/lib/library/EnableLibraryPlugin.js +51 -25
- package/lib/library/ExportPropertyLibraryPlugin.js +12 -18
- package/lib/library/JsonpLibraryPlugin.js +5 -2
- package/lib/library/ModuleLibraryPlugin.js +230 -18
- package/lib/library/SystemLibraryPlugin.js +29 -11
- package/lib/library/UmdLibraryPlugin.js +35 -32
- package/lib/logging/Logger.js +18 -15
- package/lib/logging/createConsoleLogger.js +27 -27
- package/lib/logging/runtime.js +11 -11
- package/lib/logging/truncateArgs.js +5 -5
- package/lib/node/CommonJsChunkLoadingPlugin.js +72 -75
- package/lib/node/NodeEnvironmentPlugin.js +9 -3
- package/lib/node/NodeTargetPlugin.js +9 -1
- package/lib/node/NodeTemplatePlugin.js +2 -2
- package/lib/node/NodeWatchFileSystem.js +4 -4
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -38
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +10 -11
- package/lib/node/ReadFileCompileWasmPlugin.js +11 -14
- package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -30
- package/lib/node/nodeConsole.js +12 -7
- package/lib/optimize/AggressiveMergingPlugin.js +46 -47
- package/lib/optimize/AggressiveSplittingPlugin.js +233 -238
- package/lib/optimize/ConcatenatedModule.js +620 -251
- package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
- package/lib/optimize/FlagIncludedChunksPlugin.js +93 -96
- package/lib/optimize/InnerGraph.js +139 -124
- package/lib/optimize/InnerGraphPlugin.js +29 -24
- package/lib/optimize/LimitChunkCountPlugin.js +32 -8
- package/lib/optimize/MangleExportsPlugin.js +22 -22
- package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
- package/lib/optimize/MinChunkSizePlugin.js +12 -7
- package/lib/optimize/ModuleConcatenationPlugin.js +92 -71
- package/lib/optimize/RealContentHashPlugin.js +58 -44
- package/lib/optimize/RemoveEmptyChunksPlugin.js +8 -5
- package/lib/optimize/RemoveParentModulesPlugin.js +7 -4
- package/lib/optimize/RuntimeChunkPlugin.js +22 -25
- package/lib/optimize/SideEffectsFlagPlugin.js +44 -26
- package/lib/optimize/SplitChunksPlugin.js +209 -158
- package/lib/performance/AssetsOverSizeLimitWarning.js +1 -1
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
- package/lib/performance/SizeLimitsPlugin.js +8 -5
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -64
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -4
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
- package/lib/rules/BasicEffectRulePlugin.js +14 -5
- package/lib/rules/BasicMatcherRulePlugin.js +18 -7
- package/lib/rules/ObjectMatcherRulePlugin.js +17 -6
- package/lib/rules/RuleSetCompiler.js +73 -32
- package/lib/rules/UseEffectRulePlugin.js +61 -25
- package/lib/runtime/AsyncModuleRuntimeModule.js +74 -9
- package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -4
- package/lib/runtime/BaseUriRuntimeModule.js +2 -2
- package/lib/runtime/CompatRuntimeModule.js +0 -1
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +34 -35
- package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -1
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +248 -0
- package/lib/runtime/PublicPathRuntimeModule.js +2 -2
- package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
- package/lib/runtime/StartupChunkDependenciesPlugin.js +39 -42
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +10 -9
- package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
- package/lib/runtime/SystemContextRuntimeModule.js +0 -2
- package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
- package/lib/schemes/DataUriPlugin.js +9 -31
- package/lib/schemes/FileUriPlugin.js +11 -6
- package/lib/schemes/HttpUriPlugin.js +381 -261
- package/lib/schemes/VirtualUrlPlugin.js +222 -0
- package/lib/serialization/AggregateErrorSerializer.js +41 -0
- package/lib/serialization/BinaryMiddleware.js +51 -33
- package/lib/serialization/ErrorObjectSerializer.js +7 -2
- package/lib/serialization/FileMiddleware.js +101 -71
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +130 -54
- package/lib/serialization/PlainObjectSerializer.js +1 -1
- package/lib/serialization/Serializer.js +38 -20
- package/lib/serialization/SerializerMiddleware.js +121 -49
- package/lib/serialization/SingleItemMiddleware.js +9 -7
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +9 -9
- package/lib/sharing/ConsumeSharedPlugin.js +14 -14
- package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -8
- package/lib/sharing/ProvideSharedModule.js +9 -11
- package/lib/sharing/ProvideSharedModuleFactory.js +5 -3
- package/lib/sharing/ProvideSharedPlugin.js +15 -10
- package/lib/sharing/SharePlugin.js +3 -4
- package/lib/sharing/ShareRuntimeModule.js +7 -6
- package/lib/sharing/resolveMatchedConfigs.js +27 -13
- package/lib/sharing/utils.js +37 -43
- package/lib/stats/DefaultStatsFactoryPlugin.js +455 -286
- package/lib/stats/DefaultStatsPresetPlugin.js +77 -46
- package/lib/stats/DefaultStatsPrinterPlugin.js +583 -419
- package/lib/stats/StatsFactory.js +75 -32
- package/lib/stats/StatsPrinter.js +71 -51
- package/lib/url/URLParserPlugin.js +264 -0
- package/lib/util/ArrayHelpers.js +6 -8
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +11 -10
- package/lib/util/Hash.js +37 -5
- package/lib/util/IterableHelpers.js +4 -4
- package/lib/util/LazyBucketSortedSet.js +46 -27
- package/lib/util/LazySet.js +16 -10
- package/lib/util/MapHelpers.js +1 -1
- package/lib/util/ParallelismFactorCalculator.js +2 -2
- package/lib/util/Semaphore.js +3 -3
- package/lib/util/SetHelpers.js +6 -6
- package/lib/util/SortableSet.js +11 -9
- package/lib/util/StackedCacheMap.js +2 -2
- package/lib/util/StackedMap.js +3 -3
- package/lib/util/StringXor.js +2 -1
- package/lib/util/TupleQueue.js +11 -8
- package/lib/util/TupleSet.js +44 -19
- package/lib/util/URLAbsoluteSpecifier.js +3 -4
- package/lib/util/WeakTupleMap.js +56 -42
- package/lib/util/binarySearchBounds.js +4 -3
- package/lib/util/chainedImports.js +3 -1
- package/lib/util/cleverMerge.js +171 -107
- package/lib/util/comparators.js +265 -162
- package/lib/util/compileBooleanMatcher.js +120 -41
- package/lib/util/concatenate.js +20 -16
- package/lib/util/conventions.js +73 -74
- package/lib/util/create-schema-validation.js +8 -8
- package/lib/util/createHash.js +32 -135
- package/lib/util/dataURL.js +39 -0
- package/lib/util/deprecation.js +119 -116
- package/lib/util/deterministicGrouping.js +56 -47
- package/lib/util/extractSourceMap.js +319 -0
- package/lib/util/extractUrlAndGlobal.js +1 -1
- package/lib/util/findGraphRoots.js +19 -9
- package/lib/util/fs.js +169 -141
- package/lib/util/hash/BatchedHash.js +50 -10
- package/lib/util/hash/BulkUpdateHash.js +138 -0
- package/lib/util/hash/DebugHash.js +75 -0
- package/lib/util/hash/hash-digest.js +216 -0
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +59 -17
- package/lib/util/identifier.js +124 -61
- package/lib/util/internalSerializables.js +4 -6
- package/lib/util/magicComment.js +9 -5
- package/lib/util/makeSerializable.js +2 -2
- package/lib/util/memoize.js +5 -2
- package/lib/util/objectToMap.js +3 -2
- package/lib/util/processAsyncTree.js +5 -5
- package/lib/util/propertyAccess.js +1 -1
- package/lib/util/propertyName.js +2 -3
- package/lib/util/registerExternalSerializer.js +16 -20
- package/lib/util/removeBOM.js +25 -0
- package/lib/util/runtime.js +72 -56
- package/lib/util/semver.js +44 -33
- package/lib/util/serialization.js +56 -56
- package/lib/util/smartGrouping.js +42 -27
- package/lib/util/source.js +5 -4
- package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
- package/lib/validateSchema.js +7 -9
- package/lib/wasm/EnableWasmLoadingPlugin.js +22 -12
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -5
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +15 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +28 -22
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +47 -57
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -10
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +8 -4
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +23 -17
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
- package/lib/wasm-sync/WebAssemblyGenerator.js +56 -41
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +6 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +25 -10
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +11 -12
- package/lib/wasm-sync/WebAssemblyParser.js +10 -17
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -4
- package/lib/web/FetchCompileWasmPlugin.js +6 -8
- package/lib/web/JsonpChunkLoadingPlugin.js +74 -74
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +10 -26
- package/lib/web/JsonpTemplatePlugin.js +0 -1
- package/lib/webpack.js +107 -87
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +79 -75
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +38 -51
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
- package/module.d.ts +5 -0
- package/package.json +149 -129
- package/schemas/WebpackOptions.check.d.ts +1 -1
- package/schemas/WebpackOptions.check.js +2 -2
- package/schemas/WebpackOptions.json +543 -190
- package/schemas/plugins/BannerPlugin.check.d.ts +1 -1
- package/schemas/plugins/BannerPlugin.check.js +2 -2
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/schemas/plugins/DllPlugin.check.d.ts +1 -1
- package/schemas/plugins/DllPlugin.check.js +1 -1
- package/schemas/plugins/DllReferencePlugin.check.d.ts +1 -1
- package/schemas/plugins/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/IgnorePlugin.check.d.ts +1 -1
- package/schemas/plugins/IgnorePlugin.check.js +1 -1
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +1 -1
- package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
- package/schemas/plugins/{HashedModuleIdsPlugin.check.d.ts → ManifestPlugin.check.d.ts} +2 -2
- package/schemas/plugins/ManifestPlugin.check.js +6 -0
- package/schemas/plugins/ManifestPlugin.json +98 -0
- package/schemas/plugins/ProgressPlugin.check.d.ts +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +2 -2
- package/schemas/plugins/SourceMapDevToolPlugin.json +23 -6
- package/schemas/plugins/WatchIgnorePlugin.check.d.ts +1 -1
- package/schemas/plugins/WatchIgnorePlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +2 -2
- package/schemas/plugins/container/ContainerReferencePlugin.json +4 -1
- package/schemas/plugins/container/ExternalsType.check.d.ts +1 -1
- package/schemas/plugins/container/ExternalsType.check.js +2 -2
- package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +2 -2
- package/schemas/plugins/container/ModuleFederationPlugin.json +4 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +2 -2
- package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +2 -2
- package/schemas/plugins/css/CssParserOptions.check.d.ts +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +2 -2
- package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +1 -1
- package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
- package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +1 -1
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +1 -1
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +1 -1
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/{css/CssGlobalParserOptions.check.d.ts → json/JsonModulesPluginGenerator.check.d.ts} +1 -1
- package/schemas/plugins/json/JsonModulesPluginGenerator.check.js +6 -0
- package/schemas/plugins/json/JsonModulesPluginGenerator.json +3 -0
- package/schemas/plugins/{css/CssGlobalGeneratorOptions.check.d.ts → json/JsonModulesPluginParser.check.d.ts} +1 -1
- package/schemas/plugins/json/JsonModulesPluginParser.check.js +6 -0
- package/schemas/plugins/json/JsonModulesPluginParser.json +3 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +1 -1
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +1 -1
- package/schemas/plugins/sharing/SharePlugin.check.d.ts +1 -1
- package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
- package/types.d.ts +5115 -1863
- package/SECURITY.md +0 -9
- package/lib/ModuleSourceTypesConstants.js +0 -112
- package/lib/dependencies/CssLocalIdentifierDependency.js +0 -250
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +0 -111
- package/lib/library/ModernModuleLibraryPlugin.js +0 -144
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
- package/schemas/plugins/JsonModulesPluginParser.check.d.ts +0 -7
- package/schemas/plugins/JsonModulesPluginParser.check.js +0 -6
- package/schemas/plugins/JsonModulesPluginParser.json +0 -12
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +0 -6
- package/schemas/plugins/css/CssAutoGeneratorOptions.json +0 -3
- package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssAutoParserOptions.check.js +0 -6
- package/schemas/plugins/css/CssAutoParserOptions.json +0 -3
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +0 -6
- package/schemas/plugins/css/CssGlobalGeneratorOptions.json +0 -3
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +0 -6
- package/schemas/plugins/css/CssGlobalParserOptions.json +0 -3
package/lib/FileSystemInfo.js
CHANGED
|
@@ -5,29 +5,28 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const { create: createResolver } = require("enhanced-resolve");
|
|
9
8
|
const nodeModule = require("module");
|
|
10
|
-
const asyncLib = require("neo-async");
|
|
11
9
|
const { isAbsolute } = require("path");
|
|
10
|
+
const { create: createResolver } = require("enhanced-resolve");
|
|
11
|
+
const asyncLib = require("neo-async");
|
|
12
|
+
const { DEFAULTS } = require("./config/defaults");
|
|
12
13
|
const AsyncQueue = require("./util/AsyncQueue");
|
|
13
14
|
const StackedCacheMap = require("./util/StackedCacheMap");
|
|
14
15
|
const createHash = require("./util/createHash");
|
|
15
|
-
const { join,
|
|
16
|
+
const { dirname, join, lstatReadlinkAbsolute, relative } = require("./util/fs");
|
|
16
17
|
const makeSerializable = require("./util/makeSerializable");
|
|
18
|
+
const memoize = require("./util/memoize");
|
|
17
19
|
const processAsyncTree = require("./util/processAsyncTree");
|
|
18
20
|
|
|
19
|
-
/** @typedef {import("enhanced-resolve").Resolver} Resolver */
|
|
20
21
|
/** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
|
|
21
22
|
/** @typedef {import("enhanced-resolve").ResolveFunctionAsync} ResolveFunctionAsync */
|
|
22
23
|
/** @typedef {import("./WebpackError")} WebpackError */
|
|
23
24
|
/** @typedef {import("./logging/Logger").Logger} Logger */
|
|
24
25
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
25
26
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
26
|
-
/** @typedef {
|
|
27
|
+
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
|
27
28
|
/** @typedef {import("./util/fs").IStats} IStats */
|
|
28
29
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
29
|
-
/** @typedef {import("./util/fs").PathLike} PathLike */
|
|
30
|
-
/** @typedef {import("./util/fs").StringCallback} StringCallback */
|
|
31
30
|
/**
|
|
32
31
|
* @template T
|
|
33
32
|
* @typedef {import("./util/AsyncQueue").Callback<T>} ProcessorCallback
|
|
@@ -46,8 +45,8 @@ let FS_ACCURACY = 2000;
|
|
|
46
45
|
|
|
47
46
|
const EMPTY_SET = new Set();
|
|
48
47
|
|
|
49
|
-
const
|
|
50
|
-
const
|
|
48
|
+
const RBDT_RESOLVE_INITIAL = 0;
|
|
49
|
+
const RBDT_RESOLVE_FILE = 1;
|
|
51
50
|
const RBDT_RESOLVE_DIRECTORY = 2;
|
|
52
51
|
const RBDT_RESOLVE_CJS_FILE = 3;
|
|
53
52
|
const RBDT_RESOLVE_CJS_FILE_AS_CHILD = 4;
|
|
@@ -57,7 +56,7 @@ const RBDT_FILE = 7;
|
|
|
57
56
|
const RBDT_DIRECTORY_DEPENDENCIES = 8;
|
|
58
57
|
const RBDT_FILE_DEPENDENCIES = 9;
|
|
59
58
|
|
|
60
|
-
/** @typedef {
|
|
59
|
+
/** @typedef {RBDT_RESOLVE_INITIAL | RBDT_RESOLVE_FILE | RBDT_RESOLVE_DIRECTORY | RBDT_RESOLVE_CJS_FILE | RBDT_RESOLVE_CJS_FILE_AS_CHILD | RBDT_RESOLVE_ESM_FILE | RBDT_DIRECTORY | RBDT_FILE | RBDT_DIRECTORY_DEPENDENCIES | RBDT_FILE_DEPENDENCIES} JobType */
|
|
61
60
|
|
|
62
61
|
const INVALID = Symbol("invalid");
|
|
63
62
|
|
|
@@ -73,12 +72,14 @@ const INVALID = Symbol("invalid");
|
|
|
73
72
|
* @property {string=} timestampHash
|
|
74
73
|
*/
|
|
75
74
|
|
|
75
|
+
/** @typedef {Set<string>} Symlinks */
|
|
76
|
+
|
|
76
77
|
/**
|
|
77
78
|
* @typedef {object} ContextFileSystemInfoEntry
|
|
78
79
|
* @property {number} safeTime
|
|
79
80
|
* @property {string=} timestampHash
|
|
80
81
|
* @property {ResolvedContextFileSystemInfoEntry=} resolved
|
|
81
|
-
* @property {
|
|
82
|
+
* @property {Symlinks=} symlinks
|
|
82
83
|
*/
|
|
83
84
|
|
|
84
85
|
/**
|
|
@@ -95,8 +96,6 @@ const INVALID = Symbol("invalid");
|
|
|
95
96
|
* @property {string} hash
|
|
96
97
|
*/
|
|
97
98
|
|
|
98
|
-
/** @typedef {Set<string>} Symlinks */
|
|
99
|
-
|
|
100
99
|
/**
|
|
101
100
|
* @typedef {object} ContextTimestampAndHash
|
|
102
101
|
* @property {number} safeTime
|
|
@@ -123,16 +122,26 @@ const INVALID = Symbol("invalid");
|
|
|
123
122
|
* @property {Set<SnapshotOptimizationEntry> | undefined} children
|
|
124
123
|
*/
|
|
125
124
|
|
|
125
|
+
/** @typedef {Map<string, string | false | undefined>} ResolveResults */
|
|
126
|
+
|
|
127
|
+
/** @typedef {Set<string>} Files */
|
|
128
|
+
/** @typedef {Set<string>} Directories */
|
|
129
|
+
/** @typedef {Set<string>} Missing */
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @typedef {object} ResolveDependencies
|
|
133
|
+
* @property {Files} files list of files
|
|
134
|
+
* @property {Directories} directories list of directories
|
|
135
|
+
* @property {Missing} missing list of missing entries
|
|
136
|
+
*/
|
|
137
|
+
|
|
126
138
|
/**
|
|
127
139
|
* @typedef {object} ResolveBuildDependenciesResult
|
|
128
|
-
* @property {
|
|
129
|
-
* @property {
|
|
130
|
-
* @property {
|
|
131
|
-
* @property {
|
|
132
|
-
* @property {
|
|
133
|
-
* @property {Set<string>} resolveDependencies.files list of files
|
|
134
|
-
* @property {Set<string>} resolveDependencies.directories list of directories
|
|
135
|
-
* @property {Set<string>} resolveDependencies.missing list of missing entries
|
|
140
|
+
* @property {Files} files list of files
|
|
141
|
+
* @property {Directories} directories list of directories
|
|
142
|
+
* @property {Missing} missing list of missing entries
|
|
143
|
+
* @property {ResolveResults} resolveResults stored resolve results
|
|
144
|
+
* @property {ResolveDependencies} resolveDependencies dependencies of the resolving
|
|
136
145
|
*/
|
|
137
146
|
|
|
138
147
|
/**
|
|
@@ -157,13 +166,17 @@ class SnapshotIterator {
|
|
|
157
166
|
}
|
|
158
167
|
|
|
159
168
|
/**
|
|
160
|
-
* @
|
|
169
|
+
* @template T
|
|
170
|
+
* @typedef {(snapshot: Snapshot) => T[]} GetMapsFunction
|
|
161
171
|
*/
|
|
162
172
|
|
|
173
|
+
/**
|
|
174
|
+
* @template T
|
|
175
|
+
*/
|
|
163
176
|
class SnapshotIterable {
|
|
164
177
|
/**
|
|
165
178
|
* @param {Snapshot} snapshot snapshot
|
|
166
|
-
* @param {GetMapsFunction} getMaps get maps function
|
|
179
|
+
* @param {GetMapsFunction<T>} getMaps get maps function
|
|
167
180
|
*/
|
|
168
181
|
constructor(snapshot, getMaps) {
|
|
169
182
|
this.snapshot = snapshot;
|
|
@@ -174,9 +187,9 @@ class SnapshotIterable {
|
|
|
174
187
|
let state = 0;
|
|
175
188
|
/** @type {IterableIterator<string>} */
|
|
176
189
|
let it;
|
|
177
|
-
/** @type {
|
|
190
|
+
/** @type {GetMapsFunction<T>} */
|
|
178
191
|
let getMaps;
|
|
179
|
-
/** @type {
|
|
192
|
+
/** @type {T[]} */
|
|
180
193
|
let maps;
|
|
181
194
|
/** @type {Snapshot} */
|
|
182
195
|
let snapshot;
|
|
@@ -195,7 +208,9 @@ class SnapshotIterable {
|
|
|
195
208
|
if (maps.length > 0) {
|
|
196
209
|
const map = maps.pop();
|
|
197
210
|
if (map !== undefined) {
|
|
198
|
-
it =
|
|
211
|
+
it =
|
|
212
|
+
/** @type {Set<EXPECTED_ANY> | Map<string, EXPECTED_ANY>} */
|
|
213
|
+
(map).keys();
|
|
199
214
|
state = 2;
|
|
200
215
|
} else {
|
|
201
216
|
break;
|
|
@@ -303,7 +318,7 @@ class Snapshot {
|
|
|
303
318
|
* @param {number} value start value
|
|
304
319
|
*/
|
|
305
320
|
setStartTime(value) {
|
|
306
|
-
this._flags
|
|
321
|
+
this._flags |= 1;
|
|
307
322
|
this.startTime = value;
|
|
308
323
|
}
|
|
309
324
|
|
|
@@ -340,7 +355,7 @@ class Snapshot {
|
|
|
340
355
|
* @param {FileTimestamps} value file timestamps
|
|
341
356
|
*/
|
|
342
357
|
setFileTimestamps(value) {
|
|
343
|
-
this._flags
|
|
358
|
+
this._flags |= 2;
|
|
344
359
|
this.fileTimestamps = value;
|
|
345
360
|
}
|
|
346
361
|
|
|
@@ -352,7 +367,7 @@ class Snapshot {
|
|
|
352
367
|
* @param {FileHashes} value file hashes
|
|
353
368
|
*/
|
|
354
369
|
setFileHashes(value) {
|
|
355
|
-
this._flags
|
|
370
|
+
this._flags |= 4;
|
|
356
371
|
this.fileHashes = value;
|
|
357
372
|
}
|
|
358
373
|
|
|
@@ -364,7 +379,7 @@ class Snapshot {
|
|
|
364
379
|
* @param {FileTshs} value file tshs
|
|
365
380
|
*/
|
|
366
381
|
setFileTshs(value) {
|
|
367
|
-
this._flags
|
|
382
|
+
this._flags |= 8;
|
|
368
383
|
this.fileTshs = value;
|
|
369
384
|
}
|
|
370
385
|
|
|
@@ -376,7 +391,7 @@ class Snapshot {
|
|
|
376
391
|
* @param {ContextTimestamps} value context timestamps
|
|
377
392
|
*/
|
|
378
393
|
setContextTimestamps(value) {
|
|
379
|
-
this._flags
|
|
394
|
+
this._flags |= 0x10;
|
|
380
395
|
this.contextTimestamps = value;
|
|
381
396
|
}
|
|
382
397
|
|
|
@@ -388,7 +403,7 @@ class Snapshot {
|
|
|
388
403
|
* @param {ContextHashes} value context hashes
|
|
389
404
|
*/
|
|
390
405
|
setContextHashes(value) {
|
|
391
|
-
this._flags
|
|
406
|
+
this._flags |= 0x20;
|
|
392
407
|
this.contextHashes = value;
|
|
393
408
|
}
|
|
394
409
|
|
|
@@ -400,7 +415,7 @@ class Snapshot {
|
|
|
400
415
|
* @param {ContextTshs} value context tshs
|
|
401
416
|
*/
|
|
402
417
|
setContextTshs(value) {
|
|
403
|
-
this._flags
|
|
418
|
+
this._flags |= 0x40;
|
|
404
419
|
this.contextTshs = value;
|
|
405
420
|
}
|
|
406
421
|
|
|
@@ -412,7 +427,7 @@ class Snapshot {
|
|
|
412
427
|
* @param {MissingExistence} value context tshs
|
|
413
428
|
*/
|
|
414
429
|
setMissingExistence(value) {
|
|
415
|
-
this._flags
|
|
430
|
+
this._flags |= 0x80;
|
|
416
431
|
this.missingExistence = value;
|
|
417
432
|
}
|
|
418
433
|
|
|
@@ -424,7 +439,7 @@ class Snapshot {
|
|
|
424
439
|
* @param {ManagedItemInfo} value managed item info
|
|
425
440
|
*/
|
|
426
441
|
setManagedItemInfo(value) {
|
|
427
|
-
this._flags
|
|
442
|
+
this._flags |= 0x100;
|
|
428
443
|
this.managedItemInfo = value;
|
|
429
444
|
}
|
|
430
445
|
|
|
@@ -436,7 +451,7 @@ class Snapshot {
|
|
|
436
451
|
* @param {ManagedFiles} value managed files
|
|
437
452
|
*/
|
|
438
453
|
setManagedFiles(value) {
|
|
439
|
-
this._flags
|
|
454
|
+
this._flags |= 0x200;
|
|
440
455
|
this.managedFiles = value;
|
|
441
456
|
}
|
|
442
457
|
|
|
@@ -448,7 +463,7 @@ class Snapshot {
|
|
|
448
463
|
* @param {ManagedContexts} value managed contexts
|
|
449
464
|
*/
|
|
450
465
|
setManagedContexts(value) {
|
|
451
|
-
this._flags
|
|
466
|
+
this._flags |= 0x400;
|
|
452
467
|
this.managedContexts = value;
|
|
453
468
|
}
|
|
454
469
|
|
|
@@ -460,7 +475,7 @@ class Snapshot {
|
|
|
460
475
|
* @param {ManagedMissing} value managed missing
|
|
461
476
|
*/
|
|
462
477
|
setManagedMissing(value) {
|
|
463
|
-
this._flags
|
|
478
|
+
this._flags |= 0x800;
|
|
464
479
|
this.managedMissing = value;
|
|
465
480
|
}
|
|
466
481
|
|
|
@@ -472,7 +487,7 @@ class Snapshot {
|
|
|
472
487
|
* @param {Children} value children
|
|
473
488
|
*/
|
|
474
489
|
setChildren(value) {
|
|
475
|
-
this._flags
|
|
490
|
+
this._flags |= 0x1000;
|
|
476
491
|
this.children = value;
|
|
477
492
|
}
|
|
478
493
|
|
|
@@ -528,8 +543,9 @@ class Snapshot {
|
|
|
528
543
|
}
|
|
529
544
|
|
|
530
545
|
/**
|
|
531
|
-
* @
|
|
532
|
-
* @
|
|
546
|
+
* @template T
|
|
547
|
+
* @param {GetMapsFunction<T>} getMaps first
|
|
548
|
+
* @returns {SnapshotIterable<T>} iterable
|
|
533
549
|
*/
|
|
534
550
|
_createIterable(getMaps) {
|
|
535
551
|
return new SnapshotIterable(this, getMaps);
|
|
@@ -540,7 +556,7 @@ class Snapshot {
|
|
|
540
556
|
*/
|
|
541
557
|
getFileIterable() {
|
|
542
558
|
if (this._cachedFileIterable === undefined) {
|
|
543
|
-
this._cachedFileIterable = this._createIterable(s => [
|
|
559
|
+
this._cachedFileIterable = this._createIterable((s) => [
|
|
544
560
|
s.fileTimestamps,
|
|
545
561
|
s.fileHashes,
|
|
546
562
|
s.fileTshs,
|
|
@@ -555,7 +571,7 @@ class Snapshot {
|
|
|
555
571
|
*/
|
|
556
572
|
getContextIterable() {
|
|
557
573
|
if (this._cachedContextIterable === undefined) {
|
|
558
|
-
this._cachedContextIterable = this._createIterable(s => [
|
|
574
|
+
this._cachedContextIterable = this._createIterable((s) => [
|
|
559
575
|
s.contextTimestamps,
|
|
560
576
|
s.contextHashes,
|
|
561
577
|
s.contextTshs,
|
|
@@ -570,7 +586,7 @@ class Snapshot {
|
|
|
570
586
|
*/
|
|
571
587
|
getMissingIterable() {
|
|
572
588
|
if (this._cachedMissingIterable === undefined) {
|
|
573
|
-
this._cachedMissingIterable = this._createIterable(s => [
|
|
589
|
+
this._cachedMissingIterable = this._createIterable((s) => [
|
|
574
590
|
s.missingExistence,
|
|
575
591
|
s.managedMissing
|
|
576
592
|
]);
|
|
@@ -594,9 +610,9 @@ const MIN_COMMON_SNAPSHOT_SIZE = 3;
|
|
|
594
610
|
*/
|
|
595
611
|
class SnapshotOptimization {
|
|
596
612
|
/**
|
|
597
|
-
* @param {
|
|
598
|
-
* @param {
|
|
599
|
-
* @param {
|
|
613
|
+
* @param {(snapshot: Snapshot) => boolean} has has value
|
|
614
|
+
* @param {(snapshot: Snapshot) => SnapshotOptimizationValue<U, T> | undefined} get get value
|
|
615
|
+
* @param {(snapshot: Snapshot, value: SnapshotOptimizationValue<U, T>) => void} set set value
|
|
600
616
|
* @param {boolean=} useStartTime use the start time of snapshots
|
|
601
617
|
* @param {U=} isSet value is an Set instead of a Map
|
|
602
618
|
*/
|
|
@@ -647,11 +663,14 @@ class SnapshotOptimization {
|
|
|
647
663
|
* @returns {void}
|
|
648
664
|
*/
|
|
649
665
|
optimize(newSnapshot, capturedFiles) {
|
|
666
|
+
if (capturedFiles.size === 0) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
650
669
|
/**
|
|
651
670
|
* @param {SnapshotOptimizationEntry} entry optimization entry
|
|
652
671
|
* @returns {void}
|
|
653
672
|
*/
|
|
654
|
-
const increaseSharedAndStoreOptimizationEntry = entry => {
|
|
673
|
+
const increaseSharedAndStoreOptimizationEntry = (entry) => {
|
|
655
674
|
if (entry.children !== undefined) {
|
|
656
675
|
for (const child of entry.children) {
|
|
657
676
|
increaseSharedAndStoreOptimizationEntry(child);
|
|
@@ -664,7 +683,7 @@ class SnapshotOptimization {
|
|
|
664
683
|
* @param {SnapshotOptimizationEntry} entry optimization entry
|
|
665
684
|
* @returns {void}
|
|
666
685
|
*/
|
|
667
|
-
const storeOptimizationEntry = entry => {
|
|
686
|
+
const storeOptimizationEntry = (entry) => {
|
|
668
687
|
for (const path of /** @type {SnapshotContent} */ (
|
|
669
688
|
entry.snapshotContent
|
|
670
689
|
)) {
|
|
@@ -698,7 +717,6 @@ class SnapshotOptimization {
|
|
|
698
717
|
};
|
|
699
718
|
}
|
|
700
719
|
this._map.set(path, newOptimizationEntry);
|
|
701
|
-
continue;
|
|
702
720
|
} else {
|
|
703
721
|
optimizationEntries.add(optimizationEntry);
|
|
704
722
|
}
|
|
@@ -717,6 +735,7 @@ class SnapshotOptimization {
|
|
|
717
735
|
) {
|
|
718
736
|
continue;
|
|
719
737
|
}
|
|
738
|
+
/** @type {Set<string>} */
|
|
720
739
|
const nonSharedFiles = new Set();
|
|
721
740
|
const snapshotContent =
|
|
722
741
|
/** @type {NonNullable<SnapshotOptimizationEntry["snapshotContent"]>} */
|
|
@@ -732,7 +751,6 @@ class SnapshotOptimization {
|
|
|
732
751
|
continue optimizationEntriesLabel;
|
|
733
752
|
}
|
|
734
753
|
nonSharedFiles.add(path);
|
|
735
|
-
continue;
|
|
736
754
|
}
|
|
737
755
|
}
|
|
738
756
|
if (nonSharedFiles.size === 0) {
|
|
@@ -784,8 +802,9 @@ class SnapshotOptimization {
|
|
|
784
802
|
snapshotContent: new Set(commonMap.keys()),
|
|
785
803
|
children: undefined
|
|
786
804
|
};
|
|
787
|
-
if (optimizationEntry.children === undefined)
|
|
805
|
+
if (optimizationEntry.children === undefined) {
|
|
788
806
|
optimizationEntry.children = new Set();
|
|
807
|
+
}
|
|
789
808
|
optimizationEntry.children.add(newEntry);
|
|
790
809
|
storeOptimizationEntry(newEntry);
|
|
791
810
|
this._statSharedSnapshots++;
|
|
@@ -863,9 +882,10 @@ class SnapshotOptimization {
|
|
|
863
882
|
* @param {string} str input
|
|
864
883
|
* @returns {string} result
|
|
865
884
|
*/
|
|
866
|
-
const parseString = str => {
|
|
867
|
-
if (str[0] === "'" || str[0] === "`")
|
|
885
|
+
const parseString = (str) => {
|
|
886
|
+
if (str[0] === "'" || str[0] === "`") {
|
|
868
887
|
str = `"${str.slice(1, -1).replace(/"/g, '\\"')}"`;
|
|
888
|
+
}
|
|
869
889
|
return JSON.parse(str);
|
|
870
890
|
};
|
|
871
891
|
|
|
@@ -873,7 +893,7 @@ const parseString = str => {
|
|
|
873
893
|
/**
|
|
874
894
|
* @param {number} mtime mtime
|
|
875
895
|
*/
|
|
876
|
-
const applyMtime = mtime => {
|
|
896
|
+
const applyMtime = (mtime) => {
|
|
877
897
|
if (FS_ACCURACY > 1 && mtime % 2 !== 0) FS_ACCURACY = 1;
|
|
878
898
|
else if (FS_ACCURACY > 10 && mtime % 20 !== 0) FS_ACCURACY = 10;
|
|
879
899
|
else if (FS_ACCURACY > 100 && mtime % 200 !== 0) FS_ACCURACY = 100;
|
|
@@ -919,7 +939,7 @@ const mergeSets = (a, b) => {
|
|
|
919
939
|
* Finding file or directory to manage
|
|
920
940
|
* @param {string} managedPath path that is managing by {@link FileSystemInfo}
|
|
921
941
|
* @param {string} path path to file or directory
|
|
922
|
-
* @returns {string|null} managed item
|
|
942
|
+
* @returns {string | null} managed item
|
|
923
943
|
* @example
|
|
924
944
|
* getManagedItem(
|
|
925
945
|
* '/Users/user/my-project/node_modules/',
|
|
@@ -1004,7 +1024,7 @@ const getManagedItem = (managedPath, path) => {
|
|
|
1004
1024
|
* @param {T | null} entry entry
|
|
1005
1025
|
* @returns {T["resolved"] | null | undefined} the resolved entry
|
|
1006
1026
|
*/
|
|
1007
|
-
const getResolvedTimestamp = entry => {
|
|
1027
|
+
const getResolvedTimestamp = (entry) => {
|
|
1008
1028
|
if (entry === null) return null;
|
|
1009
1029
|
if (entry.resolved !== undefined) return entry.resolved;
|
|
1010
1030
|
return entry.symlinks === undefined ? entry : undefined;
|
|
@@ -1014,7 +1034,7 @@ const getResolvedTimestamp = entry => {
|
|
|
1014
1034
|
* @param {ContextHash | null} entry entry
|
|
1015
1035
|
* @returns {string | null | undefined} the resolved entry
|
|
1016
1036
|
*/
|
|
1017
|
-
const getResolvedHash = entry => {
|
|
1037
|
+
const getResolvedHash = (entry) => {
|
|
1018
1038
|
if (entry === null) return null;
|
|
1019
1039
|
if (entry.resolved !== undefined) return entry.resolved;
|
|
1020
1040
|
return entry.symlinks === undefined ? entry.hash : undefined;
|
|
@@ -1029,8 +1049,16 @@ const addAll = (source, target) => {
|
|
|
1029
1049
|
for (const key of source) target.add(key);
|
|
1030
1050
|
};
|
|
1031
1051
|
|
|
1052
|
+
const getEsModuleLexer = memoize(() => require("es-module-lexer"));
|
|
1053
|
+
|
|
1032
1054
|
/** @typedef {Set<string>} LoggedPaths */
|
|
1033
1055
|
|
|
1056
|
+
/** @typedef {FileSystemInfoEntry | "ignore" | null} FileTimestamp */
|
|
1057
|
+
/** @typedef {ContextFileSystemInfoEntry | "ignore" | null} ContextTimestamp */
|
|
1058
|
+
/** @typedef {ResolvedContextFileSystemInfoEntry | "ignore" | null} ResolvedContextTimestamp */
|
|
1059
|
+
|
|
1060
|
+
/** @typedef {(err?: WebpackError | null, result?: boolean) => void} CheckSnapshotValidCallback */
|
|
1061
|
+
|
|
1034
1062
|
/**
|
|
1035
1063
|
* Used to access information about the filesystem in a cached way
|
|
1036
1064
|
*/
|
|
@@ -1042,7 +1070,7 @@ class FileSystemInfo {
|
|
|
1042
1070
|
* @param {Iterable<string | RegExp>=} options.managedPaths paths that are only managed by a package manager
|
|
1043
1071
|
* @param {Iterable<string | RegExp>=} options.immutablePaths paths that are immutable
|
|
1044
1072
|
* @param {Logger=} options.logger logger used to log invalid snapshots
|
|
1045
|
-
* @param {
|
|
1073
|
+
* @param {HashFunction=} options.hashFunction the hash function to use
|
|
1046
1074
|
*/
|
|
1047
1075
|
constructor(
|
|
1048
1076
|
fs,
|
|
@@ -1051,7 +1079,7 @@ class FileSystemInfo {
|
|
|
1051
1079
|
managedPaths = [],
|
|
1052
1080
|
immutablePaths = [],
|
|
1053
1081
|
logger,
|
|
1054
|
-
hashFunction =
|
|
1082
|
+
hashFunction = DEFAULTS.HASH_FUNCTION
|
|
1055
1083
|
} = {}
|
|
1056
1084
|
) {
|
|
1057
1085
|
this.fs = fs;
|
|
@@ -1060,80 +1088,80 @@ class FileSystemInfo {
|
|
|
1060
1088
|
/** @type {LoggedPaths | undefined} */
|
|
1061
1089
|
this._loggedPaths = logger ? new Set() : undefined;
|
|
1062
1090
|
this._hashFunction = hashFunction;
|
|
1063
|
-
/** @type {WeakMap<Snapshot, boolean |
|
|
1091
|
+
/** @type {WeakMap<Snapshot, boolean | CheckSnapshotValidCallback[]>} */
|
|
1064
1092
|
this._snapshotCache = new WeakMap();
|
|
1065
1093
|
this._fileTimestampsOptimization = new SnapshotOptimization(
|
|
1066
|
-
s => s.hasFileTimestamps(),
|
|
1067
|
-
s => s.fileTimestamps,
|
|
1094
|
+
(s) => s.hasFileTimestamps(),
|
|
1095
|
+
(s) => s.fileTimestamps,
|
|
1068
1096
|
(s, v) => s.setFileTimestamps(v)
|
|
1069
1097
|
);
|
|
1070
1098
|
this._fileHashesOptimization = new SnapshotOptimization(
|
|
1071
|
-
s => s.hasFileHashes(),
|
|
1072
|
-
s => s.fileHashes,
|
|
1099
|
+
(s) => s.hasFileHashes(),
|
|
1100
|
+
(s) => s.fileHashes,
|
|
1073
1101
|
(s, v) => s.setFileHashes(v),
|
|
1074
1102
|
false
|
|
1075
1103
|
);
|
|
1076
1104
|
this._fileTshsOptimization = new SnapshotOptimization(
|
|
1077
|
-
s => s.hasFileTshs(),
|
|
1078
|
-
s => s.fileTshs,
|
|
1105
|
+
(s) => s.hasFileTshs(),
|
|
1106
|
+
(s) => s.fileTshs,
|
|
1079
1107
|
(s, v) => s.setFileTshs(v)
|
|
1080
1108
|
);
|
|
1081
1109
|
this._contextTimestampsOptimization = new SnapshotOptimization(
|
|
1082
|
-
s => s.hasContextTimestamps(),
|
|
1083
|
-
s => s.contextTimestamps,
|
|
1110
|
+
(s) => s.hasContextTimestamps(),
|
|
1111
|
+
(s) => s.contextTimestamps,
|
|
1084
1112
|
(s, v) => s.setContextTimestamps(v)
|
|
1085
1113
|
);
|
|
1086
1114
|
this._contextHashesOptimization = new SnapshotOptimization(
|
|
1087
|
-
s => s.hasContextHashes(),
|
|
1088
|
-
s => s.contextHashes,
|
|
1115
|
+
(s) => s.hasContextHashes(),
|
|
1116
|
+
(s) => s.contextHashes,
|
|
1089
1117
|
(s, v) => s.setContextHashes(v),
|
|
1090
1118
|
false
|
|
1091
1119
|
);
|
|
1092
1120
|
this._contextTshsOptimization = new SnapshotOptimization(
|
|
1093
|
-
s => s.hasContextTshs(),
|
|
1094
|
-
s => s.contextTshs,
|
|
1121
|
+
(s) => s.hasContextTshs(),
|
|
1122
|
+
(s) => s.contextTshs,
|
|
1095
1123
|
(s, v) => s.setContextTshs(v)
|
|
1096
1124
|
);
|
|
1097
1125
|
this._missingExistenceOptimization = new SnapshotOptimization(
|
|
1098
|
-
s => s.hasMissingExistence(),
|
|
1099
|
-
s => s.missingExistence,
|
|
1126
|
+
(s) => s.hasMissingExistence(),
|
|
1127
|
+
(s) => s.missingExistence,
|
|
1100
1128
|
(s, v) => s.setMissingExistence(v),
|
|
1101
1129
|
false
|
|
1102
1130
|
);
|
|
1103
1131
|
this._managedItemInfoOptimization = new SnapshotOptimization(
|
|
1104
|
-
s => s.hasManagedItemInfo(),
|
|
1105
|
-
s => s.managedItemInfo,
|
|
1132
|
+
(s) => s.hasManagedItemInfo(),
|
|
1133
|
+
(s) => s.managedItemInfo,
|
|
1106
1134
|
(s, v) => s.setManagedItemInfo(v),
|
|
1107
1135
|
false
|
|
1108
1136
|
);
|
|
1109
1137
|
this._managedFilesOptimization = new SnapshotOptimization(
|
|
1110
|
-
s => s.hasManagedFiles(),
|
|
1111
|
-
s => s.managedFiles,
|
|
1138
|
+
(s) => s.hasManagedFiles(),
|
|
1139
|
+
(s) => s.managedFiles,
|
|
1112
1140
|
(s, v) => s.setManagedFiles(v),
|
|
1113
1141
|
false,
|
|
1114
1142
|
true
|
|
1115
1143
|
);
|
|
1116
1144
|
this._managedContextsOptimization = new SnapshotOptimization(
|
|
1117
|
-
s => s.hasManagedContexts(),
|
|
1118
|
-
s => s.managedContexts,
|
|
1145
|
+
(s) => s.hasManagedContexts(),
|
|
1146
|
+
(s) => s.managedContexts,
|
|
1119
1147
|
(s, v) => s.setManagedContexts(v),
|
|
1120
1148
|
false,
|
|
1121
1149
|
true
|
|
1122
1150
|
);
|
|
1123
1151
|
this._managedMissingOptimization = new SnapshotOptimization(
|
|
1124
|
-
s => s.hasManagedMissing(),
|
|
1125
|
-
s => s.managedMissing,
|
|
1152
|
+
(s) => s.hasManagedMissing(),
|
|
1153
|
+
(s) => s.managedMissing,
|
|
1126
1154
|
(s, v) => s.setManagedMissing(v),
|
|
1127
1155
|
false,
|
|
1128
1156
|
true
|
|
1129
1157
|
);
|
|
1130
|
-
/** @type {StackedCacheMap<string,
|
|
1158
|
+
/** @type {StackedCacheMap<string, FileTimestamp>} */
|
|
1131
1159
|
this._fileTimestamps = new StackedCacheMap();
|
|
1132
1160
|
/** @type {Map<string, string | null>} */
|
|
1133
1161
|
this._fileHashes = new Map();
|
|
1134
1162
|
/** @type {Map<string, TimestampAndHash | string>} */
|
|
1135
1163
|
this._fileTshs = new Map();
|
|
1136
|
-
/** @type {StackedCacheMap<string,
|
|
1164
|
+
/** @type {StackedCacheMap<string, ContextTimestamp>} */
|
|
1137
1165
|
this._contextTimestamps = new StackedCacheMap();
|
|
1138
1166
|
/** @type {Map<string, ContextHash>} */
|
|
1139
1167
|
this._contextHashes = new Map();
|
|
@@ -1183,28 +1211,34 @@ class FileSystemInfo {
|
|
|
1183
1211
|
parallelism: 10,
|
|
1184
1212
|
processor: this._getManagedItemDirectoryInfo.bind(this)
|
|
1185
1213
|
});
|
|
1186
|
-
const _unmanagedPaths =
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1214
|
+
const _unmanagedPaths = [...unmanagedPaths];
|
|
1215
|
+
/** @type {string[]} */
|
|
1216
|
+
this.unmanagedPathsWithSlash = _unmanagedPaths
|
|
1217
|
+
.filter((p) => typeof p === "string")
|
|
1218
|
+
.map((p) => join(fs, p, "_").slice(0, -1));
|
|
1219
|
+
/** @type {RegExp[]} */
|
|
1220
|
+
this.unmanagedPathsRegExps = _unmanagedPaths.filter(
|
|
1221
|
+
(p) => typeof p !== "string"
|
|
1192
1222
|
);
|
|
1193
1223
|
|
|
1194
|
-
this.managedPaths =
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1224
|
+
this.managedPaths = [...managedPaths];
|
|
1225
|
+
/** @type {string[]} */
|
|
1226
|
+
this.managedPathsWithSlash = this.managedPaths
|
|
1227
|
+
.filter((p) => typeof p === "string")
|
|
1228
|
+
.map((p) => join(fs, p, "_").slice(0, -1));
|
|
1229
|
+
/** @type {RegExp[]} */
|
|
1230
|
+
this.managedPathsRegExps = this.managedPaths.filter(
|
|
1231
|
+
(p) => typeof p !== "string"
|
|
1201
1232
|
);
|
|
1202
|
-
|
|
1203
|
-
this.
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1233
|
+
|
|
1234
|
+
this.immutablePaths = [...immutablePaths];
|
|
1235
|
+
/** @type {string[]} */
|
|
1236
|
+
this.immutablePathsWithSlash = this.immutablePaths
|
|
1237
|
+
.filter((p) => typeof p === "string")
|
|
1238
|
+
.map((p) => join(fs, p, "_").slice(0, -1));
|
|
1239
|
+
/** @type {RegExp[]} */
|
|
1240
|
+
this.immutablePathsRegExps = this.immutablePaths.filter(
|
|
1241
|
+
(p) => typeof p !== "string"
|
|
1208
1242
|
);
|
|
1209
1243
|
|
|
1210
1244
|
this._cachedDeprecatedFileTimestamps = undefined;
|
|
@@ -1310,9 +1344,10 @@ class FileSystemInfo {
|
|
|
1310
1344
|
}
|
|
1311
1345
|
|
|
1312
1346
|
/**
|
|
1347
|
+
* @private
|
|
1313
1348
|
* @param {string} path path
|
|
1314
1349
|
* @param {string} reason reason
|
|
1315
|
-
* @param {
|
|
1350
|
+
* @param {EXPECTED_ANY[]} args arguments
|
|
1316
1351
|
*/
|
|
1317
1352
|
_log(path, reason, ...args) {
|
|
1318
1353
|
const key = path + reason;
|
|
@@ -1366,7 +1401,7 @@ class FileSystemInfo {
|
|
|
1366
1401
|
}
|
|
1367
1402
|
|
|
1368
1403
|
/**
|
|
1369
|
-
* @param {ReadonlyMap<string,
|
|
1404
|
+
* @param {ReadonlyMap<string, FileTimestamp>} map timestamps
|
|
1370
1405
|
* @param {boolean=} immutable if 'map' is immutable and FileSystemInfo can keep referencing it
|
|
1371
1406
|
* @returns {void}
|
|
1372
1407
|
*/
|
|
@@ -1376,7 +1411,7 @@ class FileSystemInfo {
|
|
|
1376
1411
|
}
|
|
1377
1412
|
|
|
1378
1413
|
/**
|
|
1379
|
-
* @param {ReadonlyMap<string,
|
|
1414
|
+
* @param {ReadonlyMap<string, ContextTimestamp>} map timestamps
|
|
1380
1415
|
* @param {boolean=} immutable if 'map' is immutable and FileSystemInfo can keep referencing it
|
|
1381
1416
|
* @returns {void}
|
|
1382
1417
|
*/
|
|
@@ -1387,7 +1422,7 @@ class FileSystemInfo {
|
|
|
1387
1422
|
|
|
1388
1423
|
/**
|
|
1389
1424
|
* @param {string} path file path
|
|
1390
|
-
* @param {
|
|
1425
|
+
* @param {(err?: WebpackError | null, fileTimestamp?: FileTimestamp) => void} callback callback function
|
|
1391
1426
|
* @returns {void}
|
|
1392
1427
|
*/
|
|
1393
1428
|
getFileTimestamp(path, callback) {
|
|
@@ -1398,7 +1433,7 @@ class FileSystemInfo {
|
|
|
1398
1433
|
|
|
1399
1434
|
/**
|
|
1400
1435
|
* @param {string} path context path
|
|
1401
|
-
* @param {
|
|
1436
|
+
* @param {(err?: WebpackError | null, resolvedContextTimestamp?: ResolvedContextTimestamp) => void} callback callback function
|
|
1402
1437
|
* @returns {void}
|
|
1403
1438
|
*/
|
|
1404
1439
|
getContextTimestamp(path, callback) {
|
|
@@ -1423,8 +1458,9 @@ class FileSystemInfo {
|
|
|
1423
1458
|
}
|
|
1424
1459
|
|
|
1425
1460
|
/**
|
|
1461
|
+
* @private
|
|
1426
1462
|
* @param {string} path context path
|
|
1427
|
-
* @param {
|
|
1463
|
+
* @param {(err?: WebpackError | null, contextTimestamp?: ContextTimestamp) => void} callback callback function
|
|
1428
1464
|
* @returns {void}
|
|
1429
1465
|
*/
|
|
1430
1466
|
_getUnresolvedContextTimestamp(path, callback) {
|
|
@@ -1435,7 +1471,7 @@ class FileSystemInfo {
|
|
|
1435
1471
|
|
|
1436
1472
|
/**
|
|
1437
1473
|
* @param {string} path file path
|
|
1438
|
-
* @param {
|
|
1474
|
+
* @param {(err?: WebpackError | null, hash?: string | null) => void} callback callback function
|
|
1439
1475
|
* @returns {void}
|
|
1440
1476
|
*/
|
|
1441
1477
|
getFileHash(path, callback) {
|
|
@@ -1446,30 +1482,33 @@ class FileSystemInfo {
|
|
|
1446
1482
|
|
|
1447
1483
|
/**
|
|
1448
1484
|
* @param {string} path context path
|
|
1449
|
-
* @param {
|
|
1485
|
+
* @param {(err?: WebpackError | null, contextHash?: string) => void} callback callback function
|
|
1450
1486
|
* @returns {void}
|
|
1451
1487
|
*/
|
|
1452
1488
|
getContextHash(path, callback) {
|
|
1453
1489
|
const cache = this._contextHashes.get(path);
|
|
1454
1490
|
if (cache !== undefined) {
|
|
1455
1491
|
const resolved = getResolvedHash(cache);
|
|
1456
|
-
if (resolved !== undefined)
|
|
1492
|
+
if (resolved !== undefined) {
|
|
1457
1493
|
return callback(null, /** @type {string} */ (resolved));
|
|
1494
|
+
}
|
|
1458
1495
|
return this._resolveContextHash(cache, callback);
|
|
1459
1496
|
}
|
|
1460
1497
|
this.contextHashQueue.add(path, (err, _entry) => {
|
|
1461
1498
|
if (err) return callback(err);
|
|
1462
1499
|
const entry = /** @type {ContextHash} */ (_entry);
|
|
1463
1500
|
const resolved = getResolvedHash(entry);
|
|
1464
|
-
if (resolved !== undefined)
|
|
1501
|
+
if (resolved !== undefined) {
|
|
1465
1502
|
return callback(null, /** @type {string} */ (resolved));
|
|
1503
|
+
}
|
|
1466
1504
|
this._resolveContextHash(entry, callback);
|
|
1467
1505
|
});
|
|
1468
1506
|
}
|
|
1469
1507
|
|
|
1470
1508
|
/**
|
|
1509
|
+
* @private
|
|
1471
1510
|
* @param {string} path context path
|
|
1472
|
-
* @param {
|
|
1511
|
+
* @param {(err?: WebpackError | null, contextHash?: ContextHash | null) => void} callback callback function
|
|
1473
1512
|
* @returns {void}
|
|
1474
1513
|
*/
|
|
1475
1514
|
_getUnresolvedContextHash(path, callback) {
|
|
@@ -1480,7 +1519,7 @@ class FileSystemInfo {
|
|
|
1480
1519
|
|
|
1481
1520
|
/**
|
|
1482
1521
|
* @param {string} path context path
|
|
1483
|
-
* @param {
|
|
1522
|
+
* @param {(err?: WebpackError | null, resolvedContextTimestampAndHash?: ResolvedContextTimestampAndHash | null) => void} callback callback function
|
|
1484
1523
|
* @returns {void}
|
|
1485
1524
|
*/
|
|
1486
1525
|
getContextTsh(path, callback) {
|
|
@@ -1500,8 +1539,9 @@ class FileSystemInfo {
|
|
|
1500
1539
|
}
|
|
1501
1540
|
|
|
1502
1541
|
/**
|
|
1542
|
+
* @private
|
|
1503
1543
|
* @param {string} path context path
|
|
1504
|
-
* @param {
|
|
1544
|
+
* @param {(err?: WebpackError | null, contextTimestampAndHash?: ContextTimestampAndHash | null) => void} callback callback function
|
|
1505
1545
|
* @returns {void}
|
|
1506
1546
|
*/
|
|
1507
1547
|
_getUnresolvedContextTsh(path, callback) {
|
|
@@ -1541,31 +1581,32 @@ class FileSystemInfo {
|
|
|
1541
1581
|
/**
|
|
1542
1582
|
* @param {string} context context directory
|
|
1543
1583
|
* @param {Iterable<string>} deps dependencies
|
|
1544
|
-
* @param {
|
|
1584
|
+
* @param {(err?: Error | null, resolveBuildDependenciesResult?: ResolveBuildDependenciesResult) => void} callback callback function
|
|
1545
1585
|
* @returns {void}
|
|
1546
1586
|
*/
|
|
1547
1587
|
resolveBuildDependencies(context, deps, callback) {
|
|
1548
1588
|
const { resolveContext, resolveEsm, resolveCjs, resolveCjsAsChild } =
|
|
1549
1589
|
this._createBuildDependenciesResolvers();
|
|
1550
1590
|
|
|
1551
|
-
/** @type {
|
|
1591
|
+
/** @type {Files} */
|
|
1552
1592
|
const files = new Set();
|
|
1553
|
-
/** @type {
|
|
1593
|
+
/** @type {Symlinks} */
|
|
1554
1594
|
const fileSymlinks = new Set();
|
|
1555
|
-
/** @type {
|
|
1595
|
+
/** @type {Directories} */
|
|
1556
1596
|
const directories = new Set();
|
|
1557
|
-
/** @type {
|
|
1597
|
+
/** @type {Symlinks} */
|
|
1558
1598
|
const directorySymlinks = new Set();
|
|
1559
|
-
/** @type {
|
|
1599
|
+
/** @type {Missing} */
|
|
1560
1600
|
const missing = new Set();
|
|
1561
|
-
/** @type {
|
|
1601
|
+
/** @type {ResolveDependencies["files"]} */
|
|
1562
1602
|
const resolveFiles = new Set();
|
|
1563
|
-
/** @type {
|
|
1603
|
+
/** @type {ResolveDependencies["directories"]} */
|
|
1564
1604
|
const resolveDirectories = new Set();
|
|
1565
|
-
/** @type {
|
|
1605
|
+
/** @type {ResolveDependencies["missing"]} */
|
|
1566
1606
|
const resolveMissing = new Set();
|
|
1567
|
-
/** @type {
|
|
1607
|
+
/** @type {ResolveResults} */
|
|
1568
1608
|
const resolveResults = new Map();
|
|
1609
|
+
/** @type {Set<string>} */
|
|
1569
1610
|
const invalidResolveResults = new Set();
|
|
1570
1611
|
const resolverContext = {
|
|
1571
1612
|
fileDependencies: resolveFiles,
|
|
@@ -1576,22 +1617,18 @@ class FileSystemInfo {
|
|
|
1576
1617
|
* @param {undefined | boolean | string} expected expected result
|
|
1577
1618
|
* @returns {string} expected result
|
|
1578
1619
|
*/
|
|
1579
|
-
const expectedToString = expected =>
|
|
1620
|
+
const expectedToString = (expected) =>
|
|
1580
1621
|
expected ? ` (expected ${expected})` : "";
|
|
1581
1622
|
/** @typedef {{ type: JobType, context: string | undefined, path: string, issuer: Job | undefined, expected: undefined | boolean | string }} Job */
|
|
1582
1623
|
|
|
1583
1624
|
/**
|
|
1584
1625
|
* @param {Job} job job
|
|
1585
|
-
* @returns {
|
|
1626
|
+
* @returns {string} result
|
|
1586
1627
|
*/
|
|
1587
|
-
const jobToString = job => {
|
|
1628
|
+
const jobToString = (job) => {
|
|
1588
1629
|
switch (job.type) {
|
|
1589
|
-
case
|
|
1590
|
-
return `resolve
|
|
1591
|
-
job.expected
|
|
1592
|
-
)}`;
|
|
1593
|
-
case RBDT_RESOLVE_ESM:
|
|
1594
|
-
return `resolve esm ${job.path}${expectedToString(job.expected)}`;
|
|
1630
|
+
case RBDT_RESOLVE_FILE:
|
|
1631
|
+
return `resolve file ${job.path}${expectedToString(job.expected)}`;
|
|
1595
1632
|
case RBDT_RESOLVE_DIRECTORY:
|
|
1596
1633
|
return `resolve directory ${job.path}`;
|
|
1597
1634
|
case RBDT_RESOLVE_CJS_FILE:
|
|
@@ -1617,7 +1654,7 @@ class FileSystemInfo {
|
|
|
1617
1654
|
* @param {Job} job job
|
|
1618
1655
|
* @returns {string} string value
|
|
1619
1656
|
*/
|
|
1620
|
-
const pathToString = job => {
|
|
1657
|
+
const pathToString = (job) => {
|
|
1621
1658
|
let result = ` at ${jobToString(job)}`;
|
|
1622
1659
|
/** @type {Job | undefined} */
|
|
1623
1660
|
(job) = job.issuer;
|
|
@@ -1631,9 +1668,9 @@ class FileSystemInfo {
|
|
|
1631
1668
|
processAsyncTree(
|
|
1632
1669
|
Array.from(
|
|
1633
1670
|
deps,
|
|
1634
|
-
dep =>
|
|
1671
|
+
(dep) =>
|
|
1635
1672
|
/** @type {Job} */ ({
|
|
1636
|
-
type:
|
|
1673
|
+
type: RBDT_RESOLVE_INITIAL,
|
|
1637
1674
|
context,
|
|
1638
1675
|
path: dep,
|
|
1639
1676
|
expected: undefined,
|
|
@@ -1647,7 +1684,7 @@ class FileSystemInfo {
|
|
|
1647
1684
|
* @param {string} path path
|
|
1648
1685
|
* @returns {void}
|
|
1649
1686
|
*/
|
|
1650
|
-
const resolveDirectory = path => {
|
|
1687
|
+
const resolveDirectory = (path) => {
|
|
1651
1688
|
const key = `d\n${context}\n${path}`;
|
|
1652
1689
|
if (resolveResults.has(key)) {
|
|
1653
1690
|
return callback();
|
|
@@ -1737,27 +1774,23 @@ class FileSystemInfo {
|
|
|
1737
1774
|
}
|
|
1738
1775
|
);
|
|
1739
1776
|
};
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
resolveDirectory(path.slice(0, -1));
|
|
1754
|
-
} else {
|
|
1755
|
-
resolveFile(path);
|
|
1756
|
-
}
|
|
1777
|
+
const resolvedType =
|
|
1778
|
+
type === RBDT_RESOLVE_INITIAL
|
|
1779
|
+
? /[\\/]$/.test(path)
|
|
1780
|
+
? RBDT_RESOLVE_DIRECTORY
|
|
1781
|
+
: RBDT_RESOLVE_FILE
|
|
1782
|
+
: type;
|
|
1783
|
+
switch (resolvedType) {
|
|
1784
|
+
case RBDT_RESOLVE_FILE: {
|
|
1785
|
+
resolveFile(
|
|
1786
|
+
path,
|
|
1787
|
+
"f",
|
|
1788
|
+
/\.mjs$/.test(path) ? resolveEsm : resolveCjs
|
|
1789
|
+
);
|
|
1757
1790
|
break;
|
|
1758
1791
|
}
|
|
1759
1792
|
case RBDT_RESOLVE_DIRECTORY: {
|
|
1760
|
-
resolveDirectory(path);
|
|
1793
|
+
resolveDirectory(RBDT_RESOLVE_INITIAL ? path.slice(0, -1) : path);
|
|
1761
1794
|
break;
|
|
1762
1795
|
}
|
|
1763
1796
|
case RBDT_RESOLVE_CJS_FILE: {
|
|
@@ -1835,7 +1868,13 @@ class FileSystemInfo {
|
|
|
1835
1868
|
// Check commonjs cache for the module
|
|
1836
1869
|
/** @type {NodeModule | undefined} */
|
|
1837
1870
|
const module = require.cache[path];
|
|
1838
|
-
if (
|
|
1871
|
+
if (
|
|
1872
|
+
module &&
|
|
1873
|
+
Array.isArray(module.children) &&
|
|
1874
|
+
// https://github.com/nodejs/node/issues/59868
|
|
1875
|
+
// Force use `es-module-lexer` for mjs
|
|
1876
|
+
!/\.mjs$/.test(path)
|
|
1877
|
+
) {
|
|
1839
1878
|
children: for (const child of module.children) {
|
|
1840
1879
|
const childPath = child.filename;
|
|
1841
1880
|
if (childPath) {
|
|
@@ -1868,8 +1907,9 @@ class FileSystemInfo {
|
|
|
1868
1907
|
});
|
|
1869
1908
|
}
|
|
1870
1909
|
let request = subPath.replace(/\\/g, "/");
|
|
1871
|
-
if (request.endsWith(".js"))
|
|
1910
|
+
if (request.endsWith(".js")) {
|
|
1872
1911
|
request = request.slice(0, -3);
|
|
1912
|
+
}
|
|
1873
1913
|
push({
|
|
1874
1914
|
type: RBDT_RESOLVE_CJS_FILE_AS_CHILD,
|
|
1875
1915
|
context,
|
|
@@ -1904,7 +1944,9 @@ class FileSystemInfo {
|
|
|
1904
1944
|
);
|
|
1905
1945
|
this._warnAboutExperimentalEsmTracking = true;
|
|
1906
1946
|
}
|
|
1907
|
-
|
|
1947
|
+
|
|
1948
|
+
const lexer = getEsModuleLexer();
|
|
1949
|
+
|
|
1908
1950
|
lexer.init.then(() => {
|
|
1909
1951
|
this.fs.readFile(path, (err, content) => {
|
|
1910
1952
|
if (err) return callback(err);
|
|
@@ -1912,26 +1954,29 @@ class FileSystemInfo {
|
|
|
1912
1954
|
const context = dirname(this.fs, path);
|
|
1913
1955
|
const source = /** @type {Buffer} */ (content).toString();
|
|
1914
1956
|
const [imports] = lexer.parse(source);
|
|
1957
|
+
const added = new Set();
|
|
1915
1958
|
for (const imp of imports) {
|
|
1916
1959
|
try {
|
|
1917
1960
|
let dependency;
|
|
1918
1961
|
if (imp.d === -1) {
|
|
1919
1962
|
// import ... from "..."
|
|
1920
1963
|
dependency = parseString(
|
|
1921
|
-
source.
|
|
1964
|
+
source.slice(imp.s - 1, imp.e + 1)
|
|
1922
1965
|
);
|
|
1923
1966
|
} else if (imp.d > -1) {
|
|
1924
1967
|
// import()
|
|
1925
|
-
const expr = source.
|
|
1968
|
+
const expr = source.slice(imp.s, imp.e).trim();
|
|
1926
1969
|
dependency = parseString(expr);
|
|
1927
1970
|
} else {
|
|
1928
1971
|
// e.g. import.meta
|
|
1929
1972
|
continue;
|
|
1930
1973
|
}
|
|
1931
1974
|
|
|
1932
|
-
//
|
|
1975
|
+
// We should not track Node.js build dependencies
|
|
1933
1976
|
if (dependency.startsWith("node:")) continue;
|
|
1934
1977
|
if (builtinModules.has(dependency)) continue;
|
|
1978
|
+
// Avoid extra jobs for identical imports
|
|
1979
|
+
if (added.has(dependency)) continue;
|
|
1935
1980
|
|
|
1936
1981
|
push({
|
|
1937
1982
|
type: RBDT_RESOLVE_ESM_FILE,
|
|
@@ -1940,9 +1985,10 @@ class FileSystemInfo {
|
|
|
1940
1985
|
expected: imp.d > -1 ? false : undefined,
|
|
1941
1986
|
issuer: job
|
|
1942
1987
|
});
|
|
1988
|
+
added.add(dependency);
|
|
1943
1989
|
} catch (err1) {
|
|
1944
1990
|
logger.warn(
|
|
1945
|
-
`Parsing of ${path} for build dependencies failed at 'import(${source.
|
|
1991
|
+
`Parsing of ${path} for build dependencies failed at 'import(${source.slice(
|
|
1946
1992
|
imp.s,
|
|
1947
1993
|
imp.e
|
|
1948
1994
|
)})'.\n` +
|
|
@@ -2000,7 +2046,8 @@ class FileSystemInfo {
|
|
|
2000
2046
|
let packageData;
|
|
2001
2047
|
try {
|
|
2002
2048
|
packageData = JSON.parse(
|
|
2003
|
-
/** @type {Buffer} */
|
|
2049
|
+
/** @type {Buffer} */
|
|
2050
|
+
(content).toString("utf8")
|
|
2004
2051
|
);
|
|
2005
2052
|
} catch (parseErr) {
|
|
2006
2053
|
return callback(/** @type {Error} */ (parseErr));
|
|
@@ -2038,7 +2085,7 @@ class FileSystemInfo {
|
|
|
2038
2085
|
}
|
|
2039
2086
|
}
|
|
2040
2087
|
},
|
|
2041
|
-
err => {
|
|
2088
|
+
(err) => {
|
|
2042
2089
|
if (err) return callback(err);
|
|
2043
2090
|
for (const l of fileSymlinks) files.delete(l);
|
|
2044
2091
|
for (const l of directorySymlinks) directories.delete(l);
|
|
@@ -2059,8 +2106,8 @@ class FileSystemInfo {
|
|
|
2059
2106
|
}
|
|
2060
2107
|
|
|
2061
2108
|
/**
|
|
2062
|
-
* @param {
|
|
2063
|
-
* @param {
|
|
2109
|
+
* @param {ResolveResults} resolveResults results from resolving
|
|
2110
|
+
* @param {(err?: Error | null, result?: boolean) => void} callback callback with true when resolveResults resolve the same way
|
|
2064
2111
|
* @returns {void}
|
|
2065
2112
|
*/
|
|
2066
2113
|
checkResolveResultsValid(resolveResults, callback) {
|
|
@@ -2074,8 +2121,9 @@ class FileSystemInfo {
|
|
|
2074
2121
|
switch (type) {
|
|
2075
2122
|
case "d":
|
|
2076
2123
|
resolveContext(context, path, {}, (err, _, result) => {
|
|
2077
|
-
if (expectedResult === false)
|
|
2124
|
+
if (expectedResult === false) {
|
|
2078
2125
|
return callback(err ? undefined : INVALID);
|
|
2126
|
+
}
|
|
2079
2127
|
if (err) return callback(err);
|
|
2080
2128
|
const resultPath = /** @type {ResolveRequest} */ (result).path;
|
|
2081
2129
|
if (resultPath !== expectedResult) return callback(INVALID);
|
|
@@ -2084,8 +2132,9 @@ class FileSystemInfo {
|
|
|
2084
2132
|
break;
|
|
2085
2133
|
case "f":
|
|
2086
2134
|
resolveCjs(context, path, {}, (err, _, result) => {
|
|
2087
|
-
if (expectedResult === false)
|
|
2135
|
+
if (expectedResult === false) {
|
|
2088
2136
|
return callback(err ? undefined : INVALID);
|
|
2137
|
+
}
|
|
2089
2138
|
if (err) return callback(err);
|
|
2090
2139
|
const resultPath = /** @type {ResolveRequest} */ (result).path;
|
|
2091
2140
|
if (resultPath !== expectedResult) return callback(INVALID);
|
|
@@ -2094,8 +2143,9 @@ class FileSystemInfo {
|
|
|
2094
2143
|
break;
|
|
2095
2144
|
case "c":
|
|
2096
2145
|
resolveCjsAsChild(context, path, {}, (err, _, result) => {
|
|
2097
|
-
if (expectedResult === false)
|
|
2146
|
+
if (expectedResult === false) {
|
|
2098
2147
|
return callback(err ? undefined : INVALID);
|
|
2148
|
+
}
|
|
2099
2149
|
if (err) return callback(err);
|
|
2100
2150
|
const resultPath = /** @type {ResolveRequest} */ (result).path;
|
|
2101
2151
|
if (resultPath !== expectedResult) return callback(INVALID);
|
|
@@ -2104,8 +2154,9 @@ class FileSystemInfo {
|
|
|
2104
2154
|
break;
|
|
2105
2155
|
case "e":
|
|
2106
2156
|
resolveEsm(context, path, {}, (err, _, result) => {
|
|
2107
|
-
if (expectedResult === false)
|
|
2157
|
+
if (expectedResult === false) {
|
|
2108
2158
|
return callback(err ? undefined : INVALID);
|
|
2159
|
+
}
|
|
2109
2160
|
if (err) return callback(err);
|
|
2110
2161
|
const resultPath = /** @type {ResolveRequest} */ (result).path;
|
|
2111
2162
|
if (resultPath !== expectedResult) return callback(INVALID);
|
|
@@ -2121,7 +2172,7 @@ class FileSystemInfo {
|
|
|
2121
2172
|
* @param {Error | typeof INVALID=} err error or invalid flag
|
|
2122
2173
|
* @returns {void}
|
|
2123
2174
|
*/
|
|
2124
|
-
err => {
|
|
2175
|
+
(err) => {
|
|
2125
2176
|
if (err === INVALID) {
|
|
2126
2177
|
return callback(null, false);
|
|
2127
2178
|
}
|
|
@@ -2135,11 +2186,11 @@ class FileSystemInfo {
|
|
|
2135
2186
|
|
|
2136
2187
|
/**
|
|
2137
2188
|
* @param {number | null | undefined} startTime when processing the files has started
|
|
2138
|
-
* @param {Iterable<string> | null} files all files
|
|
2139
|
-
* @param {Iterable<string> | null} directories all directories
|
|
2140
|
-
* @param {Iterable<string> | null} missing all missing files or directories
|
|
2189
|
+
* @param {Iterable<string> | null | undefined} files all files
|
|
2190
|
+
* @param {Iterable<string> | null | undefined} directories all directories
|
|
2191
|
+
* @param {Iterable<string> | null | undefined} missing all missing files or directories
|
|
2141
2192
|
* @param {SnapshotOptions | null | undefined} options options object (for future extensions)
|
|
2142
|
-
* @param {
|
|
2193
|
+
* @param {(err: WebpackError | null, snapshot: Snapshot | null) => void} callback callback function
|
|
2143
2194
|
* @returns {void}
|
|
2144
2195
|
*/
|
|
2145
2196
|
createSnapshot(startTime, files, directories, missing, options, callback) {
|
|
@@ -2234,7 +2285,7 @@ class FileSystemInfo {
|
|
|
2234
2285
|
};
|
|
2235
2286
|
/**
|
|
2236
2287
|
* @param {string} path path
|
|
2237
|
-
* @param {
|
|
2288
|
+
* @param {ManagedFiles} managedSet managed set
|
|
2238
2289
|
* @returns {boolean} true when managed
|
|
2239
2290
|
*/
|
|
2240
2291
|
const checkManaged = (path, managedSet) => {
|
|
@@ -2285,6 +2336,7 @@ class FileSystemInfo {
|
|
|
2285
2336
|
* @returns {Set<string>} result
|
|
2286
2337
|
*/
|
|
2287
2338
|
const captureNonManaged = (items, managedSet) => {
|
|
2339
|
+
/** @type {Set<string>} */
|
|
2288
2340
|
const capturedItems = new Set();
|
|
2289
2341
|
for (const path of items) {
|
|
2290
2342
|
if (!checkManaged(path, managedSet)) capturedItems.add(path);
|
|
@@ -2292,9 +2344,12 @@ class FileSystemInfo {
|
|
|
2292
2344
|
return capturedItems;
|
|
2293
2345
|
};
|
|
2294
2346
|
/**
|
|
2295
|
-
* @param {
|
|
2347
|
+
* @param {ManagedFiles} capturedFiles captured files
|
|
2296
2348
|
*/
|
|
2297
|
-
const processCapturedFiles = capturedFiles => {
|
|
2349
|
+
const processCapturedFiles = (capturedFiles) => {
|
|
2350
|
+
if (capturedFiles.size === 0) {
|
|
2351
|
+
return;
|
|
2352
|
+
}
|
|
2298
2353
|
switch (mode) {
|
|
2299
2354
|
case 3:
|
|
2300
2355
|
this._fileTshsOptimization.optimize(snapshot, capturedFiles);
|
|
@@ -2380,9 +2435,12 @@ class FileSystemInfo {
|
|
|
2380
2435
|
processCapturedFiles(captureNonManaged(files, managedFiles));
|
|
2381
2436
|
}
|
|
2382
2437
|
/**
|
|
2383
|
-
* @param {
|
|
2438
|
+
* @param {ManagedContexts} capturedDirectories captured directories
|
|
2384
2439
|
*/
|
|
2385
|
-
const processCapturedDirectories = capturedDirectories => {
|
|
2440
|
+
const processCapturedDirectories = (capturedDirectories) => {
|
|
2441
|
+
if (capturedDirectories.size === 0) {
|
|
2442
|
+
return;
|
|
2443
|
+
}
|
|
2386
2444
|
switch (mode) {
|
|
2387
2445
|
case 3:
|
|
2388
2446
|
this._contextTshsOptimization.optimize(snapshot, capturedDirectories);
|
|
@@ -2485,7 +2543,7 @@ class FileSystemInfo {
|
|
|
2485
2543
|
jobs++;
|
|
2486
2544
|
/**
|
|
2487
2545
|
* @param {(Error | null)=} err error
|
|
2488
|
-
* @param {
|
|
2546
|
+
* @param {FileTimestamp=} entry entry
|
|
2489
2547
|
* @returns {void}
|
|
2490
2548
|
*/
|
|
2491
2549
|
const callback = (err, entry) => {
|
|
@@ -2525,9 +2583,12 @@ class FileSystemInfo {
|
|
|
2525
2583
|
);
|
|
2526
2584
|
}
|
|
2527
2585
|
/**
|
|
2528
|
-
* @param {
|
|
2586
|
+
* @param {ManagedMissing} capturedMissing captured missing
|
|
2529
2587
|
*/
|
|
2530
|
-
const processCapturedMissing = capturedMissing => {
|
|
2588
|
+
const processCapturedMissing = (capturedMissing) => {
|
|
2589
|
+
if (capturedMissing.size === 0) {
|
|
2590
|
+
return;
|
|
2591
|
+
}
|
|
2531
2592
|
this._missingExistenceOptimization.optimize(snapshot, capturedMissing);
|
|
2532
2593
|
for (const path of capturedMissing) {
|
|
2533
2594
|
const cache = this._fileTimestamps.get(path);
|
|
@@ -2588,7 +2649,7 @@ class FileSystemInfo {
|
|
|
2588
2649
|
// Fallback to normal snapshotting
|
|
2589
2650
|
/**
|
|
2590
2651
|
* @param {Set<string>} set set
|
|
2591
|
-
* @param {
|
|
2652
|
+
* @param {(set: Set<string>) => void} fn fn
|
|
2592
2653
|
*/
|
|
2593
2654
|
const process = (set, fn) => {
|
|
2594
2655
|
if (set.size === 0) return;
|
|
@@ -2697,7 +2758,7 @@ class FileSystemInfo {
|
|
|
2697
2758
|
|
|
2698
2759
|
/**
|
|
2699
2760
|
* @param {Snapshot} snapshot the snapshot made
|
|
2700
|
-
* @param {
|
|
2761
|
+
* @param {CheckSnapshotValidCallback} callback callback function
|
|
2701
2762
|
* @returns {void}
|
|
2702
2763
|
*/
|
|
2703
2764
|
checkSnapshotValid(snapshot, callback) {
|
|
@@ -2716,8 +2777,9 @@ class FileSystemInfo {
|
|
|
2716
2777
|
}
|
|
2717
2778
|
|
|
2718
2779
|
/**
|
|
2780
|
+
* @private
|
|
2719
2781
|
* @param {Snapshot} snapshot the snapshot made
|
|
2720
|
-
* @param {
|
|
2782
|
+
* @param {CheckSnapshotValidCallback} callback callback function
|
|
2721
2783
|
* @returns {void}
|
|
2722
2784
|
*/
|
|
2723
2785
|
_checkSnapshotValidNoCache(snapshot, callback) {
|
|
@@ -3019,7 +3081,7 @@ class FileSystemInfo {
|
|
|
3019
3081
|
jobs++;
|
|
3020
3082
|
/**
|
|
3021
3083
|
* @param {(WebpackError | null)=} err error
|
|
3022
|
-
* @param {
|
|
3084
|
+
* @param {ResolvedContextTimestamp=} entry entry
|
|
3023
3085
|
* @returns {void}
|
|
3024
3086
|
*/
|
|
3025
3087
|
const callback = (err, entry) => {
|
|
@@ -3123,7 +3185,7 @@ class FileSystemInfo {
|
|
|
3123
3185
|
jobs++;
|
|
3124
3186
|
/**
|
|
3125
3187
|
* @param {(WebpackError | null)=} err error
|
|
3126
|
-
* @param {
|
|
3188
|
+
* @param {ResolvedContextTimestamp=} entry entry
|
|
3127
3189
|
* @returns {void}
|
|
3128
3190
|
*/
|
|
3129
3191
|
const callback = (err, entry) => {
|
|
@@ -3222,8 +3284,8 @@ class FileSystemInfo {
|
|
|
3222
3284
|
}
|
|
3223
3285
|
|
|
3224
3286
|
/**
|
|
3225
|
-
* @type {Processor<string, FileSystemInfoEntry>}
|
|
3226
3287
|
* @private
|
|
3288
|
+
* @type {Processor<string, FileSystemInfoEntry>}
|
|
3227
3289
|
*/
|
|
3228
3290
|
_readFileTimestamp(path, callback) {
|
|
3229
3291
|
this.fs.stat(path, (err, _stat) => {
|
|
@@ -3261,8 +3323,8 @@ class FileSystemInfo {
|
|
|
3261
3323
|
}
|
|
3262
3324
|
|
|
3263
3325
|
/**
|
|
3264
|
-
* @type {Processor<string, string>}
|
|
3265
3326
|
* @private
|
|
3327
|
+
* @type {Processor<string, string>}
|
|
3266
3328
|
*/
|
|
3267
3329
|
_readFileHash(path, callback) {
|
|
3268
3330
|
this.fs.readFile(path, (err, content) => {
|
|
@@ -3288,7 +3350,7 @@ class FileSystemInfo {
|
|
|
3288
3350
|
|
|
3289
3351
|
hash.update(/** @type {string | Buffer} */ (content));
|
|
3290
3352
|
|
|
3291
|
-
const digest =
|
|
3353
|
+
const digest = hash.digest("hex");
|
|
3292
3354
|
|
|
3293
3355
|
this._fileHashes.set(path, digest);
|
|
3294
3356
|
|
|
@@ -3297,16 +3359,16 @@ class FileSystemInfo {
|
|
|
3297
3359
|
}
|
|
3298
3360
|
|
|
3299
3361
|
/**
|
|
3300
|
-
* @param {string} path path
|
|
3301
|
-
* @param {function(WebpackError | null, TimestampAndHash=) : void} callback callback
|
|
3302
3362
|
* @private
|
|
3363
|
+
* @param {string} path path
|
|
3364
|
+
* @param {(err: WebpackError | null, timestampAndHash?: TimestampAndHash | string) => void} callback callback
|
|
3303
3365
|
*/
|
|
3304
3366
|
_getFileTimestampAndHash(path, callback) {
|
|
3305
3367
|
/**
|
|
3306
3368
|
* @param {string} hash hash
|
|
3307
3369
|
* @returns {void}
|
|
3308
3370
|
*/
|
|
3309
|
-
const continueWithHash = hash => {
|
|
3371
|
+
const continueWithHash = (hash) => {
|
|
3310
3372
|
const cache = this._fileTimestamps.get(path);
|
|
3311
3373
|
if (cache !== undefined) {
|
|
3312
3374
|
if (cache !== "ignore") {
|
|
@@ -3319,7 +3381,7 @@ class FileSystemInfo {
|
|
|
3319
3381
|
return callback(null, result);
|
|
3320
3382
|
}
|
|
3321
3383
|
this._fileTshs.set(path, hash);
|
|
3322
|
-
return callback(null,
|
|
3384
|
+
return callback(null, hash);
|
|
3323
3385
|
}
|
|
3324
3386
|
this.fileTimestampQueue.add(path, (err, entry) => {
|
|
3325
3387
|
if (err) {
|
|
@@ -3349,17 +3411,18 @@ class FileSystemInfo {
|
|
|
3349
3411
|
}
|
|
3350
3412
|
|
|
3351
3413
|
/**
|
|
3414
|
+
* @private
|
|
3352
3415
|
* @template T
|
|
3353
3416
|
* @template ItemType
|
|
3354
3417
|
* @param {object} options options
|
|
3355
3418
|
* @param {string} options.path path
|
|
3356
|
-
* @param {
|
|
3357
|
-
* @param {
|
|
3358
|
-
* @param {
|
|
3359
|
-
* @param {
|
|
3360
|
-
* @param {
|
|
3361
|
-
* @param {
|
|
3362
|
-
* @param {
|
|
3419
|
+
* @param {(value: string) => ItemType} options.fromImmutablePath called when context item is an immutable path
|
|
3420
|
+
* @param {(value: string) => ItemType} options.fromManagedItem called when context item is a managed path
|
|
3421
|
+
* @param {(value: string, result: string, callback: (err?: WebpackError | null, itemType?: ItemType) => void) => void} options.fromSymlink called when context item is a symlink
|
|
3422
|
+
* @param {(value: string, stats: IStats, callback: (err?: WebpackError | null, itemType?: ItemType | null) => void) => void} options.fromFile called when context item is a file
|
|
3423
|
+
* @param {(value: string, stats: IStats, callback: (err?: WebpackError | null, itemType?: ItemType) => void) => void} options.fromDirectory called when context item is a directory
|
|
3424
|
+
* @param {(arr: string[], arr1: ItemType[]) => T} options.reduce called from all context items
|
|
3425
|
+
* @param {(err?: Error | null, result?: T | null) => void} callback callback
|
|
3363
3426
|
*/
|
|
3364
3427
|
_readContext(
|
|
3365
3428
|
{
|
|
@@ -3381,8 +3444,8 @@ class FileSystemInfo {
|
|
|
3381
3444
|
return callback(err);
|
|
3382
3445
|
}
|
|
3383
3446
|
const files = /** @type {string[]} */ (_files)
|
|
3384
|
-
.map(file => file.normalize("NFC"))
|
|
3385
|
-
.filter(file => !/^\./.test(file))
|
|
3447
|
+
.map((file) => file.normalize("NFC"))
|
|
3448
|
+
.filter((file) => !/^\./.test(file))
|
|
3386
3449
|
.sort();
|
|
3387
3450
|
asyncLib.map(
|
|
3388
3451
|
files,
|
|
@@ -3460,8 +3523,8 @@ class FileSystemInfo {
|
|
|
3460
3523
|
}
|
|
3461
3524
|
|
|
3462
3525
|
/**
|
|
3463
|
-
* @type {Processor<string, ContextFileSystemInfoEntry>}
|
|
3464
3526
|
* @private
|
|
3527
|
+
* @type {Processor<string, ContextFileSystemInfoEntry>}
|
|
3465
3528
|
*/
|
|
3466
3529
|
_readContextTimestamp(path, callback) {
|
|
3467
3530
|
this._readContext(
|
|
@@ -3470,7 +3533,7 @@ class FileSystemInfo {
|
|
|
3470
3533
|
fromImmutablePath: () =>
|
|
3471
3534
|
/** @type {ContextFileSystemInfoEntry | FileSystemInfoEntry | "ignore" | null} */
|
|
3472
3535
|
(null),
|
|
3473
|
-
fromManagedItem: info => ({
|
|
3536
|
+
fromManagedItem: (info) => ({
|
|
3474
3537
|
safeTime: 0,
|
|
3475
3538
|
timestampHash: info
|
|
3476
3539
|
}),
|
|
@@ -3487,8 +3550,9 @@ class FileSystemInfo {
|
|
|
3487
3550
|
fromFile: (file, stat, callback) => {
|
|
3488
3551
|
// Prefer the cached value over our new stat to report consistent results
|
|
3489
3552
|
const cache = this._fileTimestamps.get(file);
|
|
3490
|
-
if (cache !== undefined)
|
|
3553
|
+
if (cache !== undefined) {
|
|
3491
3554
|
return callback(null, cache === "ignore" ? null : cache);
|
|
3555
|
+
}
|
|
3492
3556
|
|
|
3493
3557
|
const mtime = Number(stat.mtime);
|
|
3494
3558
|
|
|
@@ -3554,7 +3618,7 @@ class FileSystemInfo {
|
|
|
3554
3618
|
}
|
|
3555
3619
|
}
|
|
3556
3620
|
|
|
3557
|
-
const digest =
|
|
3621
|
+
const digest = hash.digest("hex");
|
|
3558
3622
|
/** @type {ContextFileSystemInfoEntry} */
|
|
3559
3623
|
const result = {
|
|
3560
3624
|
safeTime,
|
|
@@ -3575,8 +3639,9 @@ class FileSystemInfo {
|
|
|
3575
3639
|
}
|
|
3576
3640
|
|
|
3577
3641
|
/**
|
|
3642
|
+
* @private
|
|
3578
3643
|
* @param {ContextFileSystemInfoEntry} entry entry
|
|
3579
|
-
* @param {
|
|
3644
|
+
* @param {(err?: WebpackError | null, resolvedContextTimestamp?: ResolvedContextTimestamp) => void} callback callback
|
|
3580
3645
|
* @returns {void}
|
|
3581
3646
|
*/
|
|
3582
3647
|
_resolveContextTimestamp(entry, callback) {
|
|
@@ -3601,7 +3666,7 @@ class FileSystemInfo {
|
|
|
3601
3666
|
callback();
|
|
3602
3667
|
});
|
|
3603
3668
|
},
|
|
3604
|
-
err => {
|
|
3669
|
+
(err) => {
|
|
3605
3670
|
if (err) return callback(/** @type {WebpackError} */ (err));
|
|
3606
3671
|
const hash = createHash(this._hashFunction);
|
|
3607
3672
|
hash.update(/** @type {string} */ (entry.timestampHash));
|
|
@@ -3616,7 +3681,7 @@ class FileSystemInfo {
|
|
|
3616
3681
|
null,
|
|
3617
3682
|
(entry.resolved = {
|
|
3618
3683
|
safeTime,
|
|
3619
|
-
timestampHash:
|
|
3684
|
+
timestampHash: hash.digest("hex")
|
|
3620
3685
|
})
|
|
3621
3686
|
);
|
|
3622
3687
|
}
|
|
@@ -3624,15 +3689,15 @@ class FileSystemInfo {
|
|
|
3624
3689
|
}
|
|
3625
3690
|
|
|
3626
3691
|
/**
|
|
3627
|
-
* @type {Processor<string, ContextHash>}
|
|
3628
3692
|
* @private
|
|
3693
|
+
* @type {Processor<string, ContextHash>}
|
|
3629
3694
|
*/
|
|
3630
3695
|
_readContextHash(path, callback) {
|
|
3631
3696
|
this._readContext(
|
|
3632
3697
|
{
|
|
3633
3698
|
path,
|
|
3634
3699
|
fromImmutablePath: () => /** @type {ContextHash | ""} */ (""),
|
|
3635
|
-
fromManagedItem: info => info || "",
|
|
3700
|
+
fromManagedItem: (info) => info || "",
|
|
3636
3701
|
fromSymlink: (file, target, callback) => {
|
|
3637
3702
|
callback(
|
|
3638
3703
|
null,
|
|
@@ -3678,7 +3743,7 @@ class FileSystemInfo {
|
|
|
3678
3743
|
|
|
3679
3744
|
/** @type {ContextHash} */
|
|
3680
3745
|
const result = {
|
|
3681
|
-
hash:
|
|
3746
|
+
hash: hash.digest("hex")
|
|
3682
3747
|
};
|
|
3683
3748
|
if (symlinks) result.symlinks = symlinks;
|
|
3684
3749
|
return result;
|
|
@@ -3694,8 +3759,9 @@ class FileSystemInfo {
|
|
|
3694
3759
|
}
|
|
3695
3760
|
|
|
3696
3761
|
/**
|
|
3762
|
+
* @private
|
|
3697
3763
|
* @param {ContextHash} entry context hash
|
|
3698
|
-
* @param {
|
|
3764
|
+
* @param {(err: WebpackError | null, contextHash?: string) => void} callback callback
|
|
3699
3765
|
* @returns {void}
|
|
3700
3766
|
*/
|
|
3701
3767
|
_resolveContextHash(entry, callback) {
|
|
@@ -3716,7 +3782,7 @@ class FileSystemInfo {
|
|
|
3716
3782
|
callback();
|
|
3717
3783
|
});
|
|
3718
3784
|
},
|
|
3719
|
-
err => {
|
|
3785
|
+
(err) => {
|
|
3720
3786
|
if (err) return callback(/** @type {WebpackError} */ (err));
|
|
3721
3787
|
const hash = createHash(this._hashFunction);
|
|
3722
3788
|
hash.update(entry.hash);
|
|
@@ -3724,21 +3790,18 @@ class FileSystemInfo {
|
|
|
3724
3790
|
for (const h of hashes) {
|
|
3725
3791
|
hash.update(h);
|
|
3726
3792
|
}
|
|
3727
|
-
callback(
|
|
3728
|
-
null,
|
|
3729
|
-
(entry.resolved = /** @type {string} */ (hash.digest("hex")))
|
|
3730
|
-
);
|
|
3793
|
+
callback(null, (entry.resolved = hash.digest("hex")));
|
|
3731
3794
|
}
|
|
3732
3795
|
);
|
|
3733
3796
|
}
|
|
3734
3797
|
|
|
3735
3798
|
/**
|
|
3736
|
-
* @type {Processor<string, ContextTimestampAndHash>}
|
|
3737
3799
|
* @private
|
|
3800
|
+
* @type {Processor<string, ContextTimestampAndHash>}
|
|
3738
3801
|
*/
|
|
3739
3802
|
_readContextTimestampAndHash(path, callback) {
|
|
3740
3803
|
/**
|
|
3741
|
-
* @param {
|
|
3804
|
+
* @param {ContextTimestamp} timestamp timestamp
|
|
3742
3805
|
* @param {ContextHash} hash hash
|
|
3743
3806
|
*/
|
|
3744
3807
|
const finalize = (timestamp, hash) => {
|
|
@@ -3773,22 +3836,20 @@ class FileSystemInfo {
|
|
|
3773
3836
|
{
|
|
3774
3837
|
path,
|
|
3775
3838
|
fromImmutablePath: () =>
|
|
3776
|
-
/** @type {ContextTimestampAndHash | null} */ (
|
|
3777
|
-
|
|
3839
|
+
/** @type {ContextTimestampAndHash | Omit<ContextTimestampAndHash, "safeTime"> | string | null} */ (
|
|
3840
|
+
null
|
|
3841
|
+
),
|
|
3842
|
+
fromManagedItem: (info) => ({
|
|
3778
3843
|
safeTime: 0,
|
|
3779
3844
|
timestampHash: info,
|
|
3780
3845
|
hash: info || ""
|
|
3781
3846
|
}),
|
|
3782
3847
|
fromSymlink: (file, target, callback) => {
|
|
3783
|
-
callback(
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
(
|
|
3787
|
-
|
|
3788
|
-
hash: target,
|
|
3789
|
-
symlinks: new Set([target])
|
|
3790
|
-
})
|
|
3791
|
-
);
|
|
3848
|
+
callback(null, {
|
|
3849
|
+
timestampHash: target,
|
|
3850
|
+
hash: target,
|
|
3851
|
+
symlinks: new Set([target])
|
|
3852
|
+
});
|
|
3792
3853
|
},
|
|
3793
3854
|
fromFile: (file, stat, callback) => {
|
|
3794
3855
|
this._getFileTimestampAndHash(file, callback);
|
|
@@ -3846,8 +3907,8 @@ class FileSystemInfo {
|
|
|
3846
3907
|
/** @type {ContextTimestampAndHash} */
|
|
3847
3908
|
const result = {
|
|
3848
3909
|
safeTime,
|
|
3849
|
-
timestampHash:
|
|
3850
|
-
hash:
|
|
3910
|
+
timestampHash: tsHash.digest("hex"),
|
|
3911
|
+
hash: hash.digest("hex")
|
|
3851
3912
|
};
|
|
3852
3913
|
if (symlinks) result.symlinks = symlinks;
|
|
3853
3914
|
return result;
|
|
@@ -3864,6 +3925,7 @@ class FileSystemInfo {
|
|
|
3864
3925
|
}
|
|
3865
3926
|
|
|
3866
3927
|
/**
|
|
3928
|
+
* @private
|
|
3867
3929
|
* @param {ContextTimestampAndHash} entry entry
|
|
3868
3930
|
* @param {ProcessorCallback<ResolvedContextTimestampAndHash>} callback callback
|
|
3869
3931
|
* @returns {void}
|
|
@@ -3893,7 +3955,7 @@ class FileSystemInfo {
|
|
|
3893
3955
|
callback();
|
|
3894
3956
|
});
|
|
3895
3957
|
},
|
|
3896
|
-
err => {
|
|
3958
|
+
(err) => {
|
|
3897
3959
|
if (err) return callback(/** @type {WebpackError} */ (err));
|
|
3898
3960
|
const hash = createHash(this._hashFunction);
|
|
3899
3961
|
const tsHash = createHash(this._hashFunction);
|
|
@@ -3914,8 +3976,8 @@ class FileSystemInfo {
|
|
|
3914
3976
|
null,
|
|
3915
3977
|
(entry.resolved = {
|
|
3916
3978
|
safeTime,
|
|
3917
|
-
timestampHash:
|
|
3918
|
-
hash:
|
|
3979
|
+
timestampHash: tsHash.digest("hex"),
|
|
3980
|
+
hash: hash.digest("hex")
|
|
3919
3981
|
})
|
|
3920
3982
|
);
|
|
3921
3983
|
}
|
|
@@ -3923,8 +3985,8 @@ class FileSystemInfo {
|
|
|
3923
3985
|
}
|
|
3924
3986
|
|
|
3925
3987
|
/**
|
|
3926
|
-
* @type {Processor<string, Set<string>>}
|
|
3927
3988
|
* @private
|
|
3989
|
+
* @type {Processor<string, Set<string>>}
|
|
3928
3990
|
*/
|
|
3929
3991
|
_getManagedItemDirectoryInfo(path, callback) {
|
|
3930
3992
|
this.fs.readdir(path, (err, elements) => {
|
|
@@ -3935,7 +3997,7 @@ class FileSystemInfo {
|
|
|
3935
3997
|
return callback(/** @type {WebpackError} */ (err));
|
|
3936
3998
|
}
|
|
3937
3999
|
const set = new Set(
|
|
3938
|
-
/** @type {string[]} */ (elements).map(element =>
|
|
4000
|
+
/** @type {string[]} */ (elements).map((element) =>
|
|
3939
4001
|
join(this.fs, path, element)
|
|
3940
4002
|
)
|
|
3941
4003
|
);
|
|
@@ -3944,8 +4006,8 @@ class FileSystemInfo {
|
|
|
3944
4006
|
}
|
|
3945
4007
|
|
|
3946
4008
|
/**
|
|
3947
|
-
* @type {Processor<string, string>}
|
|
3948
4009
|
* @private
|
|
4010
|
+
* @type {Processor<string, string>}
|
|
3949
4011
|
*/
|
|
3950
4012
|
_getManagedItemInfo(path, callback) {
|
|
3951
4013
|
const dir = dirname(this.fs, path);
|
|
@@ -3998,7 +4060,7 @@ class FileSystemInfo {
|
|
|
3998
4060
|
}
|
|
3999
4061
|
let data;
|
|
4000
4062
|
try {
|
|
4001
|
-
data = JSON.parse(/** @type {Buffer} */ (content).toString("
|
|
4063
|
+
data = JSON.parse(/** @type {Buffer} */ (content).toString("utf8"));
|
|
4002
4064
|
} catch (parseErr) {
|
|
4003
4065
|
return callback(/** @type {WebpackError} */ (parseErr));
|
|
4004
4066
|
}
|
|
@@ -4017,8 +4079,10 @@ class FileSystemInfo {
|
|
|
4017
4079
|
}
|
|
4018
4080
|
|
|
4019
4081
|
getDeprecatedFileTimestamps() {
|
|
4020
|
-
if (this._cachedDeprecatedFileTimestamps !== undefined)
|
|
4082
|
+
if (this._cachedDeprecatedFileTimestamps !== undefined) {
|
|
4021
4083
|
return this._cachedDeprecatedFileTimestamps;
|
|
4084
|
+
}
|
|
4085
|
+
/** @type {Map<string, number | null>} */
|
|
4022
4086
|
const map = new Map();
|
|
4023
4087
|
for (const [path, info] of this._fileTimestamps) {
|
|
4024
4088
|
if (info) map.set(path, typeof info === "object" ? info.safeTime : null);
|
|
@@ -4027,8 +4091,10 @@ class FileSystemInfo {
|
|
|
4027
4091
|
}
|
|
4028
4092
|
|
|
4029
4093
|
getDeprecatedContextTimestamps() {
|
|
4030
|
-
if (this._cachedDeprecatedContextTimestamps !== undefined)
|
|
4094
|
+
if (this._cachedDeprecatedContextTimestamps !== undefined) {
|
|
4031
4095
|
return this._cachedDeprecatedContextTimestamps;
|
|
4096
|
+
}
|
|
4097
|
+
/** @type {Map<string, number | null>} */
|
|
4032
4098
|
const map = new Map();
|
|
4033
4099
|
for (const [path, info] of this._contextTimestamps) {
|
|
4034
4100
|
if (info) map.set(path, typeof info === "object" ? info.safeTime : null);
|