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/NormalModule.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
const parseJson = require("json-parse-better-errors");
|
8
|
+
const parseJson = require("json-parse-even-better-errors");
|
9
9
|
const { getContext, runLoaders } = require("loader-runner");
|
10
10
|
const querystring = require("querystring");
|
11
11
|
const { HookMap, SyncHook, AsyncSeriesBailHook } = require("tapable");
|
@@ -22,6 +22,7 @@ const ModuleBuildError = require("./ModuleBuildError");
|
|
22
22
|
const ModuleError = require("./ModuleError");
|
23
23
|
const ModuleGraphConnection = require("./ModuleGraphConnection");
|
24
24
|
const ModuleParseError = require("./ModuleParseError");
|
25
|
+
const { JAVASCRIPT_MODULE_TYPE_AUTO } = require("./ModuleTypeConstants");
|
25
26
|
const ModuleWarning = require("./ModuleWarning");
|
26
27
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
27
28
|
const UnhandledSchemeError = require("./UnhandledSchemeError");
|
@@ -48,33 +49,62 @@ const makeSerializable = require("./util/makeSerializable");
|
|
48
49
|
const memoize = require("./util/memoize");
|
49
50
|
|
50
51
|
/** @typedef {import("webpack-sources").Source} Source */
|
51
|
-
/** @typedef {import("../declarations/LoaderContext").NormalModuleLoaderContext} NormalModuleLoaderContext */
|
52
52
|
/** @typedef {import("../declarations/WebpackOptions").Mode} Mode */
|
53
|
+
/** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
|
53
54
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
54
55
|
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
55
56
|
/** @typedef {import("./Compiler")} Compiler */
|
56
57
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
57
58
|
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
58
59
|
/** @typedef {import("./Generator")} Generator */
|
60
|
+
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
61
|
+
/** @typedef {import("./Module").BuildMeta} BuildMeta */
|
59
62
|
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
60
63
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
61
64
|
/** @typedef {import("./Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
65
|
+
/** @typedef {import("./Module").KnownBuildInfo} KnownBuildInfo */
|
62
66
|
/** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
|
63
67
|
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
|
68
|
+
/** @typedef {import("./Module").SourceTypes} SourceTypes */
|
69
|
+
/** @typedef {import("./Module").UnsafeCacheData} UnsafeCacheData */
|
64
70
|
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
65
71
|
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
72
|
+
/** @typedef {import("./ModuleTypeConstants").JavaScriptModuleTypes} JavaScriptModuleTypes */
|
66
73
|
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
|
67
74
|
/** @typedef {import("./Parser")} Parser */
|
68
75
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
76
|
+
/** @typedef {import("./ResolverFactory").ResolveContext} ResolveContext */
|
69
77
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
70
78
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
71
79
|
/** @typedef {import("./logging/Logger").Logger} WebpackLogger */
|
80
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
81
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
72
82
|
/** @typedef {import("./util/Hash")} Hash */
|
73
83
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
74
84
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
85
|
+
/** @typedef {import("./util/createHash").Algorithm} Algorithm */
|
86
|
+
/**
|
87
|
+
* @template T
|
88
|
+
* @typedef {import("./util/deprecation").FakeHook<T>} FakeHook
|
89
|
+
*/
|
90
|
+
|
91
|
+
/** @typedef {{[k: string]: any}} ParserOptions */
|
92
|
+
/** @typedef {{[k: string]: any}} GeneratorOptions */
|
93
|
+
|
94
|
+
/** @typedef {UnsafeCacheData & { parser: undefined | Parser, parserOptions: undefined | ParserOptions, generator: undefined | Generator, generatorOptions: undefined | GeneratorOptions }} NormalModuleUnsafeCacheData */
|
75
95
|
|
76
96
|
/**
|
77
|
-
* @
|
97
|
+
* @template T
|
98
|
+
* @typedef {import("../declarations/LoaderContext").LoaderContext<T>} LoaderContext
|
99
|
+
*/
|
100
|
+
|
101
|
+
/**
|
102
|
+
* @template T
|
103
|
+
* @typedef {import("../declarations/LoaderContext").NormalModuleLoaderContext<T>} NormalModuleLoaderContext
|
104
|
+
*/
|
105
|
+
|
106
|
+
/**
|
107
|
+
* @typedef {object} SourceMap
|
78
108
|
* @property {number} version
|
79
109
|
* @property {string[]} sources
|
80
110
|
* @property {string} mappings
|
@@ -92,7 +122,7 @@ const getValidate = memoize(() => require("schema-utils").validate);
|
|
92
122
|
const ABSOLUTE_PATH_REGEX = /^([a-zA-Z]:\\|\\\\|\/)/;
|
93
123
|
|
94
124
|
/**
|
95
|
-
* @typedef {
|
125
|
+
* @typedef {object} LoaderItem
|
96
126
|
* @property {string} loader
|
97
127
|
* @property {any} options
|
98
128
|
* @property {string?} ident
|
@@ -102,7 +132,7 @@ const ABSOLUTE_PATH_REGEX = /^([a-zA-Z]:\\|\\\\|\/)/;
|
|
102
132
|
/**
|
103
133
|
* @param {string} context absolute context path
|
104
134
|
* @param {string} source a source path
|
105
|
-
* @param {
|
135
|
+
* @param {object=} associatedObjectForCache an object to which the cache will be attached
|
106
136
|
* @returns {string} new source path
|
107
137
|
*/
|
108
138
|
const contextifySourceUrl = (context, source, associatedObjectForCache) => {
|
@@ -117,7 +147,7 @@ const contextifySourceUrl = (context, source, associatedObjectForCache) => {
|
|
117
147
|
/**
|
118
148
|
* @param {string} context absolute context path
|
119
149
|
* @param {SourceMap} sourceMap a source map
|
120
|
-
* @param {
|
150
|
+
* @param {object=} associatedObjectForCache an object to which the cache will be attached
|
121
151
|
* @returns {SourceMap} new source map
|
122
152
|
*/
|
123
153
|
const contextifySourceMap = (context, sourceMap, associatedObjectForCache) => {
|
@@ -127,14 +157,14 @@ const contextifySourceMap = (context, sourceMap, associatedObjectForCache) => {
|
|
127
157
|
const mapper = !sourceRoot
|
128
158
|
? source => source
|
129
159
|
: sourceRoot.endsWith("/")
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
160
|
+
? source =>
|
161
|
+
source.startsWith("/")
|
162
|
+
? `${sourceRoot.slice(0, -1)}${source}`
|
163
|
+
: `${sourceRoot}${source}`
|
164
|
+
: source =>
|
165
|
+
source.startsWith("/")
|
166
|
+
? `${sourceRoot}${source}`
|
167
|
+
: `${sourceRoot}/${source}`;
|
138
168
|
const newSources = sourceMap.sources.map(source =>
|
139
169
|
contextifySourceUrl(context, mapper(source), associatedObjectForCache)
|
140
170
|
);
|
@@ -169,11 +199,14 @@ const asBuffer = input => {
|
|
169
199
|
};
|
170
200
|
|
171
201
|
class NonErrorEmittedError extends WebpackError {
|
202
|
+
/**
|
203
|
+
* @param {any} error value which is not an instance of Error
|
204
|
+
*/
|
172
205
|
constructor(error) {
|
173
206
|
super();
|
174
207
|
|
175
208
|
this.name = "NonErrorEmittedError";
|
176
|
-
this.message =
|
209
|
+
this.message = `(Emitted value instead of an instance of Error) ${error}`;
|
177
210
|
}
|
178
211
|
}
|
179
212
|
|
@@ -184,16 +217,35 @@ makeSerializable(
|
|
184
217
|
);
|
185
218
|
|
186
219
|
/**
|
187
|
-
* @typedef {
|
188
|
-
* @property {SyncHook<[
|
189
|
-
* @property {SyncHook<[LoaderItem[], NormalModule,
|
220
|
+
* @typedef {object} NormalModuleCompilationHooks
|
221
|
+
* @property {SyncHook<[LoaderContext<any>, NormalModule]>} loader
|
222
|
+
* @property {SyncHook<[LoaderItem[], NormalModule, LoaderContext<any>]>} beforeLoaders
|
190
223
|
* @property {SyncHook<[NormalModule]>} beforeParse
|
191
224
|
* @property {SyncHook<[NormalModule]>} beforeSnapshot
|
192
|
-
* @property {HookMap<AsyncSeriesBailHook<[string, NormalModule], string | Buffer
|
193
|
-
* @property {HookMap<AsyncSeriesBailHook<[
|
225
|
+
* @property {HookMap<FakeHook<AsyncSeriesBailHook<[string, NormalModule], string | Buffer | null>>>} readResourceForScheme
|
226
|
+
* @property {HookMap<AsyncSeriesBailHook<[LoaderContext<any>], string | Buffer | null>>} readResource
|
194
227
|
* @property {AsyncSeriesBailHook<[NormalModule, NeedBuildContext], boolean>} needBuild
|
195
228
|
*/
|
196
229
|
|
230
|
+
/**
|
231
|
+
* @typedef {object} NormalModuleCreateData
|
232
|
+
* @property {string=} layer an optional layer in which the module is
|
233
|
+
* @property {JavaScriptModuleTypes | ""} type module type. When deserializing, this is set to an empty string "".
|
234
|
+
* @property {string} request request string
|
235
|
+
* @property {string} userRequest request intended by user (without loaders from config)
|
236
|
+
* @property {string} rawRequest request without resolving
|
237
|
+
* @property {LoaderItem[]} loaders list of loaders
|
238
|
+
* @property {string} resource path + query of the real resource
|
239
|
+
* @property {Record<string, any>=} resourceResolveData resource resolve data
|
240
|
+
* @property {string} context context directory for resolving
|
241
|
+
* @property {string=} matchResource path + query of the matched resource (virtual)
|
242
|
+
* @property {Parser} parser the parser used
|
243
|
+
* @property {ParserOptions=} parserOptions the options of the parser used
|
244
|
+
* @property {Generator} generator the generator used
|
245
|
+
* @property {GeneratorOptions=} generatorOptions the options of the generator used
|
246
|
+
* @property {ResolveOptions=} resolveOptions options used for resolving requests from this module
|
247
|
+
*/
|
248
|
+
|
197
249
|
/** @type {WeakMap<Compilation, NormalModuleCompilationHooks>} */
|
198
250
|
const compilationHooksMap = new WeakMap();
|
199
251
|
|
@@ -217,20 +269,32 @@ class NormalModule extends Module {
|
|
217
269
|
beforeSnapshot: new SyncHook(["module"]),
|
218
270
|
// TODO webpack 6 deprecate
|
219
271
|
readResourceForScheme: new HookMap(scheme => {
|
220
|
-
const hook =
|
272
|
+
const hook =
|
273
|
+
/** @type {NormalModuleCompilationHooks} */
|
274
|
+
(hooks).readResource.for(scheme);
|
221
275
|
return createFakeHook(
|
222
|
-
/** @type {AsyncSeriesBailHook<[string, NormalModule], string | Buffer>} */ ({
|
276
|
+
/** @type {AsyncSeriesBailHook<[string, NormalModule], string | Buffer | null>} */ ({
|
223
277
|
tap: (options, fn) =>
|
224
278
|
hook.tap(options, loaderContext =>
|
225
|
-
fn(
|
279
|
+
fn(
|
280
|
+
loaderContext.resource,
|
281
|
+
/** @type {NormalModule} */ (loaderContext._module)
|
282
|
+
)
|
226
283
|
),
|
227
284
|
tapAsync: (options, fn) =>
|
228
285
|
hook.tapAsync(options, (loaderContext, callback) =>
|
229
|
-
fn(
|
286
|
+
fn(
|
287
|
+
loaderContext.resource,
|
288
|
+
/** @type {NormalModule} */ (loaderContext._module),
|
289
|
+
callback
|
290
|
+
)
|
230
291
|
),
|
231
292
|
tapPromise: (options, fn) =>
|
232
293
|
hook.tapPromise(options, loaderContext =>
|
233
|
-
fn(
|
294
|
+
fn(
|
295
|
+
loaderContext.resource,
|
296
|
+
/** @type {NormalModule} */ (loaderContext._module)
|
297
|
+
)
|
234
298
|
)
|
235
299
|
})
|
236
300
|
);
|
@@ -240,28 +304,16 @@ class NormalModule extends Module {
|
|
240
304
|
),
|
241
305
|
needBuild: new AsyncSeriesBailHook(["module", "context"])
|
242
306
|
};
|
243
|
-
compilationHooksMap.set(
|
307
|
+
compilationHooksMap.set(
|
308
|
+
compilation,
|
309
|
+
/** @type {NormalModuleCompilationHooks} */ (hooks)
|
310
|
+
);
|
244
311
|
}
|
245
|
-
return hooks;
|
312
|
+
return /** @type {NormalModuleCompilationHooks} */ (hooks);
|
246
313
|
}
|
247
314
|
|
248
315
|
/**
|
249
|
-
* @param {
|
250
|
-
* @param {string=} options.layer an optional layer in which the module is
|
251
|
-
* @param {string} options.type module type
|
252
|
-
* @param {string} options.request request string
|
253
|
-
* @param {string} options.userRequest request intended by user (without loaders from config)
|
254
|
-
* @param {string} options.rawRequest request without resolving
|
255
|
-
* @param {LoaderItem[]} options.loaders list of loaders
|
256
|
-
* @param {string} options.resource path + query of the real resource
|
257
|
-
* @param {Record<string, any>=} options.resourceResolveData resource resolve data
|
258
|
-
* @param {string} options.context context directory for resolving
|
259
|
-
* @param {string | undefined} options.matchResource path + query of the matched resource (virtual)
|
260
|
-
* @param {Parser} options.parser the parser used
|
261
|
-
* @param {object} options.parserOptions the options of the parser used
|
262
|
-
* @param {Generator} options.generator the generator used
|
263
|
-
* @param {object} options.generatorOptions the options of the generator used
|
264
|
-
* @param {Object} options.resolveOptions options used for resolving requests from this module
|
316
|
+
* @param {NormalModuleCreateData} options options object
|
265
317
|
*/
|
266
318
|
constructor({
|
267
319
|
layer,
|
@@ -291,11 +343,13 @@ class NormalModule extends Module {
|
|
291
343
|
this.rawRequest = rawRequest;
|
292
344
|
/** @type {boolean} */
|
293
345
|
this.binary = /^(asset|webassembly)\b/.test(type);
|
294
|
-
/** @type {Parser} */
|
346
|
+
/** @type {undefined | Parser} */
|
295
347
|
this.parser = parser;
|
348
|
+
/** @type {undefined | ParserOptions} */
|
296
349
|
this.parserOptions = parserOptions;
|
297
|
-
/** @type {Generator} */
|
350
|
+
/** @type {undefined | Generator} */
|
298
351
|
this.generator = generator;
|
352
|
+
/** @type {undefined | GeneratorOptions} */
|
299
353
|
this.generatorOptions = generatorOptions;
|
300
354
|
/** @type {string} */
|
301
355
|
this.resource = resource;
|
@@ -310,13 +364,22 @@ class NormalModule extends Module {
|
|
310
364
|
}
|
311
365
|
|
312
366
|
// Info from Build
|
313
|
-
/** @type {WebpackError
|
367
|
+
/** @type {WebpackError | null} */
|
314
368
|
this.error = null;
|
315
|
-
/**
|
369
|
+
/**
|
370
|
+
* @private
|
371
|
+
* @type {Source | null}
|
372
|
+
*/
|
316
373
|
this._source = null;
|
317
|
-
/**
|
374
|
+
/**
|
375
|
+
* @private
|
376
|
+
* @type {Map<string | undefined, number> | undefined}
|
377
|
+
*/
|
318
378
|
this._sourceSizes = undefined;
|
319
|
-
/**
|
379
|
+
/**
|
380
|
+
* @private
|
381
|
+
* @type {undefined | SourceTypes}
|
382
|
+
*/
|
320
383
|
this._sourceTypes = undefined;
|
321
384
|
|
322
385
|
// Cache
|
@@ -325,6 +388,8 @@ class NormalModule extends Module {
|
|
325
388
|
this._isEvaluatingSideEffects = false;
|
326
389
|
/** @type {WeakSet<ModuleGraph> | undefined} */
|
327
390
|
this._addedSideEffectsBailout = undefined;
|
391
|
+
/** @type {Map<string, any>} */
|
392
|
+
this._codeGeneratorData = new Map();
|
328
393
|
}
|
329
394
|
|
330
395
|
/**
|
@@ -332,14 +397,12 @@ class NormalModule extends Module {
|
|
332
397
|
*/
|
333
398
|
identifier() {
|
334
399
|
if (this.layer === null) {
|
335
|
-
if (this.type ===
|
400
|
+
if (this.type === JAVASCRIPT_MODULE_TYPE_AUTO) {
|
336
401
|
return this.request;
|
337
|
-
} else {
|
338
|
-
return `${this.type}|${this.request}`;
|
339
402
|
}
|
340
|
-
|
341
|
-
return `${this.type}|${this.request}|${this.layer}`;
|
403
|
+
return `${this.type}|${this.request}`;
|
342
404
|
}
|
405
|
+
return `${this.type}|${this.request}|${this.layer}`;
|
343
406
|
}
|
344
407
|
|
345
408
|
/**
|
@@ -347,7 +410,7 @@ class NormalModule extends Module {
|
|
347
410
|
* @returns {string} a user readable identifier of the module
|
348
411
|
*/
|
349
412
|
readableIdentifier(requestShortener) {
|
350
|
-
return requestShortener.shorten(this.userRequest);
|
413
|
+
return /** @type {string} */ (requestShortener.shorten(this.userRequest));
|
351
414
|
}
|
352
415
|
|
353
416
|
/**
|
@@ -355,11 +418,13 @@ class NormalModule extends Module {
|
|
355
418
|
* @returns {string | null} an identifier for library inclusion
|
356
419
|
*/
|
357
420
|
libIdent(options) {
|
358
|
-
|
421
|
+
let ident = contextify(
|
359
422
|
options.context,
|
360
423
|
this.userRequest,
|
361
424
|
options.associatedObjectForCache
|
362
425
|
);
|
426
|
+
if (this.layer) ident = `(${this.layer})/${ident}`;
|
427
|
+
return ident;
|
363
428
|
}
|
364
429
|
|
365
430
|
/**
|
@@ -368,7 +433,7 @@ class NormalModule extends Module {
|
|
368
433
|
nameForCondition() {
|
369
434
|
const resource = this.matchResource || this.resource;
|
370
435
|
const idx = resource.indexOf("?");
|
371
|
-
if (idx >= 0) return resource.
|
436
|
+
if (idx >= 0) return resource.slice(0, idx);
|
372
437
|
return resource;
|
373
438
|
}
|
374
439
|
|
@@ -406,7 +471,7 @@ class NormalModule extends Module {
|
|
406
471
|
// TODO reconsider this for webpack 6
|
407
472
|
if (this.buildInfo) {
|
408
473
|
if (this._sourceTypes === undefined) this.getSourceTypes();
|
409
|
-
for (const type of this._sourceTypes) {
|
474
|
+
for (const type of /** @type {SourceTypes} */ (this._sourceTypes)) {
|
410
475
|
this.size(type);
|
411
476
|
}
|
412
477
|
}
|
@@ -420,15 +485,22 @@ class NormalModule extends Module {
|
|
420
485
|
/**
|
421
486
|
* Module should be unsafe cached. Get data that's needed for that.
|
422
487
|
* This data will be passed to restoreFromUnsafeCache later.
|
423
|
-
* @returns {
|
488
|
+
* @returns {UnsafeCacheData} cached data
|
424
489
|
*/
|
425
490
|
getUnsafeCacheData() {
|
426
|
-
const data =
|
491
|
+
const data =
|
492
|
+
/** @type {NormalModuleUnsafeCacheData} */
|
493
|
+
(super.getUnsafeCacheData());
|
427
494
|
data.parserOptions = this.parserOptions;
|
428
495
|
data.generatorOptions = this.generatorOptions;
|
429
496
|
return data;
|
430
497
|
}
|
431
498
|
|
499
|
+
/**
|
500
|
+
* restore unsafe cache data
|
501
|
+
* @param {NormalModuleUnsafeCacheData} unsafeCacheData data from getUnsafeCacheData
|
502
|
+
* @param {NormalModuleFactory} normalModuleFactory the normal module factory handling the unsafe caching
|
503
|
+
*/
|
432
504
|
restoreFromUnsafeCache(unsafeCacheData, normalModuleFactory) {
|
433
505
|
this._restoreFromUnsafeCache(unsafeCacheData, normalModuleFactory);
|
434
506
|
}
|
@@ -453,9 +525,9 @@ class NormalModule extends Module {
|
|
453
525
|
/**
|
454
526
|
* @param {string} context the compilation context
|
455
527
|
* @param {string} name the asset name
|
456
|
-
* @param {string} content the content
|
457
|
-
* @param {string |
|
458
|
-
* @param {
|
528
|
+
* @param {string | Buffer} content the content
|
529
|
+
* @param {(string | SourceMap)=} sourceMap an optional source map
|
530
|
+
* @param {object=} associatedObjectForCache object for caching
|
459
531
|
* @returns {Source} the created source
|
460
532
|
*/
|
461
533
|
createSourceForAsset(
|
@@ -480,7 +552,11 @@ class NormalModule extends Module {
|
|
480
552
|
return new SourceMapSource(
|
481
553
|
content,
|
482
554
|
name,
|
483
|
-
contextifySourceMap(
|
555
|
+
contextifySourceMap(
|
556
|
+
context,
|
557
|
+
/** @type {SourceMap} */ (sourceMap),
|
558
|
+
associatedObjectForCache
|
559
|
+
)
|
484
560
|
);
|
485
561
|
}
|
486
562
|
}
|
@@ -489,12 +565,14 @@ class NormalModule extends Module {
|
|
489
565
|
}
|
490
566
|
|
491
567
|
/**
|
568
|
+
* @private
|
569
|
+
* @template T
|
492
570
|
* @param {ResolverWithOptions} resolver a resolver
|
493
571
|
* @param {WebpackOptions} options webpack options
|
494
572
|
* @param {Compilation} compilation the compilation
|
495
573
|
* @param {InputFileSystem} fs file system from reading
|
496
574
|
* @param {NormalModuleCompilationHooks} hooks the hooks
|
497
|
-
* @returns {NormalModuleLoaderContext} loader context
|
575
|
+
* @returns {import("../declarations/LoaderContext").NormalModuleLoaderContext<T>} loader context
|
498
576
|
*/
|
499
577
|
_createLoaderContext(resolver, options, compilation, fs, hooks) {
|
500
578
|
const { requestShortener } = compilation.runtimeTemplate;
|
@@ -503,56 +581,86 @@ class NormalModule extends Module {
|
|
503
581
|
if (!currentLoader) return "(not in loader scope)";
|
504
582
|
return requestShortener.shorten(currentLoader.loader);
|
505
583
|
};
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
584
|
+
/**
|
585
|
+
* @returns {ResolveContext} resolve context
|
586
|
+
*/
|
587
|
+
const getResolveContext = () => ({
|
588
|
+
fileDependencies: {
|
589
|
+
add: d => /** @type {TODO} */ (loaderContext).addDependency(d)
|
590
|
+
},
|
591
|
+
contextDependencies: {
|
592
|
+
add: d => /** @type {TODO} */ (loaderContext).addContextDependency(d)
|
593
|
+
},
|
594
|
+
missingDependencies: {
|
595
|
+
add: d => /** @type {TODO} */ (loaderContext).addMissingDependency(d)
|
596
|
+
}
|
597
|
+
});
|
519
598
|
const getAbsolutify = memoize(() =>
|
520
599
|
absolutify.bindCache(compilation.compiler.root)
|
521
600
|
);
|
522
601
|
const getAbsolutifyInContext = memoize(() =>
|
523
|
-
absolutify.bindContextCache(
|
602
|
+
absolutify.bindContextCache(
|
603
|
+
/** @type {string} */
|
604
|
+
(this.context),
|
605
|
+
compilation.compiler.root
|
606
|
+
)
|
524
607
|
);
|
525
608
|
const getContextify = memoize(() =>
|
526
609
|
contextify.bindCache(compilation.compiler.root)
|
527
610
|
);
|
528
611
|
const getContextifyInContext = memoize(() =>
|
529
|
-
contextify.bindContextCache(
|
612
|
+
contextify.bindContextCache(
|
613
|
+
/** @type {string} */
|
614
|
+
(this.context),
|
615
|
+
compilation.compiler.root
|
616
|
+
)
|
530
617
|
);
|
531
618
|
const utils = {
|
532
|
-
|
533
|
-
|
619
|
+
/**
|
620
|
+
* @param {string} context context
|
621
|
+
* @param {string} request request
|
622
|
+
* @returns {string} result
|
623
|
+
*/
|
624
|
+
absolutify: (context, request) =>
|
625
|
+
context === this.context
|
534
626
|
? getAbsolutifyInContext()(request)
|
535
|
-
: getAbsolutify()(context, request)
|
536
|
-
|
537
|
-
|
538
|
-
|
627
|
+
: getAbsolutify()(context, request),
|
628
|
+
/**
|
629
|
+
* @param {string} context context
|
630
|
+
* @param {string} request request
|
631
|
+
* @returns {string} result
|
632
|
+
*/
|
633
|
+
contextify: (context, request) =>
|
634
|
+
context === this.context
|
539
635
|
? getContextifyInContext()(request)
|
540
|
-
: getContextify()(context, request)
|
541
|
-
|
636
|
+
: getContextify()(context, request),
|
637
|
+
/**
|
638
|
+
* @param {(string | typeof import("./util/Hash"))=} type type
|
639
|
+
* @returns {Hash} hash
|
640
|
+
*/
|
641
|
+
createHash: type =>
|
642
|
+
createHash(
|
643
|
+
type ||
|
644
|
+
/** @type {Algorithm} */
|
645
|
+
(compilation.outputOptions.hashFunction)
|
646
|
+
)
|
542
647
|
};
|
648
|
+
/** @type {import("../declarations/LoaderContext").NormalModuleLoaderContext<T>} */
|
543
649
|
const loaderContext = {
|
544
650
|
version: 2,
|
545
651
|
getOptions: schema => {
|
546
652
|
const loader = this.getCurrentLoader(loaderContext);
|
547
653
|
|
548
|
-
let { options } = loader;
|
654
|
+
let { options } = /** @type {LoaderItem} */ (loader);
|
549
655
|
|
550
656
|
if (typeof options === "string") {
|
551
|
-
if (options.
|
657
|
+
if (options.startsWith("{") && options.endsWith("}")) {
|
552
658
|
try {
|
553
659
|
options = parseJson(options);
|
554
|
-
} catch (
|
555
|
-
throw new Error(
|
660
|
+
} catch (err) {
|
661
|
+
throw new Error(
|
662
|
+
`Cannot parse string options: ${/** @type {Error} */ (err).message}`
|
663
|
+
);
|
556
664
|
}
|
557
665
|
} else {
|
558
666
|
options = querystring.parse(options, "&", "=", {
|
@@ -633,43 +741,61 @@ class NormalModule extends Module {
|
|
633
741
|
};
|
634
742
|
},
|
635
743
|
emitFile: (name, content, sourceMap, assetInfo) => {
|
636
|
-
|
637
|
-
|
638
|
-
|
744
|
+
const buildInfo = /** @type {BuildInfo} */ (this.buildInfo);
|
745
|
+
|
746
|
+
if (!buildInfo.assets) {
|
747
|
+
buildInfo.assets = Object.create(null);
|
748
|
+
buildInfo.assetsInfo = new Map();
|
639
749
|
}
|
640
|
-
|
641
|
-
|
750
|
+
|
751
|
+
const assets =
|
752
|
+
/** @type {NonNullable<KnownBuildInfo["assets"]>} */
|
753
|
+
(buildInfo.assets);
|
754
|
+
const assetsInfo =
|
755
|
+
/** @type {NonNullable<KnownBuildInfo["assetsInfo"]>} */
|
756
|
+
(buildInfo.assetsInfo);
|
757
|
+
|
758
|
+
assets[name] = this.createSourceForAsset(
|
759
|
+
/** @type {string} */ (options.context),
|
642
760
|
name,
|
643
761
|
content,
|
644
762
|
sourceMap,
|
645
763
|
compilation.compiler.root
|
646
764
|
);
|
647
|
-
|
765
|
+
assetsInfo.set(name, assetInfo);
|
648
766
|
},
|
649
767
|
addBuildDependency: dep => {
|
650
|
-
|
651
|
-
|
768
|
+
const buildInfo = /** @type {BuildInfo} */ (this.buildInfo);
|
769
|
+
|
770
|
+
if (buildInfo.buildDependencies === undefined) {
|
771
|
+
buildInfo.buildDependencies = new LazySet();
|
652
772
|
}
|
653
|
-
|
773
|
+
buildInfo.buildDependencies.add(dep);
|
654
774
|
},
|
655
775
|
utils,
|
656
|
-
rootContext: options.context,
|
776
|
+
rootContext: /** @type {string} */ (options.context),
|
657
777
|
webpack: true,
|
658
|
-
sourceMap:
|
778
|
+
sourceMap: Boolean(this.useSourceMap),
|
659
779
|
mode: options.mode || "production",
|
660
780
|
_module: this,
|
661
781
|
_compilation: compilation,
|
662
782
|
_compiler: compilation.compiler,
|
663
|
-
fs
|
783
|
+
fs
|
664
784
|
};
|
665
785
|
|
666
786
|
Object.assign(loaderContext, options.loader);
|
667
787
|
|
668
|
-
hooks.loader.call(loaderContext, this);
|
788
|
+
hooks.loader.call(/** @type {LoaderContext<any>} */ (loaderContext), this);
|
669
789
|
|
670
790
|
return loaderContext;
|
671
791
|
}
|
672
792
|
|
793
|
+
// TODO remove `loaderContext` in webpack@6
|
794
|
+
/**
|
795
|
+
* @param {TODO} loaderContext loader context
|
796
|
+
* @param {number} index index
|
797
|
+
* @returns {LoaderItem | null} loader
|
798
|
+
*/
|
673
799
|
getCurrentLoader(loaderContext, index = loaderContext.loaderIndex) {
|
674
800
|
if (
|
675
801
|
this.loaders &&
|
@@ -686,8 +812,8 @@ class NormalModule extends Module {
|
|
686
812
|
/**
|
687
813
|
* @param {string} context the compilation context
|
688
814
|
* @param {string | Buffer} content the content
|
689
|
-
* @param {string |
|
690
|
-
* @param {
|
815
|
+
* @param {(string | SourceMapSource | null)=} sourceMap an optional source map
|
816
|
+
* @param {object=} associatedObjectForCache object for caching
|
691
817
|
* @returns {Source} the created source
|
692
818
|
*/
|
693
819
|
createSource(context, content, sourceMap, associatedObjectForCache) {
|
@@ -707,7 +833,11 @@ class NormalModule extends Module {
|
|
707
833
|
return new SourceMapSource(
|
708
834
|
content,
|
709
835
|
contextifySourceUrl(context, identifier, associatedObjectForCache),
|
710
|
-
contextifySourceMap(
|
836
|
+
contextifySourceMap(
|
837
|
+
context,
|
838
|
+
/** @type {TODO} */ (sourceMap),
|
839
|
+
associatedObjectForCache
|
840
|
+
)
|
711
841
|
);
|
712
842
|
}
|
713
843
|
|
@@ -727,7 +857,7 @@ class NormalModule extends Module {
|
|
727
857
|
* @param {ResolverWithOptions} resolver the resolver
|
728
858
|
* @param {InputFileSystem} fs the file system
|
729
859
|
* @param {NormalModuleCompilationHooks} hooks the hooks
|
730
|
-
* @param {function(WebpackError=): void} callback callback function
|
860
|
+
* @param {function((WebpackError | null)=): void} callback callback function
|
731
861
|
* @returns {void}
|
732
862
|
*/
|
733
863
|
_doBuild(options, compilation, resolver, fs, hooks, callback) {
|
@@ -739,7 +869,14 @@ class NormalModule extends Module {
|
|
739
869
|
hooks
|
740
870
|
);
|
741
871
|
|
742
|
-
|
872
|
+
/** @typedef {[string | Buffer, string | SourceMapSource, Record<string, any>]} Result */
|
873
|
+
|
874
|
+
/**
|
875
|
+
* @param {Error | null} err err
|
876
|
+
* @param {(Result | null)=} _result result
|
877
|
+
* @returns {void}
|
878
|
+
*/
|
879
|
+
const processResult = (err, _result) => {
|
743
880
|
if (err) {
|
744
881
|
if (!(err instanceof Error)) {
|
745
882
|
err = new NonErrorEmittedError(err);
|
@@ -755,6 +892,7 @@ class NormalModule extends Module {
|
|
755
892
|
return callback(error);
|
756
893
|
}
|
757
894
|
|
895
|
+
const result = /** @type {Result} */ (_result);
|
758
896
|
const source = result[0];
|
759
897
|
const sourceMap = result.length >= 1 ? result[1] : null;
|
760
898
|
const extraInfo = result.length >= 2 ? result[2] : null;
|
@@ -766,7 +904,7 @@ class NormalModule extends Module {
|
|
766
904
|
currentLoader
|
767
905
|
? compilation.runtimeTemplate.requestShortener.shorten(
|
768
906
|
currentLoader.loader
|
769
|
-
|
907
|
+
)
|
770
908
|
: "unknown"
|
771
909
|
}) didn't return a Buffer or String`
|
772
910
|
);
|
@@ -774,9 +912,14 @@ class NormalModule extends Module {
|
|
774
912
|
return callback(error);
|
775
913
|
}
|
776
914
|
|
915
|
+
const isBinaryModule =
|
916
|
+
this.generatorOptions && this.generatorOptions.binary !== undefined
|
917
|
+
? this.generatorOptions.binary
|
918
|
+
: this.binary;
|
919
|
+
|
777
920
|
this._source = this.createSource(
|
778
|
-
options.context,
|
779
|
-
|
921
|
+
/** @type {string} */ (options.context),
|
922
|
+
isBinaryModule ? asBuffer(source) : asString(source),
|
780
923
|
sourceMap,
|
781
924
|
compilation.compiler.root
|
782
925
|
);
|
@@ -790,19 +933,29 @@ class NormalModule extends Module {
|
|
790
933
|
return callback();
|
791
934
|
};
|
792
935
|
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
936
|
+
const buildInfo = /** @type {BuildInfo} */ (this.buildInfo);
|
937
|
+
|
938
|
+
buildInfo.fileDependencies = new LazySet();
|
939
|
+
buildInfo.contextDependencies = new LazySet();
|
940
|
+
buildInfo.missingDependencies = new LazySet();
|
941
|
+
buildInfo.cacheable = true;
|
942
|
+
|
800
943
|
try {
|
801
|
-
hooks.beforeLoaders.call(
|
944
|
+
hooks.beforeLoaders.call(
|
945
|
+
this.loaders,
|
946
|
+
this,
|
947
|
+
/** @type {LoaderContext<any>} */ (loaderContext)
|
948
|
+
);
|
802
949
|
} catch (err) {
|
803
950
|
processResult(err);
|
804
951
|
return;
|
805
952
|
}
|
953
|
+
|
954
|
+
if (this.loaders.length > 0) {
|
955
|
+
/** @type {BuildInfo} */
|
956
|
+
(this.buildInfo).buildDependencies = new LazySet();
|
957
|
+
}
|
958
|
+
|
806
959
|
runLoaders(
|
807
960
|
{
|
808
961
|
resource: this.resource,
|
@@ -816,7 +969,13 @@ class NormalModule extends Module {
|
|
816
969
|
.callAsync(loaderContext, (err, result) => {
|
817
970
|
if (err) return callback(err);
|
818
971
|
if (typeof result !== "string" && !result) {
|
819
|
-
return callback(
|
972
|
+
return callback(
|
973
|
+
new UnhandledSchemeError(
|
974
|
+
/** @type {string} */
|
975
|
+
(scheme),
|
976
|
+
resource
|
977
|
+
)
|
978
|
+
);
|
820
979
|
}
|
821
980
|
return callback(null, result);
|
822
981
|
});
|
@@ -827,23 +986,43 @@ class NormalModule extends Module {
|
|
827
986
|
loaderContext._compilation =
|
828
987
|
loaderContext._compiler =
|
829
988
|
loaderContext._module =
|
989
|
+
// eslint-disable-next-line no-warning-comments
|
990
|
+
// @ts-ignore
|
830
991
|
loaderContext.fs =
|
831
992
|
undefined;
|
832
993
|
|
833
994
|
if (!result) {
|
834
|
-
|
995
|
+
/** @type {BuildInfo} */
|
996
|
+
(this.buildInfo).cacheable = false;
|
835
997
|
return processResult(
|
836
998
|
err || new Error("No result from loader-runner processing"),
|
837
999
|
null
|
838
1000
|
);
|
839
1001
|
}
|
840
|
-
|
841
|
-
this.buildInfo
|
842
|
-
|
1002
|
+
|
1003
|
+
const buildInfo = /** @type {BuildInfo} */ (this.buildInfo);
|
1004
|
+
|
1005
|
+
const fileDependencies =
|
1006
|
+
/** @type {NonNullable<KnownBuildInfo["fileDependencies"]>} */
|
1007
|
+
(buildInfo.fileDependencies);
|
1008
|
+
const contextDependencies =
|
1009
|
+
/** @type {NonNullable<KnownBuildInfo["contextDependencies"]>} */
|
1010
|
+
(buildInfo.contextDependencies);
|
1011
|
+
const missingDependencies =
|
1012
|
+
/** @type {NonNullable<KnownBuildInfo["missingDependencies"]>} */
|
1013
|
+
(buildInfo.missingDependencies);
|
1014
|
+
|
1015
|
+
fileDependencies.addAll(result.fileDependencies);
|
1016
|
+
contextDependencies.addAll(result.contextDependencies);
|
1017
|
+
missingDependencies.addAll(result.missingDependencies);
|
843
1018
|
for (const loader of this.loaders) {
|
844
|
-
|
1019
|
+
const buildDependencies =
|
1020
|
+
/** @type {NonNullable<KnownBuildInfo["buildDependencies"]>} */
|
1021
|
+
(buildInfo.buildDependencies);
|
1022
|
+
|
1023
|
+
buildDependencies.add(loader.loader);
|
845
1024
|
}
|
846
|
-
|
1025
|
+
buildInfo.cacheable = buildInfo.cacheable && result.cacheable;
|
847
1026
|
processResult(err, result.result);
|
848
1027
|
}
|
849
1028
|
);
|
@@ -860,6 +1039,11 @@ class NormalModule extends Module {
|
|
860
1039
|
this.addError(error);
|
861
1040
|
}
|
862
1041
|
|
1042
|
+
/**
|
1043
|
+
* @param {TODO} rule rule
|
1044
|
+
* @param {string} content content
|
1045
|
+
* @returns {boolean} result
|
1046
|
+
*/
|
863
1047
|
applyNoParseRule(rule, content) {
|
864
1048
|
// must start with "rule" if rule is a string
|
865
1049
|
if (typeof rule === "string") {
|
@@ -873,9 +1057,11 @@ class NormalModule extends Module {
|
|
873
1057
|
return rule.test(content);
|
874
1058
|
}
|
875
1059
|
|
876
|
-
|
877
|
-
|
878
|
-
|
1060
|
+
/**
|
1061
|
+
* @param {TODO} noParseRule no parse rule
|
1062
|
+
* @param {string} request request
|
1063
|
+
* @returns {boolean} check if module should not be parsed, returns "true" if the module should !not! be parsed, returns "false" if the module !must! be parsed
|
1064
|
+
*/
|
879
1065
|
shouldPreventParsing(noParseRule, request) {
|
880
1066
|
// if no noParseRule exists, return false
|
881
1067
|
// the module !must! be parsed.
|
@@ -901,15 +1087,23 @@ class NormalModule extends Module {
|
|
901
1087
|
return false;
|
902
1088
|
}
|
903
1089
|
|
1090
|
+
/**
|
1091
|
+
* @param {Compilation} compilation compilation
|
1092
|
+
* @private
|
1093
|
+
*/
|
904
1094
|
_initBuildHash(compilation) {
|
905
|
-
const hash = createHash(
|
1095
|
+
const hash = createHash(
|
1096
|
+
/** @type {Algorithm} */
|
1097
|
+
(compilation.outputOptions.hashFunction)
|
1098
|
+
);
|
906
1099
|
if (this._source) {
|
907
1100
|
hash.update("source");
|
908
1101
|
this._source.updateHash(hash);
|
909
1102
|
}
|
910
1103
|
hash.update("meta");
|
911
1104
|
hash.update(JSON.stringify(this.buildMeta));
|
912
|
-
|
1105
|
+
/** @type {BuildInfo} */
|
1106
|
+
(this.buildInfo).hash = /** @type {string} */ (hash.digest("hex"));
|
913
1107
|
}
|
914
1108
|
|
915
1109
|
/**
|
@@ -955,10 +1149,18 @@ class NormalModule extends Module {
|
|
955
1149
|
return callback();
|
956
1150
|
}
|
957
1151
|
|
1152
|
+
/**
|
1153
|
+
* @param {Error} e error
|
1154
|
+
* @returns {void}
|
1155
|
+
*/
|
958
1156
|
const handleParseError = e => {
|
959
|
-
const source = this._source.source();
|
1157
|
+
const source = /** @type {Source} */ (this._source).source();
|
960
1158
|
const loaders = this.loaders.map(item =>
|
961
|
-
contextify(
|
1159
|
+
contextify(
|
1160
|
+
/** @type {string} */ (options.context),
|
1161
|
+
item.loader,
|
1162
|
+
compilation.compiler.root
|
1163
|
+
)
|
962
1164
|
);
|
963
1165
|
const error = new ModuleParseError(source, e, loaders, this.type);
|
964
1166
|
this.markModuleAsErrored(error);
|
@@ -966,7 +1168,7 @@ class NormalModule extends Module {
|
|
966
1168
|
return callback();
|
967
1169
|
};
|
968
1170
|
|
969
|
-
const handleParseResult =
|
1171
|
+
const handleParseResult = () => {
|
970
1172
|
this.dependencies.sort(
|
971
1173
|
concatComparators(
|
972
1174
|
compareSelect(a => a.loc, compareLocations),
|
@@ -974,7 +1176,9 @@ class NormalModule extends Module {
|
|
974
1176
|
)
|
975
1177
|
);
|
976
1178
|
this._initBuildHash(compilation);
|
977
|
-
this._lastSuccessfulBuildMeta =
|
1179
|
+
this._lastSuccessfulBuildMeta =
|
1180
|
+
/** @type {BuildMeta} */
|
1181
|
+
(this.buildMeta);
|
978
1182
|
return handleBuildDone();
|
979
1183
|
};
|
980
1184
|
|
@@ -982,17 +1186,22 @@ class NormalModule extends Module {
|
|
982
1186
|
try {
|
983
1187
|
hooks.beforeSnapshot.call(this);
|
984
1188
|
} catch (err) {
|
985
|
-
this.markModuleAsErrored(err);
|
1189
|
+
this.markModuleAsErrored(/** @type {WebpackError} */ (err));
|
986
1190
|
return callback();
|
987
1191
|
}
|
988
1192
|
|
989
1193
|
const snapshotOptions = compilation.options.snapshot.module;
|
990
|
-
|
1194
|
+
const { cacheable } = /** @type {BuildInfo} */ (this.buildInfo);
|
1195
|
+
if (!cacheable || !snapshotOptions) {
|
991
1196
|
return callback();
|
992
1197
|
}
|
993
1198
|
// add warning for all non-absolute paths in fileDependencies, etc
|
994
1199
|
// This makes it easier to find problems with watching and/or caching
|
995
|
-
|
1200
|
+
/** @type {undefined | Set<string>} */
|
1201
|
+
let nonAbsoluteDependencies;
|
1202
|
+
/**
|
1203
|
+
* @param {LazySet<string>} deps deps
|
1204
|
+
*/
|
996
1205
|
const checkDependencies = deps => {
|
997
1206
|
for (const dep of deps) {
|
998
1207
|
if (!ABSOLUTE_PATH_REGEX.test(dep)) {
|
@@ -1004,24 +1213,39 @@ class NormalModule extends Module {
|
|
1004
1213
|
const depWithoutGlob = dep.replace(/[\\/]?\*.*$/, "");
|
1005
1214
|
const absolute = join(
|
1006
1215
|
compilation.fileSystemInfo.fs,
|
1007
|
-
|
1216
|
+
/** @type {string} */
|
1217
|
+
(this.context),
|
1008
1218
|
depWithoutGlob
|
1009
1219
|
);
|
1010
1220
|
if (absolute !== dep && ABSOLUTE_PATH_REGEX.test(absolute)) {
|
1011
1221
|
(depWithoutGlob !== dep
|
1012
|
-
?
|
1222
|
+
? /** @type {NonNullable<KnownBuildInfo["contextDependencies"]>} */
|
1223
|
+
(
|
1224
|
+
/** @type {BuildInfo} */ (this.buildInfo)
|
1225
|
+
.contextDependencies
|
1226
|
+
)
|
1013
1227
|
: deps
|
1014
1228
|
).add(absolute);
|
1015
1229
|
}
|
1016
|
-
} catch (
|
1230
|
+
} catch (_err) {
|
1017
1231
|
// ignore
|
1018
1232
|
}
|
1019
1233
|
}
|
1020
1234
|
}
|
1021
1235
|
};
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1236
|
+
const buildInfo = /** @type {BuildInfo} */ (this.buildInfo);
|
1237
|
+
const fileDependencies =
|
1238
|
+
/** @type {NonNullable<KnownBuildInfo["fileDependencies"]>} */
|
1239
|
+
(buildInfo.fileDependencies);
|
1240
|
+
const contextDependencies =
|
1241
|
+
/** @type {NonNullable<KnownBuildInfo["contextDependencies"]>} */
|
1242
|
+
(buildInfo.contextDependencies);
|
1243
|
+
const missingDependencies =
|
1244
|
+
/** @type {NonNullable<KnownBuildInfo["missingDependencies"]>} */
|
1245
|
+
(buildInfo.missingDependencies);
|
1246
|
+
checkDependencies(fileDependencies);
|
1247
|
+
checkDependencies(missingDependencies);
|
1248
|
+
checkDependencies(contextDependencies);
|
1025
1249
|
if (nonAbsoluteDependencies !== undefined) {
|
1026
1250
|
const InvalidDependenciesModuleWarning =
|
1027
1251
|
getInvalidDependenciesModuleWarning();
|
@@ -1032,19 +1256,19 @@ class NormalModule extends Module {
|
|
1032
1256
|
// convert file/context/missingDependencies into filesystem snapshot
|
1033
1257
|
compilation.fileSystemInfo.createSnapshot(
|
1034
1258
|
startTime,
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1259
|
+
fileDependencies,
|
1260
|
+
contextDependencies,
|
1261
|
+
missingDependencies,
|
1038
1262
|
snapshotOptions,
|
1039
1263
|
(err, snapshot) => {
|
1040
1264
|
if (err) {
|
1041
1265
|
this.markModuleAsErrored(err);
|
1042
1266
|
return;
|
1043
1267
|
}
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1268
|
+
buildInfo.fileDependencies = undefined;
|
1269
|
+
buildInfo.contextDependencies = undefined;
|
1270
|
+
buildInfo.missingDependencies = undefined;
|
1271
|
+
buildInfo.snapshot = snapshot;
|
1048
1272
|
return callback();
|
1049
1273
|
}
|
1050
1274
|
);
|
@@ -1053,7 +1277,7 @@ class NormalModule extends Module {
|
|
1053
1277
|
try {
|
1054
1278
|
hooks.beforeParse.call(this);
|
1055
1279
|
} catch (err) {
|
1056
|
-
this.markModuleAsErrored(err);
|
1280
|
+
this.markModuleAsErrored(/** @type {WebpackError} */ (err));
|
1057
1281
|
this._initBuildHash(compilation);
|
1058
1282
|
return callback();
|
1059
1283
|
}
|
@@ -1063,26 +1287,27 @@ class NormalModule extends Module {
|
|
1063
1287
|
const noParseRule = options.module && options.module.noParse;
|
1064
1288
|
if (this.shouldPreventParsing(noParseRule, this.request)) {
|
1065
1289
|
// We assume that we need module and exports
|
1066
|
-
|
1290
|
+
/** @type {BuildInfo} */
|
1291
|
+
(this.buildInfo).parsed = false;
|
1067
1292
|
this._initBuildHash(compilation);
|
1068
1293
|
return handleBuildDone();
|
1069
1294
|
}
|
1070
1295
|
|
1071
|
-
let result;
|
1072
1296
|
try {
|
1073
|
-
const source = this._source.source();
|
1074
|
-
|
1297
|
+
const source = /** @type {Source} */ (this._source).source();
|
1298
|
+
/** @type {Parser} */
|
1299
|
+
(this.parser).parse(this._ast || source, {
|
1075
1300
|
source,
|
1076
1301
|
current: this,
|
1077
1302
|
module: this,
|
1078
|
-
compilation
|
1079
|
-
options
|
1303
|
+
compilation,
|
1304
|
+
options
|
1080
1305
|
});
|
1081
|
-
} catch (
|
1082
|
-
handleParseError(
|
1306
|
+
} catch (parseErr) {
|
1307
|
+
handleParseError(/** @type {Error} */ (parseErr));
|
1083
1308
|
return;
|
1084
1309
|
}
|
1085
|
-
handleParseResult(
|
1310
|
+
handleParseResult();
|
1086
1311
|
});
|
1087
1312
|
}
|
1088
1313
|
|
@@ -1091,7 +1316,9 @@ class NormalModule extends Module {
|
|
1091
1316
|
* @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated
|
1092
1317
|
*/
|
1093
1318
|
getConcatenationBailoutReason(context) {
|
1094
|
-
return
|
1319
|
+
return /** @type {Generator} */ (
|
1320
|
+
this.generator
|
1321
|
+
).getConcatenationBailoutReason(this, context);
|
1095
1322
|
}
|
1096
1323
|
|
1097
1324
|
/**
|
@@ -1137,17 +1364,18 @@ class NormalModule extends Module {
|
|
1137
1364
|
// When caching is implemented here, make sure to not cache when
|
1138
1365
|
// at least one circular connection was in the loop above
|
1139
1366
|
return current;
|
1140
|
-
} else {
|
1141
|
-
return true;
|
1142
1367
|
}
|
1368
|
+
return true;
|
1143
1369
|
}
|
1144
1370
|
|
1145
1371
|
/**
|
1146
|
-
* @returns {
|
1372
|
+
* @returns {SourceTypes} types available (do not mutate)
|
1147
1373
|
*/
|
1148
1374
|
getSourceTypes() {
|
1149
1375
|
if (this._sourceTypes === undefined) {
|
1150
|
-
this._sourceTypes = this.generator.getTypes(
|
1376
|
+
this._sourceTypes = /** @type {Generator} */ (this.generator).getTypes(
|
1377
|
+
this
|
1378
|
+
);
|
1151
1379
|
}
|
1152
1380
|
return this._sourceTypes;
|
1153
1381
|
}
|
@@ -1162,31 +1390,31 @@ class NormalModule extends Module {
|
|
1162
1390
|
moduleGraph,
|
1163
1391
|
chunkGraph,
|
1164
1392
|
runtime,
|
1165
|
-
concatenationScope
|
1393
|
+
concatenationScope,
|
1394
|
+
codeGenerationResults,
|
1395
|
+
sourceTypes
|
1166
1396
|
}) {
|
1167
1397
|
/** @type {Set<string>} */
|
1168
1398
|
const runtimeRequirements = new Set();
|
1169
1399
|
|
1170
|
-
|
1400
|
+
const { parsed } = /** @type {BuildInfo} */ (this.buildInfo);
|
1401
|
+
|
1402
|
+
if (!parsed) {
|
1171
1403
|
runtimeRequirements.add(RuntimeGlobals.module);
|
1172
1404
|
runtimeRequirements.add(RuntimeGlobals.exports);
|
1173
1405
|
runtimeRequirements.add(RuntimeGlobals.thisAsExports);
|
1174
1406
|
}
|
1175
1407
|
|
1176
|
-
/** @type {Map<string, any>} */
|
1177
|
-
|
1178
|
-
const getData = () => {
|
1179
|
-
if (data === undefined) data = new Map();
|
1180
|
-
return data;
|
1181
|
-
};
|
1408
|
+
/** @type {function(): Map<string, any>} */
|
1409
|
+
const getData = () => this._codeGeneratorData;
|
1182
1410
|
|
1183
1411
|
const sources = new Map();
|
1184
|
-
for (const type of
|
1412
|
+
for (const type of sourceTypes || chunkGraph.getModuleSourceTypes(this)) {
|
1185
1413
|
const source = this.error
|
1186
1414
|
? new RawSource(
|
1187
|
-
|
1188
|
-
|
1189
|
-
: this.generator.generate(this, {
|
1415
|
+
`throw new Error(${JSON.stringify(this.error.message)});`
|
1416
|
+
)
|
1417
|
+
: /** @type {Generator} */ (this.generator).generate(this, {
|
1190
1418
|
dependencyTemplates,
|
1191
1419
|
runtimeTemplate,
|
1192
1420
|
moduleGraph,
|
@@ -1194,9 +1422,10 @@ class NormalModule extends Module {
|
|
1194
1422
|
runtimeRequirements,
|
1195
1423
|
runtime,
|
1196
1424
|
concatenationScope,
|
1425
|
+
codeGenerationResults,
|
1197
1426
|
getData,
|
1198
1427
|
type
|
1199
|
-
|
1428
|
+
});
|
1200
1429
|
|
1201
1430
|
if (source) {
|
1202
1431
|
sources.set(type, new CachedSource(source));
|
@@ -1207,7 +1436,7 @@ class NormalModule extends Module {
|
|
1207
1436
|
const resultEntry = {
|
1208
1437
|
sources,
|
1209
1438
|
runtimeRequirements,
|
1210
|
-
data
|
1439
|
+
data: this._codeGeneratorData
|
1211
1440
|
};
|
1212
1441
|
return resultEntry;
|
1213
1442
|
}
|
@@ -1228,7 +1457,7 @@ class NormalModule extends Module {
|
|
1228
1457
|
|
1229
1458
|
/**
|
1230
1459
|
* @param {NeedBuildContext} context context info
|
1231
|
-
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
1460
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
1232
1461
|
* @returns {void}
|
1233
1462
|
*/
|
1234
1463
|
needBuild(context, callback) {
|
@@ -1239,15 +1468,16 @@ class NormalModule extends Module {
|
|
1239
1468
|
// always try to build in case of an error
|
1240
1469
|
if (this.error) return callback(null, true);
|
1241
1470
|
|
1471
|
+
const { cacheable, snapshot, valueDependencies } =
|
1472
|
+
/** @type {BuildInfo} */ (this.buildInfo);
|
1473
|
+
|
1242
1474
|
// always build when module is not cacheable
|
1243
|
-
if (!
|
1475
|
+
if (!cacheable) return callback(null, true);
|
1244
1476
|
|
1245
1477
|
// build when there is no snapshot to check
|
1246
|
-
if (!
|
1478
|
+
if (!snapshot) return callback(null, true);
|
1247
1479
|
|
1248
1480
|
// build when valueDependencies have changed
|
1249
|
-
/** @type {Map<string, string | Set<string>>} */
|
1250
|
-
const valueDependencies = this.buildInfo.valueDependencies;
|
1251
1481
|
if (valueDependencies) {
|
1252
1482
|
if (!valueCacheVersions) return callback(null, true);
|
1253
1483
|
for (const [key, value] of valueDependencies) {
|
@@ -1266,7 +1496,7 @@ class NormalModule extends Module {
|
|
1266
1496
|
}
|
1267
1497
|
|
1268
1498
|
// check snapshot for validity
|
1269
|
-
fileSystemInfo.checkSnapshotValid(
|
1499
|
+
fileSystemInfo.checkSnapshotValid(snapshot, (err, valid) => {
|
1270
1500
|
if (err) return callback(err);
|
1271
1501
|
if (!valid) return callback(null, true);
|
1272
1502
|
const hooks = NormalModule.getCompilationHooks(compilation);
|
@@ -1279,7 +1509,7 @@ class NormalModule extends Module {
|
|
1279
1509
|
)
|
1280
1510
|
);
|
1281
1511
|
}
|
1282
|
-
callback(null,
|
1512
|
+
callback(null, Boolean(needBuild));
|
1283
1513
|
});
|
1284
1514
|
});
|
1285
1515
|
}
|
@@ -1294,7 +1524,10 @@ class NormalModule extends Module {
|
|
1294
1524
|
if (cachedSize !== undefined) {
|
1295
1525
|
return cachedSize;
|
1296
1526
|
}
|
1297
|
-
const size = Math.max(
|
1527
|
+
const size = Math.max(
|
1528
|
+
1,
|
1529
|
+
/** @type {Generator} */ (this.generator).getSize(this, type)
|
1530
|
+
);
|
1298
1531
|
if (this._sourceSizes === undefined) {
|
1299
1532
|
this._sourceSizes = new Map();
|
1300
1533
|
}
|
@@ -1314,7 +1547,8 @@ class NormalModule extends Module {
|
|
1314
1547
|
missingDependencies,
|
1315
1548
|
buildDependencies
|
1316
1549
|
) {
|
1317
|
-
const { snapshot, buildDependencies: buildDeps } =
|
1550
|
+
const { snapshot, buildDependencies: buildDeps } =
|
1551
|
+
/** @type {BuildInfo} */ (this.buildInfo);
|
1318
1552
|
if (snapshot) {
|
1319
1553
|
fileDependencies.addAll(snapshot.getFileIterable());
|
1320
1554
|
contextDependencies.addAll(snapshot.getContextIterable());
|
@@ -1324,7 +1558,7 @@ class NormalModule extends Module {
|
|
1324
1558
|
fileDependencies: fileDeps,
|
1325
1559
|
contextDependencies: contextDeps,
|
1326
1560
|
missingDependencies: missingDeps
|
1327
|
-
} = this.buildInfo;
|
1561
|
+
} = /** @type {BuildInfo} */ (this.buildInfo);
|
1328
1562
|
if (fileDeps !== undefined) fileDependencies.addAll(fileDeps);
|
1329
1563
|
if (contextDeps !== undefined) contextDependencies.addAll(contextDeps);
|
1330
1564
|
if (missingDeps !== undefined) missingDependencies.addAll(missingDeps);
|
@@ -1340,14 +1574,18 @@ class NormalModule extends Module {
|
|
1340
1574
|
* @returns {void}
|
1341
1575
|
*/
|
1342
1576
|
updateHash(hash, context) {
|
1343
|
-
hash.update(this.buildInfo.hash);
|
1344
|
-
|
1577
|
+
hash.update(/** @type {BuildInfo} */ (this.buildInfo).hash);
|
1578
|
+
/** @type {Generator} */
|
1579
|
+
(this.generator).updateHash(hash, {
|
1345
1580
|
module: this,
|
1346
1581
|
...context
|
1347
1582
|
});
|
1348
1583
|
super.updateHash(hash, context);
|
1349
1584
|
}
|
1350
1585
|
|
1586
|
+
/**
|
1587
|
+
* @param {ObjectSerializerContext} context context
|
1588
|
+
*/
|
1351
1589
|
serialize(context) {
|
1352
1590
|
const { write } = context;
|
1353
1591
|
// deserialize
|
@@ -1355,6 +1593,7 @@ class NormalModule extends Module {
|
|
1355
1593
|
write(this.error);
|
1356
1594
|
write(this._lastSuccessfulBuildMeta);
|
1357
1595
|
write(this._forceBuild);
|
1596
|
+
write(this._codeGeneratorData);
|
1358
1597
|
super.serialize(context);
|
1359
1598
|
}
|
1360
1599
|
|
@@ -1381,12 +1620,16 @@ class NormalModule extends Module {
|
|
1381
1620
|
return obj;
|
1382
1621
|
}
|
1383
1622
|
|
1623
|
+
/**
|
1624
|
+
* @param {ObjectDeserializerContext} context context
|
1625
|
+
*/
|
1384
1626
|
deserialize(context) {
|
1385
1627
|
const { read } = context;
|
1386
1628
|
this._source = read();
|
1387
1629
|
this.error = read();
|
1388
1630
|
this._lastSuccessfulBuildMeta = read();
|
1389
1631
|
this._forceBuild = read();
|
1632
|
+
this._codeGeneratorData = read();
|
1390
1633
|
super.deserialize(context);
|
1391
1634
|
}
|
1392
1635
|
}
|