webpack 5.106.1 → 5.107.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 +2 -2
- package/lib/APIPlugin.js +4 -2
- package/lib/AsyncDependenciesBlock.js +3 -0
- package/lib/AutomaticPrefetchPlugin.js +6 -1
- package/lib/BannerPlugin.js +10 -1
- package/lib/Cache.js +27 -5
- package/lib/CacheFacade.js +26 -0
- package/lib/Chunk.js +46 -0
- package/lib/ChunkGraph.js +111 -0
- package/lib/ChunkGroup.js +57 -13
- package/lib/ChunkTemplate.js +9 -0
- package/lib/CleanPlugin.js +14 -1
- package/lib/CodeGenerationResults.js +19 -0
- package/lib/CompatibilityPlugin.js +23 -8
- package/lib/Compilation.js +161 -27
- package/lib/Compiler.js +41 -17
- package/lib/ConcatenationScope.js +24 -1
- package/lib/ConditionalInitFragment.js +6 -0
- package/lib/ConstPlugin.js +4 -1
- package/lib/ContextExclusionPlugin.js +2 -1
- package/lib/ContextModule.js +14 -2
- package/lib/ContextModuleFactory.js +10 -0
- package/lib/ContextReplacementPlugin.js +4 -1
- package/lib/DefinePlugin.js +22 -9
- package/lib/DependenciesBlock.js +6 -1
- package/lib/Dependency.js +48 -4
- package/lib/DependencyTemplate.js +7 -1
- package/lib/DependencyTemplates.js +4 -0
- package/lib/DotenvPlugin.js +3 -0
- package/lib/DynamicEntryPlugin.js +3 -1
- package/lib/EntryOptionPlugin.js +3 -0
- package/lib/EntryPlugin.js +2 -1
- package/lib/Entrypoint.js +4 -0
- package/lib/EnvironmentPlugin.js +3 -2
- package/lib/ErrorHelpers.js +7 -0
- package/lib/EvalDevToolModulePlugin.js +3 -1
- package/lib/EvalSourceMapDevToolPlugin.js +11 -10
- package/lib/ExportsInfo.js +56 -2
- package/lib/ExportsInfoApiPlugin.js +2 -1
- package/lib/ExternalModule.js +114 -15
- package/lib/ExternalModuleFactoryPlugin.js +15 -0
- package/lib/ExternalsPlugin.js +2 -1
- package/lib/FileSystemInfo.js +291 -71
- package/lib/FlagAllModulesAsUsedPlugin.js +2 -1
- package/lib/FlagDependencyExportsPlugin.js +4 -1
- package/lib/FlagDependencyUsagePlugin.js +5 -1
- package/lib/FlagEntryExportAsUsedPlugin.js +2 -1
- package/lib/Generator.js +16 -3
- package/lib/HotModuleReplacementPlugin.js +35 -9
- package/lib/IgnorePlugin.js +4 -2
- package/lib/IgnoreWarningsPlugin.js +2 -1
- package/lib/InitFragment.js +10 -0
- package/lib/JavascriptMetaInfoPlugin.js +2 -1
- package/lib/LibraryTemplatePlugin.js +2 -1
- package/lib/LoaderOptionsPlugin.js +3 -1
- package/lib/LoaderTargetPlugin.js +2 -1
- package/lib/MainTemplate.js +15 -0
- package/lib/ManifestPlugin.js +9 -2
- package/lib/Module.js +101 -19
- package/lib/ModuleFactory.js +6 -1
- package/lib/ModuleFilenameHelpers.js +3 -0
- package/lib/ModuleGraph.js +66 -0
- package/lib/ModuleGraphConnection.js +9 -0
- package/lib/ModuleInfoHeaderPlugin.js +5 -0
- package/lib/ModuleSourceTypeConstants.js +32 -1
- package/lib/ModuleTemplate.js +8 -0
- package/lib/ModuleTypeConstants.js +12 -3
- package/lib/MultiCompiler.js +30 -2
- package/lib/MultiStats.js +8 -0
- package/lib/MultiWatching.js +3 -0
- package/lib/NoEmitOnErrorsPlugin.js +1 -1
- package/lib/NodeStuffPlugin.js +11 -2
- package/lib/NormalModule.js +43 -33
- package/lib/NormalModuleFactory.js +35 -2
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/NullFactory.js +1 -0
- package/lib/OptionsApply.js +1 -0
- package/lib/Parser.js +3 -1
- package/lib/PlatformPlugin.js +2 -1
- package/lib/PrefetchPlugin.js +2 -1
- package/lib/ProgressPlugin.js +158 -68
- package/lib/ProvidePlugin.js +3 -1
- package/lib/RawModule.js +12 -0
- package/lib/RecordIdsPlugin.js +8 -0
- package/lib/RequestShortener.js +8 -0
- package/lib/ResolverFactory.js +5 -0
- package/lib/RuntimeGlobals.js +6 -5
- package/lib/RuntimeModule.js +22 -7
- package/lib/RuntimePlugin.js +13 -0
- package/lib/RuntimeTemplate.js +35 -1
- package/lib/SelfModuleFactory.js +2 -0
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -0
- package/lib/SourceMapDevToolPlugin.js +3 -1
- package/lib/Stats.js +5 -0
- package/lib/Template.js +20 -0
- package/lib/TemplatedPathPlugin.js +10 -3
- package/lib/UseStrictPlugin.js +2 -1
- package/lib/WarnCaseSensitiveModulesPlugin.js +71 -3
- package/lib/WarnDeprecatedOptionPlugin.js +2 -2
- package/lib/WarnNoModeSetPlugin.js +17 -2
- package/lib/WatchIgnorePlugin.js +4 -1
- package/lib/Watching.js +16 -3
- package/lib/WebpackError.js +3 -74
- package/lib/WebpackIsIncludedPlugin.js +3 -1
- package/lib/WebpackOptionsApply.js +14 -1
- package/lib/WebpackOptionsDefaulter.js +1 -0
- package/lib/asset/AssetBytesGenerator.js +12 -2
- package/lib/asset/AssetBytesParser.js +1 -0
- package/lib/asset/AssetGenerator.js +42 -10
- package/lib/asset/AssetModulesPlugin.js +7 -2
- package/lib/asset/AssetParser.js +2 -0
- package/lib/asset/AssetSourceGenerator.js +12 -2
- package/lib/asset/AssetSourceParser.js +1 -0
- package/lib/asset/RawDataUrlModule.js +11 -0
- package/lib/async-modules/AsyncModuleHelpers.js +1 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -0
- package/lib/async-modules/InferAsyncModulesPlugin.js +1 -1
- package/lib/buildChunkGraph.js +19 -6
- package/lib/cache/AddBuildDependenciesPlugin.js +2 -1
- package/lib/cache/AddManagedPathsPlugin.js +2 -1
- package/lib/cache/IdleFileCachePlugin.js +2 -1
- package/lib/cache/MemoryCachePlugin.js +1 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +3 -1
- package/lib/cache/PackFileCacheStrategy.js +33 -4
- package/lib/cache/ResolverCachePlugin.js +10 -1
- package/lib/cache/getLazyHashedEtag.js +4 -0
- package/lib/cache/mergeEtags.js +2 -0
- package/lib/cli.js +33 -1
- package/lib/config/browserslistTargetHandler.js +2 -0
- package/lib/config/defaults.js +232 -12
- package/lib/config/normalization.js +15 -1
- package/lib/config/target.js +11 -0
- package/lib/container/ContainerEntryDependency.js +2 -0
- package/lib/container/ContainerEntryModule.js +12 -0
- package/lib/container/ContainerEntryModuleFactory.js +1 -0
- package/lib/container/ContainerExposedDependency.js +4 -0
- package/lib/container/ContainerPlugin.js +2 -1
- package/lib/container/ContainerReferencePlugin.js +2 -1
- package/lib/container/FallbackDependency.js +4 -0
- package/lib/container/FallbackItemDependency.js +1 -0
- package/lib/container/FallbackModule.js +12 -0
- package/lib/container/FallbackModuleFactory.js +1 -0
- package/lib/container/ModuleFederationPlugin.js +3 -1
- package/lib/container/RemoteModule.js +13 -0
- package/lib/container/RemoteRuntimeModule.js +1 -0
- package/lib/container/RemoteToExternalDependency.js +1 -0
- package/lib/container/options.js +7 -0
- package/lib/css/CssGenerator.js +336 -100
- package/lib/css/CssInjectStyleRuntimeModule.js +45 -42
- package/lib/css/CssLoadingRuntimeModule.js +23 -4
- package/lib/{CssModule.js → css/CssModule.js} +21 -15
- package/lib/css/CssModulesPlugin.js +235 -89
- package/lib/css/CssParser.js +616 -261
- package/lib/css/walkCssTokens.js +179 -2
- package/lib/debug/ProfilingPlugin.js +19 -1
- package/lib/dependencies/AMDDefineDependency.js +7 -0
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -0
- package/lib/dependencies/AMDPlugin.js +4 -1
- package/lib/dependencies/AMDRequireArrayDependency.js +6 -0
- package/lib/dependencies/AMDRequireContextDependency.js +3 -0
- package/lib/dependencies/AMDRequireDependenciesBlock.js +1 -0
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +14 -1
- package/lib/dependencies/AMDRequireDependency.js +4 -0
- package/lib/dependencies/AMDRequireItemDependency.js +1 -0
- package/lib/dependencies/AMDRuntimeModules.js +3 -0
- package/lib/dependencies/CachedConstDependency.js +6 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +64 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +62 -10
- package/lib/dependencies/CommonJsExportsDependency.js +4 -0
- package/lib/dependencies/CommonJsExportsParserPlugin.js +9 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +36 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +24 -3
- package/lib/dependencies/CommonJsPlugin.js +4 -1
- package/lib/dependencies/CommonJsRequireContextDependency.js +3 -0
- package/lib/dependencies/CommonJsRequireDependency.js +70 -4
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +5 -0
- package/lib/dependencies/ConstDependency.js +6 -1
- package/lib/dependencies/ContextDependency.js +9 -2
- package/lib/dependencies/ContextDependencyHelpers.js +4 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/ContextElementDependency.js +4 -0
- package/lib/dependencies/CreateRequireParserPlugin.js +7 -1
- package/lib/dependencies/CreateScriptUrlDependency.js +4 -0
- package/lib/dependencies/CriticalDependencyWarning.js +2 -1
- package/lib/dependencies/CssIcssExportDependency.js +339 -66
- package/lib/dependencies/CssIcssImportDependency.js +53 -8
- package/lib/dependencies/CssIcssSymbolDependency.js +16 -4
- package/lib/dependencies/CssImportDependency.js +12 -0
- package/lib/dependencies/CssUrlDependency.js +32 -0
- package/lib/dependencies/DelegatedSourceDependency.js +1 -0
- package/lib/dependencies/DllEntryDependency.js +3 -0
- package/lib/dependencies/DynamicExports.js +5 -0
- package/lib/dependencies/EntryDependency.js +1 -0
- package/lib/dependencies/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/ExternalModuleDependency.js +5 -0
- package/lib/dependencies/ExternalModuleInitFragment.js +3 -0
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +4 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +6 -0
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -0
- package/lib/dependencies/HarmonyCompatibilityDependency.js +1 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -0
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +10 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +27 -14
- package/lib/dependencies/HarmonyExportHeaderDependency.js +4 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +143 -5
- package/lib/dependencies/HarmonyExportInitFragment.js +6 -0
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +5 -0
- package/lib/dependencies/HarmonyExports.js +2 -0
- package/lib/dependencies/HarmonyImportDependency.js +21 -2
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +31 -1
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -0
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +18 -3
- package/lib/{HarmonyLinkingError.js → dependencies/HarmonyLinkingError.js} +5 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +4 -1
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -0
- package/lib/dependencies/HtmlInlineScriptDependency.js +133 -0
- package/lib/dependencies/HtmlInlineStyleDependency.js +101 -0
- package/lib/dependencies/HtmlScriptSrcDependency.js +318 -0
- package/lib/dependencies/HtmlSourceDependency.js +127 -0
- package/lib/dependencies/ImportContextDependency.js +4 -0
- package/lib/dependencies/ImportDependency.js +5 -0
- package/lib/dependencies/ImportEagerDependency.js +2 -0
- package/lib/dependencies/ImportMetaContextDependency.js +1 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -1
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +1 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +1 -0
- package/lib/dependencies/ImportMetaPlugin.js +6 -0
- package/lib/dependencies/ImportParserPlugin.js +9 -2
- package/lib/dependencies/ImportPhase.js +7 -3
- package/lib/dependencies/ImportPlugin.js +2 -1
- package/lib/dependencies/ImportWeakDependency.js +2 -0
- package/lib/dependencies/JsonExportsDependency.js +6 -1
- package/lib/dependencies/LoaderDependency.js +2 -0
- package/lib/dependencies/LoaderImportDependency.js +2 -0
- package/lib/dependencies/LoaderPlugin.js +4 -1
- package/lib/dependencies/LocalModule.js +4 -0
- package/lib/dependencies/LocalModuleDependency.js +4 -0
- package/lib/dependencies/LocalModulesHelpers.js +3 -0
- package/lib/dependencies/ModuleDecoratorDependency.js +7 -1
- package/lib/dependencies/ModuleDependency.js +7 -0
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +1 -0
- package/lib/dependencies/ModuleInitFragmentDependency.js +4 -0
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/PrefetchDependency.js +1 -0
- package/lib/dependencies/ProvidedDependency.js +6 -1
- package/lib/dependencies/PureExpressionDependency.js +7 -1
- package/lib/dependencies/RequireContextDependency.js +1 -0
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +2 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +1 -0
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -0
- package/lib/dependencies/RequireEnsureDependency.js +4 -0
- package/lib/dependencies/RequireEnsureItemDependency.js +1 -0
- package/lib/dependencies/RequireEnsurePlugin.js +2 -1
- package/lib/dependencies/RequireHeaderDependency.js +4 -0
- package/lib/dependencies/RequireIncludeDependency.js +2 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +4 -1
- package/lib/dependencies/RequireIncludePlugin.js +2 -1
- package/lib/{RequireJsStuffPlugin.js → dependencies/RequireJsStuffPlugin.js} +9 -8
- package/lib/dependencies/RequireResolveContextDependency.js +3 -0
- package/lib/dependencies/RequireResolveDependency.js +1 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +5 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +5 -1
- package/lib/dependencies/StaticExportsDependency.js +3 -0
- package/lib/dependencies/SystemPlugin.js +5 -2
- package/lib/dependencies/SystemRuntimeModule.js +1 -0
- package/lib/dependencies/URLContextDependency.js +3 -0
- package/lib/dependencies/URLDependency.js +6 -0
- package/lib/dependencies/URLPlugin.js +2 -0
- package/lib/dependencies/UnsupportedDependency.js +4 -0
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +4 -0
- package/lib/dependencies/WebAssemblyImportDependency.js +5 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -0
- package/lib/dependencies/WorkerDependency.js +6 -1
- package/lib/dependencies/WorkerPlugin.js +11 -3
- package/lib/dependencies/getFunctionExpression.js +1 -0
- package/lib/dependencies/processExportInfo.js +1 -0
- package/lib/{DelegatedModule.js → dll/DelegatedModule.js} +44 -31
- package/lib/{DelegatedModuleFactoryPlugin.js → dll/DelegatedModuleFactoryPlugin.js} +7 -4
- package/lib/{DelegatedPlugin.js → dll/DelegatedPlugin.js} +4 -3
- package/lib/{DllEntryPlugin.js → dll/DllEntryPlugin.js} +6 -5
- package/lib/{DllModule.js → dll/DllModule.js} +35 -24
- package/lib/{DllModuleFactory.js → dll/DllModuleFactory.js} +5 -4
- package/lib/{DllPlugin.js → dll/DllPlugin.js} +8 -6
- package/lib/{DllReferencePlugin.js → dll/DllReferencePlugin.js} +23 -18
- package/lib/{LibManifestPlugin.js → dll/LibManifestPlugin.js} +13 -10
- package/lib/electron/ElectronTargetPlugin.js +2 -1
- package/lib/{AbstractMethodError.js → errors/AbstractMethodError.js} +10 -1
- package/lib/{AsyncDependencyToInitialChunkError.js → errors/AsyncDependencyToInitialChunkError.js} +8 -3
- package/lib/errors/BuildCycleError.js +1 -1
- package/lib/{ChunkRenderError.js → errors/ChunkRenderError.js} +1 -1
- package/lib/{CodeGenerationError.js → errors/CodeGenerationError.js} +1 -1
- package/lib/{CommentCompilationWarning.js → errors/CommentCompilationWarning.js} +9 -3
- package/lib/{ConcurrentCompilationError.js → errors/ConcurrentCompilationError.js} +4 -2
- package/lib/{EnvironmentNotSupportAsyncWarning.js → errors/EnvironmentNotSupportAsyncWarning.js} +4 -4
- package/lib/{HookWebpackError.js → errors/HookWebpackError.js} +11 -5
- package/lib/{IgnoreErrorModuleFactory.js → errors/IgnoreErrorModuleFactory.js} +6 -4
- package/lib/{InvalidDependenciesModuleWarning.js → errors/InvalidDependenciesModuleWarning.js} +4 -3
- package/lib/errors/JSONParseError.js +114 -0
- package/lib/{ModuleBuildError.js → errors/ModuleBuildError.js} +8 -5
- package/lib/{ModuleDependencyError.js → errors/ModuleDependencyError.js} +2 -2
- package/lib/{ModuleDependencyWarning.js → errors/ModuleDependencyWarning.js} +5 -4
- package/lib/{ModuleError.js → errors/ModuleError.js} +7 -5
- package/lib/{ModuleHashingError.js → errors/ModuleHashingError.js} +1 -1
- package/lib/{ModuleNotFoundError.js → errors/ModuleNotFoundError.js} +3 -2
- package/lib/{ModuleParseError.js → errors/ModuleParseError.js} +11 -6
- package/lib/{ModuleRestoreError.js → errors/ModuleRestoreError.js} +2 -1
- package/lib/{ModuleStoreError.js → errors/ModuleStoreError.js} +2 -1
- package/lib/{ModuleWarning.js → errors/ModuleWarning.js} +8 -5
- package/lib/{NodeStuffInWebError.js → errors/NodeStuffInWebError.js} +5 -4
- package/lib/errors/NonErrorEmittedError.js +28 -0
- package/lib/{UnhandledSchemeError.js → errors/UnhandledSchemeError.js} +8 -2
- package/lib/{UnsupportedFeatureWarning.js → errors/UnsupportedFeatureWarning.js} +4 -3
- package/lib/errors/WebpackError.js +84 -0
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +2 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +5 -1
- package/lib/esm/ModuleChunkLoadingPlugin.js +3 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +5 -0
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +20 -1
- package/lib/hmr/lazyCompilationBackend.js +2 -0
- package/lib/html/HtmlGenerator.js +379 -0
- package/lib/html/HtmlModulesPlugin.js +433 -0
- package/lib/html/HtmlParser.js +1489 -0
- package/lib/html/walkHtmlTokens.js +2733 -0
- package/lib/ids/ChunkModuleIdRangePlugin.js +3 -1
- package/lib/ids/DeterministicChunkIdsPlugin.js +3 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +3 -1
- package/lib/ids/HashedModuleIdsPlugin.js +2 -1
- package/lib/ids/IdHelpers.js +22 -1
- package/lib/ids/NamedChunkIdsPlugin.js +3 -1
- package/lib/ids/NamedModuleIdsPlugin.js +3 -1
- package/lib/ids/NaturalChunkIdsPlugin.js +1 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -1
- package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -1
- package/lib/ids/SyncModuleIdsPlugin.js +3 -1
- package/lib/index.js +39 -15
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -1
- package/lib/javascript/BasicEvaluatedExpression.js +4 -2
- package/lib/javascript/ChunkFormatHelpers.js +2 -1
- package/lib/javascript/ChunkHelpers.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/EnableChunkLoadingPlugin.js +5 -1
- package/lib/javascript/JavascriptGenerator.js +10 -0
- package/lib/javascript/JavascriptModulesPlugin.js +112 -9
- package/lib/javascript/JavascriptParser.js +360 -16
- package/lib/javascript/JavascriptParserHelpers.js +7 -1
- package/lib/javascript/StartupHelpers.js +5 -0
- package/lib/json/JsonData.js +5 -0
- package/lib/json/JsonGenerator.js +21 -0
- package/lib/json/JsonModulesPlugin.js +1 -1
- package/lib/json/JsonParser.js +14 -25
- package/lib/library/AbstractLibraryPlugin.js +17 -2
- package/lib/library/AmdLibraryPlugin.js +8 -0
- package/lib/library/AssignLibraryPlugin.js +16 -0
- package/lib/library/EnableLibraryPlugin.js +8 -2
- package/lib/library/ExportPropertyLibraryPlugin.js +9 -0
- package/lib/{FalseIIFEUmdWarning.js → library/FalseIIFEUmdWarning.js} +1 -1
- package/lib/library/JsonpLibraryPlugin.js +8 -0
- package/lib/library/ModuleLibraryPlugin.js +86 -1
- package/lib/library/SystemLibraryPlugin.js +8 -0
- package/lib/library/UmdLibraryPlugin.js +16 -0
- package/lib/logging/Logger.js +17 -0
- package/lib/logging/createConsoleLogger.js +7 -0
- package/lib/logging/runtime.js +2 -0
- package/lib/logging/truncateArgs.js +2 -0
- package/lib/node/CommonJsChunkLoadingPlugin.js +5 -1
- package/lib/node/NodeEnvironmentPlugin.js +7 -3
- package/lib/node/NodeSourcePlugin.js +1 -1
- package/lib/node/NodeTargetPlugin.js +2 -1
- package/lib/node/NodeTemplatePlugin.js +3 -1
- package/lib/node/NodeWatchFileSystem.js +2 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +3 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +4 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +4 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +3 -0
- package/lib/node/nodeConsole.js +116 -64
- package/lib/optimize/AggressiveMergingPlugin.js +3 -1
- package/lib/optimize/AggressiveSplittingPlugin.js +6 -1
- package/lib/optimize/ConcatenatedModule.js +62 -6
- package/lib/optimize/EnsureChunkConditionsPlugin.js +2 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +2 -1
- package/lib/optimize/InnerGraph.js +16 -1
- package/lib/optimize/InnerGraphPlugin.js +14 -2
- package/lib/optimize/LimitChunkCountPlugin.js +9 -0
- package/lib/optimize/MangleExportsPlugin.js +5 -1
- package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -0
- package/lib/optimize/MinChunkSizePlugin.js +2 -1
- package/lib/optimize/MinMaxSizeWarning.js +5 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +36 -8
- package/lib/optimize/RealContentHashPlugin.js +104 -26
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -1
- package/lib/optimize/RuntimeChunkPlugin.js +2 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +118 -4
- package/lib/optimize/SplitChunksPlugin.js +50 -2
- package/lib/performance/AssetsOverSizeLimitWarning.js +3 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +3 -2
- package/lib/performance/NoAsyncChunksWarning.js +5 -3
- package/lib/performance/SizeLimitsPlugin.js +8 -2
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +1 -0
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +6 -0
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +1 -0
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +5 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -0
- package/lib/rules/BasicEffectRulePlugin.js +3 -0
- package/lib/rules/BasicMatcherRulePlugin.js +3 -0
- package/lib/rules/ObjectMatcherRulePlugin.js +3 -0
- package/lib/rules/RuleSetCompiler.js +18 -0
- package/lib/rules/UseEffectRulePlugin.js +10 -3
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -0
- package/lib/runtime/AutoPublicPathRuntimeModule.js +1 -0
- package/lib/runtime/BaseUriRuntimeModule.js +1 -0
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -0
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +1 -0
- package/lib/runtime/CompatRuntimeModule.js +2 -0
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -0
- package/lib/runtime/CreateScriptRuntimeModule.js +1 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +1 -0
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -0
- package/lib/runtime/EnsureChunkRuntimeModule.js +1 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +1 -0
- package/lib/runtime/GetFullHashRuntimeModule.js +1 -0
- package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -0
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -0
- package/lib/runtime/GlobalRuntimeModule.js +1 -0
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +1 -0
- package/lib/runtime/HelperRuntimeModule.js +5 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +1 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +121 -13
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +1 -0
- package/lib/runtime/NonceRuntimeModule.js +1 -0
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +1 -0
- package/lib/runtime/PublicPathRuntimeModule.js +1 -0
- package/lib/runtime/RelativeUrlRuntimeModule.js +1 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +1 -0
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +35 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +13 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -0
- package/lib/runtime/StartupEntrypointRuntimeModule.js +1 -0
- package/lib/runtime/SystemContextRuntimeModule.js +1 -0
- package/lib/runtime/ToBinaryRuntimeModule.js +1 -0
- package/lib/schemes/DataUriPlugin.js +14 -2
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +43 -1
- package/lib/schemes/VirtualUrlPlugin.js +7 -2
- package/lib/serialization/AggregateErrorSerializer.js +2 -0
- package/lib/serialization/ArraySerializer.js +2 -0
- package/lib/serialization/BinaryMiddleware.js +20 -1
- package/lib/serialization/DateObjectSerializer.js +2 -0
- package/lib/serialization/ErrorObjectSerializer.js +3 -0
- package/lib/serialization/FileMiddleware.js +21 -0
- package/lib/serialization/MapObjectSerializer.js +2 -0
- package/lib/serialization/NullPrototypeObjectSerializer.js +2 -0
- package/lib/serialization/ObjectMiddleware.js +23 -0
- package/lib/serialization/PlainObjectSerializer.js +7 -0
- package/lib/serialization/RegExpObjectSerializer.js +2 -0
- package/lib/serialization/Serializer.js +5 -0
- package/lib/serialization/SerializerMiddleware.js +14 -2
- package/lib/serialization/SetObjectSerializer.js +2 -0
- package/lib/serialization/SingleItemMiddleware.js +3 -0
- package/lib/sharing/ConsumeSharedFallbackDependency.js +1 -0
- package/lib/sharing/ConsumeSharedModule.js +15 -0
- package/lib/sharing/ConsumeSharedPlugin.js +8 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -4
- package/lib/sharing/ProvideForSharedDependency.js +1 -0
- package/lib/sharing/ProvideSharedDependency.js +4 -0
- package/lib/sharing/ProvideSharedModule.js +12 -1
- package/lib/sharing/ProvideSharedModuleFactory.js +1 -0
- package/lib/sharing/ProvideSharedPlugin.js +5 -2
- package/lib/sharing/SharePlugin.js +2 -1
- package/lib/sharing/ShareRuntimeModule.js +1 -0
- package/lib/sharing/resolveMatchedConfigs.js +4 -1
- package/lib/sharing/utils.js +8 -0
- package/lib/stats/DefaultStatsFactoryPlugin.js +58 -3
- package/lib/stats/DefaultStatsPresetPlugin.js +12 -2
- package/lib/stats/DefaultStatsPrinterPlugin.js +38 -2
- package/lib/stats/StatsFactory.js +13 -1
- package/lib/stats/StatsPrinter.js +7 -0
- package/lib/typescript/TypeScriptPlugin.js +210 -0
- package/lib/url/URLParserPlugin.js +8 -2
- package/lib/util/AppendOnlyStackedSet.js +15 -0
- package/lib/util/ArrayHelpers.js +1 -0
- package/lib/util/ArrayQueue.js +10 -5
- package/lib/util/AsyncQueue.js +22 -2
- package/lib/util/Hash.js +2 -2
- package/lib/util/IterableHelpers.js +3 -0
- package/lib/util/LazyBucketSortedSet.js +21 -0
- package/lib/util/LazySet.js +39 -0
- package/lib/util/LocConverter.js +53 -0
- package/lib/util/ParallelismFactorCalculator.js +1 -0
- package/lib/util/Queue.js +6 -3
- package/lib/util/Semaphore.js +14 -1
- package/lib/util/SetHelpers.js +3 -0
- package/lib/util/SortableSet.js +7 -1
- package/lib/util/StackedCacheMap.js +20 -3
- package/lib/util/StackedMap.js +45 -0
- package/lib/util/StringXor.js +1 -1
- package/lib/util/TupleQueue.js +7 -3
- package/lib/util/TupleSet.js +13 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -0
- package/lib/util/WeakTupleMap.js +33 -0
- package/lib/util/binarySearchBounds.js +1 -0
- package/lib/util/cleverMerge.js +19 -2
- package/lib/util/comparators.js +34 -3
- package/lib/util/compileBooleanMatcher.js +9 -0
- package/lib/util/concatenate.js +9 -3
- package/lib/util/conventions.js +46 -1
- package/lib/util/createMappings.js +118 -0
- package/lib/util/dataURL.js +1 -0
- package/lib/util/deprecation.js +19 -0
- package/lib/util/deterministicGrouping.js +20 -0
- package/lib/util/extractSourceMap.js +1 -0
- package/lib/util/extractUrlAndGlobal.js +1 -0
- package/lib/util/findGraphRoots.js +5 -0
- package/lib/{formatLocation.js → util/formatLocation.js} +4 -2
- package/lib/{SizeFormatHelpers.js → util/formatSize.js} +4 -1
- package/lib/util/fs.js +71 -8
- package/lib/util/generateDebugId.js +1 -0
- package/lib/util/hash/BatchedHash.js +1 -0
- package/lib/util/hash/BulkUpdateHash.js +1 -0
- package/lib/util/hash/hash-digest.js +8 -0
- package/lib/util/hash/md4.js +1 -1
- package/lib/util/hash/wasm-hash.js +5 -0
- package/lib/util/hash/xxhash64.js +1 -1
- package/lib/util/identifier.js +67 -0
- package/lib/util/internalSerializables.js +35 -19
- package/lib/util/magicComment.js +10 -6
- package/lib/util/makeSerializable.js +6 -0
- package/lib/util/memoize.js +2 -0
- package/lib/util/mimeTypes.js +176 -0
- package/lib/util/nonNumericOnlyHash.js +1 -0
- package/lib/util/parseJson.js +41 -0
- package/lib/util/processAsyncTree.js +8 -0
- package/lib/util/property.js +1 -0
- package/lib/util/registerExternalSerializer.js +20 -0
- package/lib/util/removeBOM.js +1 -0
- package/lib/util/runtime.js +32 -0
- package/lib/util/semver.js +15 -0
- package/lib/util/serialization.js +2 -0
- package/lib/util/smartGrouping.js +8 -0
- package/lib/util/source.js +23 -0
- package/lib/util/topologicalSort.js +69 -0
- package/lib/validateSchema.js +1 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +15 -1
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +1 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +1 -0
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +12 -3
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +12 -1
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +6 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +1 -0
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +26 -1
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +7 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +4 -0
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +10 -1
- package/lib/wasm-sync/WebAssemblyParser.js +2 -0
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -0
- package/lib/web/FetchCompileAsyncWasmPlugin.js +10 -1
- package/lib/web/FetchCompileWasmPlugin.js +13 -1
- package/lib/web/JsonpChunkLoadingPlugin.js +11 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -0
- package/lib/web/JsonpTemplatePlugin.js +2 -1
- package/lib/webpack.js +13 -1
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +10 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -0
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -1
- package/package.json +31 -31
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +161 -57
- package/schemas/plugins/{DllPlugin.check.d.ts → HtmlGeneratorOptions.check.d.ts} +1 -1
- package/schemas/plugins/HtmlGeneratorOptions.check.js +6 -0
- package/schemas/plugins/HtmlGeneratorOptions.json +3 -0
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +22 -0
- package/schemas/plugins/{DllReferencePlugin.check.d.ts → css/CssAutoOrModuleParserOptions.check.d.ts} +1 -1
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.json +3 -0
- package/schemas/plugins/dll/DllPlugin.check.d.ts +7 -0
- package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +7 -0
- package/types.d.ts +5325 -353
- package/lib/CaseSensitiveModulesWarning.js +0 -72
- package/lib/GraphHelpers.js +0 -46
- package/lib/NoModeWarning.js +0 -23
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +0 -56
- /package/schemas/plugins/{DllPlugin.check.js → dll/DllPlugin.check.js} +0 -0
- /package/schemas/plugins/{DllPlugin.json → dll/DllPlugin.json} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.check.js → dll/DllReferencePlugin.check.js} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.json → dll/DllReferencePlugin.json} +0 -0
package/lib/css/CssGenerator.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
9
|
ConcatSource,
|
|
10
|
+
OriginalSource,
|
|
10
11
|
RawSource,
|
|
11
12
|
ReplaceSource,
|
|
12
13
|
SourceMapSource
|
|
@@ -15,8 +16,11 @@ const { UsageState } = require("../ExportsInfo");
|
|
|
15
16
|
const Generator = require("../Generator");
|
|
16
17
|
const InitFragment = require("../InitFragment");
|
|
17
18
|
const {
|
|
19
|
+
CSS_TEXT_TYPE,
|
|
20
|
+
CSS_TEXT_TYPES,
|
|
18
21
|
CSS_TYPE,
|
|
19
22
|
CSS_TYPES,
|
|
23
|
+
JAVASCRIPT_AND_CSS_TEXT_TYPES,
|
|
20
24
|
JAVASCRIPT_AND_CSS_TYPES,
|
|
21
25
|
JAVASCRIPT_TYPE,
|
|
22
26
|
JAVASCRIPT_TYPES
|
|
@@ -26,6 +30,7 @@ const Template = require("../Template");
|
|
|
26
30
|
const CssImportDependency = require("../dependencies/CssImportDependency");
|
|
27
31
|
const HarmonyImportSideEffectDependency = require("../dependencies/HarmonyImportSideEffectDependency");
|
|
28
32
|
|
|
33
|
+
const { encodeMappings } = require("../util/createMappings");
|
|
29
34
|
const memoize = require("../util/memoize");
|
|
30
35
|
|
|
31
36
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
@@ -46,16 +51,77 @@ const memoize = require("../util/memoize");
|
|
|
46
51
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
47
52
|
/** @typedef {import("../util/Hash")} Hash */
|
|
48
53
|
/** @typedef {import("./CssModulesPlugin").ModuleFactoryCacheEntry} ModuleFactoryCacheEntry */
|
|
49
|
-
/** @typedef {import("
|
|
54
|
+
/** @typedef {import("./CssModule")} CssModule */
|
|
50
55
|
/** @typedef {import("../Compilation")} Compilation */
|
|
51
56
|
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
|
52
57
|
/** @typedef {import("../../declarations/WebpackOptions").CssParserExportType} CssParserExportType */
|
|
53
58
|
|
|
59
|
+
/** @typedef {{ line: number, column: number }} SourcePosition */
|
|
60
|
+
/** @typedef {Map<string, SourcePosition>} ExportLocsMap */
|
|
61
|
+
|
|
54
62
|
const getPropertyName = memoize(() => require("../util/property"));
|
|
55
63
|
const getCssModulesPlugin = memoize(() => require("./CssModulesPlugin"));
|
|
56
64
|
|
|
65
|
+
/** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Build a v3 source map that maps each line in `generatedJs` containing a
|
|
69
|
+
* known CSS-class export entry back to the corresponding selector position
|
|
70
|
+
* in the original CSS. Lines without an associated export are left
|
|
71
|
+
* unmapped — devtools simply shows them as part of the bundled JS.
|
|
72
|
+
* @param {string} generatedJs the generated JS string
|
|
73
|
+
* @param {ExportLocsMap} exportLocs map of export names to CSS source location
|
|
74
|
+
* @param {string} cssContent original CSS source content
|
|
75
|
+
* @param {string} sourceName source identifier to use in the map
|
|
76
|
+
* @returns {RawSourceMap} a v3 RawSourceMap
|
|
77
|
+
*/
|
|
78
|
+
const buildExportsSourceMap = (
|
|
79
|
+
generatedJs,
|
|
80
|
+
exportLocs,
|
|
81
|
+
cssContent,
|
|
82
|
+
sourceName
|
|
83
|
+
) => {
|
|
84
|
+
const lines = generatedJs.split("\n");
|
|
85
|
+
|
|
86
|
+
const lineByExport = new Map();
|
|
87
|
+
for (const [exportName] of exportLocs) {
|
|
88
|
+
const needle = `${JSON.stringify(exportName)}:`;
|
|
89
|
+
for (let i = 0; i < lines.length; i++) {
|
|
90
|
+
if (lines[i].includes(needle)) {
|
|
91
|
+
lineByExport.set(exportName, i);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** @type {(import("../util/createMappings").LineMappings)[]} */
|
|
98
|
+
const perLine = lines.map(() => null);
|
|
99
|
+
for (const [exportName, genLine] of lineByExport) {
|
|
100
|
+
const pos = /** @type {SourcePosition} */ (exportLocs.get(exportName));
|
|
101
|
+
// Source-map V3 uses 0-based lines and 0-based columns. webpack's
|
|
102
|
+
// dependency `loc` uses 1-based lines and 0-based columns, so subtract
|
|
103
|
+
// one from the line.
|
|
104
|
+
perLine[genLine] = {
|
|
105
|
+
generatedColumn: 0,
|
|
106
|
+
sourceIndex: 0,
|
|
107
|
+
originalLine: pos.line - 1,
|
|
108
|
+
originalColumn: pos.column
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
version: 3,
|
|
114
|
+
file: "",
|
|
115
|
+
sources: [sourceName],
|
|
116
|
+
sourcesContent: [cssContent],
|
|
117
|
+
names: [],
|
|
118
|
+
mappings: encodeMappings(perLine)
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
57
122
|
class CssGenerator extends Generator {
|
|
58
123
|
/**
|
|
124
|
+
* Creates an instance of CssGenerator.
|
|
59
125
|
* @param {CssModuleGeneratorOptions} options options
|
|
60
126
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
61
127
|
*/
|
|
@@ -70,6 +136,7 @@ class CssGenerator extends Generator {
|
|
|
70
136
|
}
|
|
71
137
|
|
|
72
138
|
/**
|
|
139
|
+
* Returns the reason this module cannot be concatenated, when one exists.
|
|
73
140
|
* @param {NormalModule} module module for which the bailout reason should be determined
|
|
74
141
|
* @param {ConcatenationBailoutReasonContext} context context
|
|
75
142
|
* @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated
|
|
@@ -83,52 +150,134 @@ class CssGenerator extends Generator {
|
|
|
83
150
|
}
|
|
84
151
|
|
|
85
152
|
/**
|
|
86
|
-
*
|
|
153
|
+
* Returns the `@charset` that will appear at the start of this module's
|
|
154
|
+
* default export, walking through text imports when the module has no
|
|
155
|
+
* local `@charset` of its own.
|
|
156
|
+
* @param {NormalModule} module the module
|
|
157
|
+
* @param {ModuleGraph} moduleGraph module graph
|
|
158
|
+
* @param {WeakSet<NormalModule>=} visited cycle guard
|
|
159
|
+
* @returns {string | undefined} the effective charset
|
|
160
|
+
*/
|
|
161
|
+
_getEffectiveCharset(module, moduleGraph, visited = new WeakSet()) {
|
|
162
|
+
if (!module || visited.has(module)) return undefined;
|
|
163
|
+
const exportType = /** @type {CssModule} */ (module).exportType;
|
|
164
|
+
if (exportType !== "text" && exportType !== "css-style-sheet") {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
visited.add(module);
|
|
168
|
+
const own =
|
|
169
|
+
module.buildInfo && /** @type {BuildInfo} */ (module.buildInfo).charset;
|
|
170
|
+
if (own !== undefined) return own;
|
|
171
|
+
if (exportType !== "text") return undefined;
|
|
172
|
+
for (const dep of module.dependencies) {
|
|
173
|
+
if (dep instanceof CssImportDependency) {
|
|
174
|
+
const depModule = /** @type {NormalModule} */ (
|
|
175
|
+
moduleGraph.getModule(dep)
|
|
176
|
+
);
|
|
177
|
+
const inherited = this._getEffectiveCharset(
|
|
178
|
+
depModule,
|
|
179
|
+
moduleGraph,
|
|
180
|
+
visited
|
|
181
|
+
);
|
|
182
|
+
if (inherited !== undefined) return inherited;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Generate JavaScript expressions that evaluate each `@import`'d module
|
|
190
|
+
* for side effects. Only used by `style` exportType, where each imported
|
|
191
|
+
* style module injects its own `<style>` element independently — no
|
|
192
|
+
* content merging happens at the parent. `text` and `css-style-sheet`
|
|
193
|
+
* instead inline their imports at build time via
|
|
194
|
+
* {@link CssGenerator#_generateMergedContentSource}.
|
|
87
195
|
* @param {NormalModule} module the module to generate CSS text for
|
|
88
196
|
* @param {GenerateContext} generateContext the generate context
|
|
89
|
-
* @
|
|
90
|
-
* @returns {{ expr: string, type: CssParserExportType }[]} JavaScript code that concatenates all imported CSS
|
|
197
|
+
* @returns {string[]} JS expressions, one per `@import` dependency
|
|
91
198
|
*/
|
|
92
|
-
|
|
93
|
-
const moduleGraph = generateContext
|
|
94
|
-
/** @type {{ expr: string, type: CssParserExportType }[]} */
|
|
199
|
+
_generateImportSideEffects(module, generateContext) {
|
|
200
|
+
const { moduleGraph, concatenationScope } = generateContext;
|
|
95
201
|
const parts = [];
|
|
96
202
|
|
|
97
|
-
// Iterate through module.dependencies to maintain source order
|
|
98
203
|
for (const dep of module.dependencies) {
|
|
99
|
-
if (dep instanceof CssImportDependency)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
204
|
+
if (!(dep instanceof CssImportDependency)) continue;
|
|
205
|
+
const depModule = /** @type {CssModule} */ (moduleGraph.getModule(dep));
|
|
206
|
+
// Concat-scoped deps are inlined into the same module; their side
|
|
207
|
+
// effect (own `<style>` injection) is emitted at the dep's own
|
|
208
|
+
// site, so no explicit reference is needed here.
|
|
209
|
+
if (concatenationScope && concatenationScope.isModuleInScope(depModule)) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
parts.push(
|
|
213
|
+
generateContext.runtimeTemplate.moduleExports({
|
|
103
214
|
module: depModule,
|
|
104
215
|
chunkGraph: generateContext.chunkGraph,
|
|
105
|
-
request:
|
|
216
|
+
request: depModule.userRequest,
|
|
106
217
|
weak: false,
|
|
107
218
|
runtimeRequirements: generateContext.runtimeRequirements
|
|
108
|
-
})
|
|
219
|
+
})
|
|
220
|
+
);
|
|
221
|
+
}
|
|
109
222
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
223
|
+
return parts;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Build a single CSS `Source` that contains, in source order, the rendered
|
|
228
|
+
* CSS text of every transitively `@import`'d module followed by the
|
|
229
|
+
* current module's own CSS text. Imports are inlined at build time so
|
|
230
|
+
* the resulting `Source` carries a single, accurate source map covering
|
|
231
|
+
* every contributing file — no runtime merge helper required.
|
|
232
|
+
*
|
|
233
|
+
* Only `text` / `css-style-sheet` imports contribute CSS text; `link` and
|
|
234
|
+
* `style` imports are emitted separately (own `.css` file or own
|
|
235
|
+
* `<style>` injection) and are skipped here.
|
|
236
|
+
*
|
|
237
|
+
* `ancestors` tracks the path from the top-level caller down to the
|
|
238
|
+
* current module — not every module ever visited. A module reappearing
|
|
239
|
+
* along a sibling branch (a "diamond import" like two different files
|
|
240
|
+
* each `@import`'ing the same shared module) must be inlined every time,
|
|
241
|
+
* matching the prior runtime behavior where each `default` getter was
|
|
242
|
+
* invoked at every import site.
|
|
243
|
+
* @param {NormalModule} module the module to render
|
|
244
|
+
* @param {GenerateContext} generateContext the generate context
|
|
245
|
+
* @param {Set<NormalModule>} ancestors modules on the current path
|
|
246
|
+
* @returns {Source | null} merged CSS source, or null when the module has no content
|
|
247
|
+
*/
|
|
248
|
+
_generateMergedContentSource(module, generateContext, ancestors) {
|
|
249
|
+
if (ancestors.has(module)) return null;
|
|
250
|
+
ancestors.add(module);
|
|
251
|
+
try {
|
|
252
|
+
const { moduleGraph } = generateContext;
|
|
253
|
+
/** @type {Source[]} */
|
|
254
|
+
const parts = [];
|
|
255
|
+
|
|
256
|
+
for (const dep of module.dependencies) {
|
|
257
|
+
if (!(dep instanceof CssImportDependency)) continue;
|
|
258
|
+
const depModule = /** @type {CssModule} */ (moduleGraph.getModule(dep));
|
|
259
|
+
if (!depModule) continue;
|
|
260
|
+
const depExportType = depModule.exportType;
|
|
261
|
+
if (depExportType !== "text" && depExportType !== "css-style-sheet") {
|
|
262
|
+
continue;
|
|
127
263
|
}
|
|
264
|
+
const depMerged = this._generateMergedContentSource(
|
|
265
|
+
depModule,
|
|
266
|
+
generateContext,
|
|
267
|
+
ancestors
|
|
268
|
+
);
|
|
269
|
+
if (depMerged) parts.push(depMerged);
|
|
128
270
|
}
|
|
129
|
-
}
|
|
130
271
|
|
|
131
|
-
|
|
272
|
+
const own = this._generateContentSource(module, generateContext);
|
|
273
|
+
if (own) parts.push(own);
|
|
274
|
+
|
|
275
|
+
if (parts.length === 0) return null;
|
|
276
|
+
if (parts.length === 1) return parts[0];
|
|
277
|
+
return new ConcatSource(...parts);
|
|
278
|
+
} finally {
|
|
279
|
+
ancestors.delete(module);
|
|
280
|
+
}
|
|
132
281
|
}
|
|
133
282
|
|
|
134
283
|
/**
|
|
@@ -171,23 +320,32 @@ class CssGenerator extends Generator {
|
|
|
171
320
|
}
|
|
172
321
|
|
|
173
322
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
323
|
+
* Serialize a CSS Source into a JS string literal with an optional
|
|
324
|
+
* inline `sourceMappingURL` data URI so DevTools can resolve the
|
|
325
|
+
* original sources at runtime.
|
|
176
326
|
* @param {Source} cssSource the CSS source
|
|
177
|
-
* @param {
|
|
327
|
+
* @param {import("../../declarations/WebpackOptions").DevTool | undefined} devtool the devtool option
|
|
178
328
|
* @returns {Source} a Source representing a JS string literal
|
|
179
329
|
*/
|
|
180
|
-
|
|
330
|
+
_cssToJsLiteral(cssSource, devtool) {
|
|
181
331
|
const { source, map } = cssSource.sourceAndMap();
|
|
182
|
-
|
|
183
|
-
const escaped = JSON.stringify(content);
|
|
332
|
+
let content = /** @type {string} */ (source);
|
|
184
333
|
if (map) {
|
|
185
|
-
|
|
334
|
+
const inlineMap =
|
|
335
|
+
typeof devtool === "string" && devtool.includes("nosources")
|
|
336
|
+
? { ...map, sourcesContent: undefined }
|
|
337
|
+
: map;
|
|
338
|
+
const base64Map = Buffer.from(JSON.stringify(inlineMap), "utf8").toString(
|
|
339
|
+
"base64"
|
|
340
|
+
);
|
|
341
|
+
const trailingNewline = content.endsWith("\n") ? "" : "\n";
|
|
342
|
+
content += `${trailingNewline}/*# sourceMappingURL=data:application/json;charset=utf-8;base64,${base64Map}*/`;
|
|
186
343
|
}
|
|
187
|
-
return new RawSource(
|
|
344
|
+
return new RawSource(JSON.stringify(content));
|
|
188
345
|
}
|
|
189
346
|
|
|
190
347
|
/**
|
|
348
|
+
* Processes the provided module.
|
|
191
349
|
* @param {NormalModule} module the current module
|
|
192
350
|
* @param {Dependency} dependency the dependency to generate
|
|
193
351
|
* @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments
|
|
@@ -245,6 +403,7 @@ class CssGenerator extends Generator {
|
|
|
245
403
|
}
|
|
246
404
|
|
|
247
405
|
/**
|
|
406
|
+
* Processes the provided module.
|
|
248
407
|
* @param {NormalModule} module the module to generate
|
|
249
408
|
* @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments
|
|
250
409
|
* @param {ReplaceSource} source the current replace source which can be modified
|
|
@@ -276,6 +435,7 @@ class CssGenerator extends Generator {
|
|
|
276
435
|
}
|
|
277
436
|
|
|
278
437
|
/**
|
|
438
|
+
* Generates generated code for this runtime module.
|
|
279
439
|
* @param {NormalModule} module module for which the code should be generated
|
|
280
440
|
* @param {GenerateContext} generateContext context for generate
|
|
281
441
|
* @returns {Source | null} generated code
|
|
@@ -291,7 +451,8 @@ class CssGenerator extends Generator {
|
|
|
291
451
|
/** @type {CssData} */
|
|
292
452
|
const cssData = {
|
|
293
453
|
esModule: /** @type {boolean} */ (this._esModule),
|
|
294
|
-
exports: new Map()
|
|
454
|
+
exports: new Map(),
|
|
455
|
+
exportLocs: new Map()
|
|
295
456
|
};
|
|
296
457
|
|
|
297
458
|
this.sourceModule(module, initFragments, source, {
|
|
@@ -301,6 +462,11 @@ class CssGenerator extends Generator {
|
|
|
301
462
|
|
|
302
463
|
switch (generateContext.type) {
|
|
303
464
|
case JAVASCRIPT_TYPE: {
|
|
465
|
+
const compilation = generateContext.runtimeTemplate.compilation;
|
|
466
|
+
const devtool = compilation.options.devtool;
|
|
467
|
+
const isCssModule = /** @type {BuildMeta} */ (module.buildMeta)
|
|
468
|
+
.isCssModule;
|
|
469
|
+
|
|
304
470
|
const generateContentCode = () => {
|
|
305
471
|
switch (exportType) {
|
|
306
472
|
case "style": {
|
|
@@ -309,15 +475,24 @@ class CssGenerator extends Generator {
|
|
|
309
475
|
generateContext
|
|
310
476
|
);
|
|
311
477
|
if (!cssSource) return "";
|
|
312
|
-
const moduleId = generateContext.chunkGraph.getModuleId(module);
|
|
313
478
|
|
|
314
479
|
generateContext.runtimeRequirements.add(
|
|
315
480
|
RuntimeGlobals.cssInjectStyle
|
|
316
481
|
);
|
|
317
482
|
|
|
483
|
+
const moduleId = generateContext.chunkGraph.getModuleId(module);
|
|
484
|
+
|
|
485
|
+
if (generateContext.concatenationScope) {
|
|
486
|
+
return new ConcatSource(
|
|
487
|
+
`__webpack_css_styles__.push([${JSON.stringify(moduleId)}, `,
|
|
488
|
+
this._cssToJsLiteral(cssSource, devtool),
|
|
489
|
+
"]);"
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
|
|
318
493
|
return new ConcatSource(
|
|
319
|
-
`${RuntimeGlobals.cssInjectStyle}(${JSON.stringify(moduleId
|
|
320
|
-
this.
|
|
494
|
+
`${RuntimeGlobals.cssInjectStyle}(${JSON.stringify(moduleId)}, `,
|
|
495
|
+
this._cssToJsLiteral(cssSource, devtool),
|
|
321
496
|
");"
|
|
322
497
|
);
|
|
323
498
|
}
|
|
@@ -329,8 +504,8 @@ class CssGenerator extends Generator {
|
|
|
329
504
|
const generateImportCode = () => {
|
|
330
505
|
switch (exportType) {
|
|
331
506
|
case "style": {
|
|
332
|
-
return this.
|
|
333
|
-
.map((
|
|
507
|
+
return this._generateImportSideEffects(module, generateContext)
|
|
508
|
+
.map((expr) => `${expr};`)
|
|
334
509
|
.join("\n");
|
|
335
510
|
}
|
|
336
511
|
default:
|
|
@@ -340,44 +515,31 @@ class CssGenerator extends Generator {
|
|
|
340
515
|
const generateExportCode = () => {
|
|
341
516
|
/** @returns {Source} generated CSS text as JS expression */
|
|
342
517
|
const generateCssText = () => {
|
|
343
|
-
const
|
|
344
|
-
module,
|
|
345
|
-
generateContext
|
|
346
|
-
);
|
|
347
|
-
const cssSource = this._generateContentSource(
|
|
518
|
+
const cssSource = this._generateMergedContentSource(
|
|
348
519
|
module,
|
|
349
|
-
generateContext
|
|
520
|
+
generateContext,
|
|
521
|
+
new Set()
|
|
350
522
|
);
|
|
351
|
-
const jsLiteral = cssSource
|
|
352
|
-
? this._cssSourceToJsStringLiteral(cssSource, module)
|
|
353
|
-
: new RawSource('""');
|
|
354
523
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
importCode.some((part) => part.type !== exportType)
|
|
359
|
-
) {
|
|
360
|
-
generateContext.runtimeRequirements.add(
|
|
361
|
-
RuntimeGlobals.cssMergeStyleSheets
|
|
362
|
-
);
|
|
524
|
+
let jsLiteral = cssSource
|
|
525
|
+
? this._cssToJsLiteral(cssSource, devtool)
|
|
526
|
+
: new RawSource('""');
|
|
363
527
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
return new ConcatSource(
|
|
372
|
-
`${generateContext.runtimeTemplate.concatenation(
|
|
373
|
-
...importCode
|
|
374
|
-
)} + `,
|
|
528
|
+
const effectiveCharset =
|
|
529
|
+
exportType === "css-style-sheet" || exportType === "text"
|
|
530
|
+
? this._getEffectiveCharset(module, generateContext.moduleGraph)
|
|
531
|
+
: undefined;
|
|
532
|
+
if (effectiveCharset !== undefined) {
|
|
533
|
+
jsLiteral = new ConcatSource(
|
|
534
|
+
`'@charset "${effectiveCharset}";\\n' + `,
|
|
375
535
|
jsLiteral
|
|
376
536
|
);
|
|
377
537
|
}
|
|
538
|
+
|
|
378
539
|
return jsLiteral;
|
|
379
540
|
};
|
|
380
541
|
/**
|
|
542
|
+
* Generates js default export.
|
|
381
543
|
* @returns {Source | null} the default export
|
|
382
544
|
*/
|
|
383
545
|
const generateJSDefaultExport = () => {
|
|
@@ -386,21 +548,19 @@ class CssGenerator extends Generator {
|
|
|
386
548
|
return generateCssText();
|
|
387
549
|
}
|
|
388
550
|
case "css-style-sheet": {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
551
|
+
// Build a constructable stylesheet from the statically
|
|
552
|
+
// merged CSS text. The merged literal carries a single
|
|
553
|
+
// inline source map covering every contributing module.
|
|
392
554
|
const fnPrefix =
|
|
393
555
|
generateContext.runtimeTemplate.supportsArrowFunction()
|
|
394
556
|
? "() => {\n"
|
|
395
557
|
: "function() {\n";
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
"sheet.replaceSync(cssText);\n" +
|
|
399
|
-
"return sheet;\n";
|
|
558
|
+
const constOrVar =
|
|
559
|
+
generateContext.runtimeTemplate.renderConst();
|
|
400
560
|
return new ConcatSource(
|
|
401
|
-
`(${fnPrefix}${constOrVar}
|
|
402
|
-
|
|
403
|
-
|
|
561
|
+
`(${fnPrefix}${constOrVar} sheet = new CSSStyleSheet();\nsheet.replaceSync(`,
|
|
562
|
+
generateCssText(),
|
|
563
|
+
");\nreturn sheet;\n})()"
|
|
404
564
|
);
|
|
405
565
|
}
|
|
406
566
|
default:
|
|
@@ -408,8 +568,6 @@ class CssGenerator extends Generator {
|
|
|
408
568
|
}
|
|
409
569
|
};
|
|
410
570
|
|
|
411
|
-
const isCSSModule = /** @type {BuildMeta} */ (module.buildMeta)
|
|
412
|
-
.isCSSModule;
|
|
413
571
|
/** @type {Source | null} */
|
|
414
572
|
const defaultExport = generateJSDefaultExport();
|
|
415
573
|
|
|
@@ -421,7 +579,7 @@ class CssGenerator extends Generator {
|
|
|
421
579
|
generateContext.runtimeRequirements.add(RuntimeGlobals.module);
|
|
422
580
|
}
|
|
423
581
|
|
|
424
|
-
if (!defaultExport && cssData.exports.size === 0 && !
|
|
582
|
+
if (!defaultExport && cssData.exports.size === 0 && !isCssModule) {
|
|
425
583
|
return new RawSource("");
|
|
426
584
|
}
|
|
427
585
|
|
|
@@ -498,7 +656,7 @@ class CssGenerator extends Generator {
|
|
|
498
656
|
// Should be after `concatenationScope` to allow module inlining
|
|
499
657
|
generateContext.runtimeRequirements.add(RuntimeGlobals.module);
|
|
500
658
|
|
|
501
|
-
if (!
|
|
659
|
+
if (!isCssModule && !needNsObj) {
|
|
502
660
|
return new ConcatSource(
|
|
503
661
|
`${module.moduleArgument}.exports = `,
|
|
504
662
|
/** @type {Source} */ (defaultExport)
|
|
@@ -546,26 +704,85 @@ class CssGenerator extends Generator {
|
|
|
546
704
|
source.add("\n");
|
|
547
705
|
}
|
|
548
706
|
}
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
case CSS_TYPE: {
|
|
707
|
+
// For link-type modules without any JS emit, skip source wrapping
|
|
552
708
|
if (
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
709
|
+
exportType === "link" &&
|
|
710
|
+
!isCssModule &&
|
|
711
|
+
cssData.exports.size === 0
|
|
712
|
+
) {
|
|
713
|
+
return source;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
const generatedJs = /** @type {string} */ (source.source());
|
|
717
|
+
const sourceName = module.readableIdentifier(
|
|
718
|
+
compilation.requestShortener
|
|
719
|
+
);
|
|
720
|
+
|
|
721
|
+
// When per-export source positions are available, emit a
|
|
722
|
+
// SourceMapSource mapping each export line back to its CSS
|
|
723
|
+
// selector; otherwise fall back to OriginalSource.
|
|
724
|
+
if (
|
|
725
|
+
/** @type {ExportLocsMap} */
|
|
726
|
+
(cssData.exportLocs).size > 0
|
|
557
727
|
) {
|
|
728
|
+
const cssOriginal = module.originalSource();
|
|
729
|
+
if (cssOriginal) {
|
|
730
|
+
const sourceMap = buildExportsSourceMap(
|
|
731
|
+
generatedJs,
|
|
732
|
+
/** @type {ExportLocsMap} */
|
|
733
|
+
(cssData.exportLocs),
|
|
734
|
+
/** @type {string} */ (cssOriginal.source()),
|
|
735
|
+
sourceName
|
|
736
|
+
);
|
|
737
|
+
return new SourceMapSource(generatedJs, sourceName, sourceMap);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
return new OriginalSource(generatedJs, sourceName);
|
|
741
|
+
}
|
|
742
|
+
case CSS_TYPE: {
|
|
743
|
+
if (!(this._exportsOnly || (exportType && exportType !== "link"))) {
|
|
558
744
|
generateContext.runtimeRequirements.add(RuntimeGlobals.hasCssModules);
|
|
559
745
|
}
|
|
560
746
|
|
|
561
747
|
return InitFragment.addToSource(source, initFragments, generateContext);
|
|
562
748
|
}
|
|
749
|
+
case CSS_TEXT_TYPE: {
|
|
750
|
+
// The merged CSS text — what consumers like
|
|
751
|
+
// `HtmlInlineStyleDependency.Template` need when they want to
|
|
752
|
+
// drop the processed CSS straight into an inline `<style>`
|
|
753
|
+
// tag. Mirrors the JS-side `generateCssText()` (charset
|
|
754
|
+
// prefix included), without the JS string-literal wrapper.
|
|
755
|
+
const cssSource = this._generateMergedContentSource(
|
|
756
|
+
module,
|
|
757
|
+
generateContext,
|
|
758
|
+
new Set()
|
|
759
|
+
);
|
|
760
|
+
|
|
761
|
+
const effectiveCharset = this._getEffectiveCharset(
|
|
762
|
+
module,
|
|
763
|
+
generateContext.moduleGraph
|
|
764
|
+
);
|
|
765
|
+
const charsetPrefix =
|
|
766
|
+
effectiveCharset !== undefined
|
|
767
|
+
? `@charset "${effectiveCharset}";\n`
|
|
768
|
+
: "";
|
|
769
|
+
|
|
770
|
+
if (!cssSource) {
|
|
771
|
+
return charsetPrefix
|
|
772
|
+
? new RawSource(charsetPrefix)
|
|
773
|
+
: new RawSource("");
|
|
774
|
+
}
|
|
775
|
+
return charsetPrefix
|
|
776
|
+
? new ConcatSource(charsetPrefix, cssSource)
|
|
777
|
+
: cssSource;
|
|
778
|
+
}
|
|
563
779
|
default:
|
|
564
780
|
return null;
|
|
565
781
|
}
|
|
566
782
|
}
|
|
567
783
|
|
|
568
784
|
/**
|
|
785
|
+
* Generates fallback output for the provided error condition.
|
|
569
786
|
* @param {Error} error the error
|
|
570
787
|
* @param {NormalModule} module module for which the code should be generated
|
|
571
788
|
* @param {GenerateContext} generateContext context for generate
|
|
@@ -587,6 +804,7 @@ class CssGenerator extends Generator {
|
|
|
587
804
|
}
|
|
588
805
|
|
|
589
806
|
/**
|
|
807
|
+
* Returns the source types available for this module.
|
|
590
808
|
* @param {NormalModule} module fresh module
|
|
591
809
|
* @returns {SourceTypes} available types (do not mutate)
|
|
592
810
|
*/
|
|
@@ -613,6 +831,19 @@ class CssGenerator extends Generator {
|
|
|
613
831
|
continue;
|
|
614
832
|
}
|
|
615
833
|
|
|
834
|
+
// Inline `<style>` blocks in HTML modules read the merged CSS
|
|
835
|
+
// text directly via the `css-text` source type — they don't go
|
|
836
|
+
// through the JS-string wrapper that other consumers use.
|
|
837
|
+
// Matched by dependency category so the CSS package doesn't
|
|
838
|
+
// have to import HtmlInlineStyleDependency.
|
|
839
|
+
if (
|
|
840
|
+
connection.dependency &&
|
|
841
|
+
connection.dependency.category === "html-style"
|
|
842
|
+
) {
|
|
843
|
+
sourceTypes.add(CSS_TEXT_TYPE);
|
|
844
|
+
continue;
|
|
845
|
+
}
|
|
846
|
+
|
|
616
847
|
if (!connection.originModule) {
|
|
617
848
|
continue;
|
|
618
849
|
}
|
|
@@ -636,9 +867,11 @@ class CssGenerator extends Generator {
|
|
|
636
867
|
this._exportsOnly ||
|
|
637
868
|
/** @type {boolean} */ (exportType && exportType !== "link")
|
|
638
869
|
) {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
870
|
+
const hasJs = sourceTypes.has(JAVASCRIPT_TYPE);
|
|
871
|
+
const hasCssText = sourceTypes.has(CSS_TEXT_TYPE);
|
|
872
|
+
if (hasJs && hasCssText) return JAVASCRIPT_AND_CSS_TEXT_TYPES;
|
|
873
|
+
if (hasJs) return JAVASCRIPT_TYPES;
|
|
874
|
+
if (hasCssText) return CSS_TEXT_TYPES;
|
|
642
875
|
return new Set();
|
|
643
876
|
}
|
|
644
877
|
if (sourceTypes.has(JAVASCRIPT_TYPE)) {
|
|
@@ -648,6 +881,7 @@ class CssGenerator extends Generator {
|
|
|
648
881
|
}
|
|
649
882
|
|
|
650
883
|
/**
|
|
884
|
+
* Returns the estimated size for the requested source type.
|
|
651
885
|
* @param {NormalModule} module the module
|
|
652
886
|
* @param {SourceType=} type source type
|
|
653
887
|
* @returns {number} estimate size of the module
|
|
@@ -660,7 +894,7 @@ class CssGenerator extends Generator {
|
|
|
660
894
|
return 42;
|
|
661
895
|
}
|
|
662
896
|
if (cssData.exports.size === 0) {
|
|
663
|
-
if (/** @type {BuildMeta} */ (module.buildMeta).
|
|
897
|
+
if (/** @type {BuildMeta} */ (module.buildMeta).isCssModule) {
|
|
664
898
|
return 42;
|
|
665
899
|
}
|
|
666
900
|
return 0;
|
|
@@ -690,11 +924,13 @@ class CssGenerator extends Generator {
|
|
|
690
924
|
}
|
|
691
925
|
|
|
692
926
|
/**
|
|
927
|
+
* Updates the hash with the data contributed by this instance.
|
|
693
928
|
* @param {Hash} hash hash that will be modified
|
|
694
929
|
* @param {UpdateHashContext} updateHashContext context for updating hash
|
|
695
930
|
*/
|
|
696
931
|
updateHash(hash, { module }) {
|
|
697
932
|
hash.update(/** @type {boolean} */ (this._esModule).toString());
|
|
933
|
+
hash.update(/** @type {boolean} */ (this._exportsOnly).toString());
|
|
698
934
|
}
|
|
699
935
|
}
|
|
700
936
|
|