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
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
const { CSS_TYPE, JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
|
|
9
9
|
const { interpolate } = require("../TemplatedPathPlugin");
|
|
10
|
-
const WebpackError = require("../WebpackError");
|
|
10
|
+
const WebpackError = require("../errors/WebpackError");
|
|
11
11
|
const { cssExportConvention } = require("../util/conventions");
|
|
12
12
|
const createHash = require("../util/createHash");
|
|
13
13
|
const { makePathsRelative } = require("../util/identifier");
|
|
14
14
|
const makeSerializable = require("../util/makeSerializable");
|
|
15
15
|
const memoize = require("../util/memoize");
|
|
16
16
|
const nonNumericOnlyHash = require("../util/nonNumericOnlyHash");
|
|
17
|
+
const { updateHashFromSource } = require("../util/source");
|
|
17
18
|
const CssIcssImportDependency = require("./CssIcssImportDependency");
|
|
18
19
|
const NullDependency = require("./NullDependency");
|
|
19
20
|
|
|
@@ -23,7 +24,8 @@ const getCssParser = memoize(() => require("../css/CssParser"));
|
|
|
23
24
|
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
|
24
25
|
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
|
|
25
26
|
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorLocalIdentName} CssGeneratorLocalIdentName */
|
|
26
|
-
/** @typedef {import("../CssModule")} CssModule */
|
|
27
|
+
/** @typedef {import("../css/CssModule")} CssModule */
|
|
28
|
+
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
27
29
|
/** @typedef {import("../Dependency")} Dependency */
|
|
28
30
|
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
29
31
|
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
|
@@ -36,12 +38,14 @@ const getCssParser = memoize(() => require("../css/CssParser"));
|
|
|
36
38
|
/** @typedef {import("../util/Hash")} Hash */
|
|
37
39
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
38
40
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
41
|
+
/** @typedef {import("../Compilation").ModulePathData} ModulePathData */
|
|
39
42
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
40
43
|
/** @typedef {import("../css/CssParser").Range} Range */
|
|
41
44
|
|
|
42
|
-
/** @typedef {(name: string) => string} ExportsConventionFn */
|
|
45
|
+
/** @typedef {(name: string) => string | string[]} ExportsConventionFn */
|
|
43
46
|
|
|
44
47
|
/**
|
|
48
|
+
* Returns local ident.
|
|
45
49
|
* @param {string} local css local
|
|
46
50
|
* @param {CssModule} module module
|
|
47
51
|
* @param {ChunkGraph} chunkGraph chunk graph
|
|
@@ -103,7 +107,7 @@ const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
|
|
103
107
|
const source = module.originalSource();
|
|
104
108
|
|
|
105
109
|
if (source) {
|
|
106
|
-
hash
|
|
110
|
+
updateHashFromSource(hash, source);
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
if (module.error) {
|
|
@@ -156,13 +160,113 @@ const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
|
|
156
160
|
return localIdent.replace(/^((-?\d)|--)/, "_$1");
|
|
157
161
|
};
|
|
158
162
|
|
|
159
|
-
/** @typedef {string | [string, string]} Value */
|
|
163
|
+
/** @typedef {string | [string, string] | [string, string, string]} Value */
|
|
160
164
|
|
|
161
165
|
// 0 - replace, 1 - replace, 2 - append, 2 - once
|
|
162
166
|
/** @typedef {0 | 1 | 2 | 3 | 4} ExportMode */
|
|
163
167
|
// 0 - normal, 1 - custom css variable, 2 - grid custom ident, 3 - composes
|
|
164
168
|
/** @typedef {0 | 1 | 2 | 3} ExportType */
|
|
165
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Computes the interpolated identifier for `(module, value, exportType)`.
|
|
172
|
+
* Module-level reference so `moduleGraph.cached` can use it as a stable
|
|
173
|
+
* computer key — repeated lookups during a build skip
|
|
174
|
+
* `cssExportConvention`, `getLocalIdent` (with its content / path hashing)
|
|
175
|
+
* and `escapeIdentifier`.
|
|
176
|
+
* @param {ModuleGraph} _moduleGraph module graph (unused, kept for `cached` signature)
|
|
177
|
+
* @param {CssModule} module css module the value resolves in
|
|
178
|
+
* @param {string} value raw value to interpolate
|
|
179
|
+
* @param {ExportType} exportType export type discriminator
|
|
180
|
+
* @param {ChunkGraph} chunkGraph chunk graph
|
|
181
|
+
* @param {RuntimeTemplate} runtimeTemplate runtime template
|
|
182
|
+
* @returns {string} interpolated identifier
|
|
183
|
+
*/
|
|
184
|
+
const computeInterpolatedIdentifier = (
|
|
185
|
+
_moduleGraph,
|
|
186
|
+
module,
|
|
187
|
+
value,
|
|
188
|
+
exportType,
|
|
189
|
+
chunkGraph,
|
|
190
|
+
runtimeTemplate
|
|
191
|
+
) => {
|
|
192
|
+
const generator = /** @type {CssGenerator} */ (module.generator);
|
|
193
|
+
const local = cssExportConvention(
|
|
194
|
+
value,
|
|
195
|
+
/** @type {CssGeneratorExportsConvention} */
|
|
196
|
+
(generator.options.exportsConvention)
|
|
197
|
+
)[0];
|
|
198
|
+
const prefix =
|
|
199
|
+
exportType === CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
|
|
200
|
+
? "--"
|
|
201
|
+
: "";
|
|
202
|
+
return (
|
|
203
|
+
prefix +
|
|
204
|
+
getCssParser().escapeIdentifier(
|
|
205
|
+
getLocalIdent(local, module, chunkGraph, runtimeTemplate),
|
|
206
|
+
runtimeTemplate.compilation.compiler.root
|
|
207
|
+
)
|
|
208
|
+
);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Top-level computer for `resolve`. Allocates a fresh `seen` set; recursive
|
|
213
|
+
* calls go through the un-cached inner path so cycle detection still works.
|
|
214
|
+
* @param {ModuleGraph} moduleGraph module graph
|
|
215
|
+
* @param {CssModule} module module to search
|
|
216
|
+
* @param {string} localName local name
|
|
217
|
+
* @param {string} importName imported export name
|
|
218
|
+
* @param {string | undefined} request request of the active `@value` import
|
|
219
|
+
* @param {ChunkGraph} chunkGraph chunk graph
|
|
220
|
+
* @param {RuntimeTemplate} runtimeTemplate runtime template
|
|
221
|
+
* @returns {string | undefined} resolved value or undefined
|
|
222
|
+
*/
|
|
223
|
+
const computeResolve = (
|
|
224
|
+
moduleGraph,
|
|
225
|
+
module,
|
|
226
|
+
localName,
|
|
227
|
+
importName,
|
|
228
|
+
request,
|
|
229
|
+
chunkGraph,
|
|
230
|
+
runtimeTemplate
|
|
231
|
+
) =>
|
|
232
|
+
CssIcssExportDependency.Template._doResolve(
|
|
233
|
+
localName,
|
|
234
|
+
importName,
|
|
235
|
+
/** @type {DependencyTemplateContext} */
|
|
236
|
+
(
|
|
237
|
+
/** @type {unknown} */
|
|
238
|
+
({ moduleGraph, module, chunkGraph, runtimeTemplate })
|
|
239
|
+
),
|
|
240
|
+
request,
|
|
241
|
+
new Set()
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Top-level computer for `resolveReferences`. See `computeResolve`.
|
|
246
|
+
* @param {ModuleGraph} moduleGraph module graph
|
|
247
|
+
* @param {CssIcssExportDependency} dep export dependency
|
|
248
|
+
* @param {CssModule} module module that hosts `dep`
|
|
249
|
+
* @param {ChunkGraph} chunkGraph chunk graph
|
|
250
|
+
* @param {RuntimeTemplate} runtimeTemplate runtime template
|
|
251
|
+
* @returns {string[]} final references, deduplicated
|
|
252
|
+
*/
|
|
253
|
+
const computeResolveReferences = (
|
|
254
|
+
moduleGraph,
|
|
255
|
+
dep,
|
|
256
|
+
module,
|
|
257
|
+
chunkGraph,
|
|
258
|
+
runtimeTemplate
|
|
259
|
+
) =>
|
|
260
|
+
CssIcssExportDependency.Template._doResolveReferences(
|
|
261
|
+
dep,
|
|
262
|
+
/** @type {DependencyTemplateContext} */
|
|
263
|
+
(
|
|
264
|
+
/** @type {unknown} */
|
|
265
|
+
({ moduleGraph, module, chunkGraph, runtimeTemplate })
|
|
266
|
+
),
|
|
267
|
+
new Set()
|
|
268
|
+
);
|
|
269
|
+
|
|
166
270
|
class CssIcssExportDependency extends NullDependency {
|
|
167
271
|
/**
|
|
168
272
|
* Example of dependency:
|
|
@@ -192,6 +296,10 @@ class CssIcssExportDependency extends NullDependency {
|
|
|
192
296
|
this.exportType = exportType;
|
|
193
297
|
/** @type {undefined | string} */
|
|
194
298
|
this._hashUpdate = undefined;
|
|
299
|
+
/** @type {undefined | string[]} */
|
|
300
|
+
this._conventionNames = undefined;
|
|
301
|
+
/** @type {undefined | string[]} */
|
|
302
|
+
this._valueConventionNames = undefined;
|
|
195
303
|
}
|
|
196
304
|
|
|
197
305
|
get type() {
|
|
@@ -199,6 +307,7 @@ class CssIcssExportDependency extends NullDependency {
|
|
|
199
307
|
}
|
|
200
308
|
|
|
201
309
|
/**
|
|
310
|
+
* Gets exports convention names.
|
|
202
311
|
* @param {string} name export name
|
|
203
312
|
* @param {CssGeneratorExportsConvention} convention convention of the export name
|
|
204
313
|
* @returns {string[]} convention results
|
|
@@ -211,6 +320,26 @@ class CssIcssExportDependency extends NullDependency {
|
|
|
211
320
|
return this._conventionNames;
|
|
212
321
|
}
|
|
213
322
|
|
|
323
|
+
/**
|
|
324
|
+
* Memoized `cssExportConvention(this.value, convention)`. Used by every
|
|
325
|
+
* code path that needs the convention-derived aliases of the composed /
|
|
326
|
+
* referenced class: `getReferencedExports`, `getWarnings`, and the template's
|
|
327
|
+
* `getIdentifier`. Caller guarantees `typeof this.value === "string"` —
|
|
328
|
+
* the array form (cross-module references) is resolved separately.
|
|
329
|
+
* @param {CssGeneratorExportsConvention} convention convention of the export name
|
|
330
|
+
* @returns {string[]} convention results
|
|
331
|
+
*/
|
|
332
|
+
getValueConventionNames(convention) {
|
|
333
|
+
if (this._valueConventionNames) {
|
|
334
|
+
return this._valueConventionNames;
|
|
335
|
+
}
|
|
336
|
+
this._valueConventionNames = cssExportConvention(
|
|
337
|
+
/** @type {string} */ (this.value),
|
|
338
|
+
convention
|
|
339
|
+
);
|
|
340
|
+
return this._valueConventionNames;
|
|
341
|
+
}
|
|
342
|
+
|
|
214
343
|
/**
|
|
215
344
|
* Returns list of exports referenced by this dependency
|
|
216
345
|
* @param {ModuleGraph} moduleGraph module graph
|
|
@@ -219,14 +348,26 @@ class CssIcssExportDependency extends NullDependency {
|
|
|
219
348
|
*/
|
|
220
349
|
getReferencedExports(moduleGraph, runtime) {
|
|
221
350
|
if (
|
|
222
|
-
this.exportMode === CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE
|
|
351
|
+
this.exportMode === CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE &&
|
|
352
|
+
typeof this.value === "string"
|
|
223
353
|
) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
354
|
+
// `composes: foo;` — the composed class (`this.value`) is the one
|
|
355
|
+
// referenced, not the class doing the composing (`this.name`). Apply
|
|
356
|
+
// the generator's `exportsConvention` so the export names produced
|
|
357
|
+
// by the convention are what the optimizer sees.
|
|
358
|
+
const module =
|
|
359
|
+
/** @type {CssModule | undefined} */
|
|
360
|
+
(moduleGraph.getParentModule(this));
|
|
361
|
+
if (!module) return super.getReferencedExports(moduleGraph, runtime);
|
|
362
|
+
const generator = /** @type {CssGenerator} */ (module.generator);
|
|
363
|
+
const names = this.getValueConventionNames(
|
|
364
|
+
/** @type {CssGeneratorExportsConvention} */
|
|
365
|
+
(generator.options.exportsConvention)
|
|
366
|
+
);
|
|
367
|
+
return names.map((name) => ({
|
|
368
|
+
name: [name],
|
|
369
|
+
canMangle: true
|
|
370
|
+
}));
|
|
230
371
|
}
|
|
231
372
|
|
|
232
373
|
return super.getReferencedExports(moduleGraph, runtime);
|
|
@@ -263,21 +404,37 @@ class CssIcssExportDependency extends NullDependency {
|
|
|
263
404
|
}
|
|
264
405
|
|
|
265
406
|
/**
|
|
266
|
-
* Returns warnings
|
|
407
|
+
* Returns warnings.
|
|
267
408
|
* @param {ModuleGraph} moduleGraph module graph
|
|
268
409
|
* @returns {WebpackError[] | null | undefined} warnings
|
|
269
410
|
*/
|
|
270
411
|
getWarnings(moduleGraph) {
|
|
271
412
|
if (
|
|
272
413
|
this.exportMode === CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE &&
|
|
273
|
-
|
|
414
|
+
typeof this.value === "string"
|
|
274
415
|
) {
|
|
275
|
-
const module =
|
|
416
|
+
const module =
|
|
417
|
+
/** @type {CssModule | undefined} */
|
|
418
|
+
(moduleGraph.getParentModule(this));
|
|
419
|
+
|
|
420
|
+
if (!module) return null;
|
|
421
|
+
|
|
422
|
+
// `ExportsInfo` only stores names produced by `exportsConvention`,
|
|
423
|
+
// so a raw `isExportProvided(this.value)` check is a false-positive
|
|
424
|
+
// for `camel-case-only` / `dashes-only` (and any custom function
|
|
425
|
+
// that drops the original spelling). Treat the composed class as
|
|
426
|
+
// provided if *any* of its convention-produced aliases is provided.
|
|
427
|
+
const generator = /** @type {CssGenerator} */ (module.generator);
|
|
428
|
+
const exportsInfo = moduleGraph.getExportsInfo(module);
|
|
429
|
+
const names = this.getValueConventionNames(
|
|
430
|
+
/** @type {CssGeneratorExportsConvention} */
|
|
431
|
+
(generator.options.exportsConvention)
|
|
432
|
+
);
|
|
433
|
+
const isProvided = names.some((name) =>
|
|
434
|
+
exportsInfo.isExportProvided(name)
|
|
435
|
+
);
|
|
276
436
|
|
|
277
|
-
if (
|
|
278
|
-
module &&
|
|
279
|
-
!moduleGraph.getExportsInfo(module).isExportProvided(this.value)
|
|
280
|
-
) {
|
|
437
|
+
if (!isProvided) {
|
|
281
438
|
const error = new WebpackError(
|
|
282
439
|
`Self-referencing name "${this.value}" not found`
|
|
283
440
|
);
|
|
@@ -291,7 +448,7 @@ class CssIcssExportDependency extends NullDependency {
|
|
|
291
448
|
}
|
|
292
449
|
|
|
293
450
|
/**
|
|
294
|
-
*
|
|
451
|
+
* Updates the hash with the data contributed by this instance.
|
|
295
452
|
* @param {Hash} hash hash to be updated
|
|
296
453
|
* @param {UpdateHashContext} context context
|
|
297
454
|
* @returns {void}
|
|
@@ -307,12 +464,17 @@ class CssIcssExportDependency extends NullDependency {
|
|
|
307
464
|
/** @type {CssGeneratorExportsConvention} */
|
|
308
465
|
(generator.options.exportsConvention)
|
|
309
466
|
);
|
|
310
|
-
|
|
467
|
+
// Include all instance state that affects the emitted output —
|
|
468
|
+
// `name`, `value`, `range`, `interpolate`, `exportMode`,
|
|
469
|
+
// `exportType` — so changes like switching `composes: foo` →
|
|
470
|
+
// `composes: bar` or `ONCE` → `APPEND` invalidate caches.
|
|
471
|
+
this._hashUpdate = `exportsConvention|${JSON.stringify(names)}|localIdentName|${JSON.stringify(generator.options.localIdentName)}|value|${JSON.stringify(this.value)}|range|${JSON.stringify(this.range)}|interpolate|${this.interpolate}|exportMode|${this.exportMode}|exportType|${this.exportType}`;
|
|
311
472
|
}
|
|
312
473
|
hash.update(this._hashUpdate);
|
|
313
474
|
}
|
|
314
475
|
|
|
315
476
|
/**
|
|
477
|
+
* Serializes this instance into the provided serializer context.
|
|
316
478
|
* @param {ObjectSerializerContext} context context
|
|
317
479
|
*/
|
|
318
480
|
serialize(context) {
|
|
@@ -327,6 +489,7 @@ class CssIcssExportDependency extends NullDependency {
|
|
|
327
489
|
}
|
|
328
490
|
|
|
329
491
|
/**
|
|
492
|
+
* Restores this instance from the provided deserializer context.
|
|
330
493
|
* @param {ObjectDeserializerContext} context context
|
|
331
494
|
*/
|
|
332
495
|
deserialize(context) {
|
|
@@ -344,22 +507,60 @@ class CssIcssExportDependency extends NullDependency {
|
|
|
344
507
|
CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends (
|
|
345
508
|
NullDependency.Template
|
|
346
509
|
) {
|
|
347
|
-
// TODO looking how to cache
|
|
348
510
|
/**
|
|
511
|
+
* Returns found reference. The top-level call (no `seen` argument) is
|
|
512
|
+
* memoized via `moduleGraph.cached` keyed by `(module, localName,
|
|
513
|
+
* importName, request, chunkGraph, runtimeTemplate)`. Recursive callers
|
|
514
|
+
* pass `seen` and skip the cache so the cycle guard is preserved — only
|
|
515
|
+
* completed top-level resolutions land in the cache.
|
|
349
516
|
* @param {string} localName local name
|
|
350
517
|
* @param {string} importName import name
|
|
351
518
|
* @param {DependencyTemplateContext} templateContext the context object
|
|
519
|
+
* @param {string | undefined} request user request of the `@value` import that was active when the reference was parsed — used to disambiguate when the same local name is imported from multiple modules
|
|
520
|
+
* @param {Set<CssIcssExportDependency>=} seen seen to prevent cyclical problems
|
|
521
|
+
* @returns {string | undefined} found reference
|
|
522
|
+
*/
|
|
523
|
+
static resolve(localName, importName, templateContext, request, seen) {
|
|
524
|
+
if (seen !== undefined) {
|
|
525
|
+
return CssIcssExportDependencyTemplate._doResolve(
|
|
526
|
+
localName,
|
|
527
|
+
importName,
|
|
528
|
+
templateContext,
|
|
529
|
+
request,
|
|
530
|
+
seen
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
const { moduleGraph, module, chunkGraph, runtimeTemplate } =
|
|
534
|
+
templateContext;
|
|
535
|
+
return moduleGraph.cached(
|
|
536
|
+
computeResolve,
|
|
537
|
+
/** @type {CssModule} */ (module),
|
|
538
|
+
localName,
|
|
539
|
+
importName,
|
|
540
|
+
request,
|
|
541
|
+
chunkGraph,
|
|
542
|
+
runtimeTemplate
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Inner recursive worker for `resolve`. Not memoized — see `resolve`.
|
|
548
|
+
* @param {string} localName local name
|
|
549
|
+
* @param {string} importName import name
|
|
550
|
+
* @param {DependencyTemplateContext} templateContext the context object
|
|
551
|
+
* @param {string | undefined} request user request
|
|
352
552
|
* @param {Set<CssIcssExportDependency>} seen seen to prevent cyclical problems
|
|
353
553
|
* @returns {string | undefined} found reference
|
|
354
554
|
*/
|
|
355
|
-
static
|
|
555
|
+
static _doResolve(localName, importName, templateContext, request, seen) {
|
|
356
556
|
const { moduleGraph } = templateContext;
|
|
357
557
|
const importDep =
|
|
358
558
|
/** @type {CssIcssImportDependency | undefined} */
|
|
359
559
|
(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
560
|
+
CssIcssExportDependencyTemplate.findImportDep(
|
|
561
|
+
templateContext.module.dependencies,
|
|
562
|
+
localName,
|
|
563
|
+
request
|
|
363
564
|
)
|
|
364
565
|
);
|
|
365
566
|
if (!importDep) return undefined;
|
|
@@ -383,13 +584,14 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
383
584
|
const { value, interpolate } = exportDep;
|
|
384
585
|
|
|
385
586
|
if (Array.isArray(value)) {
|
|
386
|
-
return
|
|
587
|
+
return CssIcssExportDependencyTemplate._doResolve(
|
|
387
588
|
value[0],
|
|
388
589
|
value[1],
|
|
389
590
|
{
|
|
390
591
|
...templateContext,
|
|
391
592
|
module
|
|
392
593
|
},
|
|
594
|
+
value[2],
|
|
393
595
|
seen
|
|
394
596
|
);
|
|
395
597
|
}
|
|
@@ -405,12 +607,65 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
405
607
|
}
|
|
406
608
|
|
|
407
609
|
/**
|
|
610
|
+
* Finds the active `CssIcssImportDependency` for a given local name. When a
|
|
611
|
+
* `request` is provided the lookup also requires the import dependency's
|
|
612
|
+
* `request` to match — this lets references that appear between two
|
|
613
|
+
* `@value foo from "..."` declarations resolve through the import that was
|
|
614
|
+
* in scope at the reference site, rather than always picking the first.
|
|
615
|
+
* @param {Iterable<Dependency>} dependencies module dependencies to search
|
|
616
|
+
* @param {string} localName local name
|
|
617
|
+
* @param {string=} request user request of the `@value` import to match
|
|
618
|
+
* @returns {CssIcssImportDependency | undefined} matching import dep, if any
|
|
619
|
+
*/
|
|
620
|
+
static findImportDep(dependencies, localName, request) {
|
|
621
|
+
/** @type {CssIcssImportDependency | undefined} */
|
|
622
|
+
let firstMatch;
|
|
623
|
+
for (const d of dependencies) {
|
|
624
|
+
if (d instanceof CssIcssImportDependency && d.localName === localName) {
|
|
625
|
+
if (request === undefined) return d;
|
|
626
|
+
if (d.request === request) return d;
|
|
627
|
+
if (firstMatch === undefined) firstMatch = d;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return firstMatch;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Resolves references. The top-level call (no `seen` argument) is
|
|
635
|
+
* memoized via `moduleGraph.cached`; recursive callers pass `seen` and
|
|
636
|
+
* bypass the cache to keep the cycle guard intact.
|
|
637
|
+
* @param {CssIcssExportDependency} dep value
|
|
638
|
+
* @param {DependencyTemplateContext} templateContext template context
|
|
639
|
+
* @param {Set<CssIcssExportDependency>=} seen to prevent cyclical problems
|
|
640
|
+
* @returns {string[]} final names
|
|
641
|
+
*/
|
|
642
|
+
static resolveReferences(dep, templateContext, seen) {
|
|
643
|
+
if (seen !== undefined) {
|
|
644
|
+
return CssIcssExportDependencyTemplate._doResolveReferences(
|
|
645
|
+
dep,
|
|
646
|
+
templateContext,
|
|
647
|
+
seen
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
const { moduleGraph, module, chunkGraph, runtimeTemplate } =
|
|
651
|
+
templateContext;
|
|
652
|
+
return moduleGraph.cached(
|
|
653
|
+
computeResolveReferences,
|
|
654
|
+
dep,
|
|
655
|
+
/** @type {CssModule} */ (module),
|
|
656
|
+
chunkGraph,
|
|
657
|
+
runtimeTemplate
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Inner recursive worker for `resolveReferences`. Not memoized.
|
|
408
663
|
* @param {CssIcssExportDependency} dep value
|
|
409
664
|
* @param {DependencyTemplateContext} templateContext template context
|
|
410
665
|
* @param {Set<CssIcssExportDependency>} seen to prevent cyclical problems
|
|
411
666
|
* @returns {string[]} final names
|
|
412
667
|
*/
|
|
413
|
-
static
|
|
668
|
+
static _doResolveReferences(dep, templateContext, seen) {
|
|
414
669
|
/** @type {string[]} */
|
|
415
670
|
const references = [];
|
|
416
671
|
|
|
@@ -421,10 +676,10 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
421
676
|
const importDep =
|
|
422
677
|
/** @type {CssIcssImportDependency | undefined} */
|
|
423
678
|
(
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
679
|
+
CssIcssExportDependencyTemplate.findImportDep(
|
|
680
|
+
templateContext.module.dependencies,
|
|
681
|
+
dep.value[0],
|
|
682
|
+
dep.value[2]
|
|
428
683
|
)
|
|
429
684
|
);
|
|
430
685
|
if (!importDep) return references;
|
|
@@ -438,7 +693,7 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
438
693
|
if (d instanceof CssIcssExportDependency && d.name === dep.value[1]) {
|
|
439
694
|
if (Array.isArray(d.value)) {
|
|
440
695
|
const deepReferences =
|
|
441
|
-
CssIcssExportDependencyTemplate.
|
|
696
|
+
CssIcssExportDependencyTemplate._doResolveReferences(
|
|
442
697
|
d,
|
|
443
698
|
{
|
|
444
699
|
...templateContext,
|
|
@@ -476,7 +731,7 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
476
731
|
) {
|
|
477
732
|
if (Array.isArray(d.value)) {
|
|
478
733
|
const deepReferences =
|
|
479
|
-
CssIcssExportDependencyTemplate.
|
|
734
|
+
CssIcssExportDependencyTemplate._doResolveReferences(
|
|
480
735
|
d,
|
|
481
736
|
templateContext,
|
|
482
737
|
seen
|
|
@@ -500,6 +755,11 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
500
755
|
}
|
|
501
756
|
|
|
502
757
|
/**
|
|
758
|
+
* Returns identifier. When the dep opts into interpolation the full
|
|
759
|
+
* computation is memoized via `moduleGraph.cached` keyed by
|
|
760
|
+
* `(module, value, exportType, chunkGraph, runtimeTemplate)` so
|
|
761
|
+
* `cssExportConvention` / `getLocalIdent` / `escapeIdentifier` are not
|
|
762
|
+
* re-run for the same identifier during code generation.
|
|
503
763
|
* @param {string} value value to identifier
|
|
504
764
|
* @param {Dependency} dependency the dependency for which the template should be applied
|
|
505
765
|
* @param {DependencyTemplateContext} templateContext the context object
|
|
@@ -507,39 +767,21 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
507
767
|
*/
|
|
508
768
|
static getIdentifier(value, dependency, templateContext) {
|
|
509
769
|
const dep = /** @type {CssIcssExportDependency} */ (dependency);
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
dep.exportType === CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
|
|
522
|
-
? "--"
|
|
523
|
-
: "";
|
|
524
|
-
|
|
525
|
-
return (
|
|
526
|
-
prefix +
|
|
527
|
-
getCssParser().escapeIdentifier(
|
|
528
|
-
getLocalIdent(
|
|
529
|
-
local,
|
|
530
|
-
/** @type {CssModule} */
|
|
531
|
-
(m),
|
|
532
|
-
templateContext.chunkGraph,
|
|
533
|
-
templateContext.runtimeTemplate
|
|
534
|
-
)
|
|
535
|
-
)
|
|
536
|
-
);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
return value;
|
|
770
|
+
if (!dep.interpolate) return value;
|
|
771
|
+
const { moduleGraph, module, chunkGraph, runtimeTemplate } =
|
|
772
|
+
templateContext;
|
|
773
|
+
return moduleGraph.cached(
|
|
774
|
+
computeInterpolatedIdentifier,
|
|
775
|
+
/** @type {CssModule} */ (module),
|
|
776
|
+
value,
|
|
777
|
+
dep.exportType,
|
|
778
|
+
chunkGraph,
|
|
779
|
+
runtimeTemplate
|
|
780
|
+
);
|
|
540
781
|
}
|
|
541
782
|
|
|
542
783
|
/**
|
|
784
|
+
* Applies the plugin by registering its hooks on the compiler.
|
|
543
785
|
* @param {Dependency} dependency the dependency for which the template should be applied
|
|
544
786
|
* @param {ReplaceSource} source the current replace source which can be modified
|
|
545
787
|
* @param {DependencyTemplateContext} templateContext the context object
|
|
@@ -569,7 +811,8 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
569
811
|
const resolved = CssIcssExportDependencyTemplate.resolve(
|
|
570
812
|
dep.value[0],
|
|
571
813
|
dep.value[1],
|
|
572
|
-
templateContext
|
|
814
|
+
templateContext,
|
|
815
|
+
dep.value[2]
|
|
573
816
|
);
|
|
574
817
|
|
|
575
818
|
// Fallback to the local name if not resolved
|
|
@@ -608,12 +851,29 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
608
851
|
.filter(Boolean)
|
|
609
852
|
);
|
|
610
853
|
const allNames = new Set([...usedNames, ...names]);
|
|
611
|
-
const unescaped = getCssParser().unescapeIdentifier(
|
|
854
|
+
const unescaped = getCssParser().unescapeIdentifier(
|
|
855
|
+
value,
|
|
856
|
+
templateContext.runtimeTemplate.compilation.compiler.root
|
|
857
|
+
);
|
|
612
858
|
|
|
859
|
+
const depLocStart =
|
|
860
|
+
dep.loc &&
|
|
861
|
+
/** @type {{ start?: { line: number, column: number } }} */ (dep.loc)
|
|
862
|
+
.start;
|
|
613
863
|
for (const used of allNames) {
|
|
614
864
|
if (dep.exportMode === CssIcssExportDependency.EXPORT_MODE.ONCE) {
|
|
615
865
|
if (cssData.exports.has(used)) return;
|
|
616
866
|
cssData.exports.set(used, unescaped);
|
|
867
|
+
if (
|
|
868
|
+
depLocStart &&
|
|
869
|
+
cssData.exportLocs &&
|
|
870
|
+
!cssData.exportLocs.has(used)
|
|
871
|
+
) {
|
|
872
|
+
cssData.exportLocs.set(used, {
|
|
873
|
+
line: depLocStart.line,
|
|
874
|
+
column: depLocStart.column
|
|
875
|
+
});
|
|
876
|
+
}
|
|
617
877
|
} else {
|
|
618
878
|
const originalValue =
|
|
619
879
|
dep.exportMode === CssIcssExportDependency.EXPORT_MODE.REPLACE
|
|
@@ -624,6 +884,19 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
624
884
|
used,
|
|
625
885
|
`${originalValue ? `${originalValue}${unescaped ? " " : ""}` : ""}${unescaped}`
|
|
626
886
|
);
|
|
887
|
+
// Record the source location once per export (use the first
|
|
888
|
+
// occurrence — for APPEND/REPLACE this corresponds to the
|
|
889
|
+
// first selector seen, which is a reasonable anchor).
|
|
890
|
+
if (
|
|
891
|
+
depLocStart &&
|
|
892
|
+
cssData.exportLocs &&
|
|
893
|
+
!cssData.exportLocs.has(used)
|
|
894
|
+
) {
|
|
895
|
+
cssData.exportLocs.set(used, {
|
|
896
|
+
line: depLocStart.line,
|
|
897
|
+
column: depLocStart.column
|
|
898
|
+
});
|
|
899
|
+
}
|
|
627
900
|
}
|
|
628
901
|
}
|
|
629
902
|
} else if (
|