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/Compilation.js
CHANGED
@@ -43,11 +43,13 @@ const Module = require("./Module");
|
|
43
43
|
const ModuleDependencyError = require("./ModuleDependencyError");
|
44
44
|
const ModuleDependencyWarning = require("./ModuleDependencyWarning");
|
45
45
|
const ModuleGraph = require("./ModuleGraph");
|
46
|
+
const ModuleHashingError = require("./ModuleHashingError");
|
46
47
|
const ModuleNotFoundError = require("./ModuleNotFoundError");
|
47
48
|
const ModuleProfile = require("./ModuleProfile");
|
48
49
|
const ModuleRestoreError = require("./ModuleRestoreError");
|
49
50
|
const ModuleStoreError = require("./ModuleStoreError");
|
50
51
|
const ModuleTemplate = require("./ModuleTemplate");
|
52
|
+
const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./ModuleTypeConstants");
|
51
53
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
52
54
|
const RuntimeTemplate = require("./RuntimeTemplate");
|
53
55
|
const Stats = require("./Stats");
|
@@ -60,7 +62,7 @@ const StatsPrinter = require("./stats/StatsPrinter");
|
|
60
62
|
const { equals: arrayEquals } = require("./util/ArrayHelpers");
|
61
63
|
const AsyncQueue = require("./util/AsyncQueue");
|
62
64
|
const LazySet = require("./util/LazySet");
|
63
|
-
const {
|
65
|
+
const { getOrInsert } = require("./util/MapHelpers");
|
64
66
|
const WeakTupleMap = require("./util/WeakTupleMap");
|
65
67
|
const { cachedCleverMerge } = require("./util/cleverMerge");
|
66
68
|
const {
|
@@ -86,11 +88,13 @@ const { isSourceEqual } = require("./util/source");
|
|
86
88
|
/** @typedef {import("../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescription */
|
87
89
|
/** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputOptions */
|
88
90
|
/** @typedef {import("../declarations/WebpackOptions").StatsOptions} StatsOptions */
|
91
|
+
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
89
92
|
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
|
90
93
|
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */
|
91
94
|
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
92
95
|
/** @typedef {import("./Cache")} Cache */
|
93
96
|
/** @typedef {import("./CacheFacade")} CacheFacade */
|
97
|
+
/** @typedef {import("./Chunk").ChunkId} ChunkId */
|
94
98
|
/** @typedef {import("./ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */
|
95
99
|
/** @typedef {import("./Compiler")} Compiler */
|
96
100
|
/** @typedef {import("./Compiler").CompilationParams} CompilationParams */
|
@@ -99,8 +103,11 @@ const { isSourceEqual } = require("./util/source");
|
|
99
103
|
/** @typedef {import("./Dependency").ReferencedExport} ReferencedExport */
|
100
104
|
/** @typedef {import("./DependencyTemplate")} DependencyTemplate */
|
101
105
|
/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
|
106
|
+
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
107
|
+
/** @typedef {import("./NormalModule").NormalModuleCompilationHooks} NormalModuleCompilationHooks */
|
102
108
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
103
109
|
/** @typedef {import("./ModuleFactory")} ModuleFactory */
|
110
|
+
/** @typedef {import("./ModuleGraphConnection")} ModuleGraphConnection */
|
104
111
|
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateDataContextInfo} ModuleFactoryCreateDataContextInfo */
|
105
112
|
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
|
106
113
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
@@ -110,40 +117,45 @@ const { isSourceEqual } = require("./util/source");
|
|
110
117
|
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsAsset} StatsAsset */
|
111
118
|
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsError} StatsError */
|
112
119
|
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsModule} StatsModule */
|
120
|
+
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
113
121
|
/** @typedef {import("./util/Hash")} Hash */
|
114
|
-
/**
|
122
|
+
/**
|
123
|
+
* @template T
|
124
|
+
* @typedef {import("./util/deprecation").FakeHook<T>} FakeHook<T>
|
125
|
+
*/
|
115
126
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
116
|
-
|
127
|
+
/** @typedef {WeakMap<Dependency, Module>} References */
|
128
|
+
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
117
129
|
/**
|
118
130
|
* @callback Callback
|
119
|
-
* @param {WebpackError=} err
|
131
|
+
* @param {(WebpackError | null)=} err
|
120
132
|
* @returns {void}
|
121
133
|
*/
|
122
134
|
|
123
135
|
/**
|
124
136
|
* @callback ModuleCallback
|
125
|
-
* @param {WebpackError=} err
|
126
|
-
* @param {Module=} result
|
137
|
+
* @param {(WebpackError | null)=} err
|
138
|
+
* @param {(Module | null)=} result
|
127
139
|
* @returns {void}
|
128
140
|
*/
|
129
141
|
|
130
142
|
/**
|
131
143
|
* @callback ModuleFactoryResultCallback
|
132
|
-
* @param {WebpackError=} err
|
144
|
+
* @param {(WebpackError | null)=} err
|
133
145
|
* @param {ModuleFactoryResult=} result
|
134
146
|
* @returns {void}
|
135
147
|
*/
|
136
148
|
|
137
149
|
/**
|
138
150
|
* @callback ModuleOrFactoryResultCallback
|
139
|
-
* @param {WebpackError=} err
|
151
|
+
* @param {(WebpackError | null)=} err
|
140
152
|
* @param {Module | ModuleFactoryResult=} result
|
141
153
|
* @returns {void}
|
142
154
|
*/
|
143
155
|
|
144
156
|
/**
|
145
157
|
* @callback ExecuteModuleCallback
|
146
|
-
* @param {WebpackError
|
158
|
+
* @param {WebpackError | null} err
|
147
159
|
* @param {ExecuteModuleResult=} result
|
148
160
|
* @returns {void}
|
149
161
|
*/
|
@@ -158,20 +170,20 @@ const { isSourceEqual } = require("./util/source");
|
|
158
170
|
/** @typedef {Record<string, Source>} CompilationAssets */
|
159
171
|
|
160
172
|
/**
|
161
|
-
* @typedef {
|
173
|
+
* @typedef {object} AvailableModulesChunkGroupMapping
|
162
174
|
* @property {ChunkGroup} chunkGroup
|
163
175
|
* @property {Set<Module>} availableModules
|
164
176
|
* @property {boolean} needCopy
|
165
177
|
*/
|
166
178
|
|
167
179
|
/**
|
168
|
-
* @typedef {
|
180
|
+
* @typedef {object} DependenciesBlockLike
|
169
181
|
* @property {Dependency[]} dependencies
|
170
182
|
* @property {AsyncDependenciesBlock[]} blocks
|
171
183
|
*/
|
172
184
|
|
173
185
|
/**
|
174
|
-
* @typedef {
|
186
|
+
* @typedef {object} ChunkPathData
|
175
187
|
* @property {string|number} id
|
176
188
|
* @property {string=} name
|
177
189
|
* @property {string} hash
|
@@ -181,25 +193,26 @@ const { isSourceEqual } = require("./util/source");
|
|
181
193
|
*/
|
182
194
|
|
183
195
|
/**
|
184
|
-
* @typedef {
|
196
|
+
* @typedef {object} ChunkHashContext
|
197
|
+
* @property {CodeGenerationResults} codeGenerationResults results of code generation
|
185
198
|
* @property {RuntimeTemplate} runtimeTemplate the runtime template
|
186
199
|
* @property {ModuleGraph} moduleGraph the module graph
|
187
200
|
* @property {ChunkGraph} chunkGraph the chunk graph
|
188
201
|
*/
|
189
202
|
|
190
203
|
/**
|
191
|
-
* @typedef {
|
204
|
+
* @typedef {object} RuntimeRequirementsContext
|
192
205
|
* @property {ChunkGraph} chunkGraph the chunk graph
|
193
206
|
* @property {CodeGenerationResults} codeGenerationResults the code generation results
|
194
207
|
*/
|
195
208
|
|
196
209
|
/**
|
197
|
-
* @typedef {
|
210
|
+
* @typedef {object} ExecuteModuleOptions
|
198
211
|
* @property {EntryOptions=} entryOptions
|
199
212
|
*/
|
200
213
|
|
201
214
|
/**
|
202
|
-
* @typedef {
|
215
|
+
* @typedef {object} ExecuteModuleResult
|
203
216
|
* @property {any} exports
|
204
217
|
* @property {boolean} cacheable
|
205
218
|
* @property {Map<string, { source: Source, info: AssetInfo }>} assets
|
@@ -210,7 +223,7 @@ const { isSourceEqual } = require("./util/source");
|
|
210
223
|
*/
|
211
224
|
|
212
225
|
/**
|
213
|
-
* @typedef {
|
226
|
+
* @typedef {object} ExecuteModuleArgument
|
214
227
|
* @property {Module} module
|
215
228
|
* @property {{ id: string, exports: any, loaded: boolean }=} moduleObject
|
216
229
|
* @property {any} preparedInfo
|
@@ -218,7 +231,7 @@ const { isSourceEqual } = require("./util/source");
|
|
218
231
|
*/
|
219
232
|
|
220
233
|
/**
|
221
|
-
* @typedef {
|
234
|
+
* @typedef {object} ExecuteModuleContext
|
222
235
|
* @property {Map<string, { source: Source, info: AssetInfo }>} assets
|
223
236
|
* @property {Chunk} chunk
|
224
237
|
* @property {ChunkGraph} chunkGraph
|
@@ -226,22 +239,22 @@ const { isSourceEqual } = require("./util/source");
|
|
226
239
|
*/
|
227
240
|
|
228
241
|
/**
|
229
|
-
* @typedef {
|
242
|
+
* @typedef {object} EntryData
|
230
243
|
* @property {Dependency[]} dependencies dependencies of the entrypoint that should be evaluated at startup
|
231
244
|
* @property {Dependency[]} includeDependencies dependencies of the entrypoint that should be included but not evaluated
|
232
245
|
* @property {EntryOptions} options options of the entrypoint
|
233
246
|
*/
|
234
247
|
|
235
248
|
/**
|
236
|
-
* @typedef {
|
249
|
+
* @typedef {object} LogEntry
|
237
250
|
* @property {string} type
|
238
|
-
* @property {any[]} args
|
251
|
+
* @property {any[]=} args
|
239
252
|
* @property {number} time
|
240
253
|
* @property {string[]=} trace
|
241
254
|
*/
|
242
255
|
|
243
256
|
/**
|
244
|
-
* @typedef {
|
257
|
+
* @typedef {object} KnownAssetInfo
|
245
258
|
* @property {boolean=} immutable true, if the asset can be long term cached forever (contains a hash)
|
246
259
|
* @property {boolean=} minimized whether the asset is minimized
|
247
260
|
* @property {string | string[]=} fullhash the value(s) of the full hash used for this asset
|
@@ -258,22 +271,24 @@ const { isSourceEqual } = require("./util/source");
|
|
258
271
|
|
259
272
|
/** @typedef {KnownAssetInfo & Record<string, any>} AssetInfo */
|
260
273
|
|
274
|
+
/** @typedef {{ path: string, info: AssetInfo }} InterpolatedPathAndAssetInfo */
|
275
|
+
|
261
276
|
/**
|
262
|
-
* @typedef {
|
277
|
+
* @typedef {object} Asset
|
263
278
|
* @property {string} name the filename of the asset
|
264
279
|
* @property {Source} source source of the asset
|
265
280
|
* @property {AssetInfo} info info about the asset
|
266
281
|
*/
|
267
282
|
|
268
283
|
/**
|
269
|
-
* @typedef {
|
284
|
+
* @typedef {object} ModulePathData
|
270
285
|
* @property {string|number} id
|
271
286
|
* @property {string} hash
|
272
287
|
* @property {function(number): string=} hashWithLength
|
273
288
|
*/
|
274
289
|
|
275
290
|
/**
|
276
|
-
* @typedef {
|
291
|
+
* @typedef {object} PathData
|
277
292
|
* @property {ChunkGraph=} chunkGraph
|
278
293
|
* @property {string=} hash
|
279
294
|
* @property {function(number): string=} hashWithLength
|
@@ -291,7 +306,7 @@ const { isSourceEqual } = require("./util/source");
|
|
291
306
|
*/
|
292
307
|
|
293
308
|
/**
|
294
|
-
* @typedef {
|
309
|
+
* @typedef {object} KnownNormalizedStatsOptions
|
295
310
|
* @property {string} context
|
296
311
|
* @property {RequestShortener} requestShortener
|
297
312
|
* @property {string} chunksSort
|
@@ -335,26 +350,41 @@ const { isSourceEqual } = require("./util/source");
|
|
335
350
|
/** @typedef {KnownNormalizedStatsOptions & Omit<StatsOptions, keyof KnownNormalizedStatsOptions> & Record<string, any>} NormalizedStatsOptions */
|
336
351
|
|
337
352
|
/**
|
338
|
-
* @typedef {
|
353
|
+
* @typedef {object} KnownCreateStatsOptionsContext
|
339
354
|
* @property {boolean=} forToString
|
340
355
|
*/
|
341
356
|
|
342
|
-
/** @typedef {
|
357
|
+
/** @typedef {Record<string, any> & KnownCreateStatsOptionsContext} CreateStatsOptionsContext */
|
358
|
+
|
359
|
+
/** @typedef {{module: Module, hash: string, runtime: RuntimeSpec, runtimes: RuntimeSpec[]}[]} CodeGenerationJobs */
|
360
|
+
|
361
|
+
/** @typedef {{javascript: ModuleTemplate}} ModuleTemplates */
|
362
|
+
|
363
|
+
/** @typedef {Set<Module>} NotCodeGeneratedModules */
|
364
|
+
|
365
|
+
/** @typedef {string | Set<string> | undefined} ValueCacheVersion */
|
343
366
|
|
344
367
|
/** @type {AssetInfo} */
|
345
368
|
const EMPTY_ASSET_INFO = Object.freeze({});
|
346
369
|
|
347
370
|
const esmDependencyCategory = "esm";
|
371
|
+
|
348
372
|
// TODO webpack 6: remove
|
349
373
|
const deprecatedNormalModuleLoaderHook = util.deprecate(
|
350
|
-
|
351
|
-
|
352
|
-
|
374
|
+
/**
|
375
|
+
* @param {Compilation} compilation compilation
|
376
|
+
* @returns {NormalModuleCompilationHooks["loader"]} hooks
|
377
|
+
*/
|
378
|
+
compilation =>
|
379
|
+
require("./NormalModule").getCompilationHooks(compilation).loader,
|
353
380
|
"Compilation.hooks.normalModuleLoader was moved to NormalModule.getCompilationHooks(compilation).loader",
|
354
381
|
"DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK"
|
355
382
|
);
|
356
383
|
|
357
384
|
// TODO webpack 6: remove
|
385
|
+
/**
|
386
|
+
* @param {ModuleTemplates | undefined} moduleTemplates module templates
|
387
|
+
*/
|
358
388
|
const defineRemovedModuleTemplates = moduleTemplates => {
|
359
389
|
Object.defineProperties(moduleTemplates, {
|
360
390
|
asset: {
|
@@ -379,30 +409,11 @@ const defineRemovedModuleTemplates = moduleTemplates => {
|
|
379
409
|
moduleTemplates = undefined;
|
380
410
|
};
|
381
411
|
|
382
|
-
const byId = compareSelect(
|
383
|
-
/**
|
384
|
-
* @param {Chunk} c chunk
|
385
|
-
* @returns {number | string} id
|
386
|
-
*/ c => c.id,
|
387
|
-
compareIds
|
388
|
-
);
|
412
|
+
const byId = compareSelect(c => c.id, compareIds);
|
389
413
|
|
390
414
|
const byNameOrHash = concatComparators(
|
391
|
-
compareSelect(
|
392
|
-
|
393
|
-
* @param {Compilation} c compilation
|
394
|
-
* @returns {string} name
|
395
|
-
*/
|
396
|
-
c => c.name,
|
397
|
-
compareIds
|
398
|
-
),
|
399
|
-
compareSelect(
|
400
|
-
/**
|
401
|
-
* @param {Compilation} c compilation
|
402
|
-
* @returns {string} hash
|
403
|
-
*/ c => c.fullHash,
|
404
|
-
compareIds
|
405
|
-
)
|
415
|
+
compareSelect(c => c.name, compareIds),
|
416
|
+
compareSelect(c => c.fullHash, compareIds)
|
406
417
|
);
|
407
418
|
|
408
419
|
const byMessage = compareSelect(err => `${err.message}`, compareStringsNumeric);
|
@@ -429,14 +440,20 @@ class Compilation {
|
|
429
440
|
* @param {CompilationParams} params the compilation parameters
|
430
441
|
*/
|
431
442
|
constructor(compiler, params) {
|
443
|
+
this._backCompat = compiler._backCompat;
|
444
|
+
|
432
445
|
const getNormalModuleLoader = () => deprecatedNormalModuleLoaderHook(this);
|
433
446
|
/** @typedef {{ additionalAssets?: true | Function }} ProcessAssetsAdditionalOptions */
|
434
447
|
/** @type {AsyncSeriesHook<[CompilationAssets], ProcessAssetsAdditionalOptions>} */
|
435
448
|
const processAssetsHook = new AsyncSeriesHook(["assets"]);
|
436
449
|
|
437
450
|
let savedAssets = new Set();
|
451
|
+
/**
|
452
|
+
* @param {CompilationAssets} assets assets
|
453
|
+
* @returns {CompilationAssets} new assets
|
454
|
+
*/
|
438
455
|
const popNewAssets = assets => {
|
439
|
-
let newAssets
|
456
|
+
let newAssets;
|
440
457
|
for (const file of Object.keys(assets)) {
|
441
458
|
if (savedAssets.has(file)) continue;
|
442
459
|
if (newAssets === undefined) {
|
@@ -472,8 +489,8 @@ class Compilation {
|
|
472
489
|
fn: (assets, callback) => {
|
473
490
|
try {
|
474
491
|
fn(assets);
|
475
|
-
} catch (
|
476
|
-
return callback(
|
492
|
+
} catch (err) {
|
493
|
+
return callback(err);
|
477
494
|
}
|
478
495
|
if (processedAssets !== undefined)
|
479
496
|
processedAssets.add(this.assets);
|
@@ -559,6 +576,11 @@ class Compilation {
|
|
559
576
|
* @returns {FakeHook<Pick<AsyncSeriesHook<T>, "tap" | "tapAsync" | "tapPromise" | "name">>} fake hook which redirects
|
560
577
|
*/
|
561
578
|
const createProcessAssetsHook = (name, stage, getArgs, code) => {
|
579
|
+
if (!this._backCompat && code) return;
|
580
|
+
/**
|
581
|
+
* @param {string} reason reason
|
582
|
+
* @returns {string} error message
|
583
|
+
*/
|
562
584
|
const errorMessage =
|
563
585
|
reason => `Can't automatically convert plugin using Compilation.hooks.${name} to Compilation.hooks.processAssets because ${reason}.
|
564
586
|
BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a single Compilation.hooks.processAssets hook.`;
|
@@ -567,7 +589,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
567
589
|
if (options.stage) {
|
568
590
|
throw new Error(errorMessage("it's using the 'stage' option"));
|
569
591
|
}
|
570
|
-
return { ...options, stage
|
592
|
+
return { ...options, stage };
|
571
593
|
};
|
572
594
|
return createFakeHook(
|
573
595
|
{
|
@@ -641,22 +663,27 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
641
663
|
|
642
664
|
/** @type {SyncHook<[]>} */
|
643
665
|
beforeChunks: new SyncHook([]),
|
644
|
-
/**
|
666
|
+
/**
|
667
|
+
* The `afterChunks` hook is called directly after the chunks and module graph have
|
668
|
+
* been created and before the chunks and modules have been optimized. This hook is useful to
|
669
|
+
* inspect, analyze, and/or modify the chunk graph.
|
670
|
+
* @type {SyncHook<[Iterable<Chunk>]>}
|
671
|
+
*/
|
645
672
|
afterChunks: new SyncHook(["chunks"]),
|
646
673
|
|
647
|
-
/** @type {SyncBailHook<[Iterable<Module>]>} */
|
674
|
+
/** @type {SyncBailHook<[Iterable<Module>], boolean | void>} */
|
648
675
|
optimizeDependencies: new SyncBailHook(["modules"]),
|
649
676
|
/** @type {SyncHook<[Iterable<Module>]>} */
|
650
677
|
afterOptimizeDependencies: new SyncHook(["modules"]),
|
651
678
|
|
652
679
|
/** @type {SyncHook<[]>} */
|
653
680
|
optimize: new SyncHook([]),
|
654
|
-
/** @type {SyncBailHook<[Iterable<Module>]>} */
|
681
|
+
/** @type {SyncBailHook<[Iterable<Module>], boolean | void>} */
|
655
682
|
optimizeModules: new SyncBailHook(["modules"]),
|
656
683
|
/** @type {SyncHook<[Iterable<Module>]>} */
|
657
684
|
afterOptimizeModules: new SyncHook(["modules"]),
|
658
685
|
|
659
|
-
/** @type {SyncBailHook<[Iterable<Chunk>, ChunkGroup[]]>} */
|
686
|
+
/** @type {SyncBailHook<[Iterable<Chunk>, ChunkGroup[]], boolean | void>} */
|
660
687
|
optimizeChunks: new SyncBailHook(["chunks", "chunkGroups"]),
|
661
688
|
/** @type {SyncHook<[Iterable<Chunk>, ChunkGroup[]]>} */
|
662
689
|
afterOptimizeChunks: new SyncHook(["chunks", "chunkGroups"]),
|
@@ -666,11 +693,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
666
693
|
/** @type {SyncHook<[Iterable<Chunk>, Iterable<Module>]>} */
|
667
694
|
afterOptimizeTree: new SyncHook(["chunks", "modules"]),
|
668
695
|
|
669
|
-
/** @type {AsyncSeriesBailHook<[Iterable<Chunk>, Iterable<Module>]>} */
|
696
|
+
/** @type {AsyncSeriesBailHook<[Iterable<Chunk>, Iterable<Module>], void>} */
|
670
697
|
optimizeChunkModules: new AsyncSeriesBailHook(["chunks", "modules"]),
|
671
698
|
/** @type {SyncHook<[Iterable<Chunk>, Iterable<Module>]>} */
|
672
699
|
afterOptimizeChunkModules: new SyncHook(["chunks", "modules"]),
|
673
|
-
/** @type {SyncBailHook<[], boolean>} */
|
700
|
+
/** @type {SyncBailHook<[], boolean | undefined>} */
|
674
701
|
shouldRecord: new SyncBailHook([]),
|
675
702
|
|
676
703
|
/** @type {SyncHook<[Chunk, Set<string>, RuntimeRequirementsContext]>} */
|
@@ -679,7 +706,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
679
706
|
"runtimeRequirements",
|
680
707
|
"context"
|
681
708
|
]),
|
682
|
-
/** @type {HookMap<SyncBailHook<[Chunk, Set<string>, RuntimeRequirementsContext]>>} */
|
709
|
+
/** @type {HookMap<SyncBailHook<[Chunk, Set<string>, RuntimeRequirementsContext], void>>} */
|
683
710
|
runtimeRequirementInChunk: new HookMap(
|
684
711
|
() => new SyncBailHook(["chunk", "runtimeRequirements", "context"])
|
685
712
|
),
|
@@ -689,7 +716,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
689
716
|
"runtimeRequirements",
|
690
717
|
"context"
|
691
718
|
]),
|
692
|
-
/** @type {HookMap<SyncBailHook<[Module, Set<string>, RuntimeRequirementsContext]>>} */
|
719
|
+
/** @type {HookMap<SyncBailHook<[Module, Set<string>, RuntimeRequirementsContext], void>>} */
|
693
720
|
runtimeRequirementInModule: new HookMap(
|
694
721
|
() => new SyncBailHook(["module", "runtimeRequirements", "context"])
|
695
722
|
),
|
@@ -699,7 +726,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
699
726
|
"runtimeRequirements",
|
700
727
|
"context"
|
701
728
|
]),
|
702
|
-
/** @type {HookMap<SyncBailHook<[Chunk, Set<string>, RuntimeRequirementsContext]>>} */
|
729
|
+
/** @type {HookMap<SyncBailHook<[Chunk, Set<string>, RuntimeRequirementsContext], void>>} */
|
703
730
|
runtimeRequirementInTree: new HookMap(
|
704
731
|
() => new SyncBailHook(["chunk", "runtimeRequirements", "context"])
|
705
732
|
),
|
@@ -813,7 +840,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
813
840
|
/** @type {AsyncSeriesHook<[CompilationAssets]>} */
|
814
841
|
processAdditionalAssets: new AsyncSeriesHook(["assets"]),
|
815
842
|
|
816
|
-
/** @type {SyncBailHook<[], boolean>} */
|
843
|
+
/** @type {SyncBailHook<[], boolean | undefined>} */
|
817
844
|
needAdditionalSeal: new SyncBailHook([]),
|
818
845
|
/** @type {AsyncSeriesHook<[]>} */
|
819
846
|
afterSeal: new AsyncSeriesHook([]),
|
@@ -831,7 +858,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
831
858
|
/** @type {SyncHook<[Chunk, string]>} */
|
832
859
|
chunkAsset: new SyncHook(["chunk", "filename"]),
|
833
860
|
|
834
|
-
/** @type {SyncWaterfallHook<[string, object, AssetInfo]>} */
|
861
|
+
/** @type {SyncWaterfallHook<[string, object, AssetInfo | undefined]>} */
|
835
862
|
assetPath: new SyncWaterfallHook(["path", "options", "assetInfo"]),
|
836
863
|
|
837
864
|
/** @type {SyncBailHook<[], boolean>} */
|
@@ -867,13 +894,19 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
867
894
|
});
|
868
895
|
/** @type {string=} */
|
869
896
|
this.name = undefined;
|
897
|
+
/** @type {number | undefined} */
|
870
898
|
this.startTime = undefined;
|
899
|
+
/** @type {number | undefined} */
|
871
900
|
this.endTime = undefined;
|
872
901
|
/** @type {Compiler} */
|
873
902
|
this.compiler = compiler;
|
874
903
|
this.resolverFactory = compiler.resolverFactory;
|
875
|
-
|
904
|
+
/** @type {InputFileSystem} */
|
905
|
+
this.inputFileSystem =
|
906
|
+
/** @type {InputFileSystem} */
|
907
|
+
(compiler.inputFileSystem);
|
876
908
|
this.fileSystemInfo = new FileSystemInfo(this.inputFileSystem, {
|
909
|
+
unmanagedPaths: compiler.unmanagedPaths,
|
877
910
|
managedPaths: compiler.managedPaths,
|
878
911
|
immutablePaths: compiler.immutablePaths,
|
879
912
|
logger: this.getLogger("webpack.FileSystemInfo"),
|
@@ -888,14 +921,14 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
888
921
|
true
|
889
922
|
);
|
890
923
|
}
|
891
|
-
/** @type {Map<string,
|
924
|
+
/** @type {Map<string, ValueCacheVersion>} */
|
892
925
|
this.valueCacheVersions = new Map();
|
893
926
|
this.requestShortener = compiler.requestShortener;
|
894
927
|
this.compilerPath = compiler.compilerPath;
|
895
928
|
|
896
929
|
this.logger = this.getLogger("webpack.Compilation");
|
897
930
|
|
898
|
-
const options = compiler.options;
|
931
|
+
const options = /** @type {WebpackOptions} */ (compiler.options);
|
899
932
|
this.options = options;
|
900
933
|
this.outputOptions = options && options.output;
|
901
934
|
/** @type {boolean} */
|
@@ -911,7 +944,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
911
944
|
this.outputOptions,
|
912
945
|
this.requestShortener
|
913
946
|
);
|
914
|
-
/** @type {
|
947
|
+
/** @type {ModuleTemplates} */
|
915
948
|
this.moduleTemplates = {
|
916
949
|
javascript: new ModuleTemplate(this.runtimeTemplate, this)
|
917
950
|
};
|
@@ -983,7 +1016,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
983
1016
|
this.asyncEntrypoints = [];
|
984
1017
|
/** @type {Set<Chunk>} */
|
985
1018
|
this.chunks = new Set();
|
986
|
-
arrayToSetDeprecation(this.chunks, "Compilation.chunks");
|
987
1019
|
/** @type {ChunkGroup[]} */
|
988
1020
|
this.chunkGroups = [];
|
989
1021
|
/** @type {Map<string, ChunkGroup>} */
|
@@ -992,8 +1024,14 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
992
1024
|
this.namedChunks = new Map();
|
993
1025
|
/** @type {Set<Module>} */
|
994
1026
|
this.modules = new Set();
|
995
|
-
|
996
|
-
|
1027
|
+
if (this._backCompat) {
|
1028
|
+
arrayToSetDeprecation(this.chunks, "Compilation.chunks");
|
1029
|
+
arrayToSetDeprecation(this.modules, "Compilation.modules");
|
1030
|
+
}
|
1031
|
+
/**
|
1032
|
+
* @private
|
1033
|
+
* @type {Map<string, Module>}
|
1034
|
+
*/
|
997
1035
|
this._modules = new Map();
|
998
1036
|
this.records = null;
|
999
1037
|
/** @type {string[]} */
|
@@ -1015,7 +1053,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1015
1053
|
/** @type {Map<DepConstructor, ModuleFactory>} */
|
1016
1054
|
this.dependencyFactories = new Map();
|
1017
1055
|
/** @type {DependencyTemplates} */
|
1018
|
-
this.dependencyTemplates = new DependencyTemplates(
|
1056
|
+
this.dependencyTemplates = new DependencyTemplates(
|
1057
|
+
this.outputOptions.hashFunction
|
1058
|
+
);
|
1059
|
+
/** @type {Record<string, number>} */
|
1019
1060
|
this.childrenCounters = {};
|
1020
1061
|
/** @type {Set<number|string>} */
|
1021
1062
|
this.usedChunkIds = null;
|
@@ -1033,7 +1074,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1033
1074
|
this.codeGeneratedModules = new WeakSet();
|
1034
1075
|
/** @type {WeakSet<Module>} */
|
1035
1076
|
this.buildTimeExecutedModules = new WeakSet();
|
1036
|
-
/**
|
1077
|
+
/**
|
1078
|
+
* @private
|
1079
|
+
* @type {Map<Module, Callback[]>}
|
1080
|
+
*/
|
1037
1081
|
this._rebuildingModules = new Map();
|
1038
1082
|
/** @type {Set<string>} */
|
1039
1083
|
this.emittedAssets = new Set();
|
@@ -1050,6 +1094,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1050
1094
|
// TODO webpack 6 remove
|
1051
1095
|
this.compilationDependencies = {
|
1052
1096
|
add: util.deprecate(
|
1097
|
+
/**
|
1098
|
+
* @param {string} item item
|
1099
|
+
* @returns {LazySet<string>} file dependencies
|
1100
|
+
*/
|
1053
1101
|
item => this.fileDependencies.add(item),
|
1054
1102
|
"Compilation.compilationDependencies is deprecated (used Compilation.fileDependencies instead)",
|
1055
1103
|
"DEP_WEBPACK_COMPILATION_COMPILATION_DEPENDENCIES"
|
@@ -1061,7 +1109,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1061
1109
|
this._codeGenerationCache = this.getCache("Compilation/codeGeneration");
|
1062
1110
|
|
1063
1111
|
const unsafeCache = options.module.unsafeCache;
|
1064
|
-
this._unsafeCache =
|
1112
|
+
this._unsafeCache = Boolean(unsafeCache);
|
1065
1113
|
this._unsafeCachePredicate =
|
1066
1114
|
typeof unsafeCache === "function" ? unsafeCache : () => true;
|
1067
1115
|
}
|
@@ -1071,15 +1119,16 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1071
1119
|
}
|
1072
1120
|
|
1073
1121
|
/**
|
1074
|
-
* @param {StatsOptions |
|
1075
|
-
* @param {CreateStatsOptionsContext} context context
|
1122
|
+
* @param {string | boolean | StatsOptions | undefined} optionsOrPreset stats option value
|
1123
|
+
* @param {CreateStatsOptionsContext=} context context
|
1076
1124
|
* @returns {NormalizedStatsOptions} normalized options
|
1077
1125
|
*/
|
1078
1126
|
createStatsOptions(optionsOrPreset, context = {}) {
|
1079
|
-
if (
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1127
|
+
if (typeof optionsOrPreset === "boolean") {
|
1128
|
+
optionsOrPreset = {
|
1129
|
+
preset: optionsOrPreset === false ? "none" : "normal"
|
1130
|
+
};
|
1131
|
+
} else if (typeof optionsOrPreset === "string") {
|
1083
1132
|
optionsOrPreset = { preset: optionsOrPreset };
|
1084
1133
|
}
|
1085
1134
|
if (typeof optionsOrPreset === "object" && optionsOrPreset !== null) {
|
@@ -1087,28 +1136,36 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1087
1136
|
// properties in the prototype chain
|
1088
1137
|
/** @type {Partial<NormalizedStatsOptions>} */
|
1089
1138
|
const options = {};
|
1139
|
+
// eslint-disable-next-line guard-for-in
|
1090
1140
|
for (const key in optionsOrPreset) {
|
1091
|
-
options[key] = optionsOrPreset[key];
|
1141
|
+
options[key] = optionsOrPreset[/** @type {keyof StatsOptions} */ (key)];
|
1092
1142
|
}
|
1093
1143
|
if (options.preset !== undefined) {
|
1094
1144
|
this.hooks.statsPreset.for(options.preset).call(options, context);
|
1095
1145
|
}
|
1096
1146
|
this.hooks.statsNormalize.call(options, context);
|
1097
1147
|
return /** @type {NormalizedStatsOptions} */ (options);
|
1098
|
-
} else {
|
1099
|
-
/** @type {Partial<NormalizedStatsOptions>} */
|
1100
|
-
const options = {};
|
1101
|
-
this.hooks.statsNormalize.call(options, context);
|
1102
|
-
return /** @type {NormalizedStatsOptions} */ (options);
|
1103
1148
|
}
|
1149
|
+
/** @type {Partial<NormalizedStatsOptions>} */
|
1150
|
+
const options = {};
|
1151
|
+
this.hooks.statsNormalize.call(options, context);
|
1152
|
+
return /** @type {NormalizedStatsOptions} */ (options);
|
1104
1153
|
}
|
1105
1154
|
|
1155
|
+
/**
|
1156
|
+
* @param {NormalizedStatsOptions} options options
|
1157
|
+
* @returns {StatsFactory} the stats factory
|
1158
|
+
*/
|
1106
1159
|
createStatsFactory(options) {
|
1107
1160
|
const statsFactory = new StatsFactory();
|
1108
1161
|
this.hooks.statsFactory.call(statsFactory, options);
|
1109
1162
|
return statsFactory;
|
1110
1163
|
}
|
1111
1164
|
|
1165
|
+
/**
|
1166
|
+
* @param {NormalizedStatsOptions} options options
|
1167
|
+
* @returns {StatsPrinter} the stats printer
|
1168
|
+
*/
|
1112
1169
|
createStatsPrinter(options) {
|
1113
1170
|
const statsPrinter = new StatsPrinter();
|
1114
1171
|
this.hooks.statsPrinter.call(statsPrinter, options);
|
@@ -1148,7 +1205,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1148
1205
|
case LogType.warn:
|
1149
1206
|
case LogType.error:
|
1150
1207
|
case LogType.trace:
|
1151
|
-
trace = ErrorHelpers.cutOffLoaderExecution(
|
1208
|
+
trace = ErrorHelpers.cutOffLoaderExecution(
|
1209
|
+
/** @type {string} */ (new Error("Trace").stack)
|
1210
|
+
)
|
1152
1211
|
.split("\n")
|
1153
1212
|
.slice(3);
|
1154
1213
|
break;
|
@@ -1161,12 +1220,13 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1161
1220
|
trace
|
1162
1221
|
};
|
1163
1222
|
if (this.hooks.log.call(name, logEntry) === undefined) {
|
1164
|
-
if (
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1223
|
+
if (
|
1224
|
+
logEntry.type === LogType.profileEnd &&
|
1225
|
+
typeof console.profileEnd === "function"
|
1226
|
+
) {
|
1227
|
+
console.profileEnd(
|
1228
|
+
`[${name}] ${/** @type {NonNullable<LogEntry["args"]>} */ (logEntry.args)[0]}`
|
1229
|
+
);
|
1170
1230
|
}
|
1171
1231
|
if (logEntries === undefined) {
|
1172
1232
|
logEntries = this.logging.get(name);
|
@@ -1176,12 +1236,13 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1176
1236
|
}
|
1177
1237
|
}
|
1178
1238
|
logEntries.push(logEntry);
|
1179
|
-
if (
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1239
|
+
if (
|
1240
|
+
logEntry.type === LogType.profile &&
|
1241
|
+
typeof console.profile === "function"
|
1242
|
+
) {
|
1243
|
+
console.profile(
|
1244
|
+
`[${name}] ${/** @type {NonNullable<LogEntry["args"]>} */ (logEntry.args)[0]}`
|
1245
|
+
);
|
1185
1246
|
}
|
1186
1247
|
}
|
1187
1248
|
},
|
@@ -1207,36 +1268,33 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1207
1268
|
}
|
1208
1269
|
return `${name}/${childName}`;
|
1209
1270
|
});
|
1210
|
-
} else {
|
1211
|
-
return this.getLogger(() => {
|
1212
|
-
if (typeof name === "function") {
|
1213
|
-
name = name();
|
1214
|
-
if (!name) {
|
1215
|
-
throw new TypeError(
|
1216
|
-
"Compilation.getLogger(name) called with a function not returning a name"
|
1217
|
-
);
|
1218
|
-
}
|
1219
|
-
}
|
1220
|
-
return `${name}/${childName}`;
|
1221
|
-
});
|
1222
1271
|
}
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
if (
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
"Logger.getChildLogger(name) called with a function not returning a name"
|
1231
|
-
);
|
1232
|
-
}
|
1272
|
+
return this.getLogger(() => {
|
1273
|
+
if (typeof name === "function") {
|
1274
|
+
name = name();
|
1275
|
+
if (!name) {
|
1276
|
+
throw new TypeError(
|
1277
|
+
"Compilation.getLogger(name) called with a function not returning a name"
|
1278
|
+
);
|
1233
1279
|
}
|
1234
|
-
|
1235
|
-
}
|
1236
|
-
}
|
1237
|
-
|
1238
|
-
|
1280
|
+
}
|
1281
|
+
return `${name}/${childName}`;
|
1282
|
+
});
|
1283
|
+
}
|
1284
|
+
if (typeof childName === "function") {
|
1285
|
+
return this.getLogger(() => {
|
1286
|
+
if (typeof childName === "function") {
|
1287
|
+
childName = childName();
|
1288
|
+
if (!childName) {
|
1289
|
+
throw new TypeError(
|
1290
|
+
"Logger.getChildLogger(name) called with a function not returning a name"
|
1291
|
+
);
|
1292
|
+
}
|
1293
|
+
}
|
1294
|
+
return `${name}/${childName}`;
|
1295
|
+
});
|
1239
1296
|
}
|
1297
|
+
return this.getLogger(`${name}/${childName}`);
|
1240
1298
|
}
|
1241
1299
|
);
|
1242
1300
|
}
|
@@ -1286,7 +1344,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1286
1344
|
}
|
1287
1345
|
this._modules.set(identifier, module);
|
1288
1346
|
this.modules.add(module);
|
1289
|
-
|
1347
|
+
if (this._backCompat)
|
1348
|
+
ModuleGraph.setModuleGraphForModule(module, this.moduleGraph);
|
1290
1349
|
if (currentProfile !== undefined) {
|
1291
1350
|
currentProfile.markIntegrationEnd();
|
1292
1351
|
}
|
@@ -1301,7 +1360,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1301
1360
|
*/
|
1302
1361
|
getModule(module) {
|
1303
1362
|
const identifier = module.identifier();
|
1304
|
-
return this._modules.get(identifier);
|
1363
|
+
return /** @type {Module} */ (this._modules.get(identifier));
|
1305
1364
|
}
|
1306
1365
|
|
1307
1366
|
/**
|
@@ -1315,7 +1374,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1315
1374
|
|
1316
1375
|
/**
|
1317
1376
|
* Schedules a build of the module object
|
1318
|
-
*
|
1319
1377
|
* @param {Module} module module to be built
|
1320
1378
|
* @param {ModuleCallback} callback the callback
|
1321
1379
|
* @returns {void}
|
@@ -1326,7 +1384,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1326
1384
|
|
1327
1385
|
/**
|
1328
1386
|
* Builds the module object
|
1329
|
-
*
|
1330
1387
|
* @param {Module} module module to be built
|
1331
1388
|
* @param {ModuleCallback} callback the callback
|
1332
1389
|
* @returns {void}
|
@@ -1362,7 +1419,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1362
1419
|
this.options,
|
1363
1420
|
this,
|
1364
1421
|
this.resolverFactory.get("normal", module.resolveOptions),
|
1365
|
-
this.inputFileSystem,
|
1422
|
+
/** @type {InputFileSystem} */ (this.inputFileSystem),
|
1366
1423
|
err => {
|
1367
1424
|
if (currentProfile !== undefined) {
|
1368
1425
|
currentProfile.markBuildingEnd();
|
@@ -1379,7 +1436,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1379
1436
|
currentProfile.markStoringEnd();
|
1380
1437
|
}
|
1381
1438
|
if (err) {
|
1382
|
-
this.hooks.failedModule.call(
|
1439
|
+
this.hooks.failedModule.call(
|
1440
|
+
module,
|
1441
|
+
/** @type {WebpackError} */ (err)
|
1442
|
+
);
|
1383
1443
|
return callback(new ModuleStoreError(module, err));
|
1384
1444
|
}
|
1385
1445
|
this.hooks.succeedModule.call(module);
|
@@ -1405,6 +1465,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1405
1465
|
* @returns {void}
|
1406
1466
|
*/
|
1407
1467
|
processModuleDependenciesNonRecursive(module) {
|
1468
|
+
/**
|
1469
|
+
* @param {DependenciesBlock} block block
|
1470
|
+
*/
|
1408
1471
|
const processDependenciesBlock = block => {
|
1409
1472
|
if (block.dependencies) {
|
1410
1473
|
let i = 0;
|
@@ -1426,7 +1489,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1426
1489
|
* @returns {void}
|
1427
1490
|
*/
|
1428
1491
|
_processModuleDependencies(module, callback) {
|
1429
|
-
/** @type {Array<{factory: ModuleFactory, dependencies: Dependency[], originModule: Module|null}>} */
|
1492
|
+
/** @type {Array<{factory: ModuleFactory, dependencies: Dependency[], context: string|undefined, originModule: Module|null}>} */
|
1430
1493
|
const sortedDependencies = [];
|
1431
1494
|
|
1432
1495
|
/** @type {DependenciesBlock} */
|
@@ -1450,6 +1513,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1450
1513
|
let inProgressSorting = 1;
|
1451
1514
|
let inProgressTransitive = 1;
|
1452
1515
|
|
1516
|
+
/**
|
1517
|
+
* @param {WebpackError=} err error
|
1518
|
+
* @returns {void}
|
1519
|
+
*/
|
1453
1520
|
const onDependenciesSorted = err => {
|
1454
1521
|
if (err) return callback(err);
|
1455
1522
|
|
@@ -1463,6 +1530,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1463
1530
|
|
1464
1531
|
for (const item of sortedDependencies) {
|
1465
1532
|
inProgressTransitive++;
|
1533
|
+
// eslint-disable-next-line no-loop-func
|
1466
1534
|
this.handleModuleCreation(item, err => {
|
1467
1535
|
// In V8, the Error objects keep a reference to the functions on the stack. These warnings &
|
1468
1536
|
// errors are created inside closures that keep a reference to the Compilation, so errors are
|
@@ -1481,6 +1549,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1481
1549
|
if (--inProgressTransitive === 0) onTransitiveTasksFinished();
|
1482
1550
|
};
|
1483
1551
|
|
1552
|
+
/**
|
1553
|
+
* @param {WebpackError=} err error
|
1554
|
+
* @returns {void}
|
1555
|
+
*/
|
1484
1556
|
const onTransitiveTasksFinished = err => {
|
1485
1557
|
if (err) return callback(err);
|
1486
1558
|
this.processDependenciesQueue.decreaseParallelism();
|
@@ -1528,7 +1600,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1528
1600
|
if (err) {
|
1529
1601
|
if (inProgressSorting <= 0) return;
|
1530
1602
|
inProgressSorting = -1;
|
1531
|
-
onDependenciesSorted(err);
|
1603
|
+
onDependenciesSorted(/** @type {WebpackError} */ (err));
|
1532
1604
|
return;
|
1533
1605
|
}
|
1534
1606
|
try {
|
@@ -1583,15 +1655,15 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1583
1655
|
} catch (err) {
|
1584
1656
|
if (inProgressSorting <= 0) return;
|
1585
1657
|
inProgressSorting = -1;
|
1586
|
-
onDependenciesSorted(err);
|
1658
|
+
onDependenciesSorted(/** @type {WebpackError} */ (err));
|
1587
1659
|
return;
|
1588
1660
|
}
|
1589
1661
|
if (--inProgressSorting === 0) onDependenciesSorted();
|
1590
1662
|
});
|
1591
1663
|
return;
|
1592
1664
|
}
|
1593
|
-
} catch (
|
1594
|
-
console.error(
|
1665
|
+
} catch (err) {
|
1666
|
+
console.error(err);
|
1595
1667
|
}
|
1596
1668
|
}
|
1597
1669
|
processDependencyForResolving(dep);
|
@@ -1658,6 +1730,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1658
1730
|
sortedDependencies.push({
|
1659
1731
|
factory: factoryCacheKey2,
|
1660
1732
|
dependencies: list,
|
1733
|
+
context: dep.getContext(),
|
1661
1734
|
originModule: module
|
1662
1735
|
});
|
1663
1736
|
}
|
@@ -1672,7 +1745,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1672
1745
|
/** @type {DependenciesBlock[]} */
|
1673
1746
|
const queue = [module];
|
1674
1747
|
do {
|
1675
|
-
const block = queue.pop();
|
1748
|
+
const block = /** @type {DependenciesBlock} */ (queue.pop());
|
1676
1749
|
if (block.dependencies) {
|
1677
1750
|
currentBlock = block;
|
1678
1751
|
let i = 0;
|
@@ -1682,13 +1755,20 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1682
1755
|
for (const b of block.blocks) queue.push(b);
|
1683
1756
|
}
|
1684
1757
|
} while (queue.length !== 0);
|
1685
|
-
} catch (
|
1686
|
-
return callback(
|
1758
|
+
} catch (err) {
|
1759
|
+
return callback(err);
|
1687
1760
|
}
|
1688
1761
|
|
1689
1762
|
if (--inProgressSorting === 0) onDependenciesSorted();
|
1690
1763
|
}
|
1691
1764
|
|
1765
|
+
/**
|
1766
|
+
* @private
|
1767
|
+
* @param {Module} originModule original module
|
1768
|
+
* @param {Dependency} dependency dependency
|
1769
|
+
* @param {Module} module cached module
|
1770
|
+
* @param {Callback} callback callback
|
1771
|
+
*/
|
1692
1772
|
_handleNewModuleFromUnsafeCache(originModule, dependency, module, callback) {
|
1693
1773
|
const moduleGraph = this.moduleGraph;
|
1694
1774
|
|
@@ -1701,16 +1781,24 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1701
1781
|
|
1702
1782
|
this._modules.set(module.identifier(), module);
|
1703
1783
|
this.modules.add(module);
|
1704
|
-
|
1784
|
+
if (this._backCompat)
|
1785
|
+
ModuleGraph.setModuleGraphForModule(module, this.moduleGraph);
|
1705
1786
|
|
1706
1787
|
this._handleModuleBuildAndDependencies(
|
1707
1788
|
originModule,
|
1708
1789
|
module,
|
1709
1790
|
true,
|
1791
|
+
false,
|
1710
1792
|
callback
|
1711
1793
|
);
|
1712
1794
|
}
|
1713
1795
|
|
1796
|
+
/**
|
1797
|
+
* @private
|
1798
|
+
* @param {Module} originModule original modules
|
1799
|
+
* @param {Dependency} dependency dependency
|
1800
|
+
* @param {Module} module cached module
|
1801
|
+
*/
|
1714
1802
|
_handleExistingModuleFromUnsafeCache(originModule, dependency, module) {
|
1715
1803
|
const moduleGraph = this.moduleGraph;
|
1716
1804
|
|
@@ -1718,7 +1806,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1718
1806
|
}
|
1719
1807
|
|
1720
1808
|
/**
|
1721
|
-
* @typedef {
|
1809
|
+
* @typedef {object} HandleModuleCreationOptions
|
1722
1810
|
* @property {ModuleFactory} factory
|
1723
1811
|
* @property {Dependency[]} dependencies
|
1724
1812
|
* @property {Module | null} originModule
|
@@ -1726,6 +1814,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1726
1814
|
* @property {string=} context
|
1727
1815
|
* @property {boolean=} recursive recurse into dependencies of the created module
|
1728
1816
|
* @property {boolean=} connectOrigin connect the resolved module with the origin module
|
1817
|
+
* @property {boolean=} checkCycle check the cycle dependencies of the created module
|
1729
1818
|
*/
|
1730
1819
|
|
1731
1820
|
/**
|
@@ -1741,7 +1830,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1741
1830
|
contextInfo,
|
1742
1831
|
context,
|
1743
1832
|
recursive = true,
|
1744
|
-
connectOrigin = recursive
|
1833
|
+
connectOrigin = recursive,
|
1834
|
+
checkCycle = !recursive
|
1745
1835
|
},
|
1746
1836
|
callback
|
1747
1837
|
) {
|
@@ -1778,10 +1868,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1778
1868
|
if (dependencies.every(d => d.optional)) {
|
1779
1869
|
this.warnings.push(err);
|
1780
1870
|
return callback();
|
1781
|
-
} else {
|
1782
|
-
this.errors.push(err);
|
1783
|
-
return callback(err);
|
1784
1871
|
}
|
1872
|
+
this.errors.push(err);
|
1873
|
+
return callback(err);
|
1785
1874
|
}
|
1786
1875
|
|
1787
1876
|
const newModule = factoryResult.module;
|
@@ -1795,27 +1884,30 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1795
1884
|
moduleGraph.setProfile(newModule, currentProfile);
|
1796
1885
|
}
|
1797
1886
|
|
1798
|
-
this.addModule(newModule, (err,
|
1887
|
+
this.addModule(newModule, (err, _module) => {
|
1799
1888
|
if (err) {
|
1800
1889
|
applyFactoryResultDependencies();
|
1801
1890
|
if (!err.module) {
|
1802
|
-
err.module =
|
1891
|
+
err.module = _module;
|
1803
1892
|
}
|
1804
1893
|
this.errors.push(err);
|
1805
1894
|
|
1806
1895
|
return callback(err);
|
1807
1896
|
}
|
1808
1897
|
|
1898
|
+
const module =
|
1899
|
+
/** @type {Module & { restoreFromUnsafeCache?: Function }} */
|
1900
|
+
(_module);
|
1901
|
+
|
1809
1902
|
if (
|
1810
1903
|
this._unsafeCache &&
|
1811
1904
|
factoryResult.cacheable !== false &&
|
1812
|
-
|
1905
|
+
module.restoreFromUnsafeCache &&
|
1813
1906
|
this._unsafeCachePredicate(module)
|
1814
1907
|
) {
|
1815
1908
|
const unsafeCacheableModule =
|
1816
|
-
/** @type {Module & { restoreFromUnsafeCache: Function }} */
|
1817
|
-
|
1818
|
-
);
|
1909
|
+
/** @type {Module & { restoreFromUnsafeCache: Function }} */
|
1910
|
+
(module);
|
1819
1911
|
for (let i = 0; i < dependencies.length; i++) {
|
1820
1912
|
const dependency = dependencies[i];
|
1821
1913
|
moduleGraph.setResolvedModule(
|
@@ -1847,14 +1939,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1847
1939
|
module,
|
1848
1940
|
originModule !== undefined ? originModule : null
|
1849
1941
|
);
|
1850
|
-
if (module !== newModule) {
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
moduleGraph.setProfile(module, currentProfile);
|
1857
|
-
}
|
1942
|
+
if (module !== newModule && currentProfile !== undefined) {
|
1943
|
+
const otherProfile = moduleGraph.getProfile(module);
|
1944
|
+
if (otherProfile !== undefined) {
|
1945
|
+
currentProfile.mergeInto(otherProfile);
|
1946
|
+
} else {
|
1947
|
+
moduleGraph.setProfile(module, currentProfile);
|
1858
1948
|
}
|
1859
1949
|
}
|
1860
1950
|
|
@@ -1862,6 +1952,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1862
1952
|
originModule,
|
1863
1953
|
module,
|
1864
1954
|
recursive,
|
1955
|
+
checkCycle,
|
1865
1956
|
callback
|
1866
1957
|
);
|
1867
1958
|
});
|
@@ -1869,10 +1960,26 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1869
1960
|
);
|
1870
1961
|
}
|
1871
1962
|
|
1872
|
-
|
1963
|
+
/**
|
1964
|
+
* @private
|
1965
|
+
* @param {Module} originModule original module
|
1966
|
+
* @param {Module} module module
|
1967
|
+
* @param {boolean} recursive true if make it recursive, otherwise false
|
1968
|
+
* @param {boolean} checkCycle true if need to check cycle, otherwise false
|
1969
|
+
* @param {ModuleCallback} callback callback
|
1970
|
+
* @returns {void}
|
1971
|
+
*/
|
1972
|
+
_handleModuleBuildAndDependencies(
|
1973
|
+
originModule,
|
1974
|
+
module,
|
1975
|
+
recursive,
|
1976
|
+
checkCycle,
|
1977
|
+
callback
|
1978
|
+
) {
|
1873
1979
|
// Check for cycles when build is trigger inside another build
|
1874
|
-
|
1875
|
-
|
1980
|
+
/** @type {Set<Module> | undefined} */
|
1981
|
+
let creatingModuleDuringBuildSet;
|
1982
|
+
if (checkCycle && this.buildQueue.isProcessing(originModule)) {
|
1876
1983
|
// Track build dependency
|
1877
1984
|
creatingModuleDuringBuildSet =
|
1878
1985
|
this.creatingModuleDuringBuild.get(originModule);
|
@@ -1926,7 +2033,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1926
2033
|
|
1927
2034
|
// This avoids deadlocks for circular dependencies
|
1928
2035
|
if (this.processDependenciesQueue.isProcessing(module)) {
|
1929
|
-
return callback();
|
2036
|
+
return callback(null, module);
|
1930
2037
|
}
|
1931
2038
|
|
1932
2039
|
this.processModuleDependencies(module, err => {
|
@@ -1967,12 +2074,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
1967
2074
|
...contextInfo
|
1968
2075
|
},
|
1969
2076
|
resolveOptions: originModule ? originModule.resolveOptions : undefined,
|
1970
|
-
context:
|
1971
|
-
|
1972
|
-
:
|
1973
|
-
|
1974
|
-
: this.compiler.context,
|
1975
|
-
dependencies: dependencies
|
2077
|
+
context:
|
2078
|
+
context ||
|
2079
|
+
(originModule ? originModule.context : this.compiler.context),
|
2080
|
+
dependencies
|
1976
2081
|
},
|
1977
2082
|
(err, result) => {
|
1978
2083
|
if (result) {
|
@@ -2004,7 +2109,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2004
2109
|
const notFoundError = new ModuleNotFoundError(
|
2005
2110
|
originModule,
|
2006
2111
|
err,
|
2007
|
-
dependencies.map(d => d.loc).
|
2112
|
+
dependencies.map(d => d.loc).find(Boolean)
|
2008
2113
|
);
|
2009
2114
|
return callback(notFoundError, factoryResult ? result : undefined);
|
2010
2115
|
}
|
@@ -2032,7 +2137,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2032
2137
|
}
|
2033
2138
|
|
2034
2139
|
/**
|
2035
|
-
* @param {
|
2140
|
+
* @param {object} options options
|
2036
2141
|
* @param {string} options.context context string path
|
2037
2142
|
* @param {Dependency} options.dependency dependency used to create Module chain
|
2038
2143
|
* @param {Partial<ModuleFactoryCreateDataContextInfo>=} options.contextInfo additional context info for the root module
|
@@ -2139,7 +2244,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2139
2244
|
}
|
2140
2245
|
};
|
2141
2246
|
entryData[target].push(entry);
|
2142
|
-
this.entries.set(
|
2247
|
+
this.entries.set(
|
2248
|
+
/** @type {NonNullable<EntryOptions["name"]>} */ (name),
|
2249
|
+
entryData
|
2250
|
+
);
|
2143
2251
|
} else {
|
2144
2252
|
entryData[target].push(entry);
|
2145
2253
|
for (const key of Object.keys(options)) {
|
@@ -2179,7 +2287,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2179
2287
|
this.hooks.failedEntry.call(entry, options, err);
|
2180
2288
|
return callback(err);
|
2181
2289
|
}
|
2182
|
-
this.hooks.succeedEntry.call(
|
2290
|
+
this.hooks.succeedEntry.call(
|
2291
|
+
entry,
|
2292
|
+
options,
|
2293
|
+
/** @type {Module} */ (module)
|
2294
|
+
);
|
2183
2295
|
return callback(null, module);
|
2184
2296
|
}
|
2185
2297
|
);
|
@@ -2239,6 +2351,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2239
2351
|
});
|
2240
2352
|
}
|
2241
2353
|
|
2354
|
+
/**
|
2355
|
+
* @private
|
2356
|
+
* @param {Set<Module>} modules modules
|
2357
|
+
*/
|
2242
2358
|
_computeAffectedModules(modules) {
|
2243
2359
|
const moduleMemCacheCache = this.compiler.moduleMemCaches;
|
2244
2360
|
if (!moduleMemCacheCache) return;
|
@@ -2255,9 +2371,13 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2255
2371
|
let statReferencesChanged = 0;
|
2256
2372
|
let statWithoutBuild = 0;
|
2257
2373
|
|
2374
|
+
/**
|
2375
|
+
* @param {Module} module module
|
2376
|
+
* @returns {References | undefined} references
|
2377
|
+
*/
|
2258
2378
|
const computeReferences = module => {
|
2259
|
-
/** @type {
|
2260
|
-
let references
|
2379
|
+
/** @type {References | undefined} */
|
2380
|
+
let references;
|
2261
2381
|
for (const connection of moduleGraph.getOutgoingConnections(module)) {
|
2262
2382
|
const d = connection.dependency;
|
2263
2383
|
const m = connection.module;
|
@@ -2270,7 +2390,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2270
2390
|
|
2271
2391
|
/**
|
2272
2392
|
* @param {Module} module the module
|
2273
|
-
* @param {
|
2393
|
+
* @param {References | undefined} references references
|
2274
2394
|
* @returns {boolean} true, when the references differ
|
2275
2395
|
*/
|
2276
2396
|
const compareReferences = (module, references) => {
|
@@ -2342,6 +2462,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2342
2462
|
}
|
2343
2463
|
}
|
2344
2464
|
|
2465
|
+
/**
|
2466
|
+
* @param {readonly ModuleGraphConnection[]} connections connections
|
2467
|
+
* @returns {symbol|boolean} result
|
2468
|
+
*/
|
2345
2469
|
const reduceAffectType = connections => {
|
2346
2470
|
let affected = false;
|
2347
2471
|
for (const { dependency } of connections) {
|
@@ -2417,13 +2541,14 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2417
2541
|
let statNew = 0;
|
2418
2542
|
/**
|
2419
2543
|
* @param {Module} module module
|
2420
|
-
* @returns {{ modules?: Map<Module, string | number | undefined>, blocks?: (string | number)[] }} references
|
2544
|
+
* @returns {{ id: string | number, modules?: Map<Module, string | number | undefined>, blocks?: (string | number | null)[] }} references
|
2421
2545
|
*/
|
2422
2546
|
const computeReferences = module => {
|
2423
|
-
|
2424
|
-
|
2425
|
-
|
2426
|
-
|
2547
|
+
const id = chunkGraph.getModuleId(module);
|
2548
|
+
/** @type {Map<Module, string | number | undefined> | undefined} */
|
2549
|
+
let modules;
|
2550
|
+
/** @type {(string | number | null)[] | undefined} */
|
2551
|
+
let blocks;
|
2427
2552
|
const outgoing = moduleGraph.getOutgoingConnectionsByModule(module);
|
2428
2553
|
if (outgoing !== undefined) {
|
2429
2554
|
for (const m of outgoing.keys()) {
|
@@ -2444,19 +2569,22 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2444
2569
|
} else {
|
2445
2570
|
blocks.push(null);
|
2446
2571
|
}
|
2572
|
+
// eslint-disable-next-line prefer-spread
|
2447
2573
|
queue.push.apply(queue, block.blocks);
|
2448
2574
|
}
|
2449
2575
|
}
|
2450
|
-
return { modules, blocks };
|
2576
|
+
return { id, modules, blocks };
|
2451
2577
|
};
|
2452
2578
|
/**
|
2453
2579
|
* @param {Module} module module
|
2454
|
-
* @param {
|
2455
|
-
* @param {
|
2456
|
-
* @param {
|
2580
|
+
* @param {object} references references
|
2581
|
+
* @param {string | number} references.id id
|
2582
|
+
* @param {Map<Module, string | number | undefined>=} references.modules modules
|
2583
|
+
* @param {(string | number | null)[]=} references.blocks blocks
|
2457
2584
|
* @returns {boolean} ok?
|
2458
2585
|
*/
|
2459
|
-
const compareReferences = (module, { modules, blocks }) => {
|
2586
|
+
const compareReferences = (module, { id, modules, blocks }) => {
|
2587
|
+
if (id !== chunkGraph.getModuleId(module)) return false;
|
2460
2588
|
if (modules !== undefined) {
|
2461
2589
|
for (const [module, id] of modules) {
|
2462
2590
|
if (chunkGraph.getModuleId(module) !== id) return false;
|
@@ -2471,9 +2599,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2471
2599
|
for (const chunk of chunkGroup.chunks) {
|
2472
2600
|
if (i >= blocks.length || blocks[i++] !== chunk.id) return false;
|
2473
2601
|
}
|
2474
|
-
} else {
|
2475
|
-
|
2602
|
+
} else if (i >= blocks.length || blocks[i++] !== null) {
|
2603
|
+
return false;
|
2476
2604
|
}
|
2605
|
+
// eslint-disable-next-line prefer-spread
|
2477
2606
|
queue.push.apply(queue, block.blocks);
|
2478
2607
|
}
|
2479
2608
|
if (i !== blocks.length) return false;
|
@@ -2482,7 +2611,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2482
2611
|
};
|
2483
2612
|
|
2484
2613
|
for (const [module, memCache] of moduleMemCaches) {
|
2485
|
-
/** @type {{ references: { modules?: Map<Module, string | number | undefined>, blocks?: (string | number)[]}, memCache: WeakTupleMap<any[], any> }} */
|
2614
|
+
/** @type {{ references: { id: string | number, modules?: Map<Module, string | number | undefined>, blocks?: (string | number | null)[]}, memCache: WeakTupleMap<any[], any> }} */
|
2486
2615
|
const cache = memCache.get(key);
|
2487
2616
|
if (cache === undefined) {
|
2488
2617
|
const memCache2 = new WeakTupleMap();
|
@@ -2511,6 +2640,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2511
2640
|
);
|
2512
2641
|
}
|
2513
2642
|
|
2643
|
+
/**
|
2644
|
+
* @param {Callback} callback callback
|
2645
|
+
*/
|
2514
2646
|
finish(callback) {
|
2515
2647
|
this.factorizeQueue.clear();
|
2516
2648
|
if (this.profile) {
|
@@ -2518,6 +2650,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2518
2650
|
const ParallelismFactorCalculator = require("./util/ParallelismFactorCalculator");
|
2519
2651
|
const p = new ParallelismFactorCalculator();
|
2520
2652
|
const moduleGraph = this.moduleGraph;
|
2653
|
+
/** @type {Map<Module, ModuleProfile>} */
|
2521
2654
|
const modulesWithProfiles = new Map();
|
2522
2655
|
for (const module of this.modules) {
|
2523
2656
|
const profile = moduleGraph.getProfile(module);
|
@@ -2563,6 +2696,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2563
2696
|
p.calculate();
|
2564
2697
|
|
2565
2698
|
const logger = this.getLogger("webpack.Compilation.ModuleProfile");
|
2699
|
+
// Avoid coverage problems due indirect changes
|
2700
|
+
/**
|
2701
|
+
* @param {number} value value
|
2702
|
+
* @param {string} msg message
|
2703
|
+
*/
|
2704
|
+
/* istanbul ignore next */
|
2566
2705
|
const logByValue = (value, msg) => {
|
2567
2706
|
if (value > 1000) {
|
2568
2707
|
logger.error(msg);
|
@@ -2576,6 +2715,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2576
2715
|
logger.debug(msg);
|
2577
2716
|
}
|
2578
2717
|
};
|
2718
|
+
/**
|
2719
|
+
* @param {string} category a category
|
2720
|
+
* @param {(profile: ModuleProfile) => number} getDuration get duration callback
|
2721
|
+
* @param {(profile: ModuleProfile) => number} getParallelism get parallelism callback
|
2722
|
+
*/
|
2579
2723
|
const logNormalSummary = (category, getDuration, getParallelism) => {
|
2580
2724
|
let sum = 0;
|
2581
2725
|
let max = 0;
|
@@ -2600,12 +2744,17 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2600
2744
|
`${Math.round(sum)} ms ${category}`
|
2601
2745
|
);
|
2602
2746
|
};
|
2747
|
+
/**
|
2748
|
+
* @param {string} category a category
|
2749
|
+
* @param {(profile: ModuleProfile) => number} getDuration get duration callback
|
2750
|
+
* @param {(profile: ModuleProfile) => number} getParallelism get parallelism callback
|
2751
|
+
*/
|
2603
2752
|
const logByLoadersSummary = (category, getDuration, getParallelism) => {
|
2604
2753
|
const map = new Map();
|
2605
2754
|
for (const [module, profile] of modulesWithProfiles) {
|
2606
|
-
const list =
|
2755
|
+
const list = getOrInsert(
|
2607
2756
|
map,
|
2608
|
-
module.type
|
2757
|
+
`${module.type}!${module.identifier().replace(/(!|^)[^!]*$/, "")}`,
|
2609
2758
|
() => []
|
2610
2759
|
);
|
2611
2760
|
list.push({ module, profile });
|
@@ -2645,9 +2794,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2645
2794
|
loaders
|
2646
2795
|
? `${
|
2647
2796
|
modules.length
|
2648
|
-
|
2797
|
+
} x ${moduleType} with ${this.requestShortener.shorten(
|
2649
2798
|
loaders
|
2650
|
-
|
2799
|
+
)}`
|
2651
2800
|
: `${modules.length} x ${moduleType}`
|
2652
2801
|
}`
|
2653
2802
|
);
|
@@ -2698,7 +2847,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2698
2847
|
const { modules, moduleMemCaches } = this;
|
2699
2848
|
this.hooks.finishModules.callAsync(modules, err => {
|
2700
2849
|
this.logger.timeEnd("finish modules");
|
2701
|
-
if (err) return callback(err);
|
2850
|
+
if (err) return callback(/** @type {WebpackError} */ (err));
|
2702
2851
|
|
2703
2852
|
// extract warnings and errors from modules
|
2704
2853
|
this.moduleGraph.freeze("dependency errors");
|
@@ -2763,6 +2912,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2763
2912
|
* @returns {void}
|
2764
2913
|
*/
|
2765
2914
|
seal(callback) {
|
2915
|
+
/**
|
2916
|
+
* @param {WebpackError=} err err
|
2917
|
+
* @returns {void}
|
2918
|
+
*/
|
2766
2919
|
const finalCallback = err => {
|
2767
2920
|
this.factorizeQueue.clear();
|
2768
2921
|
this.buildQueue.clear();
|
@@ -2777,8 +2930,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2777
2930
|
);
|
2778
2931
|
this.chunkGraph = chunkGraph;
|
2779
2932
|
|
2780
|
-
|
2781
|
-
|
2933
|
+
if (this._backCompat) {
|
2934
|
+
for (const module of this.modules) {
|
2935
|
+
ChunkGraph.setChunkGraphForModule(module, chunkGraph);
|
2936
|
+
}
|
2782
2937
|
}
|
2783
2938
|
|
2784
2939
|
this.hooks.seal.call();
|
@@ -2830,11 +2985,15 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2830
2985
|
|
2831
2986
|
this.assignDepths(entryModules);
|
2832
2987
|
|
2988
|
+
/**
|
2989
|
+
* @param {Dependency[]} deps deps
|
2990
|
+
* @returns {Module[]} sorted deps
|
2991
|
+
*/
|
2833
2992
|
const mapAndSort = deps =>
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2993
|
+
/** @type {Module[]} */
|
2994
|
+
(deps.map(dep => this.moduleGraph.getModule(dep)).filter(Boolean)).sort(
|
2995
|
+
compareModulesByIdentifier
|
2996
|
+
);
|
2838
2997
|
const includedModules = [
|
2839
2998
|
...mapAndSort(this.globalEntry.includeDependencies),
|
2840
2999
|
...mapAndSort(includeDependencies)
|
@@ -2862,12 +3021,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2862
3021
|
Entrypoints that depend on other entrypoints do not have their own runtime.
|
2863
3022
|
They will use the runtime(s) from referenced entrypoints instead.
|
2864
3023
|
Remove the 'runtime' option from the entrypoint.`);
|
2865
|
-
const entry = this.entrypoints.get(name);
|
3024
|
+
const entry = /** @type {Entrypoint} */ (this.entrypoints.get(name));
|
2866
3025
|
err.chunk = entry.getEntrypointChunk();
|
2867
3026
|
this.errors.push(err);
|
2868
3027
|
}
|
2869
3028
|
if (dependOn) {
|
2870
|
-
const entry = this.entrypoints.get(name);
|
3029
|
+
const entry = /** @type {Entrypoint} */ (this.entrypoints.get(name));
|
2871
3030
|
const referencedChunks = entry
|
2872
3031
|
.getEntrypointChunk()
|
2873
3032
|
.getAllReferencedChunks();
|
@@ -2895,7 +3054,7 @@ Remove the 'runtime' option from the entrypoint.`);
|
|
2895
3054
|
connectChunkGroupParentAndChild(dependency, entry);
|
2896
3055
|
}
|
2897
3056
|
} else if (runtime) {
|
2898
|
-
const entry = this.entrypoints.get(name);
|
3057
|
+
const entry = /** @type {Entrypoint} */ (this.entrypoints.get(name));
|
2899
3058
|
let chunk = this.namedChunks.get(runtime);
|
2900
3059
|
if (chunk) {
|
2901
3060
|
if (!runtimeChunks.has(chunk)) {
|
@@ -2906,7 +3065,9 @@ Did you mean to use 'dependOn: ${JSON.stringify(
|
|
2906
3065
|
runtime
|
2907
3066
|
)}' instead to allow using entrypoint '${name}' within the runtime of entrypoint '${runtime}'? For this '${runtime}' must always be loaded when '${name}' is used.
|
2908
3067
|
Or do you want to use the entrypoints '${name}' and '${runtime}' independently on the same page with a shared runtime? In this case give them both the same value for the 'runtime' option. It must be a name not already used by an entrypoint.`);
|
2909
|
-
const entryChunk =
|
3068
|
+
const entryChunk =
|
3069
|
+
/** @type {Chunk} */
|
3070
|
+
(entry.getEntrypointChunk());
|
2910
3071
|
err.chunk = entryChunk;
|
2911
3072
|
this.errors.push(err);
|
2912
3073
|
entry.setRuntimeChunk(entryChunk);
|
@@ -3045,13 +3206,17 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3045
3206
|
}
|
3046
3207
|
this.hooks.afterProcessAssets.call(this.assets);
|
3047
3208
|
this.logger.timeEnd("process assets");
|
3048
|
-
this.assets =
|
3049
|
-
this.
|
3050
|
-
|
3051
|
-
|
3052
|
-
|
3209
|
+
this.assets = /** @type {CompilationAssets} */ (
|
3210
|
+
this._backCompat
|
3211
|
+
? soonFrozenObjectDeprecation(
|
3212
|
+
this.assets,
|
3213
|
+
"Compilation.assets",
|
3214
|
+
"DEP_WEBPACK_COMPILATION_ASSETS",
|
3215
|
+
`BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
|
3053
3216
|
Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
|
3054
3217
|
Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.`
|
3218
|
+
)
|
3219
|
+
: Object.freeze(this.assets)
|
3055
3220
|
);
|
3056
3221
|
|
3057
3222
|
this.summarizeDependencies();
|
@@ -3138,12 +3303,15 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3138
3303
|
return hasProblems;
|
3139
3304
|
}
|
3140
3305
|
|
3306
|
+
/**
|
3307
|
+
* @param {Callback} callback callback
|
3308
|
+
*/
|
3141
3309
|
codeGeneration(callback) {
|
3142
3310
|
const { chunkGraph } = this;
|
3143
3311
|
this.codeGenerationResults = new CodeGenerationResults(
|
3144
3312
|
this.outputOptions.hashFunction
|
3145
3313
|
);
|
3146
|
-
/** @type {
|
3314
|
+
/** @type {CodeGenerationJobs} */
|
3147
3315
|
const jobs = [];
|
3148
3316
|
for (const module of this.modules) {
|
3149
3317
|
const runtimes = chunkGraph.getModuleRuntimes(module);
|
@@ -3172,54 +3340,111 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3172
3340
|
this._runCodeGenerationJobs(jobs, callback);
|
3173
3341
|
}
|
3174
3342
|
|
3343
|
+
/**
|
3344
|
+
* @private
|
3345
|
+
* @param {CodeGenerationJobs} jobs code generation jobs
|
3346
|
+
* @param {Callback} callback callback
|
3347
|
+
* @returns {void}
|
3348
|
+
*/
|
3175
3349
|
_runCodeGenerationJobs(jobs, callback) {
|
3350
|
+
if (jobs.length === 0) {
|
3351
|
+
return callback();
|
3352
|
+
}
|
3176
3353
|
let statModulesFromCache = 0;
|
3177
3354
|
let statModulesGenerated = 0;
|
3178
3355
|
const { chunkGraph, moduleGraph, dependencyTemplates, runtimeTemplate } =
|
3179
3356
|
this;
|
3180
3357
|
const results = this.codeGenerationResults;
|
3358
|
+
/** @type {WebpackError[]} */
|
3181
3359
|
const errors = [];
|
3182
|
-
|
3183
|
-
|
3184
|
-
|
3185
|
-
|
3186
|
-
|
3187
|
-
|
3188
|
-
|
3189
|
-
|
3190
|
-
|
3191
|
-
|
3192
|
-
|
3193
|
-
|
3194
|
-
|
3195
|
-
|
3196
|
-
|
3197
|
-
|
3198
|
-
|
3199
|
-
|
3200
|
-
|
3360
|
+
/** @type {NotCodeGeneratedModules | undefined} */
|
3361
|
+
let notCodeGeneratedModules;
|
3362
|
+
const runIteration = () => {
|
3363
|
+
/** @type {CodeGenerationJobs} */
|
3364
|
+
let delayedJobs = [];
|
3365
|
+
let delayedModules = new Set();
|
3366
|
+
asyncLib.eachLimit(
|
3367
|
+
jobs,
|
3368
|
+
/** @type {number} */
|
3369
|
+
(this.options.parallelism),
|
3370
|
+
(job, callback) => {
|
3371
|
+
const { module } = job;
|
3372
|
+
const { codeGenerationDependencies } = module;
|
3373
|
+
if (
|
3374
|
+
codeGenerationDependencies !== undefined &&
|
3375
|
+
(notCodeGeneratedModules === undefined ||
|
3376
|
+
codeGenerationDependencies.some(dep => {
|
3377
|
+
const referencedModule = /** @type {Module} */ (
|
3378
|
+
moduleGraph.getModule(dep)
|
3379
|
+
);
|
3380
|
+
return /** @type {NotCodeGeneratedModules} */ (
|
3381
|
+
notCodeGeneratedModules
|
3382
|
+
).has(referencedModule);
|
3383
|
+
}))
|
3384
|
+
) {
|
3385
|
+
delayedJobs.push(job);
|
3386
|
+
delayedModules.add(module);
|
3387
|
+
return callback();
|
3201
3388
|
}
|
3202
|
-
|
3203
|
-
|
3204
|
-
|
3205
|
-
|
3206
|
-
|
3207
|
-
|
3208
|
-
|
3389
|
+
const { hash, runtime, runtimes } = job;
|
3390
|
+
this._codeGenerationModule(
|
3391
|
+
module,
|
3392
|
+
runtime,
|
3393
|
+
runtimes,
|
3394
|
+
hash,
|
3395
|
+
dependencyTemplates,
|
3396
|
+
chunkGraph,
|
3397
|
+
moduleGraph,
|
3398
|
+
runtimeTemplate,
|
3399
|
+
errors,
|
3400
|
+
results,
|
3401
|
+
(err, codeGenerated) => {
|
3402
|
+
if (codeGenerated) statModulesGenerated++;
|
3403
|
+
else statModulesFromCache++;
|
3404
|
+
callback(err);
|
3405
|
+
}
|
3209
3406
|
);
|
3210
|
-
|
3211
|
-
|
3407
|
+
},
|
3408
|
+
err => {
|
3409
|
+
if (err) return callback(err);
|
3410
|
+
if (delayedJobs.length > 0) {
|
3411
|
+
if (delayedJobs.length === jobs.length) {
|
3412
|
+
return callback(
|
3413
|
+
/** @type {WebpackError} */ (
|
3414
|
+
new Error(
|
3415
|
+
`Unable to make progress during code generation because of circular code generation dependency: ${Array.from(
|
3416
|
+
delayedModules,
|
3417
|
+
m => m.identifier()
|
3418
|
+
).join(", ")}`
|
3419
|
+
)
|
3420
|
+
)
|
3421
|
+
);
|
3422
|
+
}
|
3423
|
+
jobs = delayedJobs;
|
3424
|
+
delayedJobs = [];
|
3425
|
+
notCodeGeneratedModules = delayedModules;
|
3426
|
+
delayedModules = new Set();
|
3427
|
+
return runIteration();
|
3428
|
+
}
|
3429
|
+
if (errors.length > 0) {
|
3430
|
+
errors.sort(
|
3431
|
+
compareSelect(err => err.module, compareModulesByIdentifier)
|
3432
|
+
);
|
3433
|
+
for (const error of errors) {
|
3434
|
+
this.errors.push(error);
|
3435
|
+
}
|
3212
3436
|
}
|
3437
|
+
this.logger.log(
|
3438
|
+
`${Math.round(
|
3439
|
+
(100 * statModulesGenerated) /
|
3440
|
+
(statModulesGenerated + statModulesFromCache)
|
3441
|
+
)}% code generated (${statModulesGenerated} generated, ${statModulesFromCache} from cache)`
|
3442
|
+
);
|
3443
|
+
callback();
|
3213
3444
|
}
|
3214
|
-
|
3215
|
-
|
3216
|
-
|
3217
|
-
(statModulesGenerated + statModulesFromCache)
|
3218
|
-
)}% code generated (${statModulesGenerated} generated, ${statModulesFromCache} from cache)`
|
3219
|
-
);
|
3220
|
-
callback();
|
3221
|
-
}
|
3222
|
-
);
|
3445
|
+
);
|
3446
|
+
};
|
3447
|
+
runIteration();
|
3223
3448
|
}
|
3224
3449
|
|
3225
3450
|
/**
|
@@ -3233,7 +3458,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3233
3458
|
* @param {RuntimeTemplate} runtimeTemplate runtimeTemplate
|
3234
3459
|
* @param {WebpackError[]} errors errors
|
3235
3460
|
* @param {CodeGenerationResults} results results
|
3236
|
-
* @param {function(WebpackError=, boolean=): void} callback callback
|
3461
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback
|
3237
3462
|
*/
|
3238
3463
|
_codeGenerationModule(
|
3239
3464
|
module,
|
@@ -3258,7 +3483,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3258
3483
|
)
|
3259
3484
|
);
|
3260
3485
|
cache.get((err, cachedResult) => {
|
3261
|
-
if (err) return callback(err);
|
3486
|
+
if (err) return callback(/** @type {WebpackError} */ (err));
|
3262
3487
|
let result;
|
3263
3488
|
if (!cachedResult) {
|
3264
3489
|
try {
|
@@ -3269,10 +3494,14 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3269
3494
|
moduleGraph,
|
3270
3495
|
dependencyTemplates,
|
3271
3496
|
runtimeTemplate,
|
3272
|
-
runtime
|
3497
|
+
runtime,
|
3498
|
+
codeGenerationResults: results,
|
3499
|
+
compilation: this
|
3273
3500
|
});
|
3274
3501
|
} catch (err) {
|
3275
|
-
errors.push(
|
3502
|
+
errors.push(
|
3503
|
+
new CodeGenerationError(module, /** @type {Error} */ (err))
|
3504
|
+
);
|
3276
3505
|
result = cachedResult = {
|
3277
3506
|
sources: new Map(),
|
3278
3507
|
runtimeRequirements: null
|
@@ -3285,7 +3514,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3285
3514
|
results.add(module, runtime, result);
|
3286
3515
|
}
|
3287
3516
|
if (!cachedResult) {
|
3288
|
-
cache.store(result, err =>
|
3517
|
+
cache.store(result, err =>
|
3518
|
+
callback(/** @type {WebpackError} */ (err), codeGenerated)
|
3519
|
+
);
|
3289
3520
|
} else {
|
3290
3521
|
callback(null, codeGenerated);
|
3291
3522
|
}
|
@@ -3307,7 +3538,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3307
3538
|
}
|
3308
3539
|
|
3309
3540
|
/**
|
3310
|
-
* @param {
|
3541
|
+
* @param {object} options options
|
3311
3542
|
* @param {ChunkGraph=} options.chunkGraph the chunk graph
|
3312
3543
|
* @param {Iterable<Module>=} options.modules modules
|
3313
3544
|
* @param {Iterable<Chunk>=} options.chunks chunks
|
@@ -3377,21 +3608,19 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3377
3608
|
null
|
3378
3609
|
);
|
3379
3610
|
}
|
3611
|
+
} else if (memCache) {
|
3612
|
+
memCache.set(
|
3613
|
+
`moduleRuntimeRequirements-${getRuntimeKey(runtime)}`,
|
3614
|
+
set
|
3615
|
+
);
|
3616
|
+
chunkGraph.addModuleRuntimeRequirements(
|
3617
|
+
module,
|
3618
|
+
runtime,
|
3619
|
+
set,
|
3620
|
+
false
|
3621
|
+
);
|
3380
3622
|
} else {
|
3381
|
-
|
3382
|
-
memCache.set(
|
3383
|
-
`moduleRuntimeRequirements-${getRuntimeKey(runtime)}`,
|
3384
|
-
set
|
3385
|
-
);
|
3386
|
-
chunkGraph.addModuleRuntimeRequirements(
|
3387
|
-
module,
|
3388
|
-
runtime,
|
3389
|
-
set,
|
3390
|
-
false
|
3391
|
-
);
|
3392
|
-
} else {
|
3393
|
-
chunkGraph.addModuleRuntimeRequirements(module, runtime, set);
|
3394
|
-
}
|
3623
|
+
chunkGraph.addModuleRuntimeRequirements(module, runtime, set);
|
3395
3624
|
}
|
3396
3625
|
}
|
3397
3626
|
}
|
@@ -3453,7 +3682,8 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3453
3682
|
*/
|
3454
3683
|
addRuntimeModule(chunk, module, chunkGraph = this.chunkGraph) {
|
3455
3684
|
// Deprecated ModuleGraph association
|
3456
|
-
|
3685
|
+
if (this._backCompat)
|
3686
|
+
ModuleGraph.setModuleGraphForModule(module, this.moduleGraph);
|
3457
3687
|
|
3458
3688
|
// add it to the list
|
3459
3689
|
this.modules.add(module);
|
@@ -3497,10 +3727,11 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3497
3727
|
}
|
3498
3728
|
|
3499
3729
|
/**
|
3730
|
+
* If `module` is passed, `loc` and `request` must also be passed.
|
3500
3731
|
* @param {string | ChunkGroupOptions} groupOptions options for the chunk group
|
3501
|
-
* @param {Module} module the module the references the chunk group
|
3502
|
-
* @param {DependencyLocation} loc the location from with the chunk group is referenced (inside of module)
|
3503
|
-
* @param {string} request the request from which the the chunk group is referenced
|
3732
|
+
* @param {Module=} module the module the references the chunk group
|
3733
|
+
* @param {DependencyLocation=} loc the location from with the chunk group is referenced (inside of module)
|
3734
|
+
* @param {string=} request the request from which the the chunk group is referenced
|
3504
3735
|
* @returns {ChunkGroup} the new or existing chunk group
|
3505
3736
|
*/
|
3506
3737
|
addChunkInGroup(groupOptions, module, loc, request) {
|
@@ -3514,13 +3745,24 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3514
3745
|
if (chunkGroup !== undefined) {
|
3515
3746
|
chunkGroup.addOptions(groupOptions);
|
3516
3747
|
if (module) {
|
3517
|
-
chunkGroup.addOrigin(
|
3748
|
+
chunkGroup.addOrigin(
|
3749
|
+
module,
|
3750
|
+
/** @type {DependencyLocation} */
|
3751
|
+
(loc),
|
3752
|
+
request
|
3753
|
+
);
|
3518
3754
|
}
|
3519
3755
|
return chunkGroup;
|
3520
3756
|
}
|
3521
3757
|
}
|
3522
3758
|
const chunkGroup = new ChunkGroup(groupOptions);
|
3523
|
-
if (module)
|
3759
|
+
if (module)
|
3760
|
+
chunkGroup.addOrigin(
|
3761
|
+
module,
|
3762
|
+
/** @type {DependencyLocation} */
|
3763
|
+
(loc),
|
3764
|
+
request
|
3765
|
+
);
|
3524
3766
|
const chunk = this.addChunk(name);
|
3525
3767
|
|
3526
3768
|
connectChunkGroupAndChunk(chunkGroup, chunk);
|
@@ -3578,7 +3820,6 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3578
3820
|
/**
|
3579
3821
|
* This method first looks to see if a name is provided for a new chunk,
|
3580
3822
|
* and first looks to see if any named chunks already exist and reuse that chunk instead.
|
3581
|
-
*
|
3582
3823
|
* @param {string=} name optional chunk name to be provided
|
3583
3824
|
* @returns {Chunk} create a chunk (invoked during seal event)
|
3584
3825
|
*/
|
@@ -3589,9 +3830,10 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3589
3830
|
return chunk;
|
3590
3831
|
}
|
3591
3832
|
}
|
3592
|
-
const chunk = new Chunk(name);
|
3833
|
+
const chunk = new Chunk(name, this._backCompat);
|
3593
3834
|
this.chunks.add(chunk);
|
3594
|
-
|
3835
|
+
if (this._backCompat)
|
3836
|
+
ChunkGraph.setChunkGraphForChunk(chunk, this.chunkGraph);
|
3595
3837
|
if (name) {
|
3596
3838
|
this.namedChunks.set(name, chunk);
|
3597
3839
|
}
|
@@ -3607,6 +3849,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3607
3849
|
const moduleGraph = this.moduleGraph;
|
3608
3850
|
|
3609
3851
|
const queue = new Set([module]);
|
3852
|
+
/** @type {number} */
|
3610
3853
|
let depth;
|
3611
3854
|
|
3612
3855
|
moduleGraph.setDepth(module, 0);
|
@@ -3622,7 +3865,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3622
3865
|
|
3623
3866
|
for (module of queue) {
|
3624
3867
|
queue.delete(module);
|
3625
|
-
depth = moduleGraph.getDepth(module) + 1;
|
3868
|
+
depth = /** @type {number} */ (moduleGraph.getDepth(module)) + 1;
|
3626
3869
|
|
3627
3870
|
for (const connection of moduleGraph.getOutgoingConnections(module)) {
|
3628
3871
|
const refModule = connection.module;
|
@@ -3683,7 +3926,6 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3683
3926
|
}
|
3684
3927
|
|
3685
3928
|
/**
|
3686
|
-
*
|
3687
3929
|
* @param {Module} module module relationship for removal
|
3688
3930
|
* @param {DependenciesBlockLike} block //TODO: good description
|
3689
3931
|
* @returns {void}
|
@@ -3722,16 +3964,16 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3722
3964
|
if (!module.hasReasons(this.moduleGraph, chunk.runtime)) {
|
3723
3965
|
this.removeReasonsOfDependencyBlock(module, module);
|
3724
3966
|
}
|
3725
|
-
if (
|
3726
|
-
|
3727
|
-
|
3728
|
-
|
3729
|
-
|
3967
|
+
if (
|
3968
|
+
!module.hasReasonForChunk(chunk, this.moduleGraph, this.chunkGraph) &&
|
3969
|
+
this.chunkGraph.isModuleInChunk(module, chunk)
|
3970
|
+
) {
|
3971
|
+
this.chunkGraph.disconnectChunkAndModule(chunk, module);
|
3972
|
+
this.removeChunkFromDependencies(module, chunk);
|
3730
3973
|
}
|
3731
3974
|
}
|
3732
3975
|
|
3733
3976
|
/**
|
3734
|
-
*
|
3735
3977
|
* @param {DependenciesBlock} block block tie for Chunk
|
3736
3978
|
* @param {Chunk} chunk chunk to remove from dep
|
3737
3979
|
* @returns {void}
|
@@ -3751,7 +3993,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3751
3993
|
const blocks = block.blocks;
|
3752
3994
|
for (let indexBlock = 0; indexBlock < blocks.length; indexBlock++) {
|
3753
3995
|
const asyncBlock = blocks[indexBlock];
|
3754
|
-
const chunkGroup =
|
3996
|
+
const chunkGroup =
|
3997
|
+
/** @type {ChunkGroup} */
|
3998
|
+
(this.chunkGraph.getBlockChunkGroup(asyncBlock));
|
3755
3999
|
// Grab all chunks from the first Block's AsyncDepBlock
|
3756
4000
|
const chunks = chunkGroup.chunks;
|
3757
4001
|
// For each chunk in chunkGroup
|
@@ -3822,6 +4066,8 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3822
4066
|
let statModulesFromCache = 0;
|
3823
4067
|
const { chunkGraph, runtimeTemplate, moduleMemCaches2 } = this;
|
3824
4068
|
const { hashFunction, hashDigest, hashDigestLength } = this.outputOptions;
|
4069
|
+
/** @type {WebpackError[]} */
|
4070
|
+
const errors = [];
|
3825
4071
|
for (const module of this.modules) {
|
3826
4072
|
const memCache = moduleMemCaches2 && moduleMemCaches2.get(module);
|
3827
4073
|
for (const runtime of chunkGraph.getModuleRuntimes(module)) {
|
@@ -3832,7 +4078,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3832
4078
|
module,
|
3833
4079
|
runtime,
|
3834
4080
|
digest,
|
3835
|
-
digest.
|
4081
|
+
digest.slice(0, hashDigestLength)
|
3836
4082
|
);
|
3837
4083
|
statModulesFromCache++;
|
3838
4084
|
continue;
|
@@ -3846,13 +4092,20 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3846
4092
|
hashFunction,
|
3847
4093
|
runtimeTemplate,
|
3848
4094
|
hashDigest,
|
3849
|
-
hashDigestLength
|
4095
|
+
hashDigestLength,
|
4096
|
+
errors
|
3850
4097
|
);
|
3851
4098
|
if (memCache) {
|
3852
4099
|
memCache.set(`moduleHash-${getRuntimeKey(runtime)}`, digest);
|
3853
4100
|
}
|
3854
4101
|
}
|
3855
4102
|
}
|
4103
|
+
if (errors.length > 0) {
|
4104
|
+
errors.sort(compareSelect(err => err.module, compareModulesByIdentifier));
|
4105
|
+
for (const error of errors) {
|
4106
|
+
this.errors.push(error);
|
4107
|
+
}
|
4108
|
+
}
|
3856
4109
|
this.logger.log(
|
3857
4110
|
`${statModulesHashed} modules hashed, ${statModulesFromCache} from cache (${
|
3858
4111
|
Math.round(
|
@@ -3862,6 +4115,18 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3862
4115
|
);
|
3863
4116
|
}
|
3864
4117
|
|
4118
|
+
/**
|
4119
|
+
* @private
|
4120
|
+
* @param {Module} module module
|
4121
|
+
* @param {ChunkGraph} chunkGraph the chunk graph
|
4122
|
+
* @param {RuntimeSpec} runtime runtime
|
4123
|
+
* @param {OutputOptions["hashFunction"]} hashFunction hash function
|
4124
|
+
* @param {RuntimeTemplate} runtimeTemplate runtime template
|
4125
|
+
* @param {OutputOptions["hashDigest"]} hashDigest hash digest
|
4126
|
+
* @param {OutputOptions["hashDigestLength"]} hashDigestLength hash digest length
|
4127
|
+
* @param {WebpackError[]} errors errors
|
4128
|
+
* @returns {string} module hash digest
|
4129
|
+
*/
|
3865
4130
|
_createModuleHash(
|
3866
4131
|
module,
|
3867
4132
|
chunkGraph,
|
@@ -3869,29 +4134,34 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3869
4134
|
hashFunction,
|
3870
4135
|
runtimeTemplate,
|
3871
4136
|
hashDigest,
|
3872
|
-
hashDigestLength
|
4137
|
+
hashDigestLength,
|
4138
|
+
errors
|
3873
4139
|
) {
|
3874
|
-
|
3875
|
-
|
3876
|
-
|
3877
|
-
|
3878
|
-
|
3879
|
-
|
3880
|
-
|
3881
|
-
|
3882
|
-
|
4140
|
+
let moduleHashDigest;
|
4141
|
+
try {
|
4142
|
+
const moduleHash = createHash(hashFunction);
|
4143
|
+
module.updateHash(moduleHash, {
|
4144
|
+
chunkGraph,
|
4145
|
+
runtime,
|
4146
|
+
runtimeTemplate
|
4147
|
+
});
|
4148
|
+
moduleHashDigest = /** @type {string} */ (moduleHash.digest(hashDigest));
|
4149
|
+
} catch (err) {
|
4150
|
+
errors.push(new ModuleHashingError(module, /** @type {Error} */ (err)));
|
4151
|
+
moduleHashDigest = "XXXXXX";
|
4152
|
+
}
|
3883
4153
|
chunkGraph.setModuleHashes(
|
3884
4154
|
module,
|
3885
4155
|
runtime,
|
3886
4156
|
moduleHashDigest,
|
3887
|
-
moduleHashDigest.
|
4157
|
+
moduleHashDigest.slice(0, hashDigestLength)
|
3888
4158
|
);
|
3889
4159
|
return moduleHashDigest;
|
3890
4160
|
}
|
3891
4161
|
|
3892
4162
|
createHash() {
|
3893
4163
|
this.logger.time("hashing: initialize hash");
|
3894
|
-
const chunkGraph = this.chunkGraph;
|
4164
|
+
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
3895
4165
|
const runtimeTemplate = this.runtimeTemplate;
|
3896
4166
|
const outputOptions = this.outputOptions;
|
3897
4167
|
const hashFunction = outputOptions.hashFunction;
|
@@ -3986,7 +4256,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
3986
4256
|
for (const chunk of runtimeChunks) {
|
3987
4257
|
const hasFullHashModules =
|
3988
4258
|
chunkGraph.getNumberOfChunkFullHashModules(chunk) !== 0;
|
3989
|
-
const info =
|
4259
|
+
const info =
|
4260
|
+
/** @type {RuntimeChunkInfo} */
|
4261
|
+
(runtimeChunksMap.get(chunk));
|
3990
4262
|
for (const otherInfo of info.referencedBy) {
|
3991
4263
|
if (hasFullHashModules) {
|
3992
4264
|
chunkGraph.upgradeDependentToFullHashModules(otherInfo.chunk);
|
@@ -4006,7 +4278,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
4006
4278
|
}
|
4007
4279
|
// If there are still remaining references we have cycles and want to create a warning
|
4008
4280
|
if (remaining > 0) {
|
4009
|
-
|
4281
|
+
const circularRuntimeChunkInfo = [];
|
4010
4282
|
for (const info of runtimeChunksMap.values()) {
|
4011
4283
|
if (info.remaining !== 0) {
|
4012
4284
|
circularRuntimeChunkInfo.push(info);
|
@@ -4030,7 +4302,12 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4030
4302
|
const codeGenerationJobs = [];
|
4031
4303
|
/** @type {Map<string, Map<Module, {module: Module, hash: string, runtime: RuntimeSpec, runtimes: RuntimeSpec[]}>>} */
|
4032
4304
|
const codeGenerationJobsMap = new Map();
|
4305
|
+
/** @type {WebpackError[]} */
|
4306
|
+
const errors = [];
|
4033
4307
|
|
4308
|
+
/**
|
4309
|
+
* @param {Chunk} chunk chunk
|
4310
|
+
*/
|
4034
4311
|
const processChunk = chunk => {
|
4035
4312
|
// Last minute module hash generation for modules that depend on chunk hashes
|
4036
4313
|
this.logger.time("hashing: hash runtime modules");
|
@@ -4044,7 +4321,8 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4044
4321
|
hashFunction,
|
4045
4322
|
runtimeTemplate,
|
4046
4323
|
hashDigest,
|
4047
|
-
hashDigestLength
|
4324
|
+
hashDigestLength,
|
4325
|
+
errors
|
4048
4326
|
);
|
4049
4327
|
let hashMap = codeGenerationJobsMap.get(hash);
|
4050
4328
|
if (hashMap) {
|
@@ -4068,15 +4346,16 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4068
4346
|
}
|
4069
4347
|
}
|
4070
4348
|
this.logger.timeAggregate("hashing: hash runtime modules");
|
4071
|
-
this.logger.time("hashing: hash chunks");
|
4072
|
-
const chunkHash = createHash(hashFunction);
|
4073
4349
|
try {
|
4350
|
+
this.logger.time("hashing: hash chunks");
|
4351
|
+
const chunkHash = createHash(hashFunction);
|
4074
4352
|
if (outputOptions.hashSalt) {
|
4075
4353
|
chunkHash.update(outputOptions.hashSalt);
|
4076
4354
|
}
|
4077
4355
|
chunk.updateHash(chunkHash, chunkGraph);
|
4078
4356
|
this.hooks.chunkHash.call(chunk, chunkHash, {
|
4079
4357
|
chunkGraph,
|
4358
|
+
codeGenerationResults: this.codeGenerationResults,
|
4080
4359
|
moduleGraph: this.moduleGraph,
|
4081
4360
|
runtimeTemplate: this.runtimeTemplate
|
4082
4361
|
});
|
@@ -4085,7 +4364,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4085
4364
|
);
|
4086
4365
|
hash.update(chunkHashDigest);
|
4087
4366
|
chunk.hash = chunkHashDigest;
|
4088
|
-
chunk.renderedHash = chunk.hash.
|
4367
|
+
chunk.renderedHash = chunk.hash.slice(0, hashDigestLength);
|
4089
4368
|
const fullHashModules =
|
4090
4369
|
chunkGraph.getChunkFullHashModulesIterable(chunk);
|
4091
4370
|
if (fullHashModules) {
|
@@ -4094,24 +4373,34 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4094
4373
|
this.hooks.contentHash.call(chunk);
|
4095
4374
|
}
|
4096
4375
|
} catch (err) {
|
4097
|
-
this.errors.push(
|
4376
|
+
this.errors.push(
|
4377
|
+
new ChunkRenderError(chunk, "", /** @type {Error} */ (err))
|
4378
|
+
);
|
4098
4379
|
}
|
4099
4380
|
this.logger.timeAggregate("hashing: hash chunks");
|
4100
4381
|
};
|
4101
|
-
otherChunks
|
4382
|
+
for (const chunk of otherChunks) processChunk(chunk);
|
4102
4383
|
for (const chunk of runtimeChunks) processChunk(chunk);
|
4384
|
+
if (errors.length > 0) {
|
4385
|
+
errors.sort(compareSelect(err => err.module, compareModulesByIdentifier));
|
4386
|
+
for (const error of errors) {
|
4387
|
+
this.errors.push(error);
|
4388
|
+
}
|
4389
|
+
}
|
4103
4390
|
|
4104
4391
|
this.logger.timeAggregateEnd("hashing: hash runtime modules");
|
4105
4392
|
this.logger.timeAggregateEnd("hashing: hash chunks");
|
4106
4393
|
this.logger.time("hashing: hash digest");
|
4107
4394
|
this.hooks.fullHash.call(hash);
|
4108
4395
|
this.fullHash = /** @type {string} */ (hash.digest(hashDigest));
|
4109
|
-
this.hash = this.fullHash.
|
4396
|
+
this.hash = this.fullHash.slice(0, hashDigestLength);
|
4110
4397
|
this.logger.timeEnd("hashing: hash digest");
|
4111
4398
|
|
4112
4399
|
this.logger.time("hashing: process full hash modules");
|
4113
4400
|
for (const chunk of fullHashChunks) {
|
4114
|
-
for (const module of
|
4401
|
+
for (const module of /** @type {Iterable<RuntimeModule>} */ (
|
4402
|
+
chunkGraph.getChunkFullHashModulesIterable(chunk)
|
4403
|
+
)) {
|
4115
4404
|
const moduleHash = createHash(hashFunction);
|
4116
4405
|
module.updateHash(moduleHash, {
|
4117
4406
|
chunkGraph,
|
@@ -4126,18 +4415,18 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4126
4415
|
module,
|
4127
4416
|
chunk.runtime,
|
4128
4417
|
moduleHashDigest,
|
4129
|
-
moduleHashDigest.
|
4418
|
+
moduleHashDigest.slice(0, hashDigestLength)
|
4130
4419
|
);
|
4131
4420
|
codeGenerationJobsMap.get(oldHash).get(module).hash = moduleHashDigest;
|
4132
4421
|
}
|
4133
4422
|
const chunkHash = createHash(hashFunction);
|
4134
4423
|
chunkHash.update(chunk.hash);
|
4135
4424
|
chunkHash.update(this.hash);
|
4136
|
-
const chunkHashDigest =
|
4137
|
-
|
4138
|
-
|
4425
|
+
const chunkHashDigest =
|
4426
|
+
/** @type {string} */
|
4427
|
+
(chunkHash.digest(hashDigest));
|
4139
4428
|
chunk.hash = chunkHashDigest;
|
4140
|
-
chunk.renderedHash = chunk.hash.
|
4429
|
+
chunk.renderedHash = chunk.hash.slice(0, hashDigestLength);
|
4141
4430
|
this.hooks.contentHash.call(chunk);
|
4142
4431
|
}
|
4143
4432
|
this.logger.timeEnd("hashing: process full hash modules");
|
@@ -4155,7 +4444,11 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4155
4444
|
if (!isSourceEqual(this.assets[file], source)) {
|
4156
4445
|
this.errors.push(
|
4157
4446
|
new WebpackError(
|
4158
|
-
`Conflict: Multiple assets emit different content to the same filename ${file}
|
4447
|
+
`Conflict: Multiple assets emit different content to the same filename ${file}${
|
4448
|
+
assetInfo.sourceFilename
|
4449
|
+
? `. Original source ${assetInfo.sourceFilename}`
|
4450
|
+
: ""
|
4451
|
+
}`
|
4159
4452
|
)
|
4160
4453
|
);
|
4161
4454
|
this.assets[file] = source;
|
@@ -4163,7 +4456,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4163
4456
|
return;
|
4164
4457
|
}
|
4165
4458
|
const oldInfo = this.assetsInfo.get(file);
|
4166
|
-
const newInfo =
|
4459
|
+
const newInfo = { ...oldInfo, ...assetInfo };
|
4167
4460
|
this._setAssetInfo(file, newInfo, oldInfo);
|
4168
4461
|
return;
|
4169
4462
|
}
|
@@ -4181,6 +4474,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4181
4474
|
const newRelated = newInfo && newInfo.related;
|
4182
4475
|
if (oldRelated) {
|
4183
4476
|
for (const key of Object.keys(oldRelated)) {
|
4477
|
+
/**
|
4478
|
+
* @param {string} name name
|
4479
|
+
*/
|
4184
4480
|
const remove = name => {
|
4185
4481
|
const relatedIn = this._assetsRelatedIn.get(name);
|
4186
4482
|
if (relatedIn === undefined) return;
|
@@ -4193,7 +4489,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4193
4489
|
};
|
4194
4490
|
const entry = oldRelated[key];
|
4195
4491
|
if (Array.isArray(entry)) {
|
4196
|
-
entry
|
4492
|
+
for (const name of entry) {
|
4493
|
+
remove(name);
|
4494
|
+
}
|
4197
4495
|
} else if (entry) {
|
4198
4496
|
remove(entry);
|
4199
4497
|
}
|
@@ -4201,6 +4499,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4201
4499
|
}
|
4202
4500
|
if (newRelated) {
|
4203
4501
|
for (const key of Object.keys(newRelated)) {
|
4502
|
+
/**
|
4503
|
+
* @param {string} name name
|
4504
|
+
*/
|
4204
4505
|
const add = name => {
|
4205
4506
|
let relatedIn = this._assetsRelatedIn.get(name);
|
4206
4507
|
if (relatedIn === undefined) {
|
@@ -4214,7 +4515,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4214
4515
|
};
|
4215
4516
|
const entry = newRelated[key];
|
4216
4517
|
if (Array.isArray(entry)) {
|
4217
|
-
entry
|
4518
|
+
for (const name of entry) {
|
4519
|
+
add(name);
|
4520
|
+
}
|
4218
4521
|
} else if (entry) {
|
4219
4522
|
add(entry);
|
4220
4523
|
}
|
@@ -4225,7 +4528,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4225
4528
|
/**
|
4226
4529
|
* @param {string} file file name
|
4227
4530
|
* @param {Source | function(Source): Source} newSourceOrFunction new asset source or function converting old to new
|
4228
|
-
* @param {AssetInfo | function(AssetInfo | undefined): AssetInfo} assetInfoUpdateOrFunction new asset info or function converting old to new
|
4531
|
+
* @param {(AssetInfo | function(AssetInfo | undefined): AssetInfo) | undefined} assetInfoUpdateOrFunction new asset info or function converting old to new
|
4229
4532
|
*/
|
4230
4533
|
updateAsset(
|
4231
4534
|
file,
|
@@ -4237,11 +4540,10 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4237
4540
|
`Called Compilation.updateAsset for not existing filename ${file}`
|
4238
4541
|
);
|
4239
4542
|
}
|
4240
|
-
|
4241
|
-
|
4242
|
-
|
4243
|
-
|
4244
|
-
}
|
4543
|
+
this.assets[file] =
|
4544
|
+
typeof newSourceOrFunction === "function"
|
4545
|
+
? newSourceOrFunction(this.assets[file])
|
4546
|
+
: newSourceOrFunction;
|
4245
4547
|
if (assetInfoUpdateOrFunction !== undefined) {
|
4246
4548
|
const oldInfo = this.assetsInfo.get(file) || EMPTY_ASSET_INFO;
|
4247
4549
|
if (typeof assetInfoUpdateOrFunction === "function") {
|
@@ -4256,6 +4558,10 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4256
4558
|
}
|
4257
4559
|
}
|
4258
4560
|
|
4561
|
+
/**
|
4562
|
+
* @param {string} file file name
|
4563
|
+
* @param {string} newFile the new name of file
|
4564
|
+
*/
|
4259
4565
|
renameAsset(file, newFile) {
|
4260
4566
|
const source = this.assets[file];
|
4261
4567
|
if (!source) {
|
@@ -4263,14 +4569,12 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4263
4569
|
`Called Compilation.renameAsset for not existing filename ${file}`
|
4264
4570
|
);
|
4265
4571
|
}
|
4266
|
-
if (this.assets[newFile]) {
|
4267
|
-
|
4268
|
-
|
4269
|
-
|
4270
|
-
|
4271
|
-
|
4272
|
-
);
|
4273
|
-
}
|
4572
|
+
if (this.assets[newFile] && !isSourceEqual(this.assets[file], source)) {
|
4573
|
+
this.errors.push(
|
4574
|
+
new WebpackError(
|
4575
|
+
`Conflict: Called Compilation.renameAsset for already existing filename ${newFile} with different content`
|
4576
|
+
)
|
4577
|
+
);
|
4274
4578
|
}
|
4275
4579
|
const assetInfo = this.assetsInfo.get(file);
|
4276
4580
|
// Update related in all other assets
|
@@ -4334,6 +4638,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4334
4638
|
const related = assetInfo && assetInfo.related;
|
4335
4639
|
if (related) {
|
4336
4640
|
for (const key of Object.keys(related)) {
|
4641
|
+
/**
|
4642
|
+
* @param {string} file file
|
4643
|
+
*/
|
4337
4644
|
const checkUsedAndDelete = file => {
|
4338
4645
|
if (!this._assetsRelatedIn.has(file)) {
|
4339
4646
|
this.deleteAsset(file);
|
@@ -4341,7 +4648,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4341
4648
|
};
|
4342
4649
|
const items = related[key];
|
4343
4650
|
if (Array.isArray(items)) {
|
4344
|
-
items
|
4651
|
+
for (const file of items) {
|
4652
|
+
checkUsedAndDelete(file);
|
4653
|
+
}
|
4345
4654
|
} else if (items) {
|
4346
4655
|
checkUsedAndDelete(items);
|
4347
4656
|
}
|
@@ -4375,8 +4684,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4375
4684
|
* @returns {Readonly<Asset> | undefined} the asset or undefined when not found
|
4376
4685
|
*/
|
4377
4686
|
getAsset(name) {
|
4378
|
-
if (!Object.prototype.hasOwnProperty.call(this.assets, name))
|
4379
|
-
return undefined;
|
4687
|
+
if (!Object.prototype.hasOwnProperty.call(this.assets, name)) return;
|
4380
4688
|
return {
|
4381
4689
|
name,
|
4382
4690
|
source: this.assets[name],
|
@@ -4394,9 +4702,10 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4394
4702
|
createModuleAssets() {
|
4395
4703
|
const { chunkGraph } = this;
|
4396
4704
|
for (const module of this.modules) {
|
4397
|
-
|
4398
|
-
|
4399
|
-
|
4705
|
+
const buildInfo = /** @type {BuildInfo} */ (module.buildInfo);
|
4706
|
+
if (buildInfo.assets) {
|
4707
|
+
const assetsInfo = buildInfo.assetsInfo;
|
4708
|
+
for (const assetName of Object.keys(buildInfo.assets)) {
|
4400
4709
|
const fileName = this.getPath(assetName, {
|
4401
4710
|
chunkGraph: this.chunkGraph,
|
4402
4711
|
module
|
@@ -4406,7 +4715,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4406
4715
|
}
|
4407
4716
|
this.emitAsset(
|
4408
4717
|
fileName,
|
4409
|
-
|
4718
|
+
buildInfo.assets[assetName],
|
4410
4719
|
assetsInfo ? assetsInfo.get(assetName) : undefined
|
4411
4720
|
);
|
4412
4721
|
this.hooks.moduleAsset.call(module, fileName);
|
@@ -4453,10 +4762,12 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4453
4762
|
runtimeTemplate: this.runtimeTemplate
|
4454
4763
|
});
|
4455
4764
|
} catch (err) {
|
4456
|
-
this.errors.push(
|
4765
|
+
this.errors.push(
|
4766
|
+
new ChunkRenderError(chunk, "", /** @type {Error} */ (err))
|
4767
|
+
);
|
4457
4768
|
return callback();
|
4458
4769
|
}
|
4459
|
-
asyncLib.
|
4770
|
+
asyncLib.each(
|
4460
4771
|
manifest,
|
4461
4772
|
(fileManifest, callback) => {
|
4462
4773
|
const ident = fileManifest.identifier;
|
@@ -4468,7 +4779,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4468
4779
|
);
|
4469
4780
|
|
4470
4781
|
assetCacheItem.get((err, sourceFromCache) => {
|
4471
|
-
/** @type {
|
4782
|
+
/** @type {TemplatePath} */
|
4472
4783
|
let filenameTemplate;
|
4473
4784
|
/** @type {string} */
|
4474
4785
|
let file;
|
@@ -4476,14 +4787,18 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4476
4787
|
let assetInfo;
|
4477
4788
|
|
4478
4789
|
let inTry = true;
|
4790
|
+
/**
|
4791
|
+
* @param {Error} err error
|
4792
|
+
* @returns {void}
|
4793
|
+
*/
|
4479
4794
|
const errorAndCallback = err => {
|
4480
4795
|
const filename =
|
4481
4796
|
file ||
|
4482
4797
|
(typeof file === "string"
|
4483
4798
|
? file
|
4484
4799
|
: typeof filenameTemplate === "string"
|
4485
|
-
|
4486
|
-
|
4800
|
+
? filenameTemplate
|
4801
|
+
: "");
|
4487
4802
|
|
4488
4803
|
this.errors.push(new ChunkRenderError(chunk, filename, err));
|
4489
4804
|
inTry = false;
|
@@ -4505,7 +4820,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4505
4820
|
? {
|
4506
4821
|
...pathAndInfo.info,
|
4507
4822
|
...fileManifest.info
|
4508
|
-
|
4823
|
+
}
|
4509
4824
|
: pathAndInfo.info;
|
4510
4825
|
}
|
4511
4826
|
|
@@ -4526,9 +4841,8 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4526
4841
|
` (chunks ${alreadyWritten.chunk.id} and ${chunk.id})`
|
4527
4842
|
)
|
4528
4843
|
);
|
4529
|
-
} else {
|
4530
|
-
source = alreadyWritten.source;
|
4531
4844
|
}
|
4845
|
+
source = alreadyWritten.source;
|
4532
4846
|
} else if (!source) {
|
4533
4847
|
// render the asset
|
4534
4848
|
source = fileManifest.render();
|
@@ -4569,7 +4883,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4569
4883
|
}
|
4570
4884
|
} catch (err) {
|
4571
4885
|
if (!inTry) throw err;
|
4572
|
-
errorAndCallback(err);
|
4886
|
+
errorAndCallback(/** @type {Error} */ (err));
|
4573
4887
|
}
|
4574
4888
|
});
|
4575
4889
|
},
|
@@ -4581,7 +4895,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4581
4895
|
}
|
4582
4896
|
|
4583
4897
|
/**
|
4584
|
-
* @param {
|
4898
|
+
* @param {TemplatePath} filename used to get asset path with hash
|
4585
4899
|
* @param {PathData} data context data
|
4586
4900
|
* @returns {string} interpolated path
|
4587
4901
|
*/
|
@@ -4596,9 +4910,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4596
4910
|
}
|
4597
4911
|
|
4598
4912
|
/**
|
4599
|
-
* @param {
|
4913
|
+
* @param {TemplatePath} filename used to get asset path with hash
|
4600
4914
|
* @param {PathData} data context data
|
4601
|
-
* @returns {
|
4915
|
+
* @returns {InterpolatedPathAndAssetInfo} interpolated path and asset info
|
4602
4916
|
*/
|
4603
4917
|
getPathWithInfo(filename, data = {}) {
|
4604
4918
|
if (!data.hash) {
|
@@ -4611,7 +4925,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4611
4925
|
}
|
4612
4926
|
|
4613
4927
|
/**
|
4614
|
-
* @param {
|
4928
|
+
* @param {TemplatePath} filename used to get asset path with hash
|
4615
4929
|
* @param {PathData} data context data
|
4616
4930
|
* @returns {string} interpolated path
|
4617
4931
|
*/
|
@@ -4624,9 +4938,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4624
4938
|
}
|
4625
4939
|
|
4626
4940
|
/**
|
4627
|
-
* @param {
|
4941
|
+
* @param {TemplatePath} filename used to get asset path with hash
|
4628
4942
|
* @param {PathData} data context data
|
4629
|
-
* @returns {
|
4943
|
+
* @returns {InterpolatedPathAndAssetInfo} interpolated path and asset info
|
4630
4944
|
*/
|
4631
4945
|
getAssetPathWithInfo(filename, data) {
|
4632
4946
|
const assetInfo = {};
|
@@ -4651,7 +4965,6 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4651
4965
|
* This function allows you to run another instance of webpack inside of webpack however as
|
4652
4966
|
* a child with different settings and configurations (if desired) applied. It copies all hooks, plugins
|
4653
4967
|
* from parent (or top level compiler) and creates a child Compilation
|
4654
|
-
*
|
4655
4968
|
* @param {string} name name of the child compiler
|
4656
4969
|
* @param {OutputOptions=} outputOptions // Need to convert config schema to types for this
|
4657
4970
|
* @param {Array<WebpackPluginInstance | WebpackPluginFunction>=} plugins webpack plugins that will be applied
|
@@ -4680,12 +4993,6 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4680
4993
|
processAsyncTree(
|
4681
4994
|
modules,
|
4682
4995
|
10,
|
4683
|
-
/**
|
4684
|
-
* @param {Module} module the module
|
4685
|
-
* @param {function(Module): void} push push more jobs
|
4686
|
-
* @param {Callback} callback callback
|
4687
|
-
* @returns {void}
|
4688
|
-
*/
|
4689
4996
|
(module, push, callback) => {
|
4690
4997
|
this.buildQueue.waitFor(module, err => {
|
4691
4998
|
if (err) return callback(err);
|
@@ -4703,7 +5010,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4703
5010
|
});
|
4704
5011
|
},
|
4705
5012
|
err => {
|
4706
|
-
if (err) return callback(err);
|
5013
|
+
if (err) return callback(/** @type {WebpackError} */ (err));
|
4707
5014
|
|
4708
5015
|
// Create new chunk graph, chunk and entrypoint for the build time execution
|
4709
5016
|
const chunkGraph = new ChunkGraph(
|
@@ -4715,8 +5022,8 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4715
5022
|
this.outputOptions;
|
4716
5023
|
const runtimeTemplate = this.runtimeTemplate;
|
4717
5024
|
|
4718
|
-
const chunk = new Chunk("build time chunk");
|
4719
|
-
chunk.id = chunk.name;
|
5025
|
+
const chunk = new Chunk("build time chunk", this._backCompat);
|
5026
|
+
chunk.id = /** @type {ChunkId} */ (chunk.name);
|
4720
5027
|
chunk.ids = [chunk.id];
|
4721
5028
|
chunk.runtime = runtime;
|
4722
5029
|
|
@@ -4739,6 +5046,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4739
5046
|
chunkGraph.connectChunkAndModule(chunk, module);
|
4740
5047
|
}
|
4741
5048
|
|
5049
|
+
/** @type {WebpackError[]} */
|
5050
|
+
const errors = [];
|
5051
|
+
|
4742
5052
|
// Hash modules
|
4743
5053
|
for (const module of modules) {
|
4744
5054
|
this._createModuleHash(
|
@@ -4748,15 +5058,14 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4748
5058
|
hashFunction,
|
4749
5059
|
runtimeTemplate,
|
4750
5060
|
hashDigest,
|
4751
|
-
hashDigestLength
|
5061
|
+
hashDigestLength,
|
5062
|
+
errors
|
4752
5063
|
);
|
4753
5064
|
}
|
4754
5065
|
|
4755
5066
|
const codeGenerationResults = new CodeGenerationResults(
|
4756
5067
|
this.outputOptions.hashFunction
|
4757
5068
|
);
|
4758
|
-
/** @type {WebpackError[]} */
|
4759
|
-
const errors = [];
|
4760
5069
|
/**
|
4761
5070
|
* @param {Module} module the module
|
4762
5071
|
* @param {Callback} callback callback
|
@@ -4823,7 +5132,8 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4823
5132
|
hashFunction,
|
4824
5133
|
runtimeTemplate,
|
4825
5134
|
hashDigest,
|
4826
|
-
hashDigestLength
|
5135
|
+
hashDigestLength,
|
5136
|
+
errors
|
4827
5137
|
);
|
4828
5138
|
}
|
4829
5139
|
|
@@ -4883,7 +5193,10 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4883
5193
|
missingDependencies,
|
4884
5194
|
buildDependencies
|
4885
5195
|
);
|
4886
|
-
if (
|
5196
|
+
if (
|
5197
|
+
/** @type {BuildInfo} */ (module.buildInfo).cacheable ===
|
5198
|
+
false
|
5199
|
+
) {
|
4887
5200
|
cacheable = false;
|
4888
5201
|
}
|
4889
5202
|
if (module.buildInfo && module.buildInfo.assets) {
|
@@ -4921,13 +5234,13 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4921
5234
|
};
|
4922
5235
|
const interceptModuleExecution = (__webpack_require__[
|
4923
5236
|
RuntimeGlobals.interceptModuleExecution.replace(
|
4924
|
-
|
5237
|
+
`${RuntimeGlobals.require}.`,
|
4925
5238
|
""
|
4926
5239
|
)
|
4927
5240
|
] = []);
|
4928
5241
|
const moduleCache = (__webpack_require__[
|
4929
5242
|
RuntimeGlobals.moduleCache.replace(
|
4930
|
-
|
5243
|
+
`${RuntimeGlobals.require}.`,
|
4931
5244
|
""
|
4932
5245
|
)
|
4933
5246
|
] = {});
|
@@ -4940,7 +5253,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4940
5253
|
* @returns {any} exports
|
4941
5254
|
*/
|
4942
5255
|
const __webpack_require_module__ = (moduleArgument, id) => {
|
4943
|
-
|
5256
|
+
const execOptions = {
|
4944
5257
|
id,
|
4945
5258
|
module: {
|
4946
5259
|
id,
|
@@ -4950,9 +5263,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4950
5263
|
},
|
4951
5264
|
require: __webpack_require__
|
4952
5265
|
};
|
4953
|
-
|
4954
|
-
handler(execOptions)
|
4955
|
-
|
5266
|
+
for (const handler of interceptModuleExecution) {
|
5267
|
+
handler(execOptions);
|
5268
|
+
}
|
4956
5269
|
const module = moduleArgument.module;
|
4957
5270
|
this.buildTimeExecutedModules.add(module);
|
4958
5271
|
const moduleObject = execOptions.module;
|
@@ -4970,14 +5283,14 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4970
5283
|
);
|
4971
5284
|
moduleObject.loaded = true;
|
4972
5285
|
return moduleObject.exports;
|
4973
|
-
} catch (
|
5286
|
+
} catch (execErr) {
|
4974
5287
|
if (strictModuleExceptionHandling) {
|
4975
5288
|
if (id) delete moduleCache[id];
|
4976
5289
|
} else if (strictModuleErrorHandling) {
|
4977
|
-
moduleObject.error =
|
5290
|
+
moduleObject.error = execErr;
|
4978
5291
|
}
|
4979
|
-
if (!
|
4980
|
-
throw
|
5292
|
+
if (!execErr.module) execErr.module = module;
|
5293
|
+
throw execErr;
|
4981
5294
|
}
|
4982
5295
|
};
|
4983
5296
|
|
@@ -4985,18 +5298,19 @@ This prevents using hashes of each other and should be avoided.`);
|
|
4985
5298
|
chunk
|
4986
5299
|
)) {
|
4987
5300
|
__webpack_require_module__(
|
4988
|
-
|
5301
|
+
/** @type {ExecuteModuleArgument} */
|
5302
|
+
(moduleArgumentsMap.get(runtimeModule))
|
4989
5303
|
);
|
4990
5304
|
}
|
4991
5305
|
exports = __webpack_require__(module.identifier());
|
4992
|
-
} catch (
|
5306
|
+
} catch (execErr) {
|
4993
5307
|
const err = new WebpackError(
|
4994
5308
|
`Execution of module code from module graph (${module.readableIdentifier(
|
4995
5309
|
this.requestShortener
|
4996
|
-
)}) failed: ${
|
5310
|
+
)}) failed: ${execErr.message}`
|
4997
5311
|
);
|
4998
|
-
err.stack =
|
4999
|
-
err.module =
|
5312
|
+
err.stack = execErr.stack;
|
5313
|
+
err.module = execErr.module;
|
5000
5314
|
return callback(err);
|
5001
5315
|
}
|
5002
5316
|
|
@@ -5024,7 +5338,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
5024
5338
|
const usedIds = new Set();
|
5025
5339
|
|
5026
5340
|
for (const module of this.modules) {
|
5027
|
-
if (module.type ===
|
5341
|
+
if (module.type === WEBPACK_MODULE_TYPE_RUNTIME) continue;
|
5028
5342
|
const moduleId = chunkGraph.getModuleId(module);
|
5029
5343
|
if (moduleId === null) continue;
|
5030
5344
|
if (usedIds.has(moduleId)) {
|
@@ -5059,7 +5373,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|
5059
5373
|
}
|
5060
5374
|
|
5061
5375
|
/**
|
5062
|
-
* @typedef {
|
5376
|
+
* @typedef {object} FactorizeModuleOptions
|
5063
5377
|
* @property {ModuleProfile} currentProfile
|
5064
5378
|
* @property {ModuleFactory} factory
|
5065
5379
|
* @property {Dependency[]} dependencies
|
@@ -5076,7 +5390,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|
5076
5390
|
*/
|
5077
5391
|
|
5078
5392
|
// Workaround for typescript as it doesn't support function overloading in jsdoc within a class
|
5079
|
-
|
5393
|
+
/* eslint-disable jsdoc/require-asterisk-prefix */
|
5394
|
+
Compilation.prototype.factorizeModule = /**
|
5395
|
+
@type {{
|
5080
5396
|
(options: FactorizeModuleOptions & { factoryResult?: false }, callback: ModuleCallback): void;
|
5081
5397
|
(options: FactorizeModuleOptions & { factoryResult: true }, callback: ModuleFactoryResultCallback): void;
|
5082
5398
|
}} */ (
|
@@ -5084,6 +5400,7 @@ Compilation.prototype.factorizeModule = /** @type {{
|
|
5084
5400
|
this.factorizeQueue.add(options, callback);
|
5085
5401
|
}
|
5086
5402
|
);
|
5403
|
+
/* eslint-enable jsdoc/require-asterisk-prefix */
|
5087
5404
|
|
5088
5405
|
// Hide from typescript
|
5089
5406
|
const compilationPrototype = Compilation.prototype;
|
@@ -5116,6 +5433,9 @@ Object.defineProperty(compilationPrototype, "cache", {
|
|
5116
5433
|
"DEP_WEBPACK_COMPILATION_CACHE"
|
5117
5434
|
),
|
5118
5435
|
set: util.deprecate(
|
5436
|
+
/**
|
5437
|
+
* @param {any} v value
|
5438
|
+
*/
|
5119
5439
|
v => {},
|
5120
5440
|
"Compilation.cache was removed in favor of Compilation.getCache()",
|
5121
5441
|
"DEP_WEBPACK_COMPILATION_CACHE"
|