webpack 5.59.0 → 5.94.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -38
- package/bin/webpack.js +34 -10
- package/hot/dev-server.js +19 -5
- package/hot/lazy-compilation-node.js +13 -1
- package/hot/lazy-compilation-web.js +9 -0
- package/hot/log-apply-result.js +5 -0
- package/hot/log.js +23 -4
- package/hot/only-dev-server.js +3 -2
- package/hot/poll.js +5 -2
- package/hot/signal.js +6 -2
- package/lib/APIPlugin.js +226 -122
- package/lib/AbstractMethodError.js +10 -5
- package/lib/AsyncDependenciesBlock.js +13 -5
- package/lib/AutomaticPrefetchPlugin.js +2 -1
- package/lib/BannerPlugin.js +33 -12
- package/lib/Cache.js +16 -12
- package/lib/CacheFacade.js +13 -16
- package/lib/CaseSensitiveModulesWarning.js +8 -8
- package/lib/Chunk.js +60 -33
- package/lib/ChunkGraph.js +207 -72
- package/lib/ChunkGroup.js +40 -20
- package/lib/ChunkTemplate.js +43 -0
- package/lib/CleanPlugin.js +117 -32
- package/lib/CodeGenerationResults.js +8 -7
- package/lib/CommentCompilationWarning.js +0 -1
- package/lib/CompatibilityPlugin.js +85 -46
- package/lib/Compilation.js +712 -392
- package/lib/Compiler.js +393 -172
- package/lib/ConcatenationScope.js +10 -13
- package/lib/ConditionalInitFragment.js +22 -14
- package/lib/ConstPlugin.js +104 -64
- package/lib/ContextExclusionPlugin.js +3 -3
- package/lib/ContextModule.js +283 -108
- package/lib/ContextModuleFactory.js +151 -63
- package/lib/ContextReplacementPlugin.js +25 -10
- package/lib/CssModule.js +166 -0
- package/lib/DefinePlugin.js +254 -148
- package/lib/DelegatedModule.js +29 -6
- package/lib/DelegatedModuleFactoryPlugin.js +42 -22
- package/lib/DelegatedPlugin.js +4 -0
- package/lib/DependenciesBlock.js +17 -2
- package/lib/Dependency.js +58 -29
- package/lib/DependencyTemplate.js +24 -3
- package/lib/DependencyTemplates.js +2 -2
- package/lib/DllEntryPlugin.js +18 -1
- package/lib/DllModule.js +21 -4
- package/lib/DllModuleFactory.js +2 -1
- package/lib/DllPlugin.js +9 -7
- package/lib/DllReferencePlugin.js +50 -19
- package/lib/EntryOptionPlugin.js +6 -1
- package/lib/EntryPlugin.js +7 -4
- package/lib/Entrypoint.js +2 -2
- package/lib/EnvironmentNotSupportAsyncWarning.js +52 -0
- package/lib/EnvironmentPlugin.js +5 -2
- package/lib/ErrorHelpers.js +65 -26
- package/lib/EvalDevToolModulePlugin.js +37 -13
- package/lib/EvalSourceMapDevToolPlugin.js +50 -20
- package/lib/ExportsInfo.js +234 -133
- package/lib/ExportsInfoApiPlugin.js +31 -15
- package/lib/ExternalModule.js +391 -129
- package/lib/ExternalModuleFactoryPlugin.js +65 -17
- package/lib/FileSystemInfo.js +1038 -523
- package/lib/FlagAllModulesAsUsedPlugin.js +27 -27
- package/lib/FlagDependencyExportsPlugin.js +352 -349
- package/lib/FlagDependencyUsagePlugin.js +10 -10
- package/lib/FlagEntryExportAsUsedPlugin.js +26 -23
- package/lib/Generator.js +16 -8
- package/lib/GraphHelpers.js +3 -2
- package/lib/HookWebpackError.js +11 -13
- package/lib/HotModuleReplacementPlugin.js +221 -128
- package/lib/IgnoreErrorModuleFactory.js +4 -4
- package/lib/IgnorePlugin.js +5 -4
- package/lib/IgnoreWarningsPlugin.js +6 -9
- package/lib/InitFragment.js +39 -15
- package/lib/JavascriptMetaInfoPlugin.js +27 -15
- package/lib/LibManifestPlugin.js +45 -16
- package/lib/LoaderOptionsPlugin.js +13 -3
- package/lib/MainTemplate.js +74 -21
- package/lib/Module.js +155 -34
- package/lib/ModuleBuildError.js +13 -11
- package/lib/ModuleDependencyError.js +6 -4
- package/lib/ModuleDependencyWarning.js +6 -4
- package/lib/ModuleError.js +10 -5
- package/lib/ModuleFactory.js +4 -4
- package/lib/ModuleFilenameHelpers.js +164 -54
- package/lib/ModuleGraph.js +93 -53
- package/lib/ModuleGraphConnection.js +27 -13
- package/lib/ModuleHashingError.js +29 -0
- package/lib/ModuleInfoHeaderPlugin.js +92 -33
- package/lib/ModuleNotFoundError.js +5 -2
- package/lib/ModuleParseError.js +17 -9
- package/lib/ModuleProfile.js +1 -0
- package/lib/ModuleRestoreError.js +3 -1
- package/lib/ModuleStoreError.js +3 -2
- package/lib/ModuleTemplate.js +33 -1
- package/lib/ModuleTypeConstants.js +168 -0
- package/lib/ModuleWarning.js +10 -5
- package/lib/MultiCompiler.js +115 -38
- package/lib/MultiStats.js +75 -33
- package/lib/MultiWatching.js +6 -2
- package/lib/NodeStuffPlugin.js +136 -37
- package/lib/NormalModule.js +437 -194
- package/lib/NormalModuleFactory.js +313 -116
- package/lib/NormalModuleReplacementPlugin.js +10 -4
- package/lib/NullFactory.js +1 -1
- package/lib/OptimizationStages.js +3 -3
- package/lib/Parser.js +1 -1
- package/lib/PlatformPlugin.js +39 -0
- package/lib/PrefetchPlugin.js +4 -0
- package/lib/ProgressPlugin.js +83 -28
- package/lib/ProvidePlugin.js +37 -19
- package/lib/RawModule.js +18 -5
- package/lib/RecordIdsPlugin.js +8 -8
- package/lib/RequireJsStuffPlugin.js +22 -15
- package/lib/ResolverFactory.js +8 -4
- package/lib/RuntimeGlobals.js +99 -65
- package/lib/RuntimeModule.js +17 -15
- package/lib/RuntimePlugin.js +116 -13
- package/lib/RuntimeTemplate.js +304 -102
- package/lib/SelfModuleFactory.js +12 -0
- package/lib/SizeFormatHelpers.js +2 -4
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -0
- package/lib/SourceMapDevToolPlugin.js +89 -42
- package/lib/Stats.js +12 -7
- package/lib/Template.js +30 -33
- package/lib/TemplatedPathPlugin.js +102 -34
- package/lib/UseStrictPlugin.js +37 -12
- package/lib/WarnCaseSensitiveModulesPlugin.js +12 -0
- package/lib/WarnDeprecatedOptionPlugin.js +6 -0
- package/lib/WatchIgnorePlugin.js +46 -13
- package/lib/Watching.js +139 -76
- package/lib/WebpackError.js +14 -5
- package/lib/WebpackIsIncludedPlugin.js +22 -13
- package/lib/WebpackOptionsApply.js +162 -56
- package/lib/WebpackOptionsDefaulter.js +10 -3
- package/lib/asset/AssetGenerator.js +351 -99
- package/lib/asset/AssetModulesPlugin.js +57 -33
- package/lib/asset/AssetParser.js +15 -6
- package/lib/asset/AssetSourceGenerator.js +30 -10
- package/lib/asset/AssetSourceParser.js +8 -2
- package/lib/asset/RawDataUrlModule.js +162 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +16 -13
- package/lib/async-modules/InferAsyncModulesPlugin.js +1 -1
- package/lib/buildChunkGraph.js +376 -420
- package/lib/cache/AddManagedPathsPlugin.js +6 -1
- package/lib/cache/IdleFileCachePlugin.js +26 -13
- package/lib/cache/MemoryCachePlugin.js +1 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +13 -7
- package/lib/cache/PackFileCacheStrategy.js +172 -94
- package/lib/cache/ResolverCachePlugin.js +115 -43
- package/lib/cache/getLazyHashedEtag.js +2 -2
- package/lib/cache/mergeEtags.js +16 -21
- package/lib/cli.js +195 -110
- package/lib/config/browserslistTargetHandler.js +106 -41
- package/lib/config/defaults.js +572 -154
- package/lib/config/normalization.js +361 -322
- package/lib/config/target.js +105 -66
- package/lib/container/ContainerEntryDependency.js +2 -1
- package/lib/container/ContainerEntryModule.js +27 -11
- package/lib/container/ContainerEntryModuleFactory.js +1 -1
- package/lib/container/ContainerExposedDependency.js +9 -0
- package/lib/container/ContainerPlugin.js +18 -12
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackDependency.js +13 -0
- package/lib/container/FallbackItemDependency.js +3 -0
- package/lib/container/FallbackModule.js +19 -8
- package/lib/container/FallbackModuleFactory.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +2 -0
- package/lib/container/RemoteModule.js +17 -4
- package/lib/container/RemoteRuntimeModule.js +31 -17
- package/lib/container/RemoteToExternalDependency.js +3 -0
- package/lib/container/options.js +18 -4
- package/lib/css/CssExportsGenerator.js +203 -0
- package/lib/css/CssGenerator.js +151 -0
- package/lib/css/CssLoadingRuntimeModule.js +592 -0
- package/lib/css/CssModulesPlugin.js +888 -0
- package/lib/css/CssParser.js +1049 -0
- package/lib/css/walkCssTokens.js +775 -0
- package/lib/debug/ProfilingPlugin.js +102 -54
- package/lib/dependencies/AMDDefineDependency.js +54 -10
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +204 -61
- package/lib/dependencies/AMDPlugin.js +44 -24
- package/lib/dependencies/AMDRequireArrayDependency.js +34 -10
- package/lib/dependencies/AMDRequireContextDependency.js +15 -0
- package/lib/dependencies/AMDRequireDependenciesBlock.js +6 -0
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +185 -54
- package/lib/dependencies/AMDRequireDependency.js +21 -6
- package/lib/dependencies/AMDRequireItemDependency.js +6 -0
- package/lib/dependencies/AMDRuntimeModules.js +4 -4
- package/lib/dependencies/CachedConstDependency.js +22 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +16 -2
- package/lib/dependencies/CommonJsExportRequireDependency.js +77 -47
- package/lib/dependencies/CommonJsExportsDependency.js +28 -5
- package/lib/dependencies/CommonJsExportsParserPlugin.js +111 -39
- package/lib/dependencies/CommonJsFullRequireDependency.js +42 -8
- package/lib/dependencies/CommonJsImportsParserPlugin.js +530 -130
- package/lib/dependencies/CommonJsPlugin.js +51 -26
- package/lib/dependencies/CommonJsRequireContextDependency.js +23 -2
- package/lib/dependencies/CommonJsRequireDependency.js +9 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +22 -8
- package/lib/dependencies/ConstDependency.js +12 -3
- package/lib/dependencies/ContextDependency.js +32 -5
- package/lib/dependencies/ContextDependencyHelpers.js +92 -62
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +4 -1
- package/lib/dependencies/ContextElementDependency.js +41 -4
- package/lib/dependencies/CreateScriptUrlDependency.js +22 -1
- package/lib/dependencies/CriticalDependencyWarning.js +4 -1
- package/lib/dependencies/CssExportDependency.js +156 -0
- package/lib/dependencies/CssImportDependency.js +125 -0
- package/lib/dependencies/CssLocalIdentifierDependency.js +245 -0
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +111 -0
- package/lib/dependencies/CssUrlDependency.js +164 -0
- package/lib/dependencies/DelegatedSourceDependency.js +3 -0
- package/lib/dependencies/DllEntryDependency.js +14 -0
- package/lib/dependencies/DynamicExports.js +15 -11
- package/lib/dependencies/ExportsInfoDependency.js +26 -5
- package/lib/dependencies/ExternalModuleDependency.js +109 -0
- package/lib/dependencies/ExternalModuleInitFragment.js +133 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +11 -2
- package/lib/dependencies/HarmonyAcceptImportDependency.js +9 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +6 -5
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +29 -3
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +152 -0
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +96 -51
- package/lib/dependencies/HarmonyExportExpressionDependency.js +21 -4
- package/lib/dependencies/HarmonyExportHeaderDependency.js +13 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +216 -108
- package/lib/dependencies/HarmonyExportInitFragment.js +21 -9
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +12 -0
- package/lib/dependencies/HarmonyExports.js +13 -7
- package/lib/dependencies/HarmonyImportDependency.js +65 -19
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +268 -74
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +11 -5
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +180 -36
- package/lib/dependencies/HarmonyModulesPlugin.js +33 -5
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -3
- package/lib/dependencies/ImportContextDependency.js +15 -2
- package/lib/dependencies/ImportDependency.js +50 -12
- package/lib/dependencies/ImportEagerDependency.js +11 -6
- package/lib/dependencies/ImportMetaContextDependency.js +42 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +301 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +72 -0
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +6 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +6 -0
- package/lib/dependencies/ImportMetaPlugin.js +128 -59
- package/lib/dependencies/ImportParserPlugin.js +153 -83
- package/lib/dependencies/ImportPlugin.js +21 -7
- package/lib/dependencies/ImportWeakDependency.js +11 -6
- package/lib/dependencies/JsonExportsDependency.js +38 -30
- package/lib/dependencies/LoaderDependency.js +14 -0
- package/lib/dependencies/LoaderImportDependency.js +14 -0
- package/lib/dependencies/LoaderPlugin.js +54 -40
- package/lib/dependencies/LocalModule.js +17 -1
- package/lib/dependencies/LocalModuleDependency.js +15 -0
- package/lib/dependencies/LocalModulesHelpers.js +22 -4
- package/lib/dependencies/ModuleDecoratorDependency.js +9 -1
- package/lib/dependencies/ModuleDependency.js +24 -7
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +2 -1
- package/lib/dependencies/ModuleHotAcceptDependency.js +6 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +6 -0
- package/lib/dependencies/PrefetchDependency.js +3 -0
- package/lib/dependencies/ProvidedDependency.js +43 -8
- package/lib/dependencies/PureExpressionDependency.js +73 -39
- package/lib/dependencies/RequireContextDependency.js +6 -16
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +14 -6
- package/lib/dependencies/RequireContextPlugin.js +20 -7
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +7 -0
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +29 -12
- package/lib/dependencies/RequireEnsureDependency.js +16 -2
- package/lib/dependencies/RequireEnsureItemDependency.js +3 -0
- package/lib/dependencies/RequireEnsurePlugin.js +27 -7
- package/lib/dependencies/RequireHeaderDependency.js +14 -1
- package/lib/dependencies/RequireIncludeDependency.js +6 -1
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +29 -5
- package/lib/dependencies/RequireIncludePlugin.js +25 -5
- package/lib/dependencies/RequireResolveContextDependency.js +19 -2
- package/lib/dependencies/RequireResolveDependency.js +8 -1
- package/lib/dependencies/RequireResolveHeaderDependency.js +18 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +9 -1
- package/lib/dependencies/StaticExportsDependency.js +8 -0
- package/lib/dependencies/SystemPlugin.js +49 -22
- package/lib/dependencies/SystemRuntimeModule.js +1 -1
- package/lib/dependencies/URLDependency.js +20 -13
- package/lib/dependencies/URLPlugin.js +115 -27
- package/lib/dependencies/UnsupportedDependency.js +13 -0
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +14 -0
- package/lib/dependencies/WebAssemblyImportDependency.js +9 -1
- package/lib/dependencies/WebpackIsIncludedDependency.js +6 -1
- package/lib/dependencies/WorkerDependency.js +47 -3
- package/lib/dependencies/WorkerPlugin.js +143 -59
- package/lib/dependencies/getFunctionExpression.js +9 -0
- package/lib/dependencies/processExportInfo.js +3 -1
- package/lib/electron/ElectronTargetPlugin.js +1 -0
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +3 -2
- package/lib/esm/ModuleChunkFormatPlugin.js +92 -55
- package/lib/esm/ModuleChunkLoadingPlugin.js +12 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +141 -25
- package/lib/formatLocation.js +1 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +37 -25
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +2 -1
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +13 -15
- package/lib/hmr/LazyCompilationPlugin.js +94 -41
- package/lib/hmr/lazyCompilationBackend.js +107 -44
- package/lib/ids/ChunkModuleIdRangePlugin.js +12 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +13 -6
- package/lib/ids/DeterministicModuleIdsPlugin.js +59 -35
- package/lib/ids/HashedModuleIdsPlugin.js +24 -16
- package/lib/ids/IdHelpers.js +59 -49
- package/lib/ids/NamedChunkIdsPlugin.js +13 -1
- package/lib/ids/NamedModuleIdsPlugin.js +20 -12
- package/lib/ids/NaturalModuleIdsPlugin.js +10 -13
- package/lib/ids/OccurrenceChunkIdsPlugin.js +6 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +14 -11
- package/lib/ids/SyncModuleIdsPlugin.js +146 -0
- package/lib/index.js +44 -5
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +9 -7
- package/lib/javascript/BasicEvaluatedExpression.js +133 -19
- package/lib/javascript/ChunkHelpers.js +33 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +18 -15
- package/lib/javascript/EnableChunkLoadingPlugin.js +11 -6
- package/lib/javascript/JavascriptGenerator.js +37 -6
- package/lib/javascript/JavascriptModulesPlugin.js +523 -295
- package/lib/javascript/JavascriptParser.js +1591 -574
- package/lib/javascript/JavascriptParserHelpers.js +58 -37
- package/lib/javascript/StartupHelpers.js +69 -47
- package/lib/json/JsonData.js +33 -0
- package/lib/json/JsonGenerator.js +29 -21
- package/lib/json/JsonModulesPlugin.js +13 -7
- package/lib/json/JsonParser.js +30 -16
- package/lib/library/AbstractLibraryPlugin.js +6 -2
- package/lib/library/AmdLibraryPlugin.js +34 -18
- package/lib/library/AssignLibraryPlugin.js +68 -32
- package/lib/library/EnableLibraryPlugin.js +39 -14
- package/lib/library/ExportPropertyLibraryPlugin.js +14 -5
- package/lib/library/JsonpLibraryPlugin.js +4 -3
- package/lib/library/ModernModuleLibraryPlugin.js +144 -0
- package/lib/library/ModuleLibraryPlugin.js +12 -7
- package/lib/library/SystemLibraryPlugin.js +6 -4
- package/lib/library/UmdLibraryPlugin.js +119 -100
- package/lib/logging/Logger.js +59 -6
- package/lib/logging/createConsoleLogger.js +25 -40
- package/lib/logging/runtime.js +8 -9
- package/lib/logging/truncateArgs.js +9 -8
- package/lib/node/CommonJsChunkLoadingPlugin.js +18 -2
- package/lib/node/NodeEnvironmentPlugin.js +14 -8
- package/lib/node/NodeTargetPlugin.js +7 -0
- package/lib/node/NodeTemplatePlugin.js +10 -2
- package/lib/node/NodeWatchFileSystem.js +100 -50
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +51 -26
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +13 -2
- package/lib/node/ReadFileCompileWasmPlugin.js +21 -3
- package/lib/node/RequireChunkLoadingRuntimeModule.js +49 -26
- package/lib/node/nodeConsole.js +48 -31
- package/lib/optimize/AggressiveMergingPlugin.js +10 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +26 -21
- package/lib/optimize/ConcatenatedModule.js +353 -212
- package/lib/optimize/EnsureChunkConditionsPlugin.js +4 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +14 -8
- package/lib/optimize/InnerGraph.js +30 -25
- package/lib/optimize/InnerGraphPlugin.js +105 -64
- package/lib/optimize/LimitChunkCountPlugin.js +32 -9
- package/lib/optimize/MangleExportsPlugin.js +7 -2
- package/lib/optimize/MinMaxSizeWarning.js +6 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +150 -83
- package/lib/optimize/RealContentHashPlugin.js +99 -43
- package/lib/optimize/RemoveParentModulesPlugin.js +131 -48
- package/lib/optimize/RuntimeChunkPlugin.js +15 -2
- package/lib/optimize/SideEffectsFlagPlugin.js +119 -63
- package/lib/optimize/SplitChunksPlugin.js +129 -78
- package/lib/performance/SizeLimitsPlugin.js +22 -8
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +4 -2
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +4 -1
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +8 -5
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +5 -3
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +5 -3
- package/lib/rules/BasicEffectRulePlugin.js +7 -1
- package/lib/rules/BasicMatcherRulePlugin.js +8 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +19 -2
- package/lib/rules/RuleSetCompiler.js +53 -32
- package/lib/rules/UseEffectRulePlugin.js +42 -36
- package/lib/runtime/AsyncModuleRuntimeModule.js +56 -69
- package/lib/runtime/AutoPublicPathRuntimeModule.js +25 -9
- package/lib/runtime/BaseUriRuntimeModule.js +35 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -1
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +5 -2
- package/lib/runtime/CompatRuntimeModule.js +7 -2
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +7 -4
- package/lib/runtime/CreateScriptRuntimeModule.js +38 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +13 -36
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +6 -3
- package/lib/runtime/EnsureChunkRuntimeModule.js +29 -15
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +56 -43
- package/lib/runtime/GetFullHashRuntimeModule.js +4 -3
- package/lib/runtime/GetMainFilenameRuntimeModule.js +5 -2
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +98 -0
- package/lib/runtime/GlobalRuntimeModule.js +1 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +5 -2
- package/lib/runtime/LoadScriptRuntimeModule.js +61 -45
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +5 -2
- package/lib/runtime/NonceRuntimeModule.js +24 -0
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -2
- package/lib/runtime/PublicPathRuntimeModule.js +9 -2
- package/lib/runtime/RelativeUrlRuntimeModule.js +5 -2
- package/lib/runtime/RuntimeIdRuntimeModule.js +6 -2
- package/lib/runtime/StartupChunkDependenciesPlugin.js +15 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +36 -28
- package/lib/runtime/StartupEntrypointRuntimeModule.js +13 -9
- package/lib/runtime/SystemContextRuntimeModule.js +1 -1
- package/lib/schemes/DataUriPlugin.js +16 -3
- package/lib/schemes/HttpUriPlugin.js +336 -120
- package/lib/serialization/ArraySerializer.js +22 -6
- package/lib/serialization/BinaryMiddleware.js +212 -33
- package/lib/serialization/DateObjectSerializer.js +16 -4
- package/lib/serialization/ErrorObjectSerializer.js +23 -6
- package/lib/serialization/FileMiddleware.js +187 -86
- package/lib/serialization/MapObjectSerializer.js +25 -8
- package/lib/serialization/NullPrototypeObjectSerializer.js +26 -8
- package/lib/serialization/ObjectMiddleware.js +96 -66
- package/lib/serialization/PlainObjectSerializer.js +51 -14
- package/lib/serialization/RegExpObjectSerializer.js +17 -5
- package/lib/serialization/Serializer.js +23 -5
- package/lib/serialization/SerializerMiddleware.js +8 -8
- package/lib/serialization/SetObjectSerializer.js +22 -6
- package/lib/serialization/SingleItemMiddleware.js +2 -2
- package/lib/serialization/types.js +2 -2
- package/lib/sharing/ConsumeSharedFallbackDependency.js +3 -0
- package/lib/sharing/ConsumeSharedModule.js +40 -17
- package/lib/sharing/ConsumeSharedPlugin.js +139 -102
- package/lib/sharing/ConsumeSharedRuntimeModule.js +144 -130
- package/lib/sharing/ProvideForSharedDependency.js +0 -1
- package/lib/sharing/ProvideSharedDependency.js +17 -0
- package/lib/sharing/ProvideSharedModule.js +19 -6
- package/lib/sharing/ProvideSharedModuleFactory.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +37 -30
- package/lib/sharing/SharePlugin.js +2 -2
- package/lib/sharing/ShareRuntimeModule.js +20 -10
- package/lib/sharing/resolveMatchedConfigs.js +6 -5
- package/lib/sharing/utils.js +338 -34
- package/lib/stats/DefaultStatsFactoryPlugin.js +660 -396
- package/lib/stats/DefaultStatsPresetPlugin.js +85 -25
- package/lib/stats/DefaultStatsPrinterPlugin.js +525 -145
- package/lib/stats/StatsFactory.js +128 -57
- package/lib/stats/StatsPrinter.js +77 -46
- package/lib/util/ArrayHelpers.js +35 -1
- package/lib/util/ArrayQueue.js +15 -22
- package/lib/util/AsyncQueue.js +37 -16
- package/lib/util/IterableHelpers.js +3 -4
- package/lib/util/LazyBucketSortedSet.js +60 -44
- package/lib/util/LazySet.js +11 -2
- package/lib/util/MapHelpers.js +17 -5
- package/lib/util/ParallelismFactorCalculator.js +11 -1
- package/lib/util/Queue.js +9 -3
- package/lib/util/Semaphore.js +4 -7
- package/lib/util/SetHelpers.js +5 -5
- package/lib/util/SortableSet.js +19 -6
- package/lib/util/StackedCacheMap.js +33 -3
- package/lib/util/StackedMap.js +1 -3
- package/lib/util/StringXor.js +46 -0
- package/lib/util/TupleQueue.js +9 -3
- package/lib/util/TupleSet.js +15 -5
- package/lib/util/URLAbsoluteSpecifier.js +8 -8
- package/lib/util/WeakTupleMap.js +70 -28
- package/lib/util/binarySearchBounds.js +51 -9
- package/lib/util/chainedImports.js +97 -0
- package/lib/util/cleverMerge.js +51 -36
- package/lib/util/comparators.js +146 -83
- package/lib/util/compileBooleanMatcher.js +35 -7
- package/lib/util/conventions.js +126 -0
- package/lib/util/create-schema-validation.js +9 -2
- package/lib/util/createHash.js +49 -14
- package/lib/util/deprecation.js +48 -15
- package/lib/util/deterministicGrouping.js +71 -39
- package/lib/util/extractUrlAndGlobal.js +3 -0
- package/lib/util/findGraphRoots.js +7 -5
- package/lib/util/fs.js +419 -94
- package/lib/util/hash/BatchedHash.js +10 -4
- package/lib/util/hash/md4.js +20 -0
- package/lib/util/hash/wasm-hash.js +163 -0
- package/lib/util/hash/xxhash64.js +7 -141
- package/lib/util/identifier.js +140 -93
- package/lib/util/internalSerializables.js +22 -0
- package/lib/util/makeSerializable.js +7 -0
- package/lib/util/memoize.js +10 -10
- package/lib/util/mergeScope.js +76 -0
- package/lib/util/nonNumericOnlyHash.js +22 -0
- package/lib/util/numberHash.js +84 -34
- package/lib/util/objectToMap.js +0 -1
- package/lib/util/processAsyncTree.js +7 -1
- package/lib/util/propertyAccess.js +7 -55
- package/lib/util/propertyName.js +77 -0
- package/lib/util/registerExternalSerializer.js +2 -2
- package/lib/util/runtime.js +188 -133
- package/lib/util/semver.js +64 -56
- package/lib/util/serialization.js +26 -1
- package/lib/util/smartGrouping.js +10 -10
- package/lib/util/source.js +1 -1
- package/lib/validateSchema.js +6 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +9 -4
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +70 -30
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +9 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +34 -16
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +32 -12
- package/lib/wasm-async/AsyncWebAssemblyParser.js +17 -4
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +72 -31
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +17 -6
- package/lib/wasm-sync/WebAssemblyGenerator.js +72 -52
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -4
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +53 -43
- package/lib/wasm-sync/WebAssemblyParser.js +23 -9
- package/lib/wasm-sync/WebAssemblyUtils.js +5 -4
- package/lib/web/FetchCompileAsyncWasmPlugin.js +11 -1
- package/lib/web/FetchCompileWasmPlugin.js +59 -42
- package/lib/web/JsonpChunkLoadingPlugin.js +9 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +71 -41
- package/lib/webpack.js +43 -12
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +15 -12
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +55 -40
- package/module.d.ts +233 -0
- package/package.json +85 -139
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +679 -47
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +9 -1
- package/schemas/plugins/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +4 -0
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.json +10 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +2 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +12 -1
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssAutoParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoParserOptions.json +3 -0
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssGlobalGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssGlobalParserOptions.json +3 -0
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssModuleGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssModuleParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssModuleParserOptions.json +3 -0
- package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssParserOptions.json +3 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.json +4 -0
- package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
- package/types.d.ts +5026 -1756
package/lib/buildChunkGraph.js
CHANGED
@@ -16,6 +16,7 @@ const { getEntryRuntime, mergeRuntime } = require("./util/runtime");
|
|
16
16
|
/** @typedef {import("./Compilation")} Compilation */
|
17
17
|
/** @typedef {import("./DependenciesBlock")} DependenciesBlock */
|
18
18
|
/** @typedef {import("./Dependency")} Dependency */
|
19
|
+
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
19
20
|
/** @typedef {import("./Entrypoint")} Entrypoint */
|
20
21
|
/** @typedef {import("./Module")} Module */
|
21
22
|
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
@@ -24,7 +25,7 @@ const { getEntryRuntime, mergeRuntime } = require("./util/runtime");
|
|
24
25
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
25
26
|
|
26
27
|
/**
|
27
|
-
* @typedef {
|
28
|
+
* @typedef {object} QueueItem
|
28
29
|
* @property {number} action
|
29
30
|
* @property {DependenciesBlock} block
|
30
31
|
* @property {Module} module
|
@@ -33,52 +34,90 @@ const { getEntryRuntime, mergeRuntime } = require("./util/runtime");
|
|
33
34
|
* @property {ChunkGroupInfo} chunkGroupInfo
|
34
35
|
*/
|
35
36
|
|
36
|
-
/** @typedef {Set<Module> & { plus: Set<Module> }} ModuleSetPlus */
|
37
|
-
|
38
37
|
/**
|
39
|
-
* @typedef {
|
38
|
+
* @typedef {object} ChunkGroupInfo
|
40
39
|
* @property {ChunkGroup} chunkGroup the chunk group
|
41
40
|
* @property {RuntimeSpec} runtime the runtimes
|
42
|
-
* @property {
|
43
|
-
* @property {
|
44
|
-
* @property {ModuleSetPlus[]} availableModulesToBeMerged enqueued updates to the minimal set of available modules
|
41
|
+
* @property {bigint | undefined} minAvailableModules current minimal set of modules available at this point
|
42
|
+
* @property {bigint[]} availableModulesToBeMerged enqueued updates to the minimal set of available modules
|
45
43
|
* @property {Set<Module>=} skippedItems modules that were skipped because module is already available in parent chunks (need to reconsider when minAvailableModules is shrinking)
|
46
|
-
* @property {Set<[Module,
|
47
|
-
* @property {
|
48
|
-
* @property {Set<ChunkGroupInfo>} children set of children chunk groups, that will be revisited when availableModules shrink
|
49
|
-
* @property {Set<ChunkGroupInfo>} availableSources set of chunk groups that are the source for minAvailableModules
|
50
|
-
* @property {Set<ChunkGroupInfo>} availableChildren set of chunk groups which depend on the this chunk group as availableSource
|
44
|
+
* @property {Set<[Module, ModuleGraphConnection[]]>=} skippedModuleConnections referenced modules that where skipped because they were not active in this runtime
|
45
|
+
* @property {bigint | undefined} resultingAvailableModules set of modules available including modules from this chunk group
|
46
|
+
* @property {Set<ChunkGroupInfo> | undefined} children set of children chunk groups, that will be revisited when availableModules shrink
|
47
|
+
* @property {Set<ChunkGroupInfo> | undefined} availableSources set of chunk groups that are the source for minAvailableModules
|
48
|
+
* @property {Set<ChunkGroupInfo> | undefined} availableChildren set of chunk groups which depend on the this chunk group as availableSource
|
51
49
|
* @property {number} preOrderIndex next pre order index
|
52
50
|
* @property {number} postOrderIndex next post order index
|
51
|
+
* @property {boolean} chunkLoading has a chunk loading mechanism
|
52
|
+
* @property {boolean} asyncChunks create async chunks
|
53
53
|
*/
|
54
54
|
|
55
55
|
/**
|
56
|
-
* @typedef {
|
56
|
+
* @typedef {object} BlockChunkGroupConnection
|
57
57
|
* @property {ChunkGroupInfo} originChunkGroupInfo origin chunk group
|
58
58
|
* @property {ChunkGroup} chunkGroup referenced chunk group
|
59
59
|
*/
|
60
60
|
|
61
|
-
|
62
|
-
|
61
|
+
/** @typedef {(Module | ConnectionState | ModuleGraphConnection)[]} BlockModulesInTuples */
|
62
|
+
/** @typedef {(Module | ConnectionState | ModuleGraphConnection[])[]} BlockModulesInFlattenTuples */
|
63
|
+
/** @typedef {Map<DependenciesBlock, BlockModulesInFlattenTuples>} BlockModulesMap */
|
64
|
+
/** @typedef {Map<Chunk, bigint>} MaskByChunk */
|
65
|
+
/** @typedef {Set<DependenciesBlock>} BlocksWithNestedBlocks */
|
66
|
+
/** @typedef {Map<AsyncDependenciesBlock, BlockChunkGroupConnection[]>} BlockConnections */
|
67
|
+
/** @typedef {Map<ChunkGroup, ChunkGroupInfo>} ChunkGroupInfoMap */
|
68
|
+
/** @typedef {Set<ChunkGroup>} AllCreatedChunkGroups */
|
69
|
+
/** @typedef {Map<Entrypoint, Module[]>} InputEntrypointsAndModules */
|
70
|
+
|
71
|
+
const ZERO_BIGINT = BigInt(0);
|
72
|
+
const ONE_BIGINT = BigInt(1);
|
63
73
|
|
64
74
|
/**
|
65
|
-
* @param {
|
66
|
-
* @param {
|
67
|
-
* @returns {
|
75
|
+
* @param {bigint} mask The mask to test
|
76
|
+
* @param {number} ordinal The ordinal of the bit to test
|
77
|
+
* @returns {boolean} If the ordinal-th bit is set in the mask
|
68
78
|
*/
|
69
|
-
const
|
70
|
-
|
79
|
+
const isOrdinalSetInMask = (mask, ordinal) =>
|
80
|
+
BigInt.asUintN(1, mask >> BigInt(ordinal)) !== ZERO_BIGINT;
|
81
|
+
|
82
|
+
/**
|
83
|
+
* @param {ModuleGraphConnection[]} connections list of connections
|
84
|
+
* @param {RuntimeSpec} runtime for which runtime
|
85
|
+
* @returns {ConnectionState} connection state
|
86
|
+
*/
|
87
|
+
const getActiveStateOfConnections = (connections, runtime) => {
|
88
|
+
let merged = connections[0].getActiveState(runtime);
|
89
|
+
if (merged === true) return true;
|
90
|
+
for (let i = 1; i < connections.length; i++) {
|
91
|
+
const c = connections[i];
|
92
|
+
merged = ModuleGraphConnection.addConnectionStates(
|
93
|
+
merged,
|
94
|
+
c.getActiveState(runtime)
|
95
|
+
);
|
96
|
+
if (merged === true) return true;
|
97
|
+
}
|
98
|
+
return merged;
|
71
99
|
};
|
72
100
|
|
101
|
+
/**
|
102
|
+
* @param {Module} module module
|
103
|
+
* @param {ModuleGraph} moduleGraph module graph
|
104
|
+
* @param {RuntimeSpec} runtime runtime
|
105
|
+
* @param {BlockModulesMap} blockModulesMap block modules map
|
106
|
+
*/
|
73
107
|
const extractBlockModules = (module, moduleGraph, runtime, blockModulesMap) => {
|
108
|
+
/** @type {DependenciesBlock | undefined} */
|
74
109
|
let blockCache;
|
110
|
+
/** @type {BlockModulesInTuples | undefined} */
|
75
111
|
let modules;
|
76
112
|
|
113
|
+
/** @type {BlockModulesInTuples[]} */
|
77
114
|
const arrays = [];
|
78
115
|
|
116
|
+
/** @type {DependenciesBlock[]} */
|
79
117
|
const queue = [module];
|
80
118
|
while (queue.length > 0) {
|
81
|
-
const block = queue.pop();
|
119
|
+
const block = /** @type {DependenciesBlock} */ (queue.pop());
|
120
|
+
/** @type {Module[]} */
|
82
121
|
const arr = [];
|
83
122
|
arrays.push(arr);
|
84
123
|
blockModulesMap.set(block, arr);
|
@@ -96,65 +135,81 @@ const extractBlockModules = (module, moduleGraph, runtime, blockModulesMap) => {
|
|
96
135
|
if (!m) continue;
|
97
136
|
// We skip weak connections
|
98
137
|
if (connection.weak) continue;
|
99
|
-
const state = connection.getActiveState(runtime);
|
100
|
-
// We skip inactive connections
|
101
|
-
if (state === false) continue;
|
102
138
|
|
103
139
|
const block = moduleGraph.getParentBlock(d);
|
104
140
|
let index = moduleGraph.getParentBlockIndex(d);
|
105
141
|
|
106
142
|
// deprecated fallback
|
107
143
|
if (index < 0) {
|
108
|
-
index = block.dependencies.indexOf(d);
|
144
|
+
index = /** @type {DependenciesBlock} */ (block).dependencies.indexOf(d);
|
109
145
|
}
|
110
146
|
|
111
147
|
if (blockCache !== block) {
|
112
|
-
modules =
|
148
|
+
modules =
|
149
|
+
/** @type {BlockModulesInTuples} */
|
150
|
+
(
|
151
|
+
blockModulesMap.get(
|
152
|
+
(blockCache = /** @type {DependenciesBlock} */ (block))
|
153
|
+
)
|
154
|
+
);
|
113
155
|
}
|
114
156
|
|
115
|
-
const i = index
|
116
|
-
|
117
|
-
modules[i
|
157
|
+
const i = index * 3;
|
158
|
+
/** @type {BlockModulesInTuples} */
|
159
|
+
(modules)[i] = m;
|
160
|
+
/** @type {BlockModulesInTuples} */
|
161
|
+
(modules)[i + 1] = connection.getActiveState(runtime);
|
162
|
+
/** @type {BlockModulesInTuples} */
|
163
|
+
(modules)[i + 2] = connection;
|
118
164
|
}
|
119
165
|
|
120
166
|
for (const modules of arrays) {
|
121
167
|
if (modules.length === 0) continue;
|
122
168
|
let indexMap;
|
123
169
|
let length = 0;
|
124
|
-
outer: for (let j = 0; j < modules.length; j +=
|
170
|
+
outer: for (let j = 0; j < modules.length; j += 3) {
|
125
171
|
const m = modules[j];
|
126
172
|
if (m === undefined) continue;
|
127
|
-
const state = modules[j + 1];
|
173
|
+
const state = /** @type {ConnectionState} */ (modules[j + 1]);
|
174
|
+
const connection = /** @type {ModuleGraphConnection} */ (modules[j + 2]);
|
128
175
|
if (indexMap === undefined) {
|
129
176
|
let i = 0;
|
130
|
-
for (; i < length; i +=
|
177
|
+
for (; i < length; i += 3) {
|
131
178
|
if (modules[i] === m) {
|
132
|
-
const merged = modules[i + 1];
|
179
|
+
const merged = /** @type {ConnectionState} */ (modules[i + 1]);
|
180
|
+
/** @type {ModuleGraphConnection[]} */
|
181
|
+
(/** @type {unknown} */ (modules[i + 2])).push(connection);
|
133
182
|
if (merged === true) continue outer;
|
134
183
|
modules[i + 1] = ModuleGraphConnection.addConnectionStates(
|
135
184
|
merged,
|
136
185
|
state
|
137
186
|
);
|
187
|
+
continue outer;
|
138
188
|
}
|
139
189
|
}
|
140
190
|
modules[length] = m;
|
141
191
|
length++;
|
142
192
|
modules[length] = state;
|
143
193
|
length++;
|
194
|
+
/** @type {ModuleGraphConnection[]} */
|
195
|
+
(/** @type {unknown} */ (modules[length])) = [connection];
|
196
|
+
length++;
|
144
197
|
if (length > 30) {
|
145
198
|
// To avoid worse case performance, we will use an index map for
|
146
199
|
// linear cost access, which allows to maintain O(n) complexity
|
147
200
|
// while keeping allocations down to a minimum
|
148
201
|
indexMap = new Map();
|
149
|
-
for (let i = 0; i < length; i +=
|
202
|
+
for (let i = 0; i < length; i += 3) {
|
150
203
|
indexMap.set(modules[i], i + 1);
|
151
204
|
}
|
152
205
|
}
|
153
206
|
} else {
|
154
207
|
const idx = indexMap.get(m);
|
155
208
|
if (idx !== undefined) {
|
156
|
-
const merged = modules[idx];
|
157
|
-
|
209
|
+
const merged = /** @type {ConnectionState} */ (modules[idx]);
|
210
|
+
/** @type {ModuleGraphConnection[]} */
|
211
|
+
(/** @type {unknown} */ (modules[idx + 1])).push(connection);
|
212
|
+
if (merged === true) continue;
|
158
213
|
modules[idx] = ModuleGraphConnection.addConnectionStates(
|
159
214
|
merged,
|
160
215
|
state
|
@@ -165,6 +220,12 @@ const extractBlockModules = (module, moduleGraph, runtime, blockModulesMap) => {
|
|
165
220
|
modules[length] = state;
|
166
221
|
indexMap.set(m, length);
|
167
222
|
length++;
|
223
|
+
/** @type {ModuleGraphConnection[]} */
|
224
|
+
(
|
225
|
+
/** @type {unknown} */
|
226
|
+
(modules[length])
|
227
|
+
) = [connection];
|
228
|
+
length++;
|
168
229
|
}
|
169
230
|
}
|
170
231
|
}
|
@@ -173,14 +234,14 @@ const extractBlockModules = (module, moduleGraph, runtime, blockModulesMap) => {
|
|
173
234
|
};
|
174
235
|
|
175
236
|
/**
|
176
|
-
*
|
177
237
|
* @param {Logger} logger a logger
|
178
238
|
* @param {Compilation} compilation the compilation
|
179
|
-
* @param {
|
180
|
-
* @param {
|
181
|
-
* @param {
|
182
|
-
* @param {
|
183
|
-
* @param {
|
239
|
+
* @param {InputEntrypointsAndModules} inputEntrypointsAndModules chunk groups which are processed with the modules
|
240
|
+
* @param {ChunkGroupInfoMap} chunkGroupInfoMap mapping from chunk group to available modules
|
241
|
+
* @param {BlockConnections} blockConnections connection for blocks
|
242
|
+
* @param {BlocksWithNestedBlocks} blocksWithNestedBlocks flag for blocks that have nested blocks
|
243
|
+
* @param {AllCreatedChunkGroups} allCreatedChunkGroups filled with all chunk groups that are created here
|
244
|
+
* @param {MaskByChunk} maskByChunk module content mask by chunk
|
184
245
|
*/
|
185
246
|
const visitModules = (
|
186
247
|
logger,
|
@@ -189,29 +250,50 @@ const visitModules = (
|
|
189
250
|
chunkGroupInfoMap,
|
190
251
|
blockConnections,
|
191
252
|
blocksWithNestedBlocks,
|
192
|
-
allCreatedChunkGroups
|
253
|
+
allCreatedChunkGroups,
|
254
|
+
maskByChunk
|
193
255
|
) => {
|
194
256
|
const { moduleGraph, chunkGraph, moduleMemCaches } = compilation;
|
195
257
|
|
196
258
|
const blockModulesRuntimeMap = new Map();
|
197
259
|
|
198
|
-
/** @type {
|
199
|
-
let blockModulesMapRuntime = false;
|
260
|
+
/** @type {BlockModulesMap | undefined} */
|
200
261
|
let blockModulesMap;
|
201
262
|
|
263
|
+
/** @type {Map<Module, number>} */
|
264
|
+
const ordinalByModule = new Map();
|
265
|
+
|
266
|
+
/**
|
267
|
+
* @param {Module} module The module to look up
|
268
|
+
* @returns {number} The ordinal of the module in masks
|
269
|
+
*/
|
270
|
+
const getModuleOrdinal = module => {
|
271
|
+
let ordinal = ordinalByModule.get(module);
|
272
|
+
if (ordinal === undefined) {
|
273
|
+
ordinal = ordinalByModule.size;
|
274
|
+
ordinalByModule.set(module, ordinal);
|
275
|
+
}
|
276
|
+
return ordinal;
|
277
|
+
};
|
278
|
+
|
279
|
+
for (const chunk of compilation.chunks) {
|
280
|
+
let mask = ZERO_BIGINT;
|
281
|
+
for (const m of chunkGraph.getChunkModulesIterable(chunk)) {
|
282
|
+
mask |= ONE_BIGINT << BigInt(getModuleOrdinal(m));
|
283
|
+
}
|
284
|
+
maskByChunk.set(chunk, mask);
|
285
|
+
}
|
286
|
+
|
202
287
|
/**
|
203
|
-
*
|
204
288
|
* @param {DependenciesBlock} block block
|
205
289
|
* @param {RuntimeSpec} runtime runtime
|
206
|
-
* @returns {
|
290
|
+
* @returns {BlockModulesInFlattenTuples} block modules in flatten tuples
|
207
291
|
*/
|
208
292
|
const getBlockModules = (block, runtime) => {
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
blockModulesRuntimeMap.set(runtime, blockModulesMap);
|
214
|
-
}
|
293
|
+
blockModulesMap = blockModulesRuntimeMap.get(runtime);
|
294
|
+
if (blockModulesMap === undefined) {
|
295
|
+
blockModulesMap = new Map();
|
296
|
+
blockModulesRuntimeMap.set(runtime, blockModulesMap);
|
215
297
|
}
|
216
298
|
let blockModules = blockModulesMap.get(block);
|
217
299
|
if (blockModules !== undefined) return blockModules;
|
@@ -232,13 +314,14 @@ const visitModules = (
|
|
232
314
|
for (const [block, blockModules] of map)
|
233
315
|
blockModulesMap.set(block, blockModules);
|
234
316
|
return map.get(block);
|
235
|
-
} else {
|
236
|
-
logger.time("visitModules: prepare");
|
237
|
-
extractBlockModules(module, moduleGraph, runtime, blockModulesMap);
|
238
|
-
blockModules = blockModulesMap.get(block);
|
239
|
-
logger.timeAggregate("visitModules: prepare");
|
240
|
-
return blockModules;
|
241
317
|
}
|
318
|
+
logger.time("visitModules: prepare");
|
319
|
+
extractBlockModules(module, moduleGraph, runtime, blockModulesMap);
|
320
|
+
blockModules =
|
321
|
+
/** @type {BlockModulesInFlattenTuples} */
|
322
|
+
(blockModulesMap.get(block));
|
323
|
+
logger.timeAggregate("visitModules: prepare");
|
324
|
+
return blockModules;
|
242
325
|
};
|
243
326
|
|
244
327
|
let statProcessedQueueItems = 0;
|
@@ -246,12 +329,12 @@ const visitModules = (
|
|
246
329
|
let statConnectedChunkGroups = 0;
|
247
330
|
let statProcessedChunkGroupsForMerging = 0;
|
248
331
|
let statMergedAvailableModuleSets = 0;
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
332
|
+
const statForkedAvailableModules = 0;
|
333
|
+
const statForkedAvailableModulesCount = 0;
|
334
|
+
const statForkedAvailableModulesCountPlus = 0;
|
335
|
+
const statForkedMergedModulesCount = 0;
|
336
|
+
const statForkedMergedModulesCountPlus = 0;
|
337
|
+
const statForkedResultModulesCount = 0;
|
255
338
|
let statChunkGroupInfoUpdated = 0;
|
256
339
|
let statChildChunkGroupsReconnected = 0;
|
257
340
|
|
@@ -262,12 +345,18 @@ const visitModules = (
|
|
262
345
|
/** @type {Map<DependenciesBlock, ChunkGroupInfo>} */
|
263
346
|
const blockChunkGroups = new Map();
|
264
347
|
|
348
|
+
/** @type {Map<ChunkGroupInfo, DependenciesBlock>} */
|
349
|
+
const blockByChunkGroups = new Map();
|
350
|
+
|
265
351
|
/** @type {Map<string, ChunkGroupInfo>} */
|
266
352
|
const namedChunkGroups = new Map();
|
267
353
|
|
268
354
|
/** @type {Map<string, ChunkGroupInfo>} */
|
269
355
|
const namedAsyncEntrypoints = new Map();
|
270
356
|
|
357
|
+
/** @type {Set<ChunkGroupInfo>} */
|
358
|
+
const outdatedOrderIndexChunkGroups = new Set();
|
359
|
+
|
271
360
|
const ADD_AND_ENTER_ENTRY_MODULE = 0;
|
272
361
|
const ADD_AND_ENTER_MODULE = 1;
|
273
362
|
const ENTER_MODULE = 2;
|
@@ -288,7 +377,7 @@ const visitModules = (
|
|
288
377
|
for (const [chunkGroup, modules] of inputEntrypointsAndModules) {
|
289
378
|
const runtime = getEntryRuntime(
|
290
379
|
compilation,
|
291
|
-
chunkGroup.name,
|
380
|
+
/** @type {string} */ (chunkGroup.name),
|
292
381
|
chunkGroup.options
|
293
382
|
);
|
294
383
|
/** @type {ChunkGroupInfo} */
|
@@ -296,7 +385,6 @@ const visitModules = (
|
|
296
385
|
chunkGroup,
|
297
386
|
runtime,
|
298
387
|
minAvailableModules: undefined,
|
299
|
-
minAvailableModulesOwned: false,
|
300
388
|
availableModulesToBeMerged: [],
|
301
389
|
skippedItems: undefined,
|
302
390
|
resultingAvailableModules: undefined,
|
@@ -304,22 +392,27 @@ const visitModules = (
|
|
304
392
|
availableSources: undefined,
|
305
393
|
availableChildren: undefined,
|
306
394
|
preOrderIndex: 0,
|
307
|
-
postOrderIndex: 0
|
395
|
+
postOrderIndex: 0,
|
396
|
+
chunkLoading:
|
397
|
+
chunkGroup.options.chunkLoading !== undefined
|
398
|
+
? chunkGroup.options.chunkLoading !== false
|
399
|
+
: compilation.outputOptions.chunkLoading !== false,
|
400
|
+
asyncChunks:
|
401
|
+
chunkGroup.options.asyncChunks !== undefined
|
402
|
+
? chunkGroup.options.asyncChunks
|
403
|
+
: compilation.outputOptions.asyncChunks !== false
|
308
404
|
};
|
309
405
|
chunkGroup.index = nextChunkGroupIndex++;
|
310
406
|
if (chunkGroup.getNumberOfParents() > 0) {
|
311
407
|
// minAvailableModules for child entrypoints are unknown yet, set to undefined.
|
312
408
|
// This means no module is added until other sets are merged into
|
313
409
|
// this minAvailableModules (by the parent entrypoints)
|
314
|
-
const skippedItems = new Set();
|
315
|
-
for (const module of modules) {
|
316
|
-
skippedItems.add(module);
|
317
|
-
}
|
410
|
+
const skippedItems = new Set(modules);
|
318
411
|
chunkGroupInfo.skippedItems = skippedItems;
|
319
412
|
chunkGroupsForCombining.add(chunkGroupInfo);
|
320
413
|
} else {
|
321
414
|
// The application may start here: We start with an empty list of available modules
|
322
|
-
chunkGroupInfo.minAvailableModules =
|
415
|
+
chunkGroupInfo.minAvailableModules = ZERO_BIGINT;
|
323
416
|
const chunk = chunkGroup.getEntrypointChunk();
|
324
417
|
for (const module of modules) {
|
325
418
|
queue.push({
|
@@ -342,7 +435,9 @@ const visitModules = (
|
|
342
435
|
const { chunkGroup } = chunkGroupInfo;
|
343
436
|
chunkGroupInfo.availableSources = new Set();
|
344
437
|
for (const parent of chunkGroup.parentsIterable) {
|
345
|
-
const parentChunkGroupInfo =
|
438
|
+
const parentChunkGroupInfo =
|
439
|
+
/** @type {ChunkGroupInfo} */
|
440
|
+
(chunkGroupInfoMap.get(parent));
|
346
441
|
chunkGroupInfo.availableSources.add(parentChunkGroupInfo);
|
347
442
|
if (parentChunkGroupInfo.availableChildren === undefined) {
|
348
443
|
parentChunkGroupInfo.availableChildren = new Set();
|
@@ -362,7 +457,7 @@ const visitModules = (
|
|
362
457
|
/** @type {QueueItem[]} */
|
363
458
|
let queueDelayed = [];
|
364
459
|
|
365
|
-
/** @type {[Module,
|
460
|
+
/** @type {[Module, ModuleGraphConnection[]][]} */
|
366
461
|
const skipConnectionBuffer = [];
|
367
462
|
/** @type {Module[]} */
|
368
463
|
const skipBuffer = [];
|
@@ -388,29 +483,30 @@ const visitModules = (
|
|
388
483
|
const iteratorBlock = b => {
|
389
484
|
// 1. We create a chunk group with single chunk in it for this Block
|
390
485
|
// but only once (blockChunkGroups map)
|
486
|
+
/** @type {ChunkGroupInfo | undefined} */
|
391
487
|
let cgi = blockChunkGroups.get(b);
|
392
|
-
/** @type {ChunkGroup} */
|
488
|
+
/** @type {ChunkGroup | undefined} */
|
393
489
|
let c;
|
394
|
-
/** @type {Entrypoint} */
|
490
|
+
/** @type {Entrypoint | undefined} */
|
395
491
|
let entrypoint;
|
396
492
|
const entryOptions = b.groupOptions && b.groupOptions.entryOptions;
|
397
493
|
if (cgi === undefined) {
|
398
494
|
const chunkName = (b.groupOptions && b.groupOptions.name) || b.chunkName;
|
399
495
|
if (entryOptions) {
|
400
|
-
cgi = namedAsyncEntrypoints.get(chunkName);
|
496
|
+
cgi = namedAsyncEntrypoints.get(/** @type {string} */ (chunkName));
|
401
497
|
if (!cgi) {
|
402
498
|
entrypoint = compilation.addAsyncEntrypoint(
|
403
499
|
entryOptions,
|
404
500
|
module,
|
405
|
-
b.loc,
|
406
|
-
b.request
|
501
|
+
/** @type {DependencyLocation} */ (b.loc),
|
502
|
+
/** @type {string} */ (b.request)
|
407
503
|
);
|
504
|
+
maskByChunk.set(entrypoint.chunks[0], ZERO_BIGINT);
|
408
505
|
entrypoint.index = nextChunkGroupIndex++;
|
409
506
|
cgi = {
|
410
507
|
chunkGroup: entrypoint,
|
411
508
|
runtime: entrypoint.options.runtime || entrypoint.name,
|
412
|
-
minAvailableModules:
|
413
|
-
minAvailableModulesOwned: false,
|
509
|
+
minAvailableModules: ZERO_BIGINT,
|
414
510
|
availableModulesToBeMerged: [],
|
415
511
|
skippedItems: undefined,
|
416
512
|
resultingAvailableModules: undefined,
|
@@ -418,7 +514,15 @@ const visitModules = (
|
|
418
514
|
availableSources: undefined,
|
419
515
|
availableChildren: undefined,
|
420
516
|
preOrderIndex: 0,
|
421
|
-
postOrderIndex: 0
|
517
|
+
postOrderIndex: 0,
|
518
|
+
chunkLoading:
|
519
|
+
entryOptions.chunkLoading !== undefined
|
520
|
+
? entryOptions.chunkLoading !== false
|
521
|
+
: chunkGroupInfo.chunkLoading,
|
522
|
+
asyncChunks:
|
523
|
+
entryOptions.asyncChunks !== undefined
|
524
|
+
? entryOptions.asyncChunks
|
525
|
+
: chunkGroupInfo.asyncChunks
|
422
526
|
};
|
423
527
|
chunkGroupInfoMap.set(entrypoint, cgi);
|
424
528
|
|
@@ -429,7 +533,11 @@ const visitModules = (
|
|
429
533
|
} else {
|
430
534
|
entrypoint = /** @type {Entrypoint} */ (cgi.chunkGroup);
|
431
535
|
// TODO merge entryOptions
|
432
|
-
entrypoint.addOrigin(
|
536
|
+
entrypoint.addOrigin(
|
537
|
+
module,
|
538
|
+
/** @type {DependencyLocation} */ (b.loc),
|
539
|
+
/** @type {string} */ (b.request)
|
540
|
+
);
|
433
541
|
chunkGraph.connectBlockAndChunkGroup(b, entrypoint);
|
434
542
|
}
|
435
543
|
|
@@ -437,26 +545,36 @@ const visitModules = (
|
|
437
545
|
queueDelayed.push({
|
438
546
|
action: PROCESS_ENTRY_BLOCK,
|
439
547
|
block: b,
|
440
|
-
module
|
548
|
+
module,
|
441
549
|
chunk: entrypoint.chunks[0],
|
442
550
|
chunkGroup: entrypoint,
|
443
551
|
chunkGroupInfo: cgi
|
444
552
|
});
|
553
|
+
} else if (!chunkGroupInfo.asyncChunks || !chunkGroupInfo.chunkLoading) {
|
554
|
+
// Just queue the block into the current chunk group
|
555
|
+
queue.push({
|
556
|
+
action: PROCESS_BLOCK,
|
557
|
+
block: b,
|
558
|
+
module,
|
559
|
+
chunk,
|
560
|
+
chunkGroup,
|
561
|
+
chunkGroupInfo
|
562
|
+
});
|
445
563
|
} else {
|
446
|
-
cgi = namedChunkGroups.get(chunkName);
|
564
|
+
cgi = chunkName ? namedChunkGroups.get(chunkName) : undefined;
|
447
565
|
if (!cgi) {
|
448
566
|
c = compilation.addChunkInGroup(
|
449
567
|
b.groupOptions || b.chunkName,
|
450
568
|
module,
|
451
|
-
b.loc,
|
452
|
-
b.request
|
569
|
+
/** @type {DependencyLocation} */ (b.loc),
|
570
|
+
/** @type {string} */ (b.request)
|
453
571
|
);
|
572
|
+
maskByChunk.set(c.chunks[0], ZERO_BIGINT);
|
454
573
|
c.index = nextChunkGroupIndex++;
|
455
574
|
cgi = {
|
456
575
|
chunkGroup: c,
|
457
576
|
runtime: chunkGroupInfo.runtime,
|
458
577
|
minAvailableModules: undefined,
|
459
|
-
minAvailableModulesOwned: undefined,
|
460
578
|
availableModulesToBeMerged: [],
|
461
579
|
skippedItems: undefined,
|
462
580
|
resultingAvailableModules: undefined,
|
@@ -464,7 +582,9 @@ const visitModules = (
|
|
464
582
|
availableSources: undefined,
|
465
583
|
availableChildren: undefined,
|
466
584
|
preOrderIndex: 0,
|
467
|
-
postOrderIndex: 0
|
585
|
+
postOrderIndex: 0,
|
586
|
+
chunkLoading: chunkGroupInfo.chunkLoading,
|
587
|
+
asyncChunks: chunkGroupInfo.asyncChunks
|
468
588
|
};
|
469
589
|
allCreatedChunkGroups.add(c);
|
470
590
|
chunkGroupInfoMap.set(c, cgi);
|
@@ -475,16 +595,26 @@ const visitModules = (
|
|
475
595
|
c = cgi.chunkGroup;
|
476
596
|
if (c.isInitial()) {
|
477
597
|
compilation.errors.push(
|
478
|
-
new AsyncDependencyToInitialChunkError(
|
598
|
+
new AsyncDependencyToInitialChunkError(
|
599
|
+
/** @type {string} */ (chunkName),
|
600
|
+
module,
|
601
|
+
/** @type {DependencyLocation} */ (b.loc)
|
602
|
+
)
|
479
603
|
);
|
480
604
|
c = chunkGroup;
|
605
|
+
} else {
|
606
|
+
c.addOptions(b.groupOptions);
|
481
607
|
}
|
482
|
-
c.
|
483
|
-
|
608
|
+
c.addOrigin(
|
609
|
+
module,
|
610
|
+
/** @type {DependencyLocation} */ (b.loc),
|
611
|
+
/** @type {string} */ (b.request)
|
612
|
+
);
|
484
613
|
}
|
485
614
|
blockConnections.set(b, []);
|
486
615
|
}
|
487
|
-
blockChunkGroups.set(b, cgi);
|
616
|
+
blockChunkGroups.set(b, /** @type {ChunkGroupInfo} */ (cgi));
|
617
|
+
blockByChunkGroups.set(/** @type {ChunkGroupInfo} */ (cgi), b);
|
488
618
|
} else if (entryOptions) {
|
489
619
|
entrypoint = /** @type {Entrypoint} */ (cgi.chunkGroup);
|
490
620
|
} else {
|
@@ -494,7 +624,8 @@ const visitModules = (
|
|
494
624
|
if (c !== undefined) {
|
495
625
|
// 2. We store the connection for the block
|
496
626
|
// to connect it later if needed
|
497
|
-
|
627
|
+
/** @type {BlockChunkGroupConnection[]} */
|
628
|
+
(blockConnections.get(b)).push({
|
498
629
|
originChunkGroupInfo: chunkGroupInfo,
|
499
630
|
chunkGroup: c
|
500
631
|
});
|
@@ -505,7 +636,7 @@ const visitModules = (
|
|
505
636
|
connectList = new Set();
|
506
637
|
queueConnect.set(chunkGroupInfo, connectList);
|
507
638
|
}
|
508
|
-
connectList.add(cgi);
|
639
|
+
connectList.add(/** @type {ChunkGroupInfo} */ (cgi));
|
509
640
|
|
510
641
|
// TODO check if this really need to be done for each traversal
|
511
642
|
// or if it is enough when it's queued when created
|
@@ -513,12 +644,12 @@ const visitModules = (
|
|
513
644
|
queueDelayed.push({
|
514
645
|
action: PROCESS_BLOCK,
|
515
646
|
block: b,
|
516
|
-
module
|
647
|
+
module,
|
517
648
|
chunk: c.chunks[0],
|
518
649
|
chunkGroup: c,
|
519
|
-
chunkGroupInfo: cgi
|
650
|
+
chunkGroupInfo: /** @type {ChunkGroupInfo} */ (cgi)
|
520
651
|
});
|
521
|
-
} else {
|
652
|
+
} else if (entrypoint !== undefined) {
|
522
653
|
chunkGroupInfo.chunkGroup.addAsyncEntrypoint(entrypoint);
|
523
654
|
}
|
524
655
|
};
|
@@ -533,27 +664,33 @@ const visitModules = (
|
|
533
664
|
const blockModules = getBlockModules(block, chunkGroupInfo.runtime);
|
534
665
|
|
535
666
|
if (blockModules !== undefined) {
|
536
|
-
const
|
667
|
+
const minAvailableModules =
|
668
|
+
/** @type {bigint} */
|
669
|
+
(chunkGroupInfo.minAvailableModules);
|
537
670
|
// Buffer items because order need to be reversed to get indices correct
|
538
671
|
// Traverse all referenced modules
|
539
|
-
for (let i = 0
|
672
|
+
for (let i = 0, len = blockModules.length; i < len; i += 3) {
|
540
673
|
const refModule = /** @type {Module} */ (blockModules[i]);
|
541
|
-
|
674
|
+
// For single comparisons this might be cheaper
|
675
|
+
const isModuleInChunk = chunkGraph.isModuleInChunk(refModule, chunk);
|
676
|
+
|
677
|
+
if (isModuleInChunk) {
|
542
678
|
// skip early if already connected
|
543
679
|
continue;
|
544
680
|
}
|
681
|
+
|
682
|
+
const refOrdinal = /** @type {number} */ getModuleOrdinal(refModule);
|
545
683
|
const activeState = /** @type {ConnectionState} */ (
|
546
684
|
blockModules[i + 1]
|
547
685
|
);
|
548
686
|
if (activeState !== true) {
|
549
|
-
|
687
|
+
const connections = /** @type {ModuleGraphConnection[]} */ (
|
688
|
+
blockModules[i + 2]
|
689
|
+
);
|
690
|
+
skipConnectionBuffer.push([refModule, connections]);
|
691
|
+
// We skip inactive connections
|
550
692
|
if (activeState === false) continue;
|
551
|
-
}
|
552
|
-
if (
|
553
|
-
activeState === true &&
|
554
|
-
(minAvailableModules.has(refModule) ||
|
555
|
-
minAvailableModules.plus.has(refModule))
|
556
|
-
) {
|
693
|
+
} else if (isOrdinalSetInMask(minAvailableModules, refOrdinal)) {
|
557
694
|
// already in parent chunks, skip it for now
|
558
695
|
skipBuffer.push(refModule);
|
559
696
|
continue;
|
@@ -619,15 +756,15 @@ const visitModules = (
|
|
619
756
|
const blockModules = getBlockModules(block, chunkGroupInfo.runtime);
|
620
757
|
|
621
758
|
if (blockModules !== undefined) {
|
622
|
-
// Traverse all referenced modules
|
623
|
-
for (let i =
|
759
|
+
// Traverse all referenced modules in reverse order
|
760
|
+
for (let i = blockModules.length - 3; i >= 0; i -= 3) {
|
624
761
|
const refModule = /** @type {Module} */ (blockModules[i]);
|
625
762
|
const activeState = /** @type {ConnectionState} */ (
|
626
763
|
blockModules[i + 1]
|
627
764
|
);
|
628
765
|
// enqueue, then add and enter to be in the correct order
|
629
766
|
// this is relevant with circular dependencies
|
630
|
-
|
767
|
+
queue.push({
|
631
768
|
action:
|
632
769
|
activeState === true ? ADD_AND_ENTER_ENTRY_MODULE : PROCESS_BLOCK,
|
633
770
|
block: refModule,
|
@@ -637,13 +774,6 @@ const visitModules = (
|
|
637
774
|
chunkGroupInfo
|
638
775
|
});
|
639
776
|
}
|
640
|
-
// Add buffered items in reverse order
|
641
|
-
if (queueBuffer.length > 0) {
|
642
|
-
for (let i = queueBuffer.length - 1; i >= 0; i--) {
|
643
|
-
queue.push(queueBuffer[i]);
|
644
|
-
}
|
645
|
-
queueBuffer.length = 0;
|
646
|
-
}
|
647
777
|
}
|
648
778
|
|
649
779
|
// Traverse all Blocks
|
@@ -659,7 +789,7 @@ const visitModules = (
|
|
659
789
|
const processQueue = () => {
|
660
790
|
while (queue.length) {
|
661
791
|
statProcessedQueueItems++;
|
662
|
-
const queueItem = queue.pop();
|
792
|
+
const queueItem = /** @type {QueueItem} */ (queue.pop());
|
663
793
|
module = queueItem.module;
|
664
794
|
block = queueItem.block;
|
665
795
|
chunk = queueItem.chunk;
|
@@ -675,12 +805,18 @@ const visitModules = (
|
|
675
805
|
);
|
676
806
|
// fallthrough
|
677
807
|
case ADD_AND_ENTER_MODULE: {
|
678
|
-
|
808
|
+
const isModuleInChunk = chunkGraph.isModuleInChunk(module, chunk);
|
809
|
+
|
810
|
+
if (isModuleInChunk) {
|
679
811
|
// already connected, skip it
|
680
812
|
break;
|
681
813
|
}
|
682
814
|
// We connect Module and Chunk
|
683
815
|
chunkGraph.connectChunkAndModule(chunk, module);
|
816
|
+
const moduleOrdinal = getModuleOrdinal(module);
|
817
|
+
let chunkMask = /** @type {bigint} */ (maskByChunk.get(chunk));
|
818
|
+
chunkMask |= ONE_BIGINT << BigInt(moduleOrdinal);
|
819
|
+
maskByChunk.set(chunk, chunkMask);
|
684
820
|
}
|
685
821
|
// fallthrough
|
686
822
|
case ENTER_MODULE: {
|
@@ -737,44 +873,24 @@ const visitModules = (
|
|
737
873
|
}
|
738
874
|
};
|
739
875
|
|
876
|
+
/**
|
877
|
+
* @param {ChunkGroupInfo} chunkGroupInfo The info object for the chunk group
|
878
|
+
* @returns {bigint} The mask of available modules after the chunk group
|
879
|
+
*/
|
740
880
|
const calculateResultingAvailableModules = chunkGroupInfo => {
|
741
|
-
if (chunkGroupInfo.resultingAvailableModules)
|
881
|
+
if (chunkGroupInfo.resultingAvailableModules !== undefined)
|
742
882
|
return chunkGroupInfo.resultingAvailableModules;
|
743
883
|
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
// We want to be as lazy as possible. There are multiple ways doing this:
|
748
|
-
// Note that resultingAvailableModules is stored as "(a) + (b)" as it's a ModuleSetPlus
|
749
|
-
// - resultingAvailableModules = (modules of chunk) + (minAvailableModules + minAvailableModules.plus)
|
750
|
-
// - resultingAvailableModules = (minAvailableModules + modules of chunk) + (minAvailableModules.plus)
|
751
|
-
// We choose one depending on the size of minAvailableModules vs minAvailableModules.plus
|
752
|
-
|
753
|
-
let resultingAvailableModules;
|
754
|
-
if (minAvailableModules.size > minAvailableModules.plus.size) {
|
755
|
-
// resultingAvailableModules = (modules of chunk) + (minAvailableModules + minAvailableModules.plus)
|
756
|
-
resultingAvailableModules =
|
757
|
-
/** @type {Set<Module> & {plus: Set<Module>}} */ (new Set());
|
758
|
-
for (const module of minAvailableModules.plus)
|
759
|
-
minAvailableModules.add(module);
|
760
|
-
minAvailableModules.plus = EMPTY_SET;
|
761
|
-
resultingAvailableModules.plus = minAvailableModules;
|
762
|
-
chunkGroupInfo.minAvailableModulesOwned = false;
|
763
|
-
} else {
|
764
|
-
// resultingAvailableModules = (minAvailableModules + modules of chunk) + (minAvailableModules.plus)
|
765
|
-
resultingAvailableModules =
|
766
|
-
/** @type {Set<Module> & {plus: Set<Module>}} */ (
|
767
|
-
new Set(minAvailableModules)
|
768
|
-
);
|
769
|
-
resultingAvailableModules.plus = minAvailableModules.plus;
|
770
|
-
}
|
884
|
+
let resultingAvailableModules = /** @type {bigint} */ (
|
885
|
+
chunkGroupInfo.minAvailableModules
|
886
|
+
);
|
771
887
|
|
772
888
|
// add the modules from the chunk group to the set
|
773
889
|
for (const chunk of chunkGroupInfo.chunkGroup.chunks) {
|
774
|
-
|
775
|
-
|
776
|
-
}
|
890
|
+
const mask = /** @type {bigint} */ (maskByChunk.get(chunk));
|
891
|
+
resultingAvailableModules |= mask;
|
777
892
|
}
|
893
|
+
|
778
894
|
return (chunkGroupInfo.resultingAvailableModules =
|
779
895
|
resultingAvailableModules);
|
780
896
|
};
|
@@ -821,232 +937,24 @@ const visitModules = (
|
|
821
937
|
// Execute the merge
|
822
938
|
for (const info of chunkGroupsForMerging) {
|
823
939
|
const availableModulesToBeMerged = info.availableModulesToBeMerged;
|
824
|
-
|
940
|
+
const cachedMinAvailableModules = info.minAvailableModules;
|
941
|
+
let minAvailableModules = cachedMinAvailableModules;
|
825
942
|
|
826
943
|
statMergedAvailableModuleSets += availableModulesToBeMerged.length;
|
827
944
|
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
// the list didn't shrink.
|
832
|
-
if (availableModulesToBeMerged.length > 1) {
|
833
|
-
availableModulesToBeMerged.sort(bySetSize);
|
834
|
-
}
|
835
|
-
let changed = false;
|
836
|
-
merge: for (const availableModules of availableModulesToBeMerged) {
|
837
|
-
if (cachedMinAvailableModules === undefined) {
|
838
|
-
cachedMinAvailableModules = availableModules;
|
839
|
-
info.minAvailableModules = cachedMinAvailableModules;
|
840
|
-
info.minAvailableModulesOwned = false;
|
841
|
-
changed = true;
|
945
|
+
for (const availableModules of availableModulesToBeMerged) {
|
946
|
+
if (minAvailableModules === undefined) {
|
947
|
+
minAvailableModules = availableModules;
|
842
948
|
} else {
|
843
|
-
|
844
|
-
// We own it and can modify it
|
845
|
-
if (cachedMinAvailableModules.plus === availableModules.plus) {
|
846
|
-
for (const m of cachedMinAvailableModules) {
|
847
|
-
if (!availableModules.has(m)) {
|
848
|
-
cachedMinAvailableModules.delete(m);
|
849
|
-
changed = true;
|
850
|
-
}
|
851
|
-
}
|
852
|
-
} else {
|
853
|
-
for (const m of cachedMinAvailableModules) {
|
854
|
-
if (!availableModules.has(m) && !availableModules.plus.has(m)) {
|
855
|
-
cachedMinAvailableModules.delete(m);
|
856
|
-
changed = true;
|
857
|
-
}
|
858
|
-
}
|
859
|
-
for (const m of cachedMinAvailableModules.plus) {
|
860
|
-
if (!availableModules.has(m) && !availableModules.plus.has(m)) {
|
861
|
-
// We can't remove modules from the plus part
|
862
|
-
// so we need to merge plus into the normal part to allow modifying it
|
863
|
-
const iterator =
|
864
|
-
cachedMinAvailableModules.plus[Symbol.iterator]();
|
865
|
-
// fast forward add all modules until m
|
866
|
-
/** @type {IteratorResult<Module>} */
|
867
|
-
let it;
|
868
|
-
while (!(it = iterator.next()).done) {
|
869
|
-
const module = it.value;
|
870
|
-
if (module === m) break;
|
871
|
-
cachedMinAvailableModules.add(module);
|
872
|
-
}
|
873
|
-
// check the remaining modules before adding
|
874
|
-
while (!(it = iterator.next()).done) {
|
875
|
-
const module = it.value;
|
876
|
-
if (
|
877
|
-
availableModules.has(module) ||
|
878
|
-
availableModules.plus.has(m)
|
879
|
-
) {
|
880
|
-
cachedMinAvailableModules.add(module);
|
881
|
-
}
|
882
|
-
}
|
883
|
-
cachedMinAvailableModules.plus = EMPTY_SET;
|
884
|
-
changed = true;
|
885
|
-
continue merge;
|
886
|
-
}
|
887
|
-
}
|
888
|
-
}
|
889
|
-
} else if (cachedMinAvailableModules.plus === availableModules.plus) {
|
890
|
-
// Common and fast case when the plus part is shared
|
891
|
-
// We only need to care about the normal part
|
892
|
-
if (availableModules.size < cachedMinAvailableModules.size) {
|
893
|
-
// the new availableModules is smaller so it's faster to
|
894
|
-
// fork from the new availableModules
|
895
|
-
statForkedAvailableModules++;
|
896
|
-
statForkedAvailableModulesCount += availableModules.size;
|
897
|
-
statForkedMergedModulesCount += cachedMinAvailableModules.size;
|
898
|
-
// construct a new Set as intersection of cachedMinAvailableModules and availableModules
|
899
|
-
const newSet = /** @type {ModuleSetPlus} */ (new Set());
|
900
|
-
newSet.plus = availableModules.plus;
|
901
|
-
for (const m of availableModules) {
|
902
|
-
if (cachedMinAvailableModules.has(m)) {
|
903
|
-
newSet.add(m);
|
904
|
-
}
|
905
|
-
}
|
906
|
-
statForkedResultModulesCount += newSet.size;
|
907
|
-
cachedMinAvailableModules = newSet;
|
908
|
-
info.minAvailableModulesOwned = true;
|
909
|
-
info.minAvailableModules = newSet;
|
910
|
-
changed = true;
|
911
|
-
continue merge;
|
912
|
-
}
|
913
|
-
for (const m of cachedMinAvailableModules) {
|
914
|
-
if (!availableModules.has(m)) {
|
915
|
-
// cachedMinAvailableModules need to be modified
|
916
|
-
// but we don't own it
|
917
|
-
statForkedAvailableModules++;
|
918
|
-
statForkedAvailableModulesCount +=
|
919
|
-
cachedMinAvailableModules.size;
|
920
|
-
statForkedMergedModulesCount += availableModules.size;
|
921
|
-
// construct a new Set as intersection of cachedMinAvailableModules and availableModules
|
922
|
-
// as the plus part is equal we can just take over this one
|
923
|
-
const newSet = /** @type {ModuleSetPlus} */ (new Set());
|
924
|
-
newSet.plus = availableModules.plus;
|
925
|
-
const iterator = cachedMinAvailableModules[Symbol.iterator]();
|
926
|
-
// fast forward add all modules until m
|
927
|
-
/** @type {IteratorResult<Module>} */
|
928
|
-
let it;
|
929
|
-
while (!(it = iterator.next()).done) {
|
930
|
-
const module = it.value;
|
931
|
-
if (module === m) break;
|
932
|
-
newSet.add(module);
|
933
|
-
}
|
934
|
-
// check the remaining modules before adding
|
935
|
-
while (!(it = iterator.next()).done) {
|
936
|
-
const module = it.value;
|
937
|
-
if (availableModules.has(module)) {
|
938
|
-
newSet.add(module);
|
939
|
-
}
|
940
|
-
}
|
941
|
-
statForkedResultModulesCount += newSet.size;
|
942
|
-
cachedMinAvailableModules = newSet;
|
943
|
-
info.minAvailableModulesOwned = true;
|
944
|
-
info.minAvailableModules = newSet;
|
945
|
-
changed = true;
|
946
|
-
continue merge;
|
947
|
-
}
|
948
|
-
}
|
949
|
-
} else {
|
950
|
-
for (const m of cachedMinAvailableModules) {
|
951
|
-
if (!availableModules.has(m) && !availableModules.plus.has(m)) {
|
952
|
-
// cachedMinAvailableModules need to be modified
|
953
|
-
// but we don't own it
|
954
|
-
statForkedAvailableModules++;
|
955
|
-
statForkedAvailableModulesCount +=
|
956
|
-
cachedMinAvailableModules.size;
|
957
|
-
statForkedAvailableModulesCountPlus +=
|
958
|
-
cachedMinAvailableModules.plus.size;
|
959
|
-
statForkedMergedModulesCount += availableModules.size;
|
960
|
-
statForkedMergedModulesCountPlus += availableModules.plus.size;
|
961
|
-
// construct a new Set as intersection of cachedMinAvailableModules and availableModules
|
962
|
-
const newSet = /** @type {ModuleSetPlus} */ (new Set());
|
963
|
-
newSet.plus = EMPTY_SET;
|
964
|
-
const iterator = cachedMinAvailableModules[Symbol.iterator]();
|
965
|
-
// fast forward add all modules until m
|
966
|
-
/** @type {IteratorResult<Module>} */
|
967
|
-
let it;
|
968
|
-
while (!(it = iterator.next()).done) {
|
969
|
-
const module = it.value;
|
970
|
-
if (module === m) break;
|
971
|
-
newSet.add(module);
|
972
|
-
}
|
973
|
-
// check the remaining modules before adding
|
974
|
-
while (!(it = iterator.next()).done) {
|
975
|
-
const module = it.value;
|
976
|
-
if (
|
977
|
-
availableModules.has(module) ||
|
978
|
-
availableModules.plus.has(module)
|
979
|
-
) {
|
980
|
-
newSet.add(module);
|
981
|
-
}
|
982
|
-
}
|
983
|
-
// also check all modules in cachedMinAvailableModules.plus
|
984
|
-
for (const module of cachedMinAvailableModules.plus) {
|
985
|
-
if (
|
986
|
-
availableModules.has(module) ||
|
987
|
-
availableModules.plus.has(module)
|
988
|
-
) {
|
989
|
-
newSet.add(module);
|
990
|
-
}
|
991
|
-
}
|
992
|
-
statForkedResultModulesCount += newSet.size;
|
993
|
-
cachedMinAvailableModules = newSet;
|
994
|
-
info.minAvailableModulesOwned = true;
|
995
|
-
info.minAvailableModules = newSet;
|
996
|
-
changed = true;
|
997
|
-
continue merge;
|
998
|
-
}
|
999
|
-
}
|
1000
|
-
for (const m of cachedMinAvailableModules.plus) {
|
1001
|
-
if (!availableModules.has(m) && !availableModules.plus.has(m)) {
|
1002
|
-
// cachedMinAvailableModules need to be modified
|
1003
|
-
// but we don't own it
|
1004
|
-
statForkedAvailableModules++;
|
1005
|
-
statForkedAvailableModulesCount +=
|
1006
|
-
cachedMinAvailableModules.size;
|
1007
|
-
statForkedAvailableModulesCountPlus +=
|
1008
|
-
cachedMinAvailableModules.plus.size;
|
1009
|
-
statForkedMergedModulesCount += availableModules.size;
|
1010
|
-
statForkedMergedModulesCountPlus += availableModules.plus.size;
|
1011
|
-
// construct a new Set as intersection of cachedMinAvailableModules and availableModules
|
1012
|
-
// we already know that all modules directly from cachedMinAvailableModules are in availableModules too
|
1013
|
-
const newSet = /** @type {ModuleSetPlus} */ (
|
1014
|
-
new Set(cachedMinAvailableModules)
|
1015
|
-
);
|
1016
|
-
newSet.plus = EMPTY_SET;
|
1017
|
-
const iterator =
|
1018
|
-
cachedMinAvailableModules.plus[Symbol.iterator]();
|
1019
|
-
// fast forward add all modules until m
|
1020
|
-
/** @type {IteratorResult<Module>} */
|
1021
|
-
let it;
|
1022
|
-
while (!(it = iterator.next()).done) {
|
1023
|
-
const module = it.value;
|
1024
|
-
if (module === m) break;
|
1025
|
-
newSet.add(module);
|
1026
|
-
}
|
1027
|
-
// check the remaining modules before adding
|
1028
|
-
while (!(it = iterator.next()).done) {
|
1029
|
-
const module = it.value;
|
1030
|
-
if (
|
1031
|
-
availableModules.has(module) ||
|
1032
|
-
availableModules.plus.has(module)
|
1033
|
-
) {
|
1034
|
-
newSet.add(module);
|
1035
|
-
}
|
1036
|
-
}
|
1037
|
-
statForkedResultModulesCount += newSet.size;
|
1038
|
-
cachedMinAvailableModules = newSet;
|
1039
|
-
info.minAvailableModulesOwned = true;
|
1040
|
-
info.minAvailableModules = newSet;
|
1041
|
-
changed = true;
|
1042
|
-
continue merge;
|
1043
|
-
}
|
1044
|
-
}
|
1045
|
-
}
|
949
|
+
minAvailableModules &= availableModules;
|
1046
950
|
}
|
1047
951
|
}
|
952
|
+
|
953
|
+
const changed = minAvailableModules !== cachedMinAvailableModules;
|
954
|
+
|
1048
955
|
availableModulesToBeMerged.length = 0;
|
1049
956
|
if (changed) {
|
957
|
+
info.minAvailableModules = minAvailableModules;
|
1050
958
|
info.resultingAvailableModules = undefined;
|
1051
959
|
outdatedChunkGroupInfo.add(info);
|
1052
960
|
}
|
@@ -1056,33 +964,27 @@ const visitModules = (
|
|
1056
964
|
|
1057
965
|
const processChunkGroupsForCombining = () => {
|
1058
966
|
for (const info of chunkGroupsForCombining) {
|
1059
|
-
for (const source of
|
1060
|
-
|
967
|
+
for (const source of /** @type {Set<ChunkGroupInfo>} */ (
|
968
|
+
info.availableSources
|
969
|
+
)) {
|
970
|
+
if (source.minAvailableModules === undefined) {
|
1061
971
|
chunkGroupsForCombining.delete(info);
|
1062
972
|
break;
|
1063
973
|
}
|
1064
974
|
}
|
1065
975
|
}
|
976
|
+
|
1066
977
|
for (const info of chunkGroupsForCombining) {
|
1067
|
-
|
1068
|
-
availableModules.plus = EMPTY_SET;
|
1069
|
-
const mergeSet = set => {
|
1070
|
-
if (set.size > availableModules.plus.size) {
|
1071
|
-
for (const item of availableModules.plus) availableModules.add(item);
|
1072
|
-
availableModules.plus = set;
|
1073
|
-
} else {
|
1074
|
-
for (const item of set) availableModules.add(item);
|
1075
|
-
}
|
1076
|
-
};
|
978
|
+
let availableModules = ZERO_BIGINT;
|
1077
979
|
// combine minAvailableModules from all resultingAvailableModules
|
1078
|
-
for (const source of
|
980
|
+
for (const source of /** @type {Set<ChunkGroupInfo>} */ (
|
981
|
+
info.availableSources
|
982
|
+
)) {
|
1079
983
|
const resultingAvailableModules =
|
1080
984
|
calculateResultingAvailableModules(source);
|
1081
|
-
|
1082
|
-
mergeSet(resultingAvailableModules.plus);
|
985
|
+
availableModules |= resultingAvailableModules;
|
1083
986
|
}
|
1084
987
|
info.minAvailableModules = availableModules;
|
1085
|
-
info.minAvailableModulesOwned = false;
|
1086
988
|
info.resultingAvailableModules = undefined;
|
1087
989
|
outdatedChunkGroupInfo.add(info);
|
1088
990
|
}
|
@@ -1095,12 +997,12 @@ const visitModules = (
|
|
1095
997
|
for (const info of outdatedChunkGroupInfo) {
|
1096
998
|
// 1. Reconsider skipped items
|
1097
999
|
if (info.skippedItems !== undefined) {
|
1098
|
-
const
|
1000
|
+
const minAvailableModules =
|
1001
|
+
/** @type {bigint} */
|
1002
|
+
(info.minAvailableModules);
|
1099
1003
|
for (const module of info.skippedItems) {
|
1100
|
-
|
1101
|
-
|
1102
|
-
!minAvailableModules.plus.has(module)
|
1103
|
-
) {
|
1004
|
+
const ordinal = getModuleOrdinal(module);
|
1005
|
+
if (!isOrdinalSetInMask(minAvailableModules, ordinal)) {
|
1104
1006
|
queue.push({
|
1105
1007
|
action: ADD_AND_ENTER_MODULE,
|
1106
1008
|
block: module,
|
@@ -1116,20 +1018,24 @@ const visitModules = (
|
|
1116
1018
|
|
1117
1019
|
// 2. Reconsider skipped connections
|
1118
1020
|
if (info.skippedModuleConnections !== undefined) {
|
1119
|
-
const
|
1021
|
+
const minAvailableModules =
|
1022
|
+
/** @type {bigint} */
|
1023
|
+
(info.minAvailableModules);
|
1120
1024
|
for (const entry of info.skippedModuleConnections) {
|
1121
|
-
const [module,
|
1025
|
+
const [module, connections] = entry;
|
1026
|
+
const activeState = getActiveStateOfConnections(
|
1027
|
+
connections,
|
1028
|
+
info.runtime
|
1029
|
+
);
|
1122
1030
|
if (activeState === false) continue;
|
1123
1031
|
if (activeState === true) {
|
1032
|
+
const ordinal = getModuleOrdinal(module);
|
1124
1033
|
info.skippedModuleConnections.delete(entry);
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
) {
|
1131
|
-
info.skippedItems.add(module);
|
1132
|
-
continue;
|
1034
|
+
if (isOrdinalSetInMask(minAvailableModules, ordinal)) {
|
1035
|
+
/** @type {NonNullable<ChunkGroupInfo["skippedItems"]>} */
|
1036
|
+
(info.skippedItems).add(module);
|
1037
|
+
continue;
|
1038
|
+
}
|
1133
1039
|
}
|
1134
1040
|
queue.push({
|
1135
1041
|
action: activeState === true ? ADD_AND_ENTER_MODULE : PROCESS_BLOCK,
|
@@ -1161,6 +1067,7 @@ const visitModules = (
|
|
1161
1067
|
chunkGroupsForCombining.add(cgi);
|
1162
1068
|
}
|
1163
1069
|
}
|
1070
|
+
outdatedOrderIndexChunkGroups.add(info);
|
1164
1071
|
}
|
1165
1072
|
outdatedChunkGroupInfo.clear();
|
1166
1073
|
};
|
@@ -1207,6 +1114,55 @@ const visitModules = (
|
|
1207
1114
|
}
|
1208
1115
|
}
|
1209
1116
|
|
1117
|
+
for (const info of outdatedOrderIndexChunkGroups) {
|
1118
|
+
const { chunkGroup, runtime } = info;
|
1119
|
+
|
1120
|
+
const block = blockByChunkGroups.get(info);
|
1121
|
+
|
1122
|
+
if (!block) {
|
1123
|
+
continue;
|
1124
|
+
}
|
1125
|
+
|
1126
|
+
let preOrderIndex = 0;
|
1127
|
+
let postOrderIndex = 0;
|
1128
|
+
|
1129
|
+
/**
|
1130
|
+
* @param {DependenciesBlock} current current
|
1131
|
+
* @param {BlocksWithNestedBlocks} visited visited dependencies blocks
|
1132
|
+
*/
|
1133
|
+
const process = (current, visited) => {
|
1134
|
+
const blockModules = getBlockModules(current, runtime);
|
1135
|
+
if (blockModules === undefined) {
|
1136
|
+
return;
|
1137
|
+
}
|
1138
|
+
|
1139
|
+
for (let i = 0, len = blockModules.length; i < len; i += 3) {
|
1140
|
+
const activeState = /** @type {ConnectionState} */ (
|
1141
|
+
blockModules[i + 1]
|
1142
|
+
);
|
1143
|
+
if (activeState === false) {
|
1144
|
+
continue;
|
1145
|
+
}
|
1146
|
+
const refModule = /** @type {Module} */ (blockModules[i]);
|
1147
|
+
if (visited.has(refModule)) {
|
1148
|
+
continue;
|
1149
|
+
}
|
1150
|
+
|
1151
|
+
visited.add(refModule);
|
1152
|
+
|
1153
|
+
if (refModule) {
|
1154
|
+
chunkGroup.setModulePreOrderIndex(refModule, preOrderIndex++);
|
1155
|
+
process(refModule, visited);
|
1156
|
+
chunkGroup.setModulePostOrderIndex(refModule, postOrderIndex++);
|
1157
|
+
}
|
1158
|
+
}
|
1159
|
+
};
|
1160
|
+
|
1161
|
+
process(block, new Set());
|
1162
|
+
}
|
1163
|
+
outdatedOrderIndexChunkGroups.clear();
|
1164
|
+
ordinalByModule.clear();
|
1165
|
+
|
1210
1166
|
logger.log(
|
1211
1167
|
`${statProcessedQueueItems} queue items processed (${statProcessedBlocks} blocks)`
|
1212
1168
|
);
|
@@ -1220,33 +1176,29 @@ const visitModules = (
|
|
1220
1176
|
};
|
1221
1177
|
|
1222
1178
|
/**
|
1223
|
-
*
|
1224
1179
|
* @param {Compilation} compilation the compilation
|
1225
|
-
* @param {
|
1226
|
-
* @param {
|
1227
|
-
* @param {
|
1180
|
+
* @param {BlocksWithNestedBlocks} blocksWithNestedBlocks flag for blocks that have nested blocks
|
1181
|
+
* @param {BlockConnections} blockConnections connection for blocks
|
1182
|
+
* @param {MaskByChunk} maskByChunk mapping from chunk to module mask
|
1228
1183
|
*/
|
1229
1184
|
const connectChunkGroups = (
|
1230
1185
|
compilation,
|
1231
1186
|
blocksWithNestedBlocks,
|
1232
1187
|
blockConnections,
|
1233
|
-
|
1188
|
+
maskByChunk
|
1234
1189
|
) => {
|
1235
1190
|
const { chunkGraph } = compilation;
|
1236
1191
|
|
1237
1192
|
/**
|
1238
1193
|
* Helper function to check if all modules of a chunk are available
|
1239
|
-
*
|
1240
1194
|
* @param {ChunkGroup} chunkGroup the chunkGroup to scan
|
1241
|
-
* @param {
|
1195
|
+
* @param {bigint} availableModules the comparator set
|
1242
1196
|
* @returns {boolean} return true if all modules of a chunk are available
|
1243
1197
|
*/
|
1244
1198
|
const areModulesAvailable = (chunkGroup, availableModules) => {
|
1245
1199
|
for (const chunk of chunkGroup.chunks) {
|
1246
|
-
|
1247
|
-
|
1248
|
-
return false;
|
1249
|
-
}
|
1200
|
+
const chunkMask = /** @type {bigint} */ (maskByChunk.get(chunk));
|
1201
|
+
if ((chunkMask & availableModules) !== chunkMask) return false;
|
1250
1202
|
}
|
1251
1203
|
return true;
|
1252
1204
|
};
|
@@ -1265,7 +1217,7 @@ const connectChunkGroups = (
|
|
1265
1217
|
connections.every(({ chunkGroup, originChunkGroupInfo }) =>
|
1266
1218
|
areModulesAvailable(
|
1267
1219
|
chunkGroup,
|
1268
|
-
originChunkGroupInfo.resultingAvailableModules
|
1220
|
+
/** @type {bigint} */ (originChunkGroupInfo.resultingAvailableModules)
|
1269
1221
|
)
|
1270
1222
|
)
|
1271
1223
|
) {
|
@@ -1311,7 +1263,7 @@ const cleanupUnconnectedGroups = (compilation, allCreatedChunkGroups) => {
|
|
1311
1263
|
/**
|
1312
1264
|
* This method creates the Chunk graph from the Module graph
|
1313
1265
|
* @param {Compilation} compilation the compilation
|
1314
|
-
* @param {
|
1266
|
+
* @param {InputEntrypointsAndModules} inputEntrypointsAndModules chunk groups which are processed with the modules
|
1315
1267
|
* @returns {void}
|
1316
1268
|
*/
|
1317
1269
|
const buildChunkGraph = (compilation, inputEntrypointsAndModules) => {
|
@@ -1319,18 +1271,21 @@ const buildChunkGraph = (compilation, inputEntrypointsAndModules) => {
|
|
1319
1271
|
|
1320
1272
|
// SHARED STATE
|
1321
1273
|
|
1322
|
-
/** @type {
|
1274
|
+
/** @type {BlockConnections} */
|
1323
1275
|
const blockConnections = new Map();
|
1324
1276
|
|
1325
|
-
/** @type {
|
1277
|
+
/** @type {AllCreatedChunkGroups} */
|
1326
1278
|
const allCreatedChunkGroups = new Set();
|
1327
1279
|
|
1328
|
-
/** @type {
|
1280
|
+
/** @type {ChunkGroupInfoMap} */
|
1329
1281
|
const chunkGroupInfoMap = new Map();
|
1330
1282
|
|
1331
|
-
/** @type {
|
1283
|
+
/** @type {BlocksWithNestedBlocks} */
|
1332
1284
|
const blocksWithNestedBlocks = new Set();
|
1333
1285
|
|
1286
|
+
/** @type {MaskByChunk} */
|
1287
|
+
const maskByChunk = new Map();
|
1288
|
+
|
1334
1289
|
// PART ONE
|
1335
1290
|
|
1336
1291
|
logger.time("visitModules");
|
@@ -1341,7 +1296,8 @@ const buildChunkGraph = (compilation, inputEntrypointsAndModules) => {
|
|
1341
1296
|
chunkGroupInfoMap,
|
1342
1297
|
blockConnections,
|
1343
1298
|
blocksWithNestedBlocks,
|
1344
|
-
allCreatedChunkGroups
|
1299
|
+
allCreatedChunkGroups,
|
1300
|
+
maskByChunk
|
1345
1301
|
);
|
1346
1302
|
logger.timeEnd("visitModules");
|
1347
1303
|
|
@@ -1352,7 +1308,7 @@ const buildChunkGraph = (compilation, inputEntrypointsAndModules) => {
|
|
1352
1308
|
compilation,
|
1353
1309
|
blocksWithNestedBlocks,
|
1354
1310
|
blockConnections,
|
1355
|
-
|
1311
|
+
maskByChunk
|
1356
1312
|
);
|
1357
1313
|
logger.timeEnd("connectChunkGroups");
|
1358
1314
|
|