webpack 5.111.0 → 5.112.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 +1 -1
- package/lib/Chunk.js +3 -966
- package/lib/Compilation.js +237 -138
- package/lib/Compiler.js +23 -24
- package/lib/Dependency.js +3 -551
- package/lib/DependencyTemplate.js +3 -69
- package/lib/EntryPlugin.js +3 -68
- package/lib/Entrypoint.js +3 -121
- package/lib/ExternalsPlugin.js +3 -92
- package/lib/FileSystemInfo.js +3 -4629
- package/lib/InitFragment.js +3 -204
- package/lib/LibraryTemplatePlugin.js +3 -46
- package/lib/ModuleFilenameHelpers.js +3 -400
- package/lib/ModuleNotFoundError.js +2 -2
- package/lib/MultiCompiler.js +43 -24
- package/lib/NormalModule.js +3 -2190
- package/lib/NullFactory.js +3 -22
- package/lib/ProgressPlugin.js +3 -908
- package/lib/RawModule.js +3 -197
- package/lib/RequestShortener.js +3 -37
- package/lib/SingleEntryPlugin.js +1 -1
- package/lib/WebpackError.js +2 -2
- package/lib/asset/AssetBytesGenerator.js +15 -9
- package/lib/asset/AssetBytesParser.js +3 -3
- package/lib/asset/AssetGenerator.js +61 -38
- package/lib/asset/AssetModule.js +2 -2
- package/lib/asset/AssetModulesPlugin.js +6 -9
- package/lib/asset/AssetParser.js +3 -3
- package/lib/asset/AssetSourceGenerator.js +15 -9
- package/lib/asset/AssetSourceParser.js +3 -3
- package/lib/asset/RawDataUrlModule.js +17 -10
- package/lib/asset/WebManifestGenerator.js +7 -7
- package/lib/asset/WebManifestParser.js +5 -5
- package/lib/async-modules/AsyncModuleHelpers.js +6 -5
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
- package/lib/async-modules/InferAsyncModulesPlugin.js +4 -3
- package/lib/async-modules/isGeneratorLowered.js +3 -3
- package/lib/bun/BunTargetPlugin.js +1 -1
- package/lib/cache/AddBuildDependenciesPlugin.js +2 -19
- package/lib/{Cache.js → cache/Cache.js} +1 -1
- package/lib/{CacheFacade.js → cache/CacheFacade.js} +5 -5
- package/lib/cache/IdleFileCachePlugin.js +2 -2
- package/lib/cache/MemoryCachePlugin.js +6 -6
- package/lib/cache/MemoryWithGcCachePlugin.js +9 -10
- package/lib/cache/PackFileCacheStrategy.js +11 -28
- package/lib/cache/ResolverCachePlugin.js +8 -4
- package/lib/cache/getLazyHashedEtag.js +3 -5
- package/lib/cache/mergeEtags.js +1 -1
- package/lib/{OptionsApply.js → config/OptionsApply.js} +3 -3
- package/lib/{PlatformPlugin.js → config/PlatformPlugin.js} +2 -2
- package/lib/{WebpackOptionsApply.js → config/WebpackOptionsApply.js} +217 -200
- package/lib/{WebpackOptionsDefaulter.js → config/WebpackOptionsDefaulter.js} +3 -3
- package/lib/config/browserslistTargetHandler.js +3 -9
- package/lib/{cli.js → config/cli.js} +5 -158
- package/lib/config/defaults.js +192 -122
- package/lib/config/getClaimedAssetTypes.js +28 -21
- package/lib/config/normalization.js +18 -7
- package/lib/config/target.js +13 -4
- package/lib/container/ContainerEntryDependency.js +1 -1
- package/lib/container/ContainerEntryModule.js +13 -11
- package/lib/container/ContainerEntryModuleFactory.js +2 -2
- package/lib/container/ContainerExposedDependency.js +1 -1
- package/lib/container/ContainerPlugin.js +178 -5
- package/lib/container/ContainerReferencePlugin.js +75 -14
- package/lib/container/FallbackDependency.js +1 -1
- package/lib/container/FallbackItemDependency.js +1 -1
- package/lib/container/FallbackModule.js +12 -10
- package/lib/container/FallbackModuleFactory.js +2 -2
- package/lib/container/HoistContainerReferencesPlugin.js +10 -11
- package/lib/container/ModuleFederationPlugin.js +306 -7
- package/lib/container/RemoteModule.js +14 -10
- package/lib/container/RemoteRuntimeModule.js +5 -5
- package/lib/container/RemoteToExternalDependency.js +1 -1
- package/lib/container/moduleFederationHooks.js +1 -1
- package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
- package/lib/{ContextModule.js → context/ContextModule.js} +50 -36
- package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +25 -24
- package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
- package/lib/css/CssGenerator.js +57 -42
- package/lib/css/CssInjectStyleRuntimeModule.js +36 -30
- package/lib/css/CssLoadingRuntimeModule.js +77 -44
- package/lib/css/CssModule.js +27 -29
- package/lib/css/CssModulesPlugin.js +128 -44
- package/lib/css/CssParser.js +700 -311
- package/lib/css/CssServerStylesRuntimeModule.js +3 -3
- package/lib/css/cssMinify.js +130 -54
- package/lib/css/data.js +7017 -4648
- package/lib/css/syntax-parser.js +19873 -0
- package/lib/css/syntax-printer.js +6037 -0
- package/lib/css/syntax.js +37 -17370
- package/lib/debug/ProfilingPlugin.js +55 -23
- package/lib/{DefinePlugin.js → define/DefinePlugin.js} +407 -41
- package/lib/{DotenvPlugin.js → define/DotenvPlugin.js} +25 -29
- package/lib/{EnvironmentPlugin.js → define/EnvironmentPlugin.js} +2 -2
- package/lib/deno/DenoTargetPlugin.js +1 -1
- package/lib/dependencies/ConstDependency.js +3 -120
- package/lib/dependencies/ContextElementDependency.js +5 -172
- package/lib/dependencies/NullDependency.js +3 -37
- package/lib/dependencies/{AMDDefineDependency.js → amd/AMDDefineDependency.js} +12 -11
- package/lib/dependencies/{AMDDefineDependencyParserPlugin.js → amd/AMDDefineDependencyParserPlugin.js} +10 -10
- package/lib/dependencies/{AMDPlugin.js → amd/AMDPlugin.js} +11 -11
- package/lib/dependencies/{AMDRequireArrayDependency.js → amd/AMDRequireArrayDependency.js} +15 -13
- package/lib/dependencies/{AMDRequireContextDependency.js → amd/AMDRequireContextDependency.js} +11 -10
- package/lib/dependencies/{AMDRequireDependenciesBlock.js → amd/AMDRequireDependenciesBlock.js} +7 -6
- package/lib/dependencies/{AMDRequireDependenciesBlockParserPlugin.js → amd/AMDRequireDependenciesBlockParserPlugin.js} +10 -10
- package/lib/dependencies/{AMDRequireDependency.js → amd/AMDRequireDependency.js} +13 -12
- package/lib/dependencies/{AMDRequireItemDependency.js → amd/AMDRequireItemDependency.js} +8 -7
- package/lib/dependencies/{AMDRuntimeModules.js → amd/AMDRuntimeModules.js} +3 -3
- package/lib/dependencies/{LocalModule.js → amd/LocalModule.js} +8 -4
- package/lib/dependencies/{LocalModuleDependency.js → amd/LocalModuleDependency.js} +17 -10
- package/lib/dependencies/{LocalModulesHelpers.js → amd/LocalModulesHelpers.js} +1 -1
- package/lib/dependencies/{RequireJsStuffPlugin.js → amd/RequireJsStuffPlugin.js} +9 -9
- package/lib/dependencies/{UnsupportedDependency.js → amd/UnsupportedDependency.js} +11 -10
- package/lib/dependencies/{CommonJsDependencyHelpers.js → commonjs/CommonJsDependencyHelpers.js} +8 -9
- package/lib/dependencies/{CommonJsExportRequireDependency.js → commonjs/CommonJsExportRequireDependency.js} +176 -44
- package/lib/dependencies/{CommonJsExportsDependency.js → commonjs/CommonJsExportsDependency.js} +15 -14
- package/lib/dependencies/{CommonJsExportsParserPlugin.js → commonjs/CommonJsExportsParserPlugin.js} +138 -61
- package/lib/dependencies/{CommonJsFullRequireDependency.js → commonjs/CommonJsFullRequireDependency.js} +32 -24
- package/lib/dependencies/{CommonJsImportsParserPlugin.js → commonjs/CommonJsImportsParserPlugin.js} +39 -35
- package/lib/dependencies/{CommonJsObjectExportDependency.js → commonjs/CommonJsObjectExportDependency.js} +13 -12
- package/lib/dependencies/{CommonJsPlugin.js → commonjs/CommonJsPlugin.js} +47 -35
- package/lib/dependencies/{CommonJsRequireContextDependency.js → commonjs/CommonJsRequireContextDependency.js} +15 -14
- package/lib/dependencies/{CommonJsRequireDependency.js → commonjs/CommonJsRequireDependency.js} +33 -25
- package/lib/dependencies/{CommonJsSelfReferenceDependency.js → commonjs/CommonJsSelfReferenceDependency.js} +19 -20
- package/lib/dependencies/{ModuleDecoratorDependency.js → commonjs/ModuleDecoratorDependency.js} +16 -15
- package/lib/dependencies/{RequireEnsureDependenciesBlock.js → commonjs/RequireEnsureDependenciesBlock.js} +8 -7
- package/lib/dependencies/{RequireEnsureDependenciesBlockParserPlugin.js → commonjs/RequireEnsureDependenciesBlockParserPlugin.js} +5 -5
- package/lib/dependencies/{RequireEnsureDependency.js → commonjs/RequireEnsureDependency.js} +13 -12
- package/lib/dependencies/{RequireEnsureItemDependency.js → commonjs/RequireEnsureItemDependency.js} +7 -6
- package/lib/dependencies/{RequireEnsurePlugin.js → commonjs/RequireEnsurePlugin.js} +8 -8
- package/lib/dependencies/{RequireHeaderDependency.js → commonjs/RequireHeaderDependency.js} +14 -13
- package/lib/dependencies/{RequireIncludeDependency.js → commonjs/RequireIncludeDependency.js} +13 -12
- package/lib/dependencies/{RequireIncludeDependencyParserPlugin.js → commonjs/RequireIncludeDependencyParserPlugin.js} +3 -27
- package/lib/dependencies/{RequireIncludePlugin.js → commonjs/RequireIncludePlugin.js} +4 -4
- package/lib/dependencies/{RequireResolveContextDependency.js → commonjs/RequireResolveContextDependency.js} +11 -10
- package/lib/dependencies/{RequireResolveDependency.js → commonjs/RequireResolveDependency.js} +12 -11
- package/lib/dependencies/{RequireResolveHeaderDependency.js → commonjs/RequireResolveHeaderDependency.js} +13 -12
- package/lib/dependencies/commonjs/TopLevelThisParserPlugin.js +59 -0
- package/lib/dependencies/{ContextDependency.js → context/ContextDependency.js} +15 -14
- package/lib/dependencies/{ContextDependencyHelpers.js → context/ContextDependencyHelpers.js} +34 -18
- package/lib/dependencies/{ContextDependencyTemplateAsId.js → context/ContextDependencyTemplateAsId.js} +3 -3
- package/lib/dependencies/{ContextDependencyTemplateAsRequireCall.js → context/ContextDependencyTemplateAsRequireCall.js} +3 -3
- package/lib/dependencies/context/ContextElementDependency.js +198 -0
- package/lib/dependencies/{ImportMetaContextDependency.js → context/ImportMetaContextDependency.js} +7 -6
- package/lib/dependencies/{ImportMetaContextDependencyParserPlugin.js → context/ImportMetaContextDependencyParserPlugin.js} +9 -9
- package/lib/dependencies/{ImportMetaContextPlugin.js → context/ImportMetaContextPlugin.js} +5 -5
- package/lib/dependencies/{ImportMetaGlobDependency.js → context/ImportMetaGlobDependency.js} +7 -6
- package/lib/dependencies/{ImportMetaGlobDependencyParserPlugin.js → context/ImportMetaGlobDependencyParserPlugin.js} +4 -4
- package/lib/dependencies/{ImportMetaGlobHelpers.js → context/ImportMetaGlobHelpers.js} +9 -9
- package/lib/dependencies/{RequireContextDependency.js → context/RequireContextDependency.js} +7 -6
- package/lib/dependencies/{RequireContextDependencyParserPlugin.js → context/RequireContextDependencyParserPlugin.js} +2 -2
- package/lib/dependencies/{RequireContextPlugin.js → context/RequireContextPlugin.js} +5 -5
- package/lib/dependencies/{CachedConstDependency.js → core/CachedConstDependency.js} +12 -11
- package/lib/dependencies/core/ConstDependency.js +131 -0
- package/lib/dependencies/{ImportPhase.js → core/ImportPhase.js} +5 -4
- package/lib/dependencies/{ModuleDependency.js → core/ModuleDependency.js} +10 -7
- package/lib/dependencies/{ModuleDependencyTemplateAsId.js → core/ModuleDependencyTemplateAsId.js} +3 -3
- package/lib/dependencies/{ModuleDependencyTemplateAsRequireId.js → core/ModuleDependencyTemplateAsRequireId.js} +2 -2
- package/lib/dependencies/{ModuleInitFragmentDependency.js → core/ModuleInitFragmentDependency.js} +10 -9
- package/lib/dependencies/core/NullDependency.js +44 -0
- package/lib/dependencies/{RuntimeRequirementsDependency.js → core/RuntimeRequirementsDependency.js} +10 -9
- package/lib/dependencies/{StaticExportsDependency.js → core/StaticExportsDependency.js} +15 -8
- package/lib/dependencies/{CssIcssExportDependency.js → css/CssIcssExportDependency.js} +375 -100
- package/lib/dependencies/{CssIcssImportDependency.js → css/CssIcssImportDependency.js} +26 -22
- package/lib/dependencies/{CssIcssSymbolDependency.js → css/CssIcssSymbolDependency.js} +13 -12
- package/lib/dependencies/{CssImportDependency.js → css/CssImportDependency.js} +15 -11
- package/lib/dependencies/{CssUrlDependency.js → css/CssUrlDependency.js} +26 -21
- package/lib/dependencies/{CreateRequireParserPlugin.js → esm/CreateRequireParserPlugin.js} +9 -9
- package/lib/dependencies/{HarmonyAcceptDependency.js → esm/ESMAcceptDependency.js} +41 -38
- package/lib/dependencies/esm/ESMAcceptImportDependency.js +39 -0
- package/lib/dependencies/{HarmonyCompatibilityDependency.js → esm/ESMCompatibilityDependency.js} +40 -41
- package/lib/dependencies/{HarmonyDetectionParserPlugin.js → esm/ESMDetectionParserPlugin.js} +22 -21
- package/lib/dependencies/{HarmonyEvaluatedImportSpecifierDependency.js → esm/ESMEvaluatedImportSpecifierDependency.js} +33 -30
- package/lib/dependencies/{HarmonyExportDependencyParserPlugin.js → esm/ESMExportDependencyParserPlugin.js} +62 -93
- package/lib/dependencies/{HarmonyExportExpressionDependency.js → esm/ESMExportExpressionDependency.js} +83 -49
- package/lib/dependencies/{HarmonyExportHeaderDependency.js → esm/ESMExportHeaderDependency.js} +17 -15
- package/lib/dependencies/esm/ESMExportImportedSideEffectDependency.js +37 -0
- package/lib/dependencies/{HarmonyExportImportedSpecifierDependency.js → esm/ESMExportImportedSpecifierDependency.js} +136 -122
- package/lib/dependencies/{HarmonyExportInitFragment.js → esm/ESMExportInitFragment.js} +68 -43
- package/lib/dependencies/{HarmonyExportSpecifierDependency.js → esm/ESMExportSpecifierDependency.js} +68 -65
- package/lib/dependencies/{HarmonyExports.js → esm/ESMExports.js} +4 -4
- package/lib/dependencies/{HarmonyImportBareSideEffectDependency.js → esm/ESMImportBareSideEffectDependency.js} +21 -13
- package/lib/dependencies/{HarmonyImportDependency.js → esm/ESMImportDependency.js} +74 -71
- package/lib/dependencies/{HarmonyImportDependencyParserPlugin.js → esm/ESMImportDependencyParserPlugin.js} +199 -97
- package/lib/dependencies/{HarmonyImportGuard.js → esm/ESMImportGuard.js} +26 -29
- package/lib/dependencies/{HarmonyImportSideEffectDependency.js → esm/ESMImportSideEffectDependency.js} +86 -43
- package/lib/dependencies/{HarmonyImportSpecifierDependency.js → esm/ESMImportSpecifierDependency.js} +110 -61
- package/lib/dependencies/esm/ESMModulesPlugin.js +207 -0
- package/lib/dependencies/{HarmonyTopLevelThisParserPlugin.js → esm/ESMTopLevelThisParserPlugin.js} +7 -7
- package/lib/dependencies/{TopLevelAwaitDependency.js → esm/TopLevelAwaitDependency.js} +12 -11
- package/lib/dependencies/{DynamicExports.js → helpers/DynamicExports.js} +2 -2
- package/lib/{util → dependencies/helpers}/chainedImports.js +8 -9
- package/lib/dependencies/{processExportInfo.js → helpers/processExportInfo.js} +4 -4
- package/lib/{util → dependencies/helpers}/traverseDestructuringAssignmentProperties.js +1 -1
- package/lib/dependencies/{ImportMetaHotAcceptDependency.js → hmr/ImportMetaHotAcceptDependency.js} +8 -7
- package/lib/dependencies/{ImportMetaHotDeclineDependency.js → hmr/ImportMetaHotDeclineDependency.js} +8 -7
- package/lib/dependencies/{ModuleHotAcceptDependency.js → hmr/ModuleHotAcceptDependency.js} +8 -7
- package/lib/dependencies/{ModuleHotDeclineDependency.js → hmr/ModuleHotDeclineDependency.js} +8 -7
- package/lib/dependencies/{HtmlEntryDependency.js → html/HtmlEntryDependency.js} +125 -243
- package/lib/dependencies/{HtmlInlineHtmlDependency.js → html/HtmlInlineHtmlDependency.js} +13 -12
- package/lib/dependencies/{HtmlInlineScriptDependency.js → html/HtmlInlineScriptDependency.js} +72 -23
- package/lib/dependencies/{HtmlInlineStyleDependency.js → html/HtmlInlineStyleDependency.js} +53 -19
- package/lib/dependencies/{HtmlSourceDependency.js → html/HtmlSourceDependency.js} +23 -16
- package/lib/dependencies/{ImportContextDependency.js → import/ImportContextDependency.js} +24 -10
- package/lib/dependencies/{ImportDependency.js → import/ImportDependency.js} +26 -18
- package/lib/dependencies/{ImportEagerDependency.js → import/ImportEagerDependency.js} +18 -10
- package/lib/dependencies/{ImportParserPlugin.js → import/ImportParserPlugin.js} +20 -20
- package/lib/dependencies/{ImportPlugin.js → import/ImportPlugin.js} +4 -4
- package/lib/dependencies/{ImportWeakDependency.js → import/ImportWeakDependency.js} +18 -10
- package/lib/dependencies/{importOptionsCheck.js → import/importOptionsCheck.js} +2 -2
- package/lib/dependencies/{BuildTimeConstDependency.js → import-meta/BuildTimeConstDependency.js} +12 -11
- package/lib/dependencies/{ImportMetaMainDependency.js → import-meta/ImportMetaMainDependency.js} +12 -11
- package/lib/dependencies/{ImportMetaPlugin.js → import-meta/ImportMetaPlugin.js} +126 -107
- package/lib/dependencies/{SystemPlugin.js → system/SystemPlugin.js} +11 -38
- package/lib/dependencies/{SystemRuntimeModule.js → system/SystemRuntimeModule.js} +3 -3
- package/lib/dependencies/{ImportMetaResolveDependency.js → url/ImportMetaResolveDependency.js} +9 -8
- package/lib/dependencies/{URLContextDependency.js → url/URLContextDependency.js} +11 -10
- package/lib/dependencies/{URLDependency.js → url/URLDependency.js} +34 -25
- package/lib/{url → dependencies/url}/URLParserPlugin.js +22 -26
- package/lib/dependencies/{URLPlugin.js → url/URLPlugin.js} +6 -7
- package/lib/dependencies/{WebAssemblyExportImportedDependency.js → wasm/WebAssemblyExportImportedDependency.js} +18 -11
- package/lib/dependencies/{WebAssemblyImportDependency.js → wasm/WebAssemblyImportDependency.js} +19 -12
- package/lib/dependencies/{CreateScriptUrlDependency.js → worker/CreateScriptUrlDependency.js} +12 -11
- package/lib/dependencies/{WorkerAndWorkletPlugin.js → worker/WorkerAndWorkletPlugin.js} +46 -54
- package/lib/dependencies/{WorkerDependency.js → worker/WorkerDependency.js} +28 -20
- package/lib/dependencies/{WorkletDependency.js → worker/WorkletDependency.js} +25 -27
- package/lib/{EvalDevToolModulePlugin.js → devtool/EvalDevToolModulePlugin.js} +20 -6
- package/lib/{EvalSourceMapDevToolPlugin.js → devtool/EvalSourceMapDevToolPlugin.js} +32 -24
- package/lib/devtool/ModuleFilenameHelpers.js +413 -0
- package/lib/{SourceMapDevToolModuleOptionsPlugin.js → devtool/SourceMapDevToolModuleOptionsPlugin.js} +10 -3
- package/lib/{SourceMapDevToolPlugin.js → devtool/SourceMapDevToolPlugin.js} +207 -129
- package/lib/{util → devtool}/generateDebugId.js +1 -1
- package/lib/{IgnoreWarningsPlugin.js → diagnostics/IgnoreWarningsPlugin.js} +2 -2
- package/lib/{NoEmitOnErrorsPlugin.js → diagnostics/NoEmitOnErrorsPlugin.js} +1 -1
- package/lib/diagnostics/WarnCaseSensitiveModulesPlugin.js +64 -0
- package/lib/{WarnDeprecatedOptionPlugin.js → diagnostics/WarnDeprecatedOptionPlugin.js} +2 -22
- package/lib/diagnostics/WarnNoModeSetPlugin.js +27 -0
- package/lib/dll/DelegatedModule.js +20 -18
- package/lib/dll/DelegatedModuleFactoryPlugin.js +2 -2
- package/lib/dll/DelegatedPlugin.js +1 -1
- package/lib/{dependencies → dll}/DelegatedSourceDependency.js +5 -4
- package/lib/{dependencies → dll}/DllEntryDependency.js +6 -5
- package/lib/dll/DllEntryPlugin.js +3 -3
- package/lib/dll/DllModule.js +11 -9
- package/lib/dll/DllModuleFactory.js +3 -3
- package/lib/dll/DllPlugin.js +18 -6
- package/lib/dll/DllReferencePlugin.js +102 -26
- package/lib/dll/LibManifestPlugin.js +9 -7
- package/lib/electron/ElectronTargetPlugin.js +2 -2
- package/lib/{DynamicEntryPlugin.js → entry/DynamicEntryPlugin.js} +3 -3
- package/lib/{dependencies → entry}/EntryDependency.js +11 -2
- package/lib/{EntryOptionPlugin.js → entry/EntryOptionPlugin.js} +6 -6
- package/lib/entry/EntryPlugin.js +75 -0
- package/lib/{performance → errors}/AssetsOverSizeLimitWarning.js +2 -2
- package/lib/errors/AsyncDependencyToInitialChunkError.js +2 -2
- package/lib/errors/BuildCycleError.js +1 -1
- package/lib/{WarnCaseSensitiveModulesPlugin.js → errors/CaseSensitiveModulesWarning.js} +4 -56
- package/lib/errors/ChunkRenderError.js +1 -1
- package/lib/errors/CodeGenerationError.js +1 -1
- package/lib/errors/CommentCompilationWarning.js +1 -1
- package/lib/errors/ConflictingEntryExportsWarning.js +38 -0
- package/lib/{dependencies → errors}/CriticalDependencyWarning.js +4 -3
- package/lib/errors/DeprecatedOptionWarning.js +30 -0
- package/lib/errors/DllManifestError.js +26 -0
- package/lib/{performance → errors}/DuplicatePackagesWarning.js +6 -6
- package/lib/{dependencies/HarmonyLinkingError.js → errors/ESMLinkingError.js} +4 -4
- package/lib/{performance → errors}/EntrypointsOverSizeLimitWarning.js +2 -2
- package/lib/errors/EnvironmentNotSupportAsyncWarning.js +2 -2
- package/lib/errors/ErrorHelpers.js +222 -0
- package/lib/errors/ExternalStarReexportError.js +2 -2
- package/lib/{library → errors}/FalseIIFEUmdWarning.js +1 -1
- package/lib/errors/HookWebpackError.js +6 -5
- package/lib/errors/IgnoreErrorModuleFactory.js +3 -3
- package/lib/errors/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/{optimize → errors}/MinMaxSizeWarning.js +1 -1
- package/lib/errors/ModuleBuildError.js +1 -1
- package/lib/errors/ModuleDependencyError.js +2 -2
- package/lib/errors/ModuleDependencyWarning.js +2 -2
- package/lib/errors/ModuleError.js +1 -1
- package/lib/errors/ModuleHashingError.js +1 -1
- package/lib/errors/ModuleNotFoundError.js +3 -3
- package/lib/errors/ModuleParseError.js +1 -1
- package/lib/errors/ModuleRestoreError.js +1 -1
- package/lib/errors/ModuleStoreError.js +1 -1
- package/lib/errors/ModuleWarning.js +1 -1
- package/lib/{performance → errors}/NoAsyncChunksWarning.js +1 -1
- package/lib/{WarnNoModeSetPlugin.js → errors/NoModeWarning.js} +2 -19
- package/lib/errors/NodeStuffInWebError.js +7 -2
- package/lib/errors/PathVariableError.js +31 -0
- package/lib/errors/RequireIncludeDeprecationWarning.js +40 -0
- package/lib/{performance → errors}/RuntimeInLargeChunkWarning.js +1 -1
- package/lib/errors/RuntimeModuleGenerationError.js +51 -0
- package/lib/errors/SSRManifestAutoPublicPathWarning.js +24 -0
- package/lib/errors/SystemImportDeprecationWarning.js +43 -0
- package/lib/errors/UnmergeableEntryExportsError.js +34 -0
- package/lib/errors/UnsupportedFeatureWarning.js +1 -1
- package/lib/{wasm-sync → errors}/UnsupportedWebAssemblyFeatureError.js +1 -1
- package/lib/{wasm-sync → errors}/WebAssemblyInInitialChunkError.js +7 -5
- package/lib/errors/WebpackError.js +12 -3
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +2 -2
- package/lib/esm/ModuleChunkFormatPlugin.js +19 -19
- package/lib/esm/ModuleChunkLoadingPlugin.js +3 -3
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +8 -8
- package/lib/{ExternalModule.js → externals/ExternalModule.js} +85 -63
- package/lib/{ExternalModuleFactoryPlugin.js → externals/ExternalModuleFactoryPlugin.js} +41 -39
- package/lib/externals/ExternalsPlugin.js +99 -0
- package/lib/fs/FileSystemInfo.js +4642 -0
- package/lib/{util → fs}/fs.js +22 -9
- package/lib/{AsyncDependenciesBlock.js → graph/AsyncDependenciesBlock.js} +27 -4
- package/lib/graph/Chunk.js +985 -0
- package/lib/{ChunkGraph.js → graph/ChunkGraph.js} +187 -80
- package/lib/{ChunkGroup.js → graph/ChunkGroup.js} +11 -3
- package/lib/{DependenciesBlock.js → graph/DependenciesBlock.js} +16 -4
- package/lib/graph/Dependency.js +628 -0
- package/lib/graph/Entrypoint.js +136 -0
- package/lib/{ExportsInfo.js → graph/ExportsInfo.js} +151 -99
- package/lib/{HotUpdateChunk.js → graph/HotUpdateChunk.js} +8 -0
- package/lib/{ModuleGraph.js → graph/ModuleGraph.js} +36 -39
- package/lib/{ModuleGraphConnection.js → graph/ModuleGraphConnection.js} +2 -2
- package/lib/{buildChunkGraph.js → graph/buildChunkGraph.js} +163 -72
- package/lib/{util → graph}/findGraphRoots.js +20 -21
- package/lib/graph/isDependencyKind.js +23 -0
- package/lib/hmr/HotModuleReplacement.runtime.js +2 -2
- package/lib/{HotModuleReplacementPlugin.js → hmr/HotModuleReplacementPlugin.js} +49 -47
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +3 -3
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +10 -8
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +2 -2
- package/lib/hmr/LazyCompilationPlugin.js +34 -26
- package/lib/html/HtmlGenerator.js +168 -125
- package/lib/html/HtmlModule.js +6 -2
- package/lib/html/HtmlModulesPlugin.js +260 -215
- package/lib/html/HtmlParser.js +598 -292
- package/lib/html/builtinEmbeddedRenderer.js +60 -13
- package/lib/html/data.js +23 -1
- package/lib/html/htmlMinify.js +120 -51
- package/lib/html/syntax-parser.js +15796 -0
- package/lib/html/syntax-printer.js +1034 -0
- package/lib/html/syntax.js +37 -14062
- package/lib/html/xmlMinify.js +67 -0
- package/lib/ids/ChunkModuleIdRangePlugin.js +2 -2
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +31 -4
- package/lib/ids/IdHelpers.js +4 -4
- package/lib/ids/NaturalChunkIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +6 -5
- package/lib/ids/OccurrenceModuleIdsPlugin.js +6 -5
- package/lib/{RecordIdsPlugin.js → ids/RecordIdsPlugin.js} +5 -5
- package/lib/ids/SyncModuleIdsPlugin.js +3 -3
- package/lib/{util → ids}/numberHash.js +1 -1
- package/lib/index.js +348 -99
- package/lib/{APIPlugin.js → javascript/APIPlugin.js} +29 -30
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -5
- package/lib/javascript/BasicEvaluatedExpression.js +4 -4
- package/lib/javascript/ChunkHelpers.js +64 -4
- package/lib/javascript/CommonJsChunkFormatPlugin.js +4 -7
- package/lib/{CompatibilityPlugin.js → javascript/CompatibilityPlugin.js} +10 -11
- package/lib/{ConstPlugin.js → javascript/ConstPlugin.js} +90 -139
- package/lib/{ExportsInfoApiPlugin.js → javascript/ExportsInfoApiPlugin.js} +5 -5
- package/lib/{dependencies → javascript}/ExportsInfoDependency.js +10 -9
- package/lib/javascript/JavascriptGenerator.js +25 -18
- package/lib/{JavascriptMetaInfoPlugin.js → javascript/JavascriptMetaInfoPlugin.js} +7 -7
- package/lib/javascript/JavascriptModule.js +4 -3
- package/lib/javascript/JavascriptModulesPlugin.js +458 -256
- package/lib/javascript/JavascriptParser.js +916 -287
- package/lib/javascript/JavascriptParserHelpers.js +1 -1
- package/lib/javascript/MergedEntryExports.js +196 -0
- package/lib/javascript/ScopeAnalyzer.js +3840 -5
- package/lib/javascript/StartupHelpers.js +6 -6
- package/lib/{UseStrictPlugin.js → javascript/UseStrictPlugin.js} +12 -15
- package/lib/{dependencies → javascript}/WebpackIsIncludedDependency.js +10 -9
- package/lib/{WebpackIsIncludedPlugin.js → javascript/WebpackIsIncludedPlugin.js} +8 -8
- package/lib/javascript/data.js +533 -122
- package/lib/javascript/jsMinify.js +272 -0
- package/lib/javascript/regexp.js +67 -32
- package/lib/javascript/syntax-parser.js +18561 -0
- package/lib/javascript/syntax-printer-data.js +933 -0
- package/lib/javascript/syntax-printer.js +47106 -0
- package/lib/javascript/syntax.js +20 -10946
- package/lib/json/JsonData.js +1 -1
- package/lib/{dependencies → json}/JsonExportsDependency.js +8 -7
- package/lib/json/JsonGenerator.js +17 -11
- package/lib/json/JsonModule.js +2 -2
- package/lib/json/JsonModulesPlugin.js +1 -1
- package/lib/json/JsonParser.js +5 -5
- package/lib/json/jsonMinify.js +69 -0
- package/lib/library/AbstractLibraryPlugin.js +28 -15
- package/lib/library/AmdLibraryPlugin.js +4 -4
- package/lib/library/AssignLibraryPlugin.js +27 -11
- package/lib/library/EnableLibraryPlugin.js +1 -1
- package/lib/library/ExportPropertyLibraryPlugin.js +4 -4
- package/lib/library/JsonpLibraryPlugin.js +1 -1
- package/lib/library/LibraryTemplatePlugin.js +53 -0
- package/lib/library/ModuleLibraryPlugin.js +207 -285
- package/lib/library/SystemLibraryPlugin.js +6 -8
- package/lib/library/UmdLibraryPlugin.js +3 -4
- package/lib/{dependencies → loaders}/LoaderDependency.js +3 -3
- package/lib/{dependencies → loaders}/LoaderImportDependency.js +9 -3
- package/lib/{LoaderOptionsPlugin.js → loaders/LoaderOptionsPlugin.js} +30 -12
- package/lib/{dependencies → loaders}/LoaderPlugin.js +27 -2
- package/lib/loaders/LoaderRunner.js +160 -22
- package/lib/{LoaderTargetPlugin.js → loaders/LoaderTargetPlugin.js} +2 -2
- package/lib/logging/Logger.js +7 -9
- package/lib/logging/ProgressPlugin.js +957 -0
- package/lib/{CodeGenerationResults.js → module/CodeGenerationResults.js} +7 -7
- package/lib/{Generator.js → module/Generator.js} +38 -14
- package/lib/{Module.js → module/Module.js} +122 -54
- package/lib/{ModuleFactory.js → module/ModuleFactory.js} +3 -3
- package/lib/module/NormalModule.js +2348 -0
- package/lib/{NormalModuleFactory.js → module/NormalModuleFactory.js} +53 -54
- package/lib/module/NullFactory.js +29 -0
- package/lib/{Parser.js → module/Parser.js} +3 -3
- package/lib/module/RawModule.js +208 -0
- package/lib/{SelfModuleFactory.js → module/SelfModuleFactory.js} +1 -1
- package/lib/{util → module}/extractSourceMap.js +2 -2
- package/lib/{util → module}/findCaseMismatch.js +2 -2
- package/lib/node/CommonJsChunkLoadingPlugin.js +3 -3
- package/lib/{dependencies → node}/ExternalModuleDependency.js +8 -7
- package/lib/{dependencies → node}/ExternalModuleInitFragment.js +6 -5
- package/lib/{dependencies → node}/ExternalModuleInitFragmentDependency.js +14 -9
- package/lib/node/NodeEnvironmentPlugin.js +11 -1
- package/lib/{NodeStuffPlugin.js → node/NodeStuffPlugin.js} +17 -17
- package/lib/node/NodeTargetPlugin.js +1 -1
- package/lib/node/NodeWatchFileSystem.js +61 -15
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +7 -7
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +9 -7
- package/lib/node/ReadFileCompileWasmPlugin.js +7 -5
- package/lib/node/RequireChunkLoadingRuntimeModule.js +7 -7
- package/lib/node/nodeConsole.js +2 -4
- package/lib/optimize/AggressiveMergingPlugin.js +5 -7
- package/lib/optimize/AggressiveSplittingPlugin.js +12 -8
- package/lib/{CircularModulesPlugin.js → optimize/CircularModulesPlugin.js} +13 -13
- package/lib/optimize/ConcatenatedModule.js +305 -309
- package/lib/{ConcatenationScope.js → optimize/ConcatenationScope.js} +39 -6
- package/lib/optimize/ConstExportsPlugin.js +7 -7
- package/lib/optimize/EnsureChunkConditionsPlugin.js +3 -3
- package/lib/{FlagAllModulesAsUsedPlugin.js → optimize/FlagAllModulesAsUsedPlugin.js} +3 -3
- package/lib/{FlagDependencyExportsPlugin.js → optimize/FlagDependencyExportsPlugin.js} +25 -30
- package/lib/{FlagDependencyUsagePlugin.js → optimize/FlagDependencyUsagePlugin.js} +26 -30
- package/lib/{FlagEntryExportAsUsedPlugin.js → optimize/FlagEntryExportAsUsedPlugin.js} +2 -2
- package/lib/optimize/FlagIncludedChunksPlugin.js +5 -13
- package/lib/optimize/InlineExports.js +11 -3
- package/lib/optimize/InnerGraph.js +5 -13
- package/lib/optimize/InnerGraphPlugin.js +17 -23
- package/lib/optimize/LazyBarrels.js +584 -0
- package/lib/{util → optimize}/LazyBucketSortedSet.js +2 -2
- package/lib/optimize/LimitChunkCountPlugin.js +21 -15
- package/lib/optimize/MangleExportsPlugin.js +8 -9
- package/lib/optimize/MergeDuplicateChunksPlugin.js +7 -6
- package/lib/optimize/MinChunkSizePlugin.js +9 -6
- package/lib/optimize/ModuleConcatenationPlugin.js +23 -16
- package/lib/{dependencies → optimize}/PureExpressionDependency.js +11 -10
- package/lib/optimize/RealContentHashPlugin.js +16 -7
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -2
- package/lib/optimize/RemoveParentModulesPlugin.js +4 -4
- package/lib/optimize/SideEffectsFlagPlugin.js +25 -37
- package/lib/optimize/SplitChunksPlugin.js +715 -159
- package/lib/{util → optimize}/TupleQueue.js +9 -9
- package/lib/optimize/chunkSetIntersections.js +437 -0
- package/lib/{util → optimize}/deterministicGrouping.js +25 -30
- package/lib/{BannerPlugin.js → output/BannerPlugin.js} +82 -14
- package/lib/{CleanPlugin.js → output/CleanPlugin.js} +66 -24
- package/lib/{CopyPlugin.js → output/CopyPlugin.js} +142 -67
- package/lib/{ManifestPlugin.js → output/ManifestPlugin.js} +91 -17
- package/lib/output/SSRManifestPlugin.js +349 -0
- package/lib/performance/AnalyzableBailoutsPlugin.js +1 -1
- package/lib/performance/AsyncChunkWaterfallsPlugin.js +1 -1
- package/lib/performance/BroadContextsPlugin.js +4 -4
- package/lib/performance/CacheEffectivenessPlugin.js +5 -7
- package/lib/performance/ConflictingResourceHintsPlugin.js +1 -1
- package/lib/performance/DuplicateModulesPlugin.js +3 -4
- package/lib/performance/DuplicatePackagesPlugin.js +3 -3
- package/lib/performance/DynamicExportsPlugin.js +2 -2
- package/lib/performance/EvalUsagePlugin.js +3 -3
- package/lib/performance/HotspotsPlugin.js +11 -10
- package/lib/performance/LargeModulesPlugin.js +2 -3
- package/lib/performance/LegacyJavascriptPlugin.js +1 -2
- package/lib/performance/MissingSideEffectsPlugin.js +2 -3
- package/lib/performance/MissingSourceMapsPlugin.js +5 -6
- package/lib/performance/PureAnnotationsPlugin.js +3 -3
- package/lib/performance/RedundantDynamicImportsPlugin.js +6 -8
- package/lib/performance/ScopeHoistingBailoutsPlugin.js +2 -2
- package/lib/performance/SizeLimitsPlugin.js +13 -16
- package/lib/performance/TopLevelThisPlugin.js +8 -7
- package/lib/performance/UnsplitVendorsPlugin.js +1 -2
- package/lib/performance/UnusedAliasesPlugin.js +6 -7
- package/lib/performance/UnusedAssetsPlugin.js +5 -5
- package/lib/performance/UnusedDefinesPlugin.js +2 -2
- package/lib/performance/UnusedExternalsPlugin.js +3 -4
- package/lib/performance/UnusedFederationPlugin.js +2 -4
- package/lib/performance/UnusedModulesPlugin.js +5 -4
- package/lib/performance/getModuleSize.js +1 -1
- package/lib/performance/hasOnlyUnusedExports.js +4 -4
- package/lib/performance/isOnlyReexported.js +7 -6
- package/lib/{AutomaticPrefetchPlugin.js → prefetch/AutomaticPrefetchPlugin.js} +4 -5
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +2 -2
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +7 -9
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +4 -4
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -4
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +4 -4
- package/lib/{dependencies → prefetch}/PrefetchDependency.js +1 -1
- package/lib/{PrefetchPlugin.js → prefetch/PrefetchPlugin.js} +2 -2
- package/lib/prefetch/ResourceHintPlugin.js +82 -65
- package/lib/prefetch/ResourceHintRuntimeModule.js +3 -3
- package/lib/prefetch/StartupAssetHintRuntimeModule.js +10 -13
- package/lib/prefetch/parseResourceHintOptions.js +4 -3
- package/lib/{ProvidePlugin.js → provide/ProvidePlugin.js} +7 -7
- package/lib/{dependencies → provide}/ProvidedDependency.js +14 -13
- package/lib/{IgnorePlugin.js → resolve/IgnorePlugin.js} +30 -13
- package/lib/{NormalModuleReplacementPlugin.js → resolve/NormalModuleReplacementPlugin.js} +4 -4
- package/lib/{ResolverFactory.js → resolve/ResolverFactory.js} +18 -5
- package/lib/resolve/getResolveOptionsKey.js +59 -0
- package/lib/rules/RuleSetCompiler.js +27 -46
- package/lib/runtime/AsyncModuleGeneratorRuntimeModule.js +2 -2
- package/lib/runtime/AsyncModuleRuntimeModule.js +10 -9
- package/lib/runtime/AutoPublicPathRuntimeModule.js +5 -5
- package/lib/runtime/BaseUriRuntimeModule.js +3 -3
- package/lib/runtime/ChunkNameRuntimeModule.js +2 -2
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +2 -2
- package/lib/runtime/CompatRuntimeModule.js +4 -4
- package/lib/runtime/ConcatenationWrapRuntimeModule.js +2 -2
- package/lib/runtime/ConstructRequireRuntimeModule.js +2 -2
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
- package/lib/runtime/CreateScriptRuntimeModule.js +2 -2
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +2 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +6 -6
- package/lib/runtime/EnsureChunkRuntimeModule.js +4 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +9 -10
- package/lib/runtime/GetFullHashRuntimeModule.js +2 -2
- package/lib/runtime/GetMainFilenameRuntimeModule.js +4 -4
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +3 -3
- package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +3 -3
- package/lib/runtime/GlobalRuntimeModule.js +5 -7
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +3 -3
- package/lib/runtime/HelperRuntimeModule.js +16 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +3 -3
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +135 -102
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +2 -2
- package/lib/runtime/NonceRuntimeModule.js +2 -2
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -4
- package/lib/runtime/PublicPathRuntimeModule.js +2 -2
- package/lib/runtime/RelativeUrlRuntimeModule.js +2 -2
- package/lib/{RuntimeGlobals.js → runtime/RuntimeGlobals.js} +18 -1
- package/lib/runtime/RuntimeIdRuntimeModule.js +4 -4
- package/lib/{RuntimeModule.js → runtime/RuntimeModule.js} +36 -21
- package/lib/{RuntimePlugin.js → runtime/RuntimePlugin.js} +48 -50
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +2 -2
- package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +2 -2
- package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +5 -5
- package/lib/runtime/StartupEntrypointRuntimeModule.js +3 -3
- package/lib/runtime/SystemContextRuntimeModule.js +2 -2
- package/lib/runtime/ToBinaryRuntimeModule.js +3 -3
- package/lib/runtime/WorkerRuntimeModule.js +1 -1
- package/lib/runtime/baseUri.js +1 -1
- package/lib/schemes/DataUriPlugin.js +4 -7
- package/lib/schemes/HttpUriPlugin.js +67 -11
- package/lib/schemes/VirtualUrlPlugin.js +50 -16
- package/lib/serialization/AggregateErrorSerializer.js +2 -2
- package/lib/serialization/BinaryMiddleware.js +9 -9
- package/lib/serialization/FileMiddleware.js +19 -19
- package/lib/serialization/ObjectMiddleware.js +77 -49
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/serialization/SingleItemMiddleware.js +4 -2
- package/lib/sharing/ConsumeSharedFallbackDependency.js +9 -1
- package/lib/sharing/ConsumeSharedModule.js +18 -14
- package/lib/sharing/ConsumeSharedPlugin.js +148 -42
- package/lib/sharing/ConsumeSharedRuntimeModule.js +8 -8
- package/lib/sharing/ProvideForSharedDependency.js +9 -1
- package/lib/sharing/ProvideSharedDependency.js +1 -1
- package/lib/sharing/ProvideSharedModule.js +11 -9
- package/lib/sharing/ProvideSharedModuleFactory.js +2 -2
- package/lib/sharing/ProvideSharedPlugin.js +111 -20
- package/lib/sharing/SharePlugin.js +102 -9
- package/lib/sharing/ShareRuntimeModule.js +6 -6
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/{util → sharing}/semver.js +19 -19
- package/lib/sharing/utils.js +59 -2
- package/lib/stats/DefaultStatsFactoryPlugin.js +25 -23
- package/lib/stats/DefaultStatsPresetPlugin.js +1 -1
- package/lib/stats/DefaultStatsPrinterPlugin.js +3 -3
- package/lib/{MultiStats.js → stats/MultiStats.js} +4 -4
- package/lib/{Stats.js → stats/Stats.js} +4 -4
- package/lib/stats/StatsFactory.js +14 -13
- package/lib/{ChunkTemplate.js → template/ChunkTemplate.js} +7 -7
- package/lib/{ConditionalInitFragment.js → template/ConditionalInitFragment.js} +3 -3
- package/lib/template/DependencyTemplate.js +77 -0
- package/lib/{DependencyTemplates.js → template/DependencyTemplates.js} +9 -4
- package/lib/template/InitFragment.js +223 -0
- package/lib/{MainTemplate.js → template/MainTemplate.js} +11 -11
- package/lib/{ModuleInfoHeaderPlugin.js → template/ModuleInfoHeaderPlugin.js} +30 -8
- package/lib/{ModuleTemplate.js → template/ModuleTemplate.js} +6 -6
- package/lib/{RuntimeTemplate.js → template/RuntimeTemplate.js} +178 -106
- package/lib/{Template.js → template/Template.js} +13 -11
- package/lib/{TemplatedPathPlugin.js → template/TemplatedPathPlugin.js} +35 -82
- package/lib/typescript/TypeScriptPlugin.js +5 -6
- package/lib/util/LocConverter.js +4 -7
- package/lib/util/RequestShortener.js +44 -0
- package/lib/util/SortableSet.js +87 -22
- package/lib/util/SourceProcessor.js +364 -66
- package/lib/util/TupleSet.js +27 -27
- package/lib/util/WeakTupleMap.js +10 -12
- package/lib/util/buildDiagnostics.js +2 -2
- package/lib/util/comparators.js +10 -10
- package/lib/util/concatenate.js +32 -151
- package/lib/util/createHooksRegistry.js +1 -2
- package/lib/util/createMappings.js +111 -0
- package/lib/util/dataURL.js +96 -18
- package/lib/util/deprecation.js +1 -1
- package/lib/util/extractComments.js +118 -0
- package/lib/util/formatLocation.js +1 -1
- package/lib/util/globUtils.js +197 -16
- package/lib/util/haltVisitors.js +51 -0
- package/lib/util/handlerKeys.js +2 -2
- package/lib/util/hash/wasm-hash.js +3 -4
- package/lib/util/identifier.js +117 -1
- package/lib/util/implicitTypeLoaderFallback.js +6 -4
- package/lib/util/internalSerializables.js +295 -103
- package/lib/util/magicComment.js +12 -7
- package/lib/util/makeSerializable.js +23 -4
- package/lib/util/parseJson.js +1 -1
- package/lib/util/preloadModuleType.js +5 -2
- package/lib/util/registerExternalSerializer.js +2 -2
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +1 -1
- package/lib/util/serialization.js +4 -1
- package/lib/util/source.js +2 -2
- package/lib/util/terminalColors.js +161 -0
- package/lib/{wasm-async → wasm}/AsyncWasmCompileRuntimeModule.js +5 -5
- package/lib/{wasm-async → wasm}/AsyncWasmLoadingRuntimeModule.js +5 -5
- package/lib/{wasm-async → wasm}/AsyncWasmModule.js +9 -5
- package/lib/{wasm-async → wasm}/AsyncWebAssemblyGenerator.js +11 -6
- package/lib/{wasm-async → wasm}/AsyncWebAssemblyJavascriptGenerator.js +16 -11
- package/lib/{wasm-async → wasm}/AsyncWebAssemblyModulesPlugin.js +26 -10
- package/lib/{wasm-async → wasm}/AsyncWebAssemblyParser.js +8 -8
- package/lib/wasm/EnableWasmLoadingPlugin.js +1 -1
- package/lib/{wasm-async → wasm}/UniversalCompileAsyncWasmPlugin.js +9 -7
- package/lib/wasm/wasmModuleFilename.js +2 -2
- package/lib/wasm-sync/SyncWasmModule.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +11 -12
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +3 -3
- package/lib/wasm-sync/WebAssemblyGenerator.js +15 -9
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +19 -16
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +9 -7
- package/lib/wasm-sync/WebAssemblyParser.js +6 -6
- package/lib/wasm-sync/WebAssemblyUtils.js +8 -9
- package/lib/{MultiWatching.js → watch/MultiWatching.js} +3 -3
- package/lib/{WatchIgnorePlugin.js → watch/WatchIgnorePlugin.js} +43 -9
- package/lib/{Watching.js → watch/Watching.js} +8 -8
- package/lib/web/FetchCompileAsyncWasmPlugin.js +8 -6
- package/lib/web/FetchCompileWasmPlugin.js +6 -4
- package/lib/web/JsonpChunkLoadingPlugin.js +3 -3
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +6 -6
- package/lib/web/JsonpTemplatePlugin.js +1 -1
- package/lib/webpack.js +27 -17
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -3
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -6
- package/package.json +70 -40
- package/schemas/WebpackOptions.check.js +2 -1
- package/schemas/WebpackOptions.d.json.ts +2 -0
- package/schemas/WebpackOptions.json +294 -74
- package/schemas/plugins/BannerPlugin.check.js +2 -1
- package/schemas/plugins/BannerPlugin.json +29 -2
- package/schemas/plugins/HtmlGeneratorOptions.check.js +1 -0
- package/schemas/plugins/HtmlParserOptions.check.js +2 -1
- package/schemas/plugins/IgnorePlugin.check.js +1 -0
- package/schemas/plugins/IgnorePlugin.d.json.ts +2 -0
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -0
- package/schemas/plugins/ManifestPlugin.check.js +1 -0
- package/schemas/plugins/ManifestPlugin.json +3 -3
- package/schemas/plugins/ProgressPlugin.check.js +2 -1
- package/schemas/plugins/ProgressPlugin.json +2 -7
- package/schemas/plugins/SSRManifestPlugin.check.js +7 -0
- package/schemas/plugins/SSRManifestPlugin.json +20 -0
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +2 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +44 -12
- package/schemas/plugins/WatchIgnorePlugin.check.js +2 -1
- package/schemas/plugins/WatchIgnorePlugin.json +12 -3
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -0
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -0
- package/schemas/plugins/asset/AssetParserOptions.check.js +1 -0
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -0
- package/schemas/plugins/container/ContainerPlugin.check.js +2 -1
- package/schemas/plugins/container/ContainerPlugin.json +8 -0
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -0
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +2 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +40 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -0
- package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -0
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -0
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -0
- package/schemas/plugins/css/CssParserOptions.check.js +1 -0
- package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -0
- package/schemas/plugins/dll/DllPlugin.check.js +1 -0
- package/schemas/plugins/dll/DllReferencePlugin.check.js +2 -1
- package/schemas/plugins/dll/DllReferencePlugin.json +3 -18
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -0
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +1 -0
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +1 -0
- package/schemas/plugins/json/JsonModulesPluginGenerator.check.js +1 -0
- package/schemas/plugins/json/JsonModulesPluginParser.check.js +1 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -0
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -0
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +1 -0
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -0
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +1 -0
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +2 -1
- package/schemas/plugins/sharing/ConsumeSharedPlugin.json +32 -0
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +2 -1
- package/schemas/plugins/sharing/ProvideSharedPlugin.json +32 -0
- package/schemas/plugins/sharing/SharePlugin.check.js +2 -1
- package/schemas/plugins/sharing/SharePlugin.json +32 -0
- package/types.d.ts +13915 -8414
- package/lib/ErrorHelpers.js +0 -107
- package/lib/LazyBarrel.js +0 -388
- package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -39
- package/lib/dependencies/HarmonyModulesPlugin.js +0 -192
- package/lib/javascript/ChunkFormatHelpers.js +0 -71
- package/lib/javascript/grammar.js +0 -5546
- package/lib/javascript/parser.js +0 -1494
- package/lib/javascript/regexpData.js +0 -51
- package/lib/performance/getSourceModules.js +0 -22
- package/lib/util/Semaphore.js +0 -65
- package/lib/util/objectToMap.js +0 -15
- package/schemas/WebpackOptions.check.d.ts +0 -7
- package/schemas/_container.json +0 -155
- package/schemas/_sharing.json +0 -118
- package/schemas/plugins/BannerPlugin.check.d.ts +0 -7
- package/schemas/plugins/HtmlGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/HtmlParserOptions.check.d.ts +0 -7
- package/schemas/plugins/IgnorePlugin.check.d.ts +0 -7
- package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +0 -7
- package/schemas/plugins/ManifestPlugin.check.d.ts +0 -7
- package/schemas/plugins/ProgressPlugin.check.d.ts +0 -7
- package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +0 -7
- package/schemas/plugins/WatchIgnorePlugin.check.d.ts +0 -7
- package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/asset/AssetParserOptions.check.d.ts +0 -7
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/container/ContainerPlugin.check.d.ts +0 -7
- package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +0 -7
- package/schemas/plugins/container/ExternalsType.check.d.ts +0 -7
- package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +0 -7
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssParserOptions.check.d.ts +0 -7
- package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +0 -7
- package/schemas/plugins/dll/DllPlugin.check.d.ts +0 -7
- package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +0 -7
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +0 -7
- package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +0 -7
- package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +0 -7
- package/schemas/plugins/json/JsonModulesPluginGenerator.check.d.ts +0 -7
- package/schemas/plugins/json/JsonModulesPluginParser.check.d.ts +0 -7
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +0 -7
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +0 -7
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +0 -7
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +0 -7
- package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +0 -7
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +0 -7
- package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +0 -7
- package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +0 -7
- package/schemas/plugins/sharing/SharePlugin.check.d.ts +0 -7
- /package/lib/{validateSchema.js → config/validateSchema.js} +0 -0
- /package/lib/{util → css}/conventions.js +0 -0
- /package/lib/{util → css}/topologicalSort.js +0 -0
- /package/lib/dependencies/{getFunctionExpression.js → helpers/getFunctionExpression.js} +0 -0
- /package/lib/{util → externals}/extractUrlAndGlobal.js +0 -0
- /package/lib/{util → fs}/StackedCacheMap.js +0 -0
- /package/lib/{util → javascript}/StackedMap.js +0 -0
- /package/lib/{ModuleProfile.js → module/ModuleProfile.js} +0 -0
- /package/lib/{ModuleSourceTypeConstants.js → module/ModuleSourceTypeConstants.js} +0 -0
- /package/lib/{ModuleTypeConstants.js → module/ModuleTypeConstants.js} +0 -0
- /package/lib/{OptimizationStages.js → optimize/OptimizationStages.js} +0 -0
- /package/lib/{util → optimize}/Queue.js +0 -0
- /package/lib/{util → stats}/smartGrouping.js +0 -0
package/lib/css/CssParser.js
CHANGED
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const path = require("path");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const CssUrlDependency = require("../dependencies/CssUrlDependency");
|
|
17
|
-
const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
|
|
9
|
+
const ConstDependency = require("../dependencies/core/ConstDependency");
|
|
10
|
+
const StaticExportsDependency = require("../dependencies/core/StaticExportsDependency");
|
|
11
|
+
const CssIcssExportDependency = require("../dependencies/css/CssIcssExportDependency");
|
|
12
|
+
const CssIcssImportDependency = require("../dependencies/css/CssIcssImportDependency");
|
|
13
|
+
const CssIcssSymbolDependency = require("../dependencies/css/CssIcssSymbolDependency");
|
|
14
|
+
const CssImportDependency = require("../dependencies/css/CssImportDependency");
|
|
15
|
+
const CssUrlDependency = require("../dependencies/css/CssUrlDependency");
|
|
18
16
|
const WebpackError = require("../errors/WebpackError");
|
|
17
|
+
const { CSS_MODULE_TYPE_AUTO } = require("../module/ModuleTypeConstants");
|
|
18
|
+
const Parser = require("../module/Parser");
|
|
19
19
|
const ResourceHintPlugin = require("../prefetch/ResourceHintPlugin");
|
|
20
20
|
const LocConverter = require("../util/LocConverter");
|
|
21
21
|
const { parseResource } = require("../util/identifier");
|
|
@@ -24,23 +24,30 @@ const {
|
|
|
24
24
|
parseCommentOptionsInRange
|
|
25
25
|
} = require("../util/magicComment");
|
|
26
26
|
const memoize = require("../util/memoize");
|
|
27
|
-
const
|
|
28
|
-
|
|
27
|
+
const {
|
|
28
|
+
CSS_MODULES_KEYWORD_OPTIONS,
|
|
29
|
+
getCssModulesKeywords
|
|
30
|
+
} = require("./data");
|
|
31
|
+
const { SourceProcessor } = require("./syntax");
|
|
29
32
|
const {
|
|
30
33
|
A,
|
|
34
|
+
Field,
|
|
35
|
+
Flag,
|
|
31
36
|
NodeType,
|
|
32
|
-
|
|
37
|
+
Part,
|
|
38
|
+
asciiCaseInsensitiveMatch,
|
|
33
39
|
buildSkipSet,
|
|
34
|
-
|
|
40
|
+
isAsciiWhitespace,
|
|
35
41
|
isDashedIdentifier,
|
|
36
|
-
|
|
42
|
+
isSimpleIdentifier,
|
|
37
43
|
normalizeUrl,
|
|
44
|
+
rangeAsciiCaseInsensitiveMatch,
|
|
38
45
|
rangeEquals,
|
|
39
|
-
rangeEqualsLowerCase,
|
|
40
46
|
skipEscape,
|
|
41
47
|
toLowerCaseIfNeeded,
|
|
42
48
|
unescapeIdentifier
|
|
43
|
-
} = require("./syntax");
|
|
49
|
+
} = require("./syntax-parser");
|
|
50
|
+
const topologicalSort = require("./topologicalSort");
|
|
44
51
|
|
|
45
52
|
const getUnsupportedFeatureWarning = memoize(() =>
|
|
46
53
|
require("../errors/UnsupportedFeatureWarning")
|
|
@@ -56,7 +63,7 @@ const getCommentCompilationWarning = memoize(() =>
|
|
|
56
63
|
|
|
57
64
|
// `SourceProcessor` drives the parse and hands already-built AST nodes to the visitors; positions are read from those nodes' ranges rather than re-scanning the source.
|
|
58
65
|
|
|
59
|
-
/** @import { BuildInfo, BuildMeta } from "../Module" */
|
|
66
|
+
/** @import { BuildInfo, BuildMeta } from "../module/Module" */
|
|
60
67
|
/**
|
|
61
68
|
* @import CssModule, {
|
|
62
69
|
* CssModuleBuildInfo,
|
|
@@ -64,7 +71,7 @@ const getCommentCompilationWarning = memoize(() =>
|
|
|
64
71
|
* Inheritance
|
|
65
72
|
* } from "./CssModule"
|
|
66
73
|
*/
|
|
67
|
-
/** @import { ParserState, PreparsedAst } from "../Parser" */
|
|
74
|
+
/** @import { ParserState, PreparsedAst } from "../module/Parser" */
|
|
68
75
|
/**
|
|
69
76
|
* @import {
|
|
70
77
|
* AtRule,
|
|
@@ -77,13 +84,14 @@ const getCommentCompilationWarning = memoize(() =>
|
|
|
77
84
|
* Token,
|
|
78
85
|
* UrlToken,
|
|
79
86
|
* VisitorMap
|
|
80
|
-
* } from "./syntax"
|
|
87
|
+
* } from "./syntax-parser"
|
|
81
88
|
*/
|
|
82
89
|
/**
|
|
83
90
|
* @import {
|
|
84
91
|
* CssAutoOrModuleParserOptions
|
|
85
92
|
* } from "../../declarations/WebpackOptions"
|
|
86
93
|
*/
|
|
94
|
+
/** @import { MagicCommentOptions } from "../util/magicComment" */
|
|
87
95
|
|
|
88
96
|
/** @typedef {[number, number]} Range */
|
|
89
97
|
/** @typedef {{ line: number, column: number }} Position */
|
|
@@ -96,8 +104,14 @@ const getCommentCompilationWarning = memoize(() =>
|
|
|
96
104
|
* out — no `<media-in-parens>` is unconditionally true on every engine).
|
|
97
105
|
* @typedef {{ kind: "condition" | "type", text: string } | { kind: "boolean", value: boolean } | { kind: "unsupported" }} CustomMediaValue
|
|
98
106
|
*/
|
|
99
|
-
/** @typedef {
|
|
100
|
-
/** @typedef {{ name: string
|
|
107
|
+
/** @typedef {{ node: MediaNode, uses: CustomMediaUse[] }} CustomMediaQuery */
|
|
108
|
+
/** @typedef {CustomMediaValue | { kind: "alias", name: string } | { kind: "or", parts: ({ text: string } | { alias: string } | { query: CustomMediaQuery })[] } | ({ kind: "query" } & CustomMediaQuery)} CustomMediaDefinition */
|
|
109
|
+
/**
|
|
110
|
+
* One `(--name)` a `@media` prelude or a `@custom-media` value asks for. `slot`
|
|
111
|
+
* is what the condition written there joins: nothing, an `and`, or `not` / `or`.
|
|
112
|
+
* @typedef {{ name: string, start: number, end: number, invalid: boolean, leading: boolean, slot: MediaSlot }} CustomMediaUse
|
|
113
|
+
*/
|
|
114
|
+
/** @typedef {"alone" | "and" | "or"} MediaSlot */
|
|
101
115
|
/**
|
|
102
116
|
* A `@media` prelude captured as its boolean shape, so a `true` / `false`
|
|
103
117
|
* definition found later can be folded into it. Node ids are recycled per
|
|
@@ -125,6 +139,75 @@ const CC_LEFT_CURLY = "{".charCodeAt(0);
|
|
|
125
139
|
const CC_LOWER_V = "v".charCodeAt(0);
|
|
126
140
|
const CC_UPPER_V = "V".charCodeAt(0);
|
|
127
141
|
const CC_REVERSE_SOLIDUS = "\\".charCodeAt(0);
|
|
142
|
+
const CC_LEFT_PARENTHESIS = "(".charCodeAt(0);
|
|
143
|
+
const CC_RIGHT_PARENTHESIS = ")".charCodeAt(0);
|
|
144
|
+
const CC_QUOTATION_MARK = '"'.charCodeAt(0);
|
|
145
|
+
const CC_APOSTROPHE = "'".charCodeAt(0);
|
|
146
|
+
|
|
147
|
+
// A media condition's top-level keyword: an ASCII word outside every `(…)`.
|
|
148
|
+
const MEDIA_WORD_RE = /[a-z]+/gi;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* A media condition as it can stand in a slot: in parentheses of its own where
|
|
152
|
+
* the slot joins it to others by an operator it does not share, else as written.
|
|
153
|
+
* @param {string} text the condition
|
|
154
|
+
* @param {MediaSlot} slot what the slot joins it to
|
|
155
|
+
* @returns {string} the condition to write there
|
|
156
|
+
*/
|
|
157
|
+
const mediaConditionFor = (text, slot) => {
|
|
158
|
+
if (slot === "alone") return text;
|
|
159
|
+
let depth = 0;
|
|
160
|
+
let outside = "";
|
|
161
|
+
let groups = 0;
|
|
162
|
+
for (let i = 0; i < text.length; i++) {
|
|
163
|
+
const code = text.charCodeAt(i);
|
|
164
|
+
if (code === CC_LEFT_PARENTHESIS) {
|
|
165
|
+
if (depth++ === 0) groups++;
|
|
166
|
+
} else if (code === CC_RIGHT_PARENTHESIS) {
|
|
167
|
+
depth--;
|
|
168
|
+
} else if (depth === 0) {
|
|
169
|
+
outside += text[i];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const words = (outside.match(MEDIA_WORD_RE) || []).map((word) =>
|
|
173
|
+
word.toLowerCase()
|
|
174
|
+
);
|
|
175
|
+
if (groups === 1 && words.length === 0) return text;
|
|
176
|
+
// An `and` chain takes more `and` terms as they are, and nothing else.
|
|
177
|
+
if (slot === "and" && words.every((word) => word === "and")) return text;
|
|
178
|
+
return `(${text})`;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Each `:--name` a selector list asks for, outside strings and escapes and not
|
|
183
|
+
* after a second `:`, as the offsets of the colon and the name's end.
|
|
184
|
+
* @param {string} list the selector list
|
|
185
|
+
* @returns {{ name: string, start: number, end: number }[]} the names, in order
|
|
186
|
+
*/
|
|
187
|
+
const customSelectorNames = (list) => {
|
|
188
|
+
/** @type {{ name: string, start: number, end: number }[]} */
|
|
189
|
+
const found = [];
|
|
190
|
+
for (let i = 0; i < list.length; i++) {
|
|
191
|
+
const code = list.charCodeAt(i);
|
|
192
|
+
if (code === CC_REVERSE_SOLIDUS) {
|
|
193
|
+
i++;
|
|
194
|
+
} else if (code === CC_QUOTATION_MARK || code === CC_APOSTROPHE) {
|
|
195
|
+
for (i++; i < list.length && list.charCodeAt(i) !== code; i++) {
|
|
196
|
+
if (list.charCodeAt(i) === CC_REVERSE_SOLIDUS) i++;
|
|
197
|
+
}
|
|
198
|
+
} else if (
|
|
199
|
+
code === CC_COLON &&
|
|
200
|
+
(i === 0 || list.charCodeAt(i - 1) !== CC_COLON) &&
|
|
201
|
+
list.startsWith("--", i + 1)
|
|
202
|
+
) {
|
|
203
|
+
let end = i + 3;
|
|
204
|
+
while (end < list.length && /[\w\u0080-\uFFFF-]/.test(list[end])) end++;
|
|
205
|
+
found.push({ name: list.slice(i + 1, end), start: i, end });
|
|
206
|
+
i = end - 1;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return found;
|
|
210
|
+
};
|
|
128
211
|
|
|
129
212
|
// A parsed CSS comment. `loc` is computed on demand — only magic-comment error
|
|
130
213
|
// warnings read it, so comment-heavy CSS skips the per-comment line/col work.
|
|
@@ -164,13 +247,14 @@ const fontMimeType = (request) => {
|
|
|
164
247
|
return getMimeTypes().lookup(resourcePath);
|
|
165
248
|
};
|
|
166
249
|
|
|
167
|
-
//
|
|
168
|
-
// walked without modules
|
|
169
|
-
// `Ident` visitor no-ops, the `Declaration` visitor returns early,
|
|
170
|
-
// `url
|
|
171
|
-
// rewrites and image-set fences
|
|
172
|
-
// are read
|
|
173
|
-
// `:export { k: v }` captures each value's byte range from
|
|
250
|
+
// WHY: skip options for a non-CSS-Modules parse. The selector prelude is never
|
|
251
|
+
// walked without modules, and the value and function-arg leaves reach nothing —
|
|
252
|
+
// the `Ident` visitor no-ops, the `Declaration` visitor returns early, and there
|
|
253
|
+
// is no ICSS. `url`, functions, strings, blocks and commas are kept, carrying
|
|
254
|
+
// the `url()` rewrites and image-set fences, and at-rule preludes too, since
|
|
255
|
+
// `@media` and `@import` are read. A CSS-Modules parse skips nothing: selectors
|
|
256
|
+
// are walked, and ICSS `:export { k: v }` captures each value's byte range from
|
|
257
|
+
// its first and last node.
|
|
174
258
|
const SKIP_NON_MODULES = {
|
|
175
259
|
types: buildSkipSet([
|
|
176
260
|
NodeType.Number,
|
|
@@ -207,10 +291,6 @@ const VALUE_AS_ALIAS = /\s+as\s+/;
|
|
|
207
291
|
// `@value name value`: end of the name run (first non-space followed by space).
|
|
208
292
|
const VALUE_NAME_BOUNDARY = /\S\s/;
|
|
209
293
|
const ONLY_WHITESPACE = /^\s+$/;
|
|
210
|
-
// A `@value` whose whole value is one `.class` / `#id`, the only shape whose
|
|
211
|
-
// localizable ident is knowable without re-parsing the substitution.
|
|
212
|
-
const SIMPLE_CLASS_OR_ID_VALUE =
|
|
213
|
-
/^([.#])(-?(?:[A-Za-z_]|[\u0080-\uFFFF])(?:[\w-]|[\u0080-\uFFFF])*)$/;
|
|
214
294
|
// Relative request prefix (`./` or `../`) — `isSelfReferenceRequest` per `from`.
|
|
215
295
|
const RELATIVE_REQUEST = /^\.{1,2}\//;
|
|
216
296
|
|
|
@@ -271,10 +351,14 @@ const knownPropertyForRange = (index, input, start, end) => {
|
|
|
271
351
|
const hit = index.get(h);
|
|
272
352
|
if (hit === undefined) return undefined;
|
|
273
353
|
if (typeof hit === "string") {
|
|
274
|
-
return
|
|
354
|
+
return rangeAsciiCaseInsensitiveMatch(input, start, end, hit)
|
|
355
|
+
? hit
|
|
356
|
+
: undefined;
|
|
275
357
|
}
|
|
276
358
|
for (let i = 0; i < hit.length; i++) {
|
|
277
|
-
if (
|
|
359
|
+
if (rangeAsciiCaseInsensitiveMatch(input, start, end, hit[i])) {
|
|
360
|
+
return hit[i];
|
|
361
|
+
}
|
|
278
362
|
}
|
|
279
363
|
return undefined;
|
|
280
364
|
};
|
|
@@ -291,14 +375,14 @@ const counterFunctionNameIndex = (input, start, end, escapedName) => {
|
|
|
291
375
|
// The `target-counter(url, name, style?)` cross-reference forms (Generated Content for Paged Media) name the counter second; print engines read them.
|
|
292
376
|
if (escapedName !== undefined) {
|
|
293
377
|
if (
|
|
294
|
-
|
|
295
|
-
|
|
378
|
+
asciiCaseInsensitiveMatch(escapedName, "counter") ||
|
|
379
|
+
asciiCaseInsensitiveMatch(escapedName, "counters")
|
|
296
380
|
) {
|
|
297
381
|
return 0;
|
|
298
382
|
}
|
|
299
383
|
if (
|
|
300
|
-
|
|
301
|
-
|
|
384
|
+
asciiCaseInsensitiveMatch(escapedName, "target-counter") ||
|
|
385
|
+
asciiCaseInsensitiveMatch(escapedName, "target-counters")
|
|
302
386
|
) {
|
|
303
387
|
return 1;
|
|
304
388
|
}
|
|
@@ -306,13 +390,24 @@ const counterFunctionNameIndex = (input, start, end, escapedName) => {
|
|
|
306
390
|
}
|
|
307
391
|
switch (end - start) {
|
|
308
392
|
case 7:
|
|
309
|
-
return
|
|
393
|
+
return rangeAsciiCaseInsensitiveMatch(input, start, end, "counter")
|
|
394
|
+
? 0
|
|
395
|
+
: -1;
|
|
310
396
|
case 8:
|
|
311
|
-
return
|
|
397
|
+
return rangeAsciiCaseInsensitiveMatch(input, start, end, "counters")
|
|
398
|
+
? 0
|
|
399
|
+
: -1;
|
|
312
400
|
case 14:
|
|
313
|
-
return
|
|
401
|
+
return rangeAsciiCaseInsensitiveMatch(input, start, end, "target-counter")
|
|
402
|
+
? 1
|
|
403
|
+
: -1;
|
|
314
404
|
case 15:
|
|
315
|
-
return
|
|
405
|
+
return rangeAsciiCaseInsensitiveMatch(
|
|
406
|
+
input,
|
|
407
|
+
start,
|
|
408
|
+
end,
|
|
409
|
+
"target-counters"
|
|
410
|
+
)
|
|
316
411
|
? 1
|
|
317
412
|
: -1;
|
|
318
413
|
default:
|
|
@@ -340,7 +435,7 @@ const buildKnownProperties = (options = {}) => {
|
|
|
340
435
|
knownProperties.set(
|
|
341
436
|
property,
|
|
342
437
|
/** @type {Map<string, number>} */
|
|
343
|
-
(
|
|
438
|
+
(getCssModulesKeywords().get(property))
|
|
344
439
|
);
|
|
345
440
|
}
|
|
346
441
|
}
|
|
@@ -471,13 +566,13 @@ const gridAreaNames = (input, start, end) => {
|
|
|
471
566
|
const names = [];
|
|
472
567
|
let i = start;
|
|
473
568
|
while (i < end) {
|
|
474
|
-
while (i < end &&
|
|
569
|
+
while (i < end && isAsciiWhitespace(input.charCodeAt(i))) i++;
|
|
475
570
|
if (i >= end) break;
|
|
476
571
|
const nameStart = i;
|
|
477
572
|
let nullCell = true;
|
|
478
573
|
while (i < end) {
|
|
479
574
|
const cc = input.charCodeAt(i);
|
|
480
|
-
if (
|
|
575
|
+
if (isAsciiWhitespace(cc)) break;
|
|
481
576
|
if (cc === CC_REVERSE_SOLIDUS) {
|
|
482
577
|
i = Math.min(skipEscape(input, i), end);
|
|
483
578
|
nullCell = false;
|
|
@@ -523,32 +618,42 @@ const isPureBodyAtRule = (name) =>
|
|
|
523
618
|
name === "@container" ||
|
|
524
619
|
name === "@scope";
|
|
525
620
|
|
|
621
|
+
/**
|
|
622
|
+
* A rule's or function's name as written, escapes kept.
|
|
623
|
+
* @param {AstNode} n at-rule, declaration or function
|
|
624
|
+
* @returns {string} the raw name
|
|
625
|
+
*/
|
|
626
|
+
const rawNameOf = (n) =>
|
|
627
|
+
A.source(A.startOf(Part.name, n), A.endOf(Part.name, n));
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* @param {AstNode} n an ident, string or hash
|
|
631
|
+
* @returns {string} its value, escapes resolved
|
|
632
|
+
*/
|
|
633
|
+
const stringValue = (n) => /** @type {string} */ (A.value(n));
|
|
634
|
+
|
|
526
635
|
/**
|
|
527
636
|
* Scan a rule body once: does it hold a direct declaration counted against the enclosing rule (a declaration, or one in a transparent conditional-group at-rule like `@media`/`@supports`/…) and does it hold a nested block (qualified rule or any block-bearing at-rule)?
|
|
528
|
-
* @param {
|
|
529
|
-
* @param {Rule[] | null} childRules rule-body child rules
|
|
637
|
+
* @param {AstNode} rule rule with a block
|
|
530
638
|
* @returns {{ hasDirectDecl: boolean, hasNestedBlock: boolean }} scan result
|
|
531
639
|
*/
|
|
532
|
-
const scanRuleBody = (
|
|
533
|
-
let hasDirectDecl =
|
|
640
|
+
const scanRuleBody = (rule) => {
|
|
641
|
+
let hasDirectDecl = A.fieldCount(Field.declarations, rule) > 0;
|
|
534
642
|
let hasNestedBlock = false;
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
) {
|
|
550
|
-
hasDirectDecl = true;
|
|
551
|
-
}
|
|
643
|
+
for (let i = 0, count = A.fieldCount(Field.rules, rule); i < count; i++) {
|
|
644
|
+
const child = A.field(i, Field.rules, rule);
|
|
645
|
+
const t = A.type(child);
|
|
646
|
+
if (t === NodeType.QualifiedRule) {
|
|
647
|
+
hasNestedBlock = true;
|
|
648
|
+
} else if (t === NodeType.AtRule) {
|
|
649
|
+
if (A.startOf(Part.block, child) === -1) continue;
|
|
650
|
+
hasNestedBlock = true;
|
|
651
|
+
if (
|
|
652
|
+
!hasDirectDecl &&
|
|
653
|
+
!isPureBodyAtRule(`@${toLowerCaseIfNeeded(rawNameOf(child))}`) &&
|
|
654
|
+
scanRuleBody(child).hasDirectDecl
|
|
655
|
+
) {
|
|
656
|
+
hasDirectDecl = true;
|
|
552
657
|
}
|
|
553
658
|
}
|
|
554
659
|
}
|
|
@@ -563,12 +668,14 @@ const scanRuleBody = (declarations, childRules) => {
|
|
|
563
668
|
const parseValueAtRuleParams = (str) => {
|
|
564
669
|
if (VALUE_IMPORT_FORM.test(str)) {
|
|
565
670
|
str = str.replace(CSS_COMMENT, " ").trim().replace(/;$/, "");
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
671
|
+
// Split on the first `from` keyword delimited by CSS whitespace (only
|
|
672
|
+
// ` \t\n\f\r`, not JS `\s`, which also matches U+00A0 valid in a name),
|
|
673
|
+
// so a path or name containing the substring (`./from-colors.css`) isn't it.
|
|
674
|
+
const fromMatch = /^([\s\S]+?)[ \t\n\f\r]+from[ \t\n\f\r]+([\s\S]+)$/i.exec(
|
|
675
|
+
str
|
|
676
|
+
);
|
|
677
|
+
const path = (fromMatch ? fromMatch[2] : "").trim().replace(/['"]/g, "");
|
|
678
|
+
let content = (fromMatch ? fromMatch[1] : str).trim();
|
|
572
679
|
|
|
573
680
|
if (content.startsWith("(") && content.endsWith(")")) {
|
|
574
681
|
content = content.slice(1, -1);
|
|
@@ -665,7 +772,7 @@ const parseImportPrelude = (prelude) => {
|
|
|
665
772
|
}
|
|
666
773
|
if (
|
|
667
774
|
t === NodeType.Function &&
|
|
668
|
-
|
|
775
|
+
asciiCaseInsensitiveMatch(A.name(cv), "url")
|
|
669
776
|
) {
|
|
670
777
|
urlNode = cv;
|
|
671
778
|
continue;
|
|
@@ -680,13 +787,13 @@ const parseImportPrelude = (prelude) => {
|
|
|
680
787
|
|
|
681
788
|
if (!layerNode && !supportsNode) {
|
|
682
789
|
if (t === NodeType.Ident) {
|
|
683
|
-
if (
|
|
790
|
+
if (asciiCaseInsensitiveMatch(stringValue(cv), "layer")) {
|
|
684
791
|
layerNode = cv;
|
|
685
792
|
continue;
|
|
686
793
|
}
|
|
687
794
|
} else if (
|
|
688
795
|
t === NodeType.Function &&
|
|
689
|
-
|
|
796
|
+
asciiCaseInsensitiveMatch(A.name(cv), "layer")
|
|
690
797
|
) {
|
|
691
798
|
layerNode = cv;
|
|
692
799
|
continue;
|
|
@@ -696,7 +803,7 @@ const parseImportPrelude = (prelude) => {
|
|
|
696
803
|
if (
|
|
697
804
|
!supportsNode &&
|
|
698
805
|
t === NodeType.Function &&
|
|
699
|
-
|
|
806
|
+
asciiCaseInsensitiveMatch(A.name(cv), "supports")
|
|
700
807
|
) {
|
|
701
808
|
supportsNode = /** @type {FunctionNode} */ (cv);
|
|
702
809
|
continue;
|
|
@@ -722,8 +829,8 @@ const parseIcssImportRequest = (second, rule, source) => {
|
|
|
722
829
|
if (A.type(second) === NodeType.Function) {
|
|
723
830
|
args = A.children(second);
|
|
724
831
|
} else {
|
|
725
|
-
for (const p of A.
|
|
726
|
-
if (A.type(p) === NodeType.SimpleBlock && A.
|
|
832
|
+
for (const p of A.children(rule)) {
|
|
833
|
+
if (A.type(p) === NodeType.SimpleBlock && A.value(p) === "(") {
|
|
727
834
|
args = A.children(p);
|
|
728
835
|
break;
|
|
729
836
|
}
|
|
@@ -735,7 +842,7 @@ const parseIcssImportRequest = (second, rule, source) => {
|
|
|
735
842
|
if (!innerStrToken || A.type(innerStrToken) !== NodeType.String) {
|
|
736
843
|
const errorPos =
|
|
737
844
|
A.type(second) === NodeType.Function
|
|
738
|
-
? A.
|
|
845
|
+
? A.endOf(Part.name, second) + 1
|
|
739
846
|
: A.end(second);
|
|
740
847
|
return { errorPos };
|
|
741
848
|
}
|
|
@@ -829,7 +936,7 @@ class CssParser extends Parser {
|
|
|
829
936
|
* themselves. Same-kind redeclarations are silent.
|
|
830
937
|
* @param {ParserState} state parser state
|
|
831
938
|
* @param {Map<string, { kind: string, line: number, column: number, entries: number[] }[]>} declaredExports collected declarations grouped by (name, kind)
|
|
832
|
-
* @param {import("../dependencies/CssIcssExportDependency").CssExportEntry[]} cssExportEntries all export entries — losers are demoted in place
|
|
939
|
+
* @param {import("../dependencies/css/CssIcssExportDependency").CssExportEntry[]} cssExportEntries all export entries — losers are demoted in place
|
|
833
940
|
* @returns {void}
|
|
834
941
|
*/
|
|
835
942
|
_resolveAmbiguousExports(state, declaredExports, cssExportEntries) {
|
|
@@ -931,8 +1038,8 @@ class CssParser extends Parser {
|
|
|
931
1038
|
* `CssUrlDependency`. Magic comments win over the project-wide default.
|
|
932
1039
|
* @param {CssUrlDependency} dep dep
|
|
933
1040
|
* @param {string} request asset request
|
|
934
|
-
* @param {
|
|
935
|
-
* @param {import("../Dependency").DependencyLocation} loc location for warnings
|
|
1041
|
+
* @param {MagicCommentOptions | null | undefined} options parsed comment options
|
|
1042
|
+
* @param {import("../graph/Dependency").DependencyLocation} loc location for warnings
|
|
936
1043
|
* @returns {void}
|
|
937
1044
|
*/
|
|
938
1045
|
const applyResourceHintDefaults = (dep, request, options, loc) => {
|
|
@@ -1014,7 +1121,7 @@ class CssParser extends Parser {
|
|
|
1014
1121
|
// All `:export`-style exports are collected into a single
|
|
1015
1122
|
// `CssIcssExportDependency` per module (emitted at parse end) instead of one
|
|
1016
1123
|
// `Dependency` per export — far fewer retained objects on CSS-heavy builds.
|
|
1017
|
-
/** @type {import("../dependencies/CssIcssExportDependency").CssExportEntry[]} */
|
|
1124
|
+
/** @type {import("../dependencies/css/CssIcssExportDependency").CssExportEntry[]} */
|
|
1018
1125
|
const cssExportEntries = [];
|
|
1019
1126
|
/**
|
|
1020
1127
|
* @param {number} sl start line
|
|
@@ -1022,11 +1129,11 @@ class CssParser extends Parser {
|
|
|
1022
1129
|
* @param {number} el end line
|
|
1023
1130
|
* @param {number} ec end column
|
|
1024
1131
|
* @param {string} name export name
|
|
1025
|
-
* @param {import("../dependencies/CssIcssExportDependency").Value} value value or [localName, importName, request?]
|
|
1132
|
+
* @param {import("../dependencies/css/CssIcssExportDependency").Value} value value or [localName, importName, request?]
|
|
1026
1133
|
* @param {Range=} range source range to replace, when present
|
|
1027
1134
|
* @param {boolean=} interpolate whether the value needs interpolation
|
|
1028
|
-
* @param {import("../dependencies/CssIcssExportDependency").ExportMode=} exportMode export mode
|
|
1029
|
-
* @param {import("../dependencies/CssIcssExportDependency").ExportType=} exportType export type
|
|
1135
|
+
* @param {import("../dependencies/css/CssIcssExportDependency").ExportMode=} exportMode export mode
|
|
1136
|
+
* @param {import("../dependencies/css/CssIcssExportDependency").ExportType=} exportType export type
|
|
1030
1137
|
* @returns {void}
|
|
1031
1138
|
*/
|
|
1032
1139
|
const addCssExport = (
|
|
@@ -1164,10 +1271,10 @@ class CssParser extends Parser {
|
|
|
1164
1271
|
* @param {Range} range byte range to scan for magic comments
|
|
1165
1272
|
* @param {number} warnStart start offset of the loc for an invalid-`webpackIgnore` warning (computed lazily)
|
|
1166
1273
|
* @param {number} warnEnd end offset of that loc
|
|
1167
|
-
* @returns {{ ignored: boolean, options:
|
|
1274
|
+
* @returns {{ ignored: boolean, options: MagicCommentOptions | null }} parsed options and `webpackIgnore` flag
|
|
1168
1275
|
*/
|
|
1169
1276
|
const magicCommentsIn = (range, warnStart, warnEnd) => {
|
|
1170
|
-
/** @type {{ options:
|
|
1277
|
+
/** @type {{ options: MagicCommentOptions | null, errors: (Error & { comment: Comment })[] | null }} */
|
|
1171
1278
|
const { options, errors } = parseCommentOptionsInRange(
|
|
1172
1279
|
/** @type {(Comment & { range: [number, number], value: string })[]} */ (
|
|
1173
1280
|
comments
|
|
@@ -1228,13 +1335,15 @@ class CssParser extends Parser {
|
|
|
1228
1335
|
let customMediaQueries;
|
|
1229
1336
|
/** @type {Map<string, string> | undefined} */
|
|
1230
1337
|
let customSelectorDefs;
|
|
1338
|
+
/** @type {Map<string, string | null> | undefined} */
|
|
1339
|
+
let customSelectorValues;
|
|
1231
1340
|
/** @type {{ name: string, start: number, end: number }[] | undefined} */
|
|
1232
1341
|
let customSelectorUses;
|
|
1233
1342
|
|
|
1234
1343
|
/**
|
|
1235
1344
|
* Unescape a CSS identifier from a source byte range — for value spans not
|
|
1236
1345
|
* backed by a single token (string contents, `--` dashed-ident bodies,
|
|
1237
|
-
* composed names). Token-backed names use `
|
|
1346
|
+
* composed names). Token-backed names use `stringValue(node)` instead.
|
|
1238
1347
|
* @param {number} start start offset
|
|
1239
1348
|
* @param {number} end end offset
|
|
1240
1349
|
* @returns {string} the unescaped identifier
|
|
@@ -1325,7 +1434,7 @@ class CssParser extends Parser {
|
|
|
1325
1434
|
},
|
|
1326
1435
|
/**
|
|
1327
1436
|
* Rule entry: report an impure leaf-ish rule (prelude purity is known, body already parsed), push the inherited-context frame, reset per-rule selector flags.
|
|
1328
|
-
* @param {{ isRulePrelude: boolean, treatAsLeaf: boolean, ownSkip: boolean,
|
|
1437
|
+
* @param {{ isRulePrelude: boolean, treatAsLeaf: boolean, ownSkip: boolean, rule: AstNode, preludeStart: number, preludeEnd: number }} opts entry options
|
|
1329
1438
|
*/
|
|
1330
1439
|
enterBlock(opts) {
|
|
1331
1440
|
if (!this.enabled) return;
|
|
@@ -1333,8 +1442,7 @@ class CssParser extends Parser {
|
|
|
1333
1442
|
isRulePrelude,
|
|
1334
1443
|
treatAsLeaf,
|
|
1335
1444
|
ownSkip,
|
|
1336
|
-
|
|
1337
|
-
childRules,
|
|
1445
|
+
rule,
|
|
1338
1446
|
preludeStart,
|
|
1339
1447
|
preludeEnd
|
|
1340
1448
|
} = opts;
|
|
@@ -1347,13 +1455,10 @@ class CssParser extends Parser {
|
|
|
1347
1455
|
isRulePrelude &&
|
|
1348
1456
|
this.ruleImpure;
|
|
1349
1457
|
if (reportable) {
|
|
1350
|
-
const hasBody =
|
|
1458
|
+
const hasBody = A.startOf(Part.block, rule) !== -1;
|
|
1351
1459
|
let leaf = treatAsLeaf || !hasBody;
|
|
1352
1460
|
if (!leaf && hasBody) {
|
|
1353
|
-
const { hasDirectDecl, hasNestedBlock } = scanRuleBody(
|
|
1354
|
-
declarations,
|
|
1355
|
-
childRules
|
|
1356
|
-
);
|
|
1461
|
+
const { hasDirectDecl, hasNestedBlock } = scanRuleBody(rule);
|
|
1357
1462
|
leaf = hasDirectDecl || !hasNestedBlock;
|
|
1358
1463
|
}
|
|
1359
1464
|
if (leaf) this.report(preludeStart, preludeEnd);
|
|
@@ -1425,7 +1530,7 @@ class CssParser extends Parser {
|
|
|
1425
1530
|
|
|
1426
1531
|
/**
|
|
1427
1532
|
* Comment visitor (`NodeType.Comment`): push every comment (in source order) onto the local `comments`, read back by `advanceCommentCursor` (pure-mode flags) and `parseCommentOptionsInRange` (magic comments).
|
|
1428
|
-
* @param {import("./syntax").CssPath} path walk path at the comment node
|
|
1533
|
+
* @param {import("./syntax-parser").CssPath} path walk path at the comment node
|
|
1429
1534
|
*/
|
|
1430
1535
|
const commentVisitor = (path) => {
|
|
1431
1536
|
const node = path.node;
|
|
@@ -1555,22 +1660,26 @@ class CssParser extends Parser {
|
|
|
1555
1660
|
};
|
|
1556
1661
|
|
|
1557
1662
|
// Body `{ name: value; … }` is parsed eagerly (§5.4.4) — emit a dep per declaration.
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
const
|
|
1663
|
+
if (A.startOf(Part.block, rule) === -1) return A.end(second);
|
|
1664
|
+
for (
|
|
1665
|
+
let i = 0, count = A.fieldCount(Field.declarations, rule);
|
|
1666
|
+
i < count;
|
|
1667
|
+
i++
|
|
1668
|
+
) {
|
|
1669
|
+
const decl = A.field(i, Field.declarations, rule);
|
|
1670
|
+
const valueCount = A.childCount(decl);
|
|
1671
|
+
if (valueCount === 0) continue;
|
|
1672
|
+
const rawStart = A.start(A.child(0, decl));
|
|
1673
|
+
const rawEnd = A.end(A.child(valueCount - 1, decl));
|
|
1565
1674
|
createDep(
|
|
1566
|
-
source.slice(A.
|
|
1675
|
+
source.slice(A.startOf(Part.name, decl), A.endOf(Part.name, decl)),
|
|
1567
1676
|
source.slice(rawStart, rawEnd),
|
|
1568
|
-
A.
|
|
1677
|
+
A.endOf(Part.name, decl),
|
|
1569
1678
|
rawEnd
|
|
1570
1679
|
);
|
|
1571
1680
|
}
|
|
1572
1681
|
|
|
1573
|
-
return skipWhiteLine(source, A.
|
|
1682
|
+
return skipWhiteLine(source, A.endOf(Part.block, rule));
|
|
1574
1683
|
};
|
|
1575
1684
|
|
|
1576
1685
|
/**
|
|
@@ -1610,9 +1719,13 @@ class CssParser extends Parser {
|
|
|
1610
1719
|
if (!def || def.importName || typeof def.value !== "string") {
|
|
1611
1720
|
return undefined;
|
|
1612
1721
|
}
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1722
|
+
// Only one `.class` / `#id` has a localizable ident knowable without
|
|
1723
|
+
// re-parsing the substitution.
|
|
1724
|
+
const value = def.value.trim();
|
|
1725
|
+
const prefix = value.charAt(0);
|
|
1726
|
+
return (prefix === "." || prefix === "#") &&
|
|
1727
|
+
isSimpleIdentifier(value.slice(1))
|
|
1728
|
+
? [prefix, value.slice(1)]
|
|
1616
1729
|
: undefined;
|
|
1617
1730
|
};
|
|
1618
1731
|
|
|
@@ -1631,6 +1744,100 @@ class CssParser extends Parser {
|
|
|
1631
1744
|
return isDashedIdentifier(value) ? value.slice(2) : undefined;
|
|
1632
1745
|
};
|
|
1633
1746
|
|
|
1747
|
+
/**
|
|
1748
|
+
* Add the entry for an ident naming an imported `@value`, which `CssIcssExportDependency` scopes and names once the import resolves.
|
|
1749
|
+
* @param {string} identifier `@value` name as written
|
|
1750
|
+
* @param {number} start ident start offset
|
|
1751
|
+
* @param {number} end ident end offset
|
|
1752
|
+
* @param {import("../dependencies/css/CssIcssExportDependency").ExportMode} exportMode one of the `RESOLVED_*` modes
|
|
1753
|
+
* @param {import("../dependencies/css/CssIcssExportDependency").Value=} value the reference, when it carries more than `getReexport` gives
|
|
1754
|
+
*/
|
|
1755
|
+
const addResolvedExport = (
|
|
1756
|
+
identifier,
|
|
1757
|
+
start,
|
|
1758
|
+
end,
|
|
1759
|
+
exportMode,
|
|
1760
|
+
value = getReexport(identifier)
|
|
1761
|
+
) => {
|
|
1762
|
+
const { line: sl, column: sc } = locConverter.get(start);
|
|
1763
|
+
const { line: el, column: ec } = locConverter.get(end);
|
|
1764
|
+
addCssExport(
|
|
1765
|
+
sl,
|
|
1766
|
+
sc,
|
|
1767
|
+
el,
|
|
1768
|
+
ec,
|
|
1769
|
+
identifier,
|
|
1770
|
+
value,
|
|
1771
|
+
[start, end],
|
|
1772
|
+
true,
|
|
1773
|
+
exportMode
|
|
1774
|
+
);
|
|
1775
|
+
};
|
|
1776
|
+
|
|
1777
|
+
/**
|
|
1778
|
+
* Add the export entry for an ident a declaration site (an at-rule prelude, `local()`) localizes. A `@value` is resolved first: a local one exports under the ident it names, an imported one is left for `CssIcssExportDependency` to name once the import resolves.
|
|
1779
|
+
* @param {string} identifier ident as written in the source
|
|
1780
|
+
* @param {number} start ident start offset
|
|
1781
|
+
* @param {number} end ident end offset
|
|
1782
|
+
* @param {string | undefined} kind export kind for conflict tracking, undefined for a usage
|
|
1783
|
+
* @param {import("../dependencies/css/CssIcssExportDependency").ExportType} exportType export type
|
|
1784
|
+
*/
|
|
1785
|
+
const addLocalizedExport = (identifier, start, end, kind, exportType) => {
|
|
1786
|
+
const def =
|
|
1787
|
+
icssDefinitions.size === 0
|
|
1788
|
+
? undefined
|
|
1789
|
+
: icssDefinitions.get(identifier);
|
|
1790
|
+
if (def !== undefined && def.importName) {
|
|
1791
|
+
addResolvedExport(
|
|
1792
|
+
identifier,
|
|
1793
|
+
start,
|
|
1794
|
+
end,
|
|
1795
|
+
CssIcssExportDependency.EXPORT_MODE.RESOLVED_NAME
|
|
1796
|
+
);
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1799
|
+
const { line: sl, column: sc } = locConverter.get(start);
|
|
1800
|
+
const { line: el, column: ec } = locConverter.get(end);
|
|
1801
|
+
let name = identifier;
|
|
1802
|
+
let exportMode = CssIcssExportDependency.EXPORT_MODE.ONCE;
|
|
1803
|
+
if (def !== undefined) {
|
|
1804
|
+
const value = typeof def.value === "string" ? def.value.trim() : "";
|
|
1805
|
+
if (isSimpleIdentifier(value)) {
|
|
1806
|
+
name = value;
|
|
1807
|
+
} else {
|
|
1808
|
+
exportMode = CssIcssExportDependency.EXPORT_MODE.NONE;
|
|
1809
|
+
this._emitWarning(
|
|
1810
|
+
state,
|
|
1811
|
+
CssIcssExportDependency.notSimpleIdentifierMessage(
|
|
1812
|
+
identifier,
|
|
1813
|
+
value
|
|
1814
|
+
),
|
|
1815
|
+
locConverter,
|
|
1816
|
+
start,
|
|
1817
|
+
end
|
|
1818
|
+
);
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
if (
|
|
1822
|
+
kind !== undefined &&
|
|
1823
|
+
exportMode === CssIcssExportDependency.EXPORT_MODE.ONCE
|
|
1824
|
+
) {
|
|
1825
|
+
recordDeclaration(name, kind, sl, sc);
|
|
1826
|
+
}
|
|
1827
|
+
addCssExport(
|
|
1828
|
+
sl,
|
|
1829
|
+
sc,
|
|
1830
|
+
el,
|
|
1831
|
+
ec,
|
|
1832
|
+
name,
|
|
1833
|
+
getReexport(identifier),
|
|
1834
|
+
[start, end],
|
|
1835
|
+
true,
|
|
1836
|
+
exportMode,
|
|
1837
|
+
exportType
|
|
1838
|
+
);
|
|
1839
|
+
};
|
|
1840
|
+
|
|
1634
1841
|
/**
|
|
1635
1842
|
* Process a `local(...)` / `global(...)` pseudo-function: strip the call (and a leading legacy `:`) via a presentational dep, then emit `local()`'s inner top-level idents as ICSS exports.
|
|
1636
1843
|
* @param {FunctionNode} fn parsed local/global function node
|
|
@@ -1641,7 +1848,7 @@ class CssParser extends Parser {
|
|
|
1641
1848
|
// Replace `local(` / `global(` (and a leading `:` for the `:local(`/`:global(` selector form) with empty.
|
|
1642
1849
|
const fnStart = A.start(fn);
|
|
1643
1850
|
const isColon = input.charCodeAt(fnStart - 1) === CC_COLON;
|
|
1644
|
-
const openEnd = A.
|
|
1851
|
+
const openEnd = A.endOf(Part.name, fn) + 1;
|
|
1645
1852
|
module.addPresentationalDependency(
|
|
1646
1853
|
new ConstDependency("", [isColon ? fnStart - 1 : fnStart, openEnd])
|
|
1647
1854
|
);
|
|
@@ -1649,19 +1856,23 @@ class CssParser extends Parser {
|
|
|
1649
1856
|
if (type === 1) {
|
|
1650
1857
|
for (const cv of A.children(fn)) {
|
|
1651
1858
|
if (A.type(cv) !== NodeType.Ident) continue;
|
|
1652
|
-
let identifier =
|
|
1859
|
+
let identifier = stringValue(cv);
|
|
1860
|
+
if (!isDashedIdentifier(identifier)) {
|
|
1861
|
+
addLocalizedExport(
|
|
1862
|
+
identifier,
|
|
1863
|
+
A.start(cv),
|
|
1864
|
+
A.end(cv),
|
|
1865
|
+
declarationKind,
|
|
1866
|
+
CssIcssExportDependency.EXPORT_TYPE.NORMAL
|
|
1867
|
+
);
|
|
1868
|
+
continue;
|
|
1869
|
+
}
|
|
1653
1870
|
// Cursor reads instead of `A.loc` — no location objects allocated.
|
|
1654
1871
|
const { line: sl, column: sc } = locConverter.get(A.start(cv));
|
|
1655
1872
|
const { line: el, column: ec } = locConverter.get(A.end(cv));
|
|
1656
|
-
|
|
1657
|
-
if (isDashedIdent) identifier = identifier.slice(2);
|
|
1873
|
+
identifier = identifier.slice(2);
|
|
1658
1874
|
if (declarationKind !== undefined) {
|
|
1659
|
-
recordDeclaration(
|
|
1660
|
-
identifier,
|
|
1661
|
-
isDashedIdent ? "custom property" : declarationKind,
|
|
1662
|
-
sl,
|
|
1663
|
-
sc
|
|
1664
|
-
);
|
|
1875
|
+
recordDeclaration(identifier, "custom property", sl, sc);
|
|
1665
1876
|
}
|
|
1666
1877
|
addCssExport(
|
|
1667
1878
|
sl,
|
|
@@ -1673,9 +1884,7 @@ class CssParser extends Parser {
|
|
|
1673
1884
|
[A.start(cv), A.end(cv)],
|
|
1674
1885
|
true,
|
|
1675
1886
|
CssIcssExportDependency.EXPORT_MODE.ONCE,
|
|
1676
|
-
|
|
1677
|
-
? CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
|
|
1678
|
-
: CssIcssExportDependency.EXPORT_TYPE.NORMAL
|
|
1887
|
+
CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
|
|
1679
1888
|
);
|
|
1680
1889
|
}
|
|
1681
1890
|
}
|
|
@@ -1695,13 +1904,13 @@ class CssParser extends Parser {
|
|
|
1695
1904
|
*/
|
|
1696
1905
|
const processLocalAtRule = (atRule, options, kind) => {
|
|
1697
1906
|
let found = false;
|
|
1698
|
-
for (const cv of A.
|
|
1907
|
+
for (const cv of A.children(atRule)) {
|
|
1699
1908
|
const cvType = A.type(cv);
|
|
1700
1909
|
if (cvType === NodeType.Whitespace) continue;
|
|
1701
1910
|
|
|
1702
1911
|
if (cvType === NodeType.String) {
|
|
1703
1912
|
if (!found && options.string) {
|
|
1704
|
-
const value =
|
|
1913
|
+
const value = stringValue(cv);
|
|
1705
1914
|
const { line: sl, column: sc } = locConverter.get(A.start(cv));
|
|
1706
1915
|
const { line: el, column: ec } = locConverter.get(A.end(cv));
|
|
1707
1916
|
recordDeclaration(value, kind, sl, sc);
|
|
@@ -1724,26 +1933,18 @@ class CssParser extends Parser {
|
|
|
1724
1933
|
|
|
1725
1934
|
if (cvType === NodeType.Ident) {
|
|
1726
1935
|
if (!found && options.identifier) {
|
|
1727
|
-
const identifier =
|
|
1936
|
+
const identifier = stringValue(cv);
|
|
1728
1937
|
if (
|
|
1729
1938
|
options.identifier instanceof RegExp &&
|
|
1730
1939
|
options.identifier.test(identifier)
|
|
1731
1940
|
) {
|
|
1732
1941
|
continue;
|
|
1733
1942
|
}
|
|
1734
|
-
|
|
1735
|
-
const { line: el, column: ec } = locConverter.get(A.end(cv));
|
|
1736
|
-
recordDeclaration(identifier, kind, sl, sc);
|
|
1737
|
-
addCssExport(
|
|
1738
|
-
sl,
|
|
1739
|
-
sc,
|
|
1740
|
-
el,
|
|
1741
|
-
ec,
|
|
1943
|
+
addLocalizedExport(
|
|
1742
1944
|
identifier,
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
CssIcssExportDependency.EXPORT_MODE.ONCE,
|
|
1945
|
+
A.start(cv),
|
|
1946
|
+
A.end(cv),
|
|
1947
|
+
kind,
|
|
1747
1948
|
CssIcssExportDependency.EXPORT_TYPE.NORMAL
|
|
1748
1949
|
);
|
|
1749
1950
|
found = true;
|
|
@@ -1754,10 +1955,10 @@ class CssParser extends Parser {
|
|
|
1754
1955
|
|
|
1755
1956
|
if (cvType === NodeType.Function) {
|
|
1756
1957
|
const fn = /** @type {FunctionNode} */ (cv);
|
|
1757
|
-
const fname = A.
|
|
1758
|
-
const type =
|
|
1958
|
+
const fname = A.name(fn);
|
|
1959
|
+
const type = asciiCaseInsensitiveMatch(fname, "local")
|
|
1759
1960
|
? 1
|
|
1760
|
-
:
|
|
1961
|
+
: asciiCaseInsensitiveMatch(fname, "global")
|
|
1761
1962
|
? 2
|
|
1762
1963
|
: undefined;
|
|
1763
1964
|
if (!found && type) {
|
|
@@ -1769,7 +1970,8 @@ class CssParser extends Parser {
|
|
|
1769
1970
|
if (
|
|
1770
1971
|
this.options.dashedIdents &&
|
|
1771
1972
|
isLocalMode() &&
|
|
1772
|
-
(
|
|
1973
|
+
(asciiCaseInsensitiveMatch(fname, "var") ||
|
|
1974
|
+
asciiCaseInsensitiveMatch(fname, "style"))
|
|
1773
1975
|
) {
|
|
1774
1976
|
processDashedIdentInVarFunction(fn);
|
|
1775
1977
|
}
|
|
@@ -1913,7 +2115,7 @@ class CssParser extends Parser {
|
|
|
1913
2115
|
if (!rangeIsDashedIdentifier(input, identStart, identEnd)) {
|
|
1914
2116
|
// `var(v)` where `@value v: --foo` names the same property `var(--foo)`
|
|
1915
2117
|
// does, so it is scoped here rather than substituted verbatim.
|
|
1916
|
-
const dashedName = localizableDashedValue(A.
|
|
2118
|
+
const dashedName = localizableDashedValue(A.source(identNode));
|
|
1917
2119
|
if (dashedName !== undefined) {
|
|
1918
2120
|
handledDashedValueIdents.add(identStart);
|
|
1919
2121
|
emitNamedDashedIdentExport(dashedName, identStart, identEnd);
|
|
@@ -1929,7 +2131,12 @@ class CssParser extends Parser {
|
|
|
1929
2131
|
if (
|
|
1930
2132
|
j >= fv.length ||
|
|
1931
2133
|
A.type(fv[j]) !== NodeType.Ident ||
|
|
1932
|
-
!
|
|
2134
|
+
!rangeAsciiCaseInsensitiveMatch(
|
|
2135
|
+
input,
|
|
2136
|
+
A.start(fv[j]),
|
|
2137
|
+
A.end(fv[j]),
|
|
2138
|
+
"from"
|
|
2139
|
+
)
|
|
1933
2140
|
) {
|
|
1934
2141
|
emitDashedIdentExport(identStart, identEnd);
|
|
1935
2142
|
return;
|
|
@@ -2064,7 +2271,7 @@ class CssParser extends Parser {
|
|
|
2064
2271
|
if (isLocal) {
|
|
2065
2272
|
while (
|
|
2066
2273
|
trailStart > 0 &&
|
|
2067
|
-
|
|
2274
|
+
isAsciiWhitespace(source.charCodeAt(trailStart - 1))
|
|
2068
2275
|
) {
|
|
2069
2276
|
trailStart--;
|
|
2070
2277
|
}
|
|
@@ -2090,8 +2297,8 @@ class CssParser extends Parser {
|
|
|
2090
2297
|
}
|
|
2091
2298
|
const attrNameNode = attrParts[ai];
|
|
2092
2299
|
if (!attrNameNode || A.type(attrNameNode) !== NodeType.Ident) return;
|
|
2093
|
-
const attrName =
|
|
2094
|
-
if (!
|
|
2300
|
+
const attrName = stringValue(attrNameNode);
|
|
2301
|
+
if (!asciiCaseInsensitiveMatch(attrName, "class")) return;
|
|
2095
2302
|
ai++;
|
|
2096
2303
|
while (
|
|
2097
2304
|
ai < attrParts.length &&
|
|
@@ -2102,11 +2309,11 @@ class CssParser extends Parser {
|
|
|
2102
2309
|
// `=` or `~=` (two `Delim` tokens for the latter).
|
|
2103
2310
|
const op1 = attrParts[ai];
|
|
2104
2311
|
if (!op1 || A.type(op1) !== NodeType.Delim) return;
|
|
2105
|
-
const op1v = A.
|
|
2312
|
+
const op1v = A.source(op1);
|
|
2106
2313
|
if (op1v === "~") {
|
|
2107
2314
|
ai++;
|
|
2108
2315
|
const op2 = attrParts[ai];
|
|
2109
|
-
if (!op2 || A.type(op2) !== NodeType.Delim || A.
|
|
2316
|
+
if (!op2 || A.type(op2) !== NodeType.Delim || A.source(op2) !== "=") {
|
|
2110
2317
|
return;
|
|
2111
2318
|
}
|
|
2112
2319
|
} else if (op1v !== "=") {
|
|
@@ -2160,7 +2367,7 @@ class CssParser extends Parser {
|
|
|
2160
2367
|
if (!this.options.customIdents) return;
|
|
2161
2368
|
for (const cv of cvs) {
|
|
2162
2369
|
if (A.type(cv) !== NodeType.Ident) continue;
|
|
2163
|
-
const name =
|
|
2370
|
+
const name = stringValue(cv);
|
|
2164
2371
|
if (isDashedIdentifier(name)) continue;
|
|
2165
2372
|
const start = A.start(cv);
|
|
2166
2373
|
const end = A.end(cv);
|
|
@@ -2188,11 +2395,11 @@ class CssParser extends Parser {
|
|
|
2188
2395
|
* @returns {void}
|
|
2189
2396
|
*/
|
|
2190
2397
|
const emitCounterIdent = (node, reservedFrom) => {
|
|
2191
|
-
const name =
|
|
2398
|
+
const name = stringValue(node);
|
|
2192
2399
|
if (isDashedIdentifier(name)) return;
|
|
2193
2400
|
const reserved =
|
|
2194
2401
|
/** @type {Map<string, number>} */
|
|
2195
|
-
(
|
|
2402
|
+
(getCssModulesKeywords().get(reservedFrom));
|
|
2196
2403
|
if (reserved.has(toLowerCaseIfNeeded(name))) return;
|
|
2197
2404
|
const start = A.start(node);
|
|
2198
2405
|
const end = A.end(node);
|
|
@@ -2283,9 +2490,9 @@ class CssParser extends Parser {
|
|
|
2283
2490
|
if (!next) break;
|
|
2284
2491
|
const nextType = A.type(next);
|
|
2285
2492
|
if (nextType === NodeType.Ident) {
|
|
2286
|
-
const raw = A.
|
|
2287
|
-
const isLocal =
|
|
2288
|
-
if (isLocal ||
|
|
2493
|
+
const raw = A.source(next);
|
|
2494
|
+
const isLocal = asciiCaseInsensitiveMatch(raw, "local");
|
|
2495
|
+
if (isLocal || asciiCaseInsensitiveMatch(raw, "global")) {
|
|
2289
2496
|
const id = isLocal ? "local" : "global";
|
|
2290
2497
|
// Bare `:local` / `:global`: switch the segment (and top-level persistent) mode and strip the marker.
|
|
2291
2498
|
const afterIsWhitespace = stripBareMarker(
|
|
@@ -2313,9 +2520,9 @@ class CssParser extends Parser {
|
|
|
2313
2520
|
}
|
|
2314
2521
|
} else if (nextType === NodeType.Function) {
|
|
2315
2522
|
const fn = /** @type {FunctionNode} */ (next);
|
|
2316
|
-
const rawName = A.
|
|
2317
|
-
const isLocal =
|
|
2318
|
-
if (isLocal ||
|
|
2523
|
+
const rawName = A.name(fn);
|
|
2524
|
+
const isLocal = asciiCaseInsensitiveMatch(rawName, "local");
|
|
2525
|
+
if (isLocal || asciiCaseInsensitiveMatch(rawName, "global")) {
|
|
2319
2526
|
// `:local(…)` / `:global(…)`: scope mode to the args and strip the `:name(` … `)` wrapper.
|
|
2320
2527
|
stripFunctionMarker(v, fn, isLocal);
|
|
2321
2528
|
walkSelectorList(
|
|
@@ -2331,12 +2538,12 @@ class CssParser extends Parser {
|
|
|
2331
2538
|
}
|
|
2332
2539
|
case NodeType.Function: {
|
|
2333
2540
|
// `::view-transition-group(name .class…)` etc.: scope the part name + classes as custom idents (the `v` char guard skips the slice for the common `:is`/`:not`/… functions).
|
|
2334
|
-
const fnNameStart = A.
|
|
2541
|
+
const fnNameStart = A.startOf(Part.name, v);
|
|
2335
2542
|
if (
|
|
2336
2543
|
segmentMode === "local" &&
|
|
2337
2544
|
(input.charCodeAt(fnNameStart) === CC_LOWER_V ||
|
|
2338
2545
|
input.charCodeAt(fnNameStart) === CC_UPPER_V) &&
|
|
2339
|
-
VIEW_TRANSITION_PART_PSEUDO.test(A.
|
|
2546
|
+
VIEW_TRANSITION_PART_PSEUDO.test(A.name(v))
|
|
2340
2547
|
) {
|
|
2341
2548
|
walkViewTransitionPart(A.children(v));
|
|
2342
2549
|
break;
|
|
@@ -2346,12 +2553,12 @@ class CssParser extends Parser {
|
|
|
2346
2553
|
break;
|
|
2347
2554
|
}
|
|
2348
2555
|
case NodeType.Hash: {
|
|
2349
|
-
if (A.
|
|
2556
|
+
if (!A.flag(Flag.id, v) || segmentMode !== "local") {
|
|
2350
2557
|
break;
|
|
2351
2558
|
}
|
|
2352
2559
|
// ID selectors emit the ICSS export but aren't a `composes:` anchor.
|
|
2353
2560
|
const idValueStart = A.start(v) + 1;
|
|
2354
|
-
const idName =
|
|
2561
|
+
const idName = stringValue(v);
|
|
2355
2562
|
const { line: idSl, column: idSc } = locConverter.get(A.start(v));
|
|
2356
2563
|
const { line: idEl, column: idEc } = locConverter.get(A.end(v));
|
|
2357
2564
|
recordDeclaration(idName, "id", idSl, idSc);
|
|
@@ -2371,7 +2578,7 @@ class CssParser extends Parser {
|
|
|
2371
2578
|
}
|
|
2372
2579
|
case NodeType.SimpleBlock: {
|
|
2373
2580
|
const block = /** @type {SimpleBlock} */ (v);
|
|
2374
|
-
const bt = A.
|
|
2581
|
+
const bt = A.value(block);
|
|
2375
2582
|
if (bt === "[") {
|
|
2376
2583
|
// Attribute selectors `[class="foo"]` localize only in local mode.
|
|
2377
2584
|
if (segmentMode === "local") handleAttributeSelector(block);
|
|
@@ -2382,7 +2589,7 @@ class CssParser extends Parser {
|
|
|
2382
2589
|
break;
|
|
2383
2590
|
}
|
|
2384
2591
|
case NodeType.Delim: {
|
|
2385
|
-
const delim = A.
|
|
2592
|
+
const delim = A.source(v);
|
|
2386
2593
|
if (delim === "&") {
|
|
2387
2594
|
// Pure-mode: a nesting `&` inherits a pure ancestor's purity.
|
|
2388
2595
|
if (topLevel && pure.ancestorHadLocal()) pure.markLocal();
|
|
@@ -2393,7 +2600,7 @@ class CssParser extends Parser {
|
|
|
2393
2600
|
if (!next || A.type(next) !== NodeType.Ident) break;
|
|
2394
2601
|
if (segmentMode === "local") {
|
|
2395
2602
|
// `.<ident>` in local mode is a class selector (dep covers the ident bytes only).
|
|
2396
|
-
const name =
|
|
2603
|
+
const name = stringValue(next);
|
|
2397
2604
|
// Cursor reads instead of `A.loc` — this is the hottest export site.
|
|
2398
2605
|
const { line: sl, column: sc } = locConverter.get(A.start(next));
|
|
2399
2606
|
const { line: el, column: ec } = locConverter.get(A.end(next));
|
|
@@ -2414,7 +2621,7 @@ class CssParser extends Parser {
|
|
|
2414
2621
|
pure.markLocal();
|
|
2415
2622
|
} else if (icssDefinitions.size !== 0) {
|
|
2416
2623
|
// `.<ident>` in global mode: not localized, but the ident may be `@value`-defined and need ICSS rewrite.
|
|
2417
|
-
const ident = A.
|
|
2624
|
+
const ident = A.source(next);
|
|
2418
2625
|
if (!isDashedIdentifier(ident) && icssDefinitions.has(ident)) {
|
|
2419
2626
|
emitICSSSymbol(ident, A.start(next), A.end(next));
|
|
2420
2627
|
}
|
|
@@ -2426,7 +2633,7 @@ class CssParser extends Parser {
|
|
|
2426
2633
|
case NodeType.Ident: {
|
|
2427
2634
|
// A bare `@value`-defined ident stands in for a selector; only worth the slice when definitions exist.
|
|
2428
2635
|
if (icssDefinitions.size === 0) break;
|
|
2429
|
-
const ident = A.
|
|
2636
|
+
const ident = A.source(v);
|
|
2430
2637
|
if (isDashedIdentifier(ident) || !icssDefinitions.has(ident)) {
|
|
2431
2638
|
break;
|
|
2432
2639
|
}
|
|
@@ -2439,6 +2646,19 @@ class CssParser extends Parser {
|
|
|
2439
2646
|
? localizableSelectorValue(ident)
|
|
2440
2647
|
: undefined;
|
|
2441
2648
|
if (localizable === undefined) {
|
|
2649
|
+
if (
|
|
2650
|
+
segmentMode === "local" &&
|
|
2651
|
+
/** @type {IcssDefinition} */ (icssDefinitions.get(ident))
|
|
2652
|
+
.importName
|
|
2653
|
+
) {
|
|
2654
|
+
addResolvedExport(
|
|
2655
|
+
ident,
|
|
2656
|
+
identStart,
|
|
2657
|
+
identEnd,
|
|
2658
|
+
CssIcssExportDependency.EXPORT_MODE.RESOLVED_SELECTOR
|
|
2659
|
+
);
|
|
2660
|
+
break;
|
|
2661
|
+
}
|
|
2442
2662
|
emitICSSSymbol(ident, identStart, identEnd);
|
|
2443
2663
|
break;
|
|
2444
2664
|
}
|
|
@@ -2563,7 +2783,7 @@ class CssParser extends Parser {
|
|
|
2563
2783
|
* @returns {void}
|
|
2564
2784
|
*/
|
|
2565
2785
|
const finishTopLevelRule = (node, blockBearing) => {
|
|
2566
|
-
if (!blockBearing || A.
|
|
2786
|
+
if (!blockBearing || A.startOf(Part.block, node) !== -1) {
|
|
2567
2787
|
allowImport = false;
|
|
2568
2788
|
}
|
|
2569
2789
|
pure.markSeenTopLevelRule();
|
|
@@ -2757,7 +2977,7 @@ class CssParser extends Parser {
|
|
|
2757
2977
|
}
|
|
2758
2978
|
if (
|
|
2759
2979
|
A.type(cv) === NodeType.Ident &&
|
|
2760
|
-
|
|
2980
|
+
asciiCaseInsensitiveMatch(A.source(cv), "global")
|
|
2761
2981
|
) {
|
|
2762
2982
|
fromSource = { kind: "global" };
|
|
2763
2983
|
phase = "done";
|
|
@@ -2774,9 +2994,9 @@ class CssParser extends Parser {
|
|
|
2774
2994
|
}
|
|
2775
2995
|
|
|
2776
2996
|
if (A.type(cv) === NodeType.Ident) {
|
|
2777
|
-
const identValue = A.
|
|
2997
|
+
const identValue = A.source(cv);
|
|
2778
2998
|
if (
|
|
2779
|
-
|
|
2999
|
+
asciiCaseInsensitiveMatch(identValue, "from") &&
|
|
2780
3000
|
classNames.length > 0 &&
|
|
2781
3001
|
nextNonWhitespace(group, i + 1) < group.length
|
|
2782
3002
|
) {
|
|
@@ -2793,7 +3013,7 @@ class CssParser extends Parser {
|
|
|
2793
3013
|
|
|
2794
3014
|
if (A.type(cv) === NodeType.Function) {
|
|
2795
3015
|
const fn = /** @type {FunctionNode} */ (cv);
|
|
2796
|
-
const isGlobal =
|
|
3016
|
+
const isGlobal = asciiCaseInsensitiveMatch(A.name(fn), "global");
|
|
2797
3017
|
for (const inner of A.children(fn)) {
|
|
2798
3018
|
if (A.type(inner) === NodeType.Ident) {
|
|
2799
3019
|
classNames.push({
|
|
@@ -2840,10 +3060,10 @@ class CssParser extends Parser {
|
|
|
2840
3060
|
let resumeAt = A.end(decl);
|
|
2841
3061
|
if (source.charCodeAt(A.end(decl)) === CC_SEMICOLON) {
|
|
2842
3062
|
resumeAt = A.end(decl) + 1;
|
|
2843
|
-
while (
|
|
3063
|
+
while (isAsciiWhitespace(source.charCodeAt(resumeAt))) resumeAt++;
|
|
2844
3064
|
}
|
|
2845
3065
|
module.addPresentationalDependency(
|
|
2846
|
-
new ConstDependency("", [A.
|
|
3066
|
+
new ConstDependency("", [A.startOf(Part.name, decl), resumeAt])
|
|
2847
3067
|
);
|
|
2848
3068
|
};
|
|
2849
3069
|
|
|
@@ -2853,26 +3073,36 @@ class CssParser extends Parser {
|
|
|
2853
3073
|
* @param {string | undefined} escapedName the unescaped function name when it carries an escape, undefined for the raw byte-range path
|
|
2854
3074
|
*/
|
|
2855
3075
|
const emitUrlFunction = (fn, escapedName) => {
|
|
2856
|
-
const fnNameStart = A.
|
|
2857
|
-
const fnNameEnd = A.
|
|
3076
|
+
const fnNameStart = A.startOf(Part.name, fn);
|
|
3077
|
+
const fnNameEnd = A.endOf(Part.name, fn);
|
|
2858
3078
|
let isUrlOrSrc;
|
|
2859
3079
|
let isImageSet = false;
|
|
2860
3080
|
if (escapedName !== undefined) {
|
|
2861
3081
|
isUrlOrSrc =
|
|
2862
|
-
|
|
2863
|
-
|
|
3082
|
+
asciiCaseInsensitiveMatch(escapedName, "url") ||
|
|
3083
|
+
asciiCaseInsensitiveMatch(escapedName, "src");
|
|
2864
3084
|
if (!isUrlOrSrc) isImageSet = IMAGE_SET_FUNCTION.test(escapedName);
|
|
2865
3085
|
} else {
|
|
2866
3086
|
const nameLength = fnNameEnd - fnNameStart;
|
|
2867
3087
|
isUrlOrSrc =
|
|
2868
3088
|
nameLength === 3 &&
|
|
2869
|
-
(
|
|
2870
|
-
|
|
3089
|
+
(rangeAsciiCaseInsensitiveMatch(
|
|
3090
|
+
input,
|
|
3091
|
+
fnNameStart,
|
|
3092
|
+
fnNameEnd,
|
|
3093
|
+
"url"
|
|
3094
|
+
) ||
|
|
3095
|
+
rangeAsciiCaseInsensitiveMatch(
|
|
3096
|
+
input,
|
|
3097
|
+
fnNameStart,
|
|
3098
|
+
fnNameEnd,
|
|
3099
|
+
"src"
|
|
3100
|
+
));
|
|
2871
3101
|
if (!isUrlOrSrc) {
|
|
2872
3102
|
// Suffix probe first, so only a vendor-prefixed `…-image-set` pays the slice + regex.
|
|
2873
3103
|
isImageSet =
|
|
2874
3104
|
nameLength >= 9 &&
|
|
2875
|
-
|
|
3105
|
+
rangeAsciiCaseInsensitiveMatch(
|
|
2876
3106
|
input,
|
|
2877
3107
|
fnNameEnd - 9,
|
|
2878
3108
|
fnNameEnd,
|
|
@@ -2972,18 +3202,18 @@ class CssParser extends Parser {
|
|
|
2972
3202
|
"Any '@import' rules must precede all other rules",
|
|
2973
3203
|
locConverter,
|
|
2974
3204
|
A.start(at),
|
|
2975
|
-
A.
|
|
3205
|
+
A.endOf(Part.name, at)
|
|
2976
3206
|
);
|
|
2977
3207
|
return;
|
|
2978
3208
|
}
|
|
2979
3209
|
const importStart = A.start(at);
|
|
2980
|
-
const importNameEnd = A.
|
|
3210
|
+
const importNameEnd = A.endOf(Part.name, at);
|
|
2981
3211
|
// We only accept `;`-terminated @import; block / EOF / `}` ends are silent bails.
|
|
2982
3212
|
if (source.charCodeAt(A.end(at)) !== CC_SEMICOLON) return;
|
|
2983
3213
|
|
|
2984
3214
|
// Walk the prelude in spec order (URL → layer? → supports? → media query); anything else joins the media query.
|
|
2985
3215
|
const { urlNode, layerNode, supportsNode } = parseImportPrelude(
|
|
2986
|
-
A.
|
|
3216
|
+
A.children(at)
|
|
2987
3217
|
);
|
|
2988
3218
|
|
|
2989
3219
|
const semi = A.end(at) + 1; // position past `;`
|
|
@@ -3005,7 +3235,7 @@ class CssParser extends Parser {
|
|
|
3005
3235
|
let url;
|
|
3006
3236
|
if (A.type(urlNode) === NodeType.Ident) {
|
|
3007
3237
|
// URL given as identifier — resolve via CSS Modules `@value`.
|
|
3008
|
-
const identName = A.
|
|
3238
|
+
const identName = A.source(urlNode);
|
|
3009
3239
|
const def = icssDefinitions.get(identName);
|
|
3010
3240
|
if (!def) {
|
|
3011
3241
|
this._emitWarning(
|
|
@@ -3044,7 +3274,7 @@ class CssParser extends Parser {
|
|
|
3044
3274
|
} else if (A.type(urlNode) === NodeType.Url) {
|
|
3045
3275
|
const ut = /** @type {UrlToken} */ (urlNode);
|
|
3046
3276
|
url = normalizeUrl(
|
|
3047
|
-
input.slice(A.
|
|
3277
|
+
input.slice(A.startOf(Part.value, ut), A.endOf(Part.value, ut)),
|
|
3048
3278
|
false
|
|
3049
3279
|
);
|
|
3050
3280
|
} else if (A.type(urlNode) === NodeType.String) {
|
|
@@ -3099,7 +3329,7 @@ class CssParser extends Parser {
|
|
|
3099
3329
|
if (A.type(layerNode) === NodeType.Function) {
|
|
3100
3330
|
// `layer(<ident>)` — extract content between `(` and `)`.
|
|
3101
3331
|
const fn = /** @type {FunctionNode} */ (layerNode);
|
|
3102
|
-
layer = input.slice(A.
|
|
3332
|
+
layer = input.slice(A.endOf(Part.name, fn) + 1, A.end(fn) - 1).trim();
|
|
3103
3333
|
} else {
|
|
3104
3334
|
// Bare `layer` ident — anonymous layer.
|
|
3105
3335
|
layer = "";
|
|
@@ -3110,18 +3340,18 @@ class CssParser extends Parser {
|
|
|
3110
3340
|
let supports;
|
|
3111
3341
|
if (supportsNode) {
|
|
3112
3342
|
supports = input
|
|
3113
|
-
.slice(A.
|
|
3343
|
+
.slice(A.endOf(Part.name, supportsNode) + 1, A.end(supportsNode) - 1)
|
|
3114
3344
|
.trim();
|
|
3115
3345
|
}
|
|
3116
3346
|
|
|
3117
3347
|
// Media query = whatever sits between the last url/layer/supports part and the closing `;`, trimmed. Start at the next non-whitespace prelude node (skips the gap, comments included).
|
|
3118
3348
|
const lastPrefixPart = supportsNode || layerNode || urlNode;
|
|
3119
3349
|
const afterIdx =
|
|
3120
|
-
/** @type {AstNode[]} */ (A.
|
|
3121
|
-
const nextIdx = nextNonWhitespace(A.
|
|
3350
|
+
/** @type {AstNode[]} */ (A.children(at)).indexOf(lastPrefixPart) + 1;
|
|
3351
|
+
const nextIdx = nextNonWhitespace(A.children(at), afterIdx);
|
|
3122
3352
|
const mediaStart =
|
|
3123
|
-
nextIdx < A.
|
|
3124
|
-
? A.start(A.
|
|
3353
|
+
nextIdx < A.children(at).length
|
|
3354
|
+
? A.start(A.children(at)[nextIdx])
|
|
3125
3355
|
: A.end(at);
|
|
3126
3356
|
/** @type {undefined | string} */
|
|
3127
3357
|
let media;
|
|
@@ -3169,7 +3399,7 @@ class CssParser extends Parser {
|
|
|
3169
3399
|
*/
|
|
3170
3400
|
const handleValueAtRule = (at) => {
|
|
3171
3401
|
const start = A.start(at);
|
|
3172
|
-
const nameEnd = A.
|
|
3402
|
+
const nameEnd = A.endOf(Part.name, at);
|
|
3173
3403
|
const semi = A.end(at);
|
|
3174
3404
|
const atRuleEnd =
|
|
3175
3405
|
source.charCodeAt(semi) === CC_SEMICOLON ? semi + 1 : semi;
|
|
@@ -3295,7 +3525,7 @@ class CssParser extends Parser {
|
|
|
3295
3525
|
return ident;
|
|
3296
3526
|
}
|
|
3297
3527
|
if (A.type(k) !== NodeType.Ident) return undefined;
|
|
3298
|
-
const v = A.
|
|
3528
|
+
const v = A.source(k);
|
|
3299
3529
|
if (!isDashedIdentifier(v)) return undefined;
|
|
3300
3530
|
ident = v;
|
|
3301
3531
|
}
|
|
@@ -3317,13 +3547,13 @@ class CssParser extends Parser {
|
|
|
3317
3547
|
new ConstDependency("", [start, ruleEnd])
|
|
3318
3548
|
);
|
|
3319
3549
|
|
|
3320
|
-
const prelude = A.
|
|
3550
|
+
const prelude = A.children(at);
|
|
3321
3551
|
let i = 0;
|
|
3322
3552
|
while (i < prelude.length && A.type(prelude[i]) === NodeType.Whitespace) {
|
|
3323
3553
|
i++;
|
|
3324
3554
|
}
|
|
3325
3555
|
if (i >= prelude.length || A.type(prelude[i]) !== NodeType.Ident) return;
|
|
3326
|
-
const name = A.
|
|
3556
|
+
const name = A.source(prelude[i]);
|
|
3327
3557
|
if (!isDashedIdentifier(name)) return;
|
|
3328
3558
|
i++;
|
|
3329
3559
|
|
|
@@ -3370,10 +3600,17 @@ class CssParser extends Parser {
|
|
|
3370
3600
|
return { kind: "alias", name: nested };
|
|
3371
3601
|
}
|
|
3372
3602
|
}
|
|
3373
|
-
// A reference anywhere else
|
|
3374
|
-
//
|
|
3375
|
-
|
|
3376
|
-
|
|
3603
|
+
// A reference anywhere else is captured as a `@media` prelude is, and
|
|
3604
|
+
// folded once every name it reads is known.
|
|
3605
|
+
if (hasCustomMediaRef(prelude, vs, ve)) {
|
|
3606
|
+
/** @type {CustomMediaUse[]} */
|
|
3607
|
+
const uses = [];
|
|
3608
|
+
const node = captureMediaQuery(prelude, vs, ve, uses);
|
|
3609
|
+
for (const use of uses) {
|
|
3610
|
+
if (use.invalid) return CUSTOM_MEDIA_UNSUPPORTED;
|
|
3611
|
+
}
|
|
3612
|
+
return { kind: "query", node, uses };
|
|
3613
|
+
}
|
|
3377
3614
|
if (A.type(first) === NodeType.SimpleBlock) {
|
|
3378
3615
|
return { kind: "condition", text: valueText };
|
|
3379
3616
|
}
|
|
@@ -3381,14 +3618,14 @@ class CssParser extends Parser {
|
|
|
3381
3618
|
const s = A.start(first);
|
|
3382
3619
|
const e = A.end(first);
|
|
3383
3620
|
if (ve - vs === 1) {
|
|
3384
|
-
if (
|
|
3621
|
+
if (rangeAsciiCaseInsensitiveMatch(input, s, e, "true")) {
|
|
3385
3622
|
return CUSTOM_MEDIA_TRUE;
|
|
3386
3623
|
}
|
|
3387
|
-
if (
|
|
3624
|
+
if (rangeAsciiCaseInsensitiveMatch(input, s, e, "false")) {
|
|
3388
3625
|
return CUSTOM_MEDIA_FALSE;
|
|
3389
3626
|
}
|
|
3390
3627
|
}
|
|
3391
|
-
if (
|
|
3628
|
+
if (rangeAsciiCaseInsensitiveMatch(input, s, e, "not")) {
|
|
3392
3629
|
// `not (…)` is a media condition (wrap so it stays a media-in-parens);
|
|
3393
3630
|
// `not <type>` is a media type.
|
|
3394
3631
|
let j = vs + 1;
|
|
@@ -3404,7 +3641,7 @@ class CssParser extends Parser {
|
|
|
3404
3641
|
|
|
3405
3642
|
// Comma list → `(seg1 or seg2 …)`; supported only when every segment is a
|
|
3406
3643
|
// media-in-parens (or a name standing for one).
|
|
3407
|
-
/** @type {({ text: string } | { alias: string })[]} */
|
|
3644
|
+
/** @type {({ text: string } | { alias: string } | { query: CustomMediaQuery })[]} */
|
|
3408
3645
|
const parts = [];
|
|
3409
3646
|
let ok = true;
|
|
3410
3647
|
/** @type {AstNode[]} */
|
|
@@ -3430,15 +3667,26 @@ class CssParser extends Parser {
|
|
|
3430
3667
|
else parts.push({ alias: nested });
|
|
3431
3668
|
return;
|
|
3432
3669
|
}
|
|
3670
|
+
// Any other condition is one group in the `or`; a media type is none.
|
|
3433
3671
|
if (
|
|
3434
|
-
A.type(f)
|
|
3435
|
-
|
|
3436
|
-
|
|
3672
|
+
A.type(f) !== NodeType.SimpleBlock &&
|
|
3673
|
+
!(
|
|
3674
|
+
A.type(f) === NodeType.Ident &&
|
|
3675
|
+
rangeAsciiCaseInsensitiveMatch(input, A.start(f), A.end(f), "not")
|
|
3676
|
+
)
|
|
3437
3677
|
) {
|
|
3678
|
+
ok = false;
|
|
3679
|
+
return;
|
|
3680
|
+
}
|
|
3681
|
+
if (!hasCustomMediaRef(seg, a, b)) {
|
|
3438
3682
|
parts.push({ text: `(${text})` });
|
|
3439
3683
|
return;
|
|
3440
3684
|
}
|
|
3441
|
-
|
|
3685
|
+
/** @type {CustomMediaUse[]} */
|
|
3686
|
+
const uses = [];
|
|
3687
|
+
const node = captureMediaCondition(seg, a, b, uses, true);
|
|
3688
|
+
if (uses.some((use) => use.invalid)) ok = false;
|
|
3689
|
+
else parts.push({ query: { node, uses } });
|
|
3442
3690
|
};
|
|
3443
3691
|
for (let k = vs; k < ve; k++) {
|
|
3444
3692
|
if (A.type(prelude[k]) === NodeType.Comma) {
|
|
@@ -3479,15 +3727,26 @@ class CssParser extends Parser {
|
|
|
3479
3727
|
let ok = true;
|
|
3480
3728
|
let anyTrue = false;
|
|
3481
3729
|
for (const part of def.parts) {
|
|
3482
|
-
if (
|
|
3730
|
+
if ("text" in part) {
|
|
3483
3731
|
texts.push(part.text);
|
|
3484
3732
|
continue;
|
|
3485
3733
|
}
|
|
3486
|
-
const inner =
|
|
3734
|
+
const inner =
|
|
3735
|
+
"alias" in part
|
|
3736
|
+
? resolveCustomMediaValue(part.alias, resolving)
|
|
3737
|
+
: resolveCustomMediaQuery(
|
|
3738
|
+
part.query.node,
|
|
3739
|
+
part.query.uses,
|
|
3740
|
+
resolving
|
|
3741
|
+
);
|
|
3487
3742
|
// A media query list is an `or`, so a constant segment drops out of it.
|
|
3488
|
-
if (inner.kind === "boolean")
|
|
3489
|
-
|
|
3490
|
-
else
|
|
3743
|
+
if (inner.kind === "boolean") {
|
|
3744
|
+
anyTrue = anyTrue || inner.value;
|
|
3745
|
+
} else if (inner.kind === "condition") {
|
|
3746
|
+
texts.push(mediaConditionFor(inner.text, "or"));
|
|
3747
|
+
} else {
|
|
3748
|
+
ok = false;
|
|
3749
|
+
}
|
|
3491
3750
|
}
|
|
3492
3751
|
value = !ok
|
|
3493
3752
|
? CUSTOM_MEDIA_UNSUPPORTED
|
|
@@ -3500,6 +3759,8 @@ class CssParser extends Parser {
|
|
|
3500
3759
|
text:
|
|
3501
3760
|
texts.length === 1 ? texts[0] : `(${texts.join(" or ")})`
|
|
3502
3761
|
};
|
|
3762
|
+
} else if (def.kind === "query") {
|
|
3763
|
+
value = resolveCustomMediaQuery(def.node, def.uses, resolving);
|
|
3503
3764
|
} else {
|
|
3504
3765
|
value = def;
|
|
3505
3766
|
}
|
|
@@ -3508,6 +3769,35 @@ class CssParser extends Parser {
|
|
|
3508
3769
|
return value;
|
|
3509
3770
|
};
|
|
3510
3771
|
|
|
3772
|
+
/**
|
|
3773
|
+
* What a `@custom-media` value reading other names resolves to: the value
|
|
3774
|
+
* folded once each name resolves, or unsupported where one does not.
|
|
3775
|
+
* @param {MediaNode} node the captured value
|
|
3776
|
+
* @param {CustomMediaUse[]} uses the names it reads
|
|
3777
|
+
* @param {Set<string>} resolving names currently being resolved
|
|
3778
|
+
* @returns {CustomMediaValue} what it resolves to
|
|
3779
|
+
*/
|
|
3780
|
+
const resolveCustomMediaQuery = (node, uses, resolving) => {
|
|
3781
|
+
for (const use of uses) {
|
|
3782
|
+
const inner = resolveCustomMediaValue(use.name, resolving);
|
|
3783
|
+
if (
|
|
3784
|
+
inner.kind === "unsupported" ||
|
|
3785
|
+
(inner.kind === "type" && !use.leading)
|
|
3786
|
+
) {
|
|
3787
|
+
return CUSTOM_MEDIA_UNSUPPORTED;
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3790
|
+
const folded = foldMediaNode(node, resolving);
|
|
3791
|
+
if (typeof folded === "boolean") {
|
|
3792
|
+
return folded ? CUSTOM_MEDIA_TRUE : CUSTOM_MEDIA_FALSE;
|
|
3793
|
+
}
|
|
3794
|
+
// A query led by a media type stands for a type, as one written out does.
|
|
3795
|
+
const condition =
|
|
3796
|
+
folded.charCodeAt(0) === CC_LEFT_PARENTHESIS ||
|
|
3797
|
+
/^not\s*\(/i.test(folded);
|
|
3798
|
+
return { kind: condition ? "condition" : "type", text: folded };
|
|
3799
|
+
};
|
|
3800
|
+
|
|
3511
3801
|
/**
|
|
3512
3802
|
* Whether a node is the media keyword `word` (media queries are ASCII
|
|
3513
3803
|
* case-insensitive).
|
|
@@ -3517,7 +3807,7 @@ class CssParser extends Parser {
|
|
|
3517
3807
|
*/
|
|
3518
3808
|
const isMediaKeyword = (node, word) =>
|
|
3519
3809
|
A.type(node) === NodeType.Ident &&
|
|
3520
|
-
|
|
3810
|
+
rangeAsciiCaseInsensitiveMatch(input, A.start(node), A.end(node), word);
|
|
3521
3811
|
|
|
3522
3812
|
/**
|
|
3523
3813
|
* First significant index in `tokens[from…to)`.
|
|
@@ -3568,7 +3858,7 @@ class CssParser extends Parser {
|
|
|
3568
3858
|
const hasCustomMediaRefIn = (node) => {
|
|
3569
3859
|
const count = A.childCount(node);
|
|
3570
3860
|
for (let k = 0; k < count; k++) {
|
|
3571
|
-
const child = A.
|
|
3861
|
+
const child = A.child(k, node);
|
|
3572
3862
|
const type = A.type(child);
|
|
3573
3863
|
if (type !== NodeType.SimpleBlock && type !== NodeType.Function) {
|
|
3574
3864
|
continue;
|
|
@@ -3625,9 +3915,10 @@ class CssParser extends Parser {
|
|
|
3625
3915
|
* @param {number} to one past the last index
|
|
3626
3916
|
* @param {boolean} leading whether the term starts a top-level query
|
|
3627
3917
|
* @param {CustomMediaUse[]} uses the prelude's use list, appended to
|
|
3918
|
+
* @param {MediaSlot} slot what the term is joined to
|
|
3628
3919
|
* @returns {MediaNode} the captured term
|
|
3629
3920
|
*/
|
|
3630
|
-
const captureMediaInParens = (tokens, from, to, leading, uses) => {
|
|
3921
|
+
const captureMediaInParens = (tokens, from, to, leading, uses, slot) => {
|
|
3631
3922
|
const a = mediaTrimStart(tokens, from, to);
|
|
3632
3923
|
const b = mediaTrimEnd(tokens, a, to);
|
|
3633
3924
|
if (a >= b) return { kind: "text", text: "" };
|
|
@@ -3643,13 +3934,20 @@ class CssParser extends Parser {
|
|
|
3643
3934
|
start: A.start(block),
|
|
3644
3935
|
end: A.end(block),
|
|
3645
3936
|
invalid: mediaExtra.hasExtra,
|
|
3646
|
-
leading
|
|
3937
|
+
leading,
|
|
3938
|
+
slot
|
|
3647
3939
|
};
|
|
3648
3940
|
uses.push(use);
|
|
3649
3941
|
return { kind: "ref", text, use };
|
|
3650
3942
|
}
|
|
3651
3943
|
const children = A.children(block);
|
|
3652
|
-
const inner = captureMediaCondition(
|
|
3944
|
+
const inner = captureMediaCondition(
|
|
3945
|
+
children,
|
|
3946
|
+
0,
|
|
3947
|
+
children.length,
|
|
3948
|
+
uses,
|
|
3949
|
+
true
|
|
3950
|
+
);
|
|
3653
3951
|
return inner.kind === "text"
|
|
3654
3952
|
? { kind: "text", text }
|
|
3655
3953
|
: { kind: "group", operand: inner };
|
|
@@ -3662,33 +3960,46 @@ class CssParser extends Parser {
|
|
|
3662
3960
|
* @param {number} from first index
|
|
3663
3961
|
* @param {number} to one past the last index
|
|
3664
3962
|
* @param {CustomMediaUse[]} uses the prelude's use list, appended to
|
|
3963
|
+
* @param {boolean} alone whether nothing outside joins the condition
|
|
3665
3964
|
* @returns {MediaNode} the captured condition
|
|
3666
3965
|
*/
|
|
3667
|
-
const captureMediaCondition = (tokens, from, to, uses) => {
|
|
3966
|
+
const captureMediaCondition = (tokens, from, to, uses, alone) => {
|
|
3668
3967
|
const a = mediaTrimStart(tokens, from, to);
|
|
3669
3968
|
const b = mediaTrimEnd(tokens, a, to);
|
|
3670
3969
|
if (a >= b) return { kind: "text", text: "" };
|
|
3671
3970
|
if (isMediaKeyword(tokens[a], "not")) {
|
|
3672
3971
|
return {
|
|
3673
3972
|
kind: "not",
|
|
3674
|
-
operand: captureMediaInParens(tokens, a + 1, b, false, uses)
|
|
3973
|
+
operand: captureMediaInParens(tokens, a + 1, b, false, uses, "or")
|
|
3675
3974
|
};
|
|
3676
3975
|
}
|
|
3976
|
+
let isOr = false;
|
|
3977
|
+
let single = true;
|
|
3978
|
+
for (let i = a; i < b; i++) {
|
|
3979
|
+
if (isMediaKeyword(tokens[i], "or")) isOr = true;
|
|
3980
|
+
if (
|
|
3981
|
+
isMediaKeyword(tokens[i], "and") ||
|
|
3982
|
+
isMediaKeyword(tokens[i], "or")
|
|
3983
|
+
) {
|
|
3984
|
+
single = false;
|
|
3985
|
+
}
|
|
3986
|
+
}
|
|
3987
|
+
/** @type {MediaSlot} */
|
|
3988
|
+
const slot = single && alone ? "alone" : isOr ? "or" : "and";
|
|
3677
3989
|
/** @type {MediaNode[]} */
|
|
3678
3990
|
const terms = [];
|
|
3679
|
-
let isOr = false;
|
|
3680
3991
|
let start = a;
|
|
3681
3992
|
for (let i = a; i <= b; i++) {
|
|
3682
|
-
const atEnd = i === b;
|
|
3683
3993
|
if (
|
|
3684
|
-
|
|
3994
|
+
i !== b &&
|
|
3685
3995
|
!isMediaKeyword(tokens[i], "and") &&
|
|
3686
3996
|
!isMediaKeyword(tokens[i], "or")
|
|
3687
3997
|
) {
|
|
3688
3998
|
continue;
|
|
3689
3999
|
}
|
|
3690
|
-
|
|
3691
|
-
|
|
4000
|
+
terms.push(
|
|
4001
|
+
captureMediaInParens(tokens, start, i, start === a, uses, slot)
|
|
4002
|
+
);
|
|
3692
4003
|
start = i + 1;
|
|
3693
4004
|
}
|
|
3694
4005
|
if (terms.length === 1) return terms[0];
|
|
@@ -3714,7 +4025,9 @@ class CssParser extends Parser {
|
|
|
3714
4025
|
(!isMediaKeyword(tokens[a], "not") ||
|
|
3715
4026
|
rest >= b ||
|
|
3716
4027
|
A.type(tokens[rest]) !== NodeType.SimpleBlock);
|
|
3717
|
-
if (!startsWithType)
|
|
4028
|
+
if (!startsWithType) {
|
|
4029
|
+
return captureMediaCondition(tokens, a, b, uses, true);
|
|
4030
|
+
}
|
|
3718
4031
|
// `[not | only]? <type> [and <condition-without-or>]?` — the type itself is
|
|
3719
4032
|
// never constant, so only the `and` chain after it can fold.
|
|
3720
4033
|
let split = b;
|
|
@@ -3728,7 +4041,9 @@ class CssParser extends Parser {
|
|
|
3728
4041
|
kind: "typed",
|
|
3729
4042
|
text: mediaText(tokens, a, mediaTrimEnd(tokens, a, split)),
|
|
3730
4043
|
rest:
|
|
3731
|
-
split === b
|
|
4044
|
+
split === b
|
|
4045
|
+
? null
|
|
4046
|
+
: captureMediaCondition(tokens, split + 1, b, uses, false)
|
|
3732
4047
|
};
|
|
3733
4048
|
};
|
|
3734
4049
|
|
|
@@ -3738,7 +4053,7 @@ class CssParser extends Parser {
|
|
|
3738
4053
|
* @param {AtRule} at the `@media` at-rule
|
|
3739
4054
|
*/
|
|
3740
4055
|
const collectMediaQuery = (at) => {
|
|
3741
|
-
const prelude = A.
|
|
4056
|
+
const prelude = A.children(at);
|
|
3742
4057
|
const start = mediaTrimStart(prelude, 0, prelude.length);
|
|
3743
4058
|
const end = mediaTrimEnd(prelude, start, prelude.length);
|
|
3744
4059
|
if (start >= end || !hasCustomMediaRef(prelude, start, end)) return;
|
|
@@ -3776,7 +4091,9 @@ class CssParser extends Parser {
|
|
|
3776
4091
|
const value = resolveCustomMediaValue(node.use.name, resolving);
|
|
3777
4092
|
if (node.use.invalid) return node.text;
|
|
3778
4093
|
if (value.kind === "boolean") return value.value;
|
|
3779
|
-
if (value.kind === "condition")
|
|
4094
|
+
if (value.kind === "condition") {
|
|
4095
|
+
return mediaConditionFor(value.text, node.use.slot);
|
|
4096
|
+
}
|
|
3780
4097
|
if (value.kind === "type" && node.use.leading) return value.text;
|
|
3781
4098
|
return node.text;
|
|
3782
4099
|
}
|
|
@@ -3841,7 +4158,7 @@ class CssParser extends Parser {
|
|
|
3841
4158
|
new ConstDependency("", [start, ruleEnd])
|
|
3842
4159
|
);
|
|
3843
4160
|
|
|
3844
|
-
const prelude = A.
|
|
4161
|
+
const prelude = A.children(at);
|
|
3845
4162
|
let i = 0;
|
|
3846
4163
|
while (i < prelude.length && A.type(prelude[i]) === NodeType.Whitespace) {
|
|
3847
4164
|
i++;
|
|
@@ -3856,7 +4173,7 @@ class CssParser extends Parser {
|
|
|
3856
4173
|
) {
|
|
3857
4174
|
return;
|
|
3858
4175
|
}
|
|
3859
|
-
const name = A.
|
|
4176
|
+
const name = A.source(nameNode);
|
|
3860
4177
|
if (!isDashedIdentifier(name)) return;
|
|
3861
4178
|
const list = input.slice(A.end(nameNode), end).trim();
|
|
3862
4179
|
if (list.length === 0) return;
|
|
@@ -3877,10 +4194,10 @@ class CssParser extends Parser {
|
|
|
3877
4194
|
next &&
|
|
3878
4195
|
A.type(next) === NodeType.Ident &&
|
|
3879
4196
|
A.end(t) === A.start(next) &&
|
|
3880
|
-
isDashedIdentifier(A.
|
|
4197
|
+
isDashedIdentifier(A.source(next))
|
|
3881
4198
|
) {
|
|
3882
4199
|
(customSelectorUses || (customSelectorUses = [])).push({
|
|
3883
|
-
name: A.
|
|
4200
|
+
name: A.source(next),
|
|
3884
4201
|
start: A.start(t),
|
|
3885
4202
|
end: A.end(next)
|
|
3886
4203
|
});
|
|
@@ -3891,6 +4208,43 @@ class CssParser extends Parser {
|
|
|
3891
4208
|
}
|
|
3892
4209
|
};
|
|
3893
4210
|
|
|
4211
|
+
/**
|
|
4212
|
+
* The selector list a `@custom-selector` name stands for, each name it reads
|
|
4213
|
+
* written as `:is(…)` in turn, memoized; undefined when unknown or on a cycle.
|
|
4214
|
+
* @param {string} name the dashed ident
|
|
4215
|
+
* @param {Set<string>} resolving names currently being resolved
|
|
4216
|
+
* @returns {string | undefined} the list
|
|
4217
|
+
*/
|
|
4218
|
+
const resolveCustomSelector = (name, resolving) => {
|
|
4219
|
+
const cached = customSelectorValues && customSelectorValues.get(name);
|
|
4220
|
+
if (cached !== undefined) return cached === null ? undefined : cached;
|
|
4221
|
+
const list = customSelectorDefs && customSelectorDefs.get(name);
|
|
4222
|
+
if (list === undefined || resolving.has(name)) return undefined;
|
|
4223
|
+
resolving.add(name);
|
|
4224
|
+
/** @type {string | null} */
|
|
4225
|
+
let written = "";
|
|
4226
|
+
let at = 0;
|
|
4227
|
+
for (const found of customSelectorNames(list)) {
|
|
4228
|
+
if (!customSelectorDefs || !customSelectorDefs.has(found.name)) {
|
|
4229
|
+
continue;
|
|
4230
|
+
}
|
|
4231
|
+
const inner = resolveCustomSelector(found.name, resolving);
|
|
4232
|
+
if (inner === undefined) {
|
|
4233
|
+
written = null;
|
|
4234
|
+
break;
|
|
4235
|
+
}
|
|
4236
|
+
written += `${list.slice(at, found.start)}:is(${inner})`;
|
|
4237
|
+
at = found.end;
|
|
4238
|
+
}
|
|
4239
|
+
if (written !== null) written += list.slice(at);
|
|
4240
|
+
resolving.delete(name);
|
|
4241
|
+
(customSelectorValues || (customSelectorValues = new Map())).set(
|
|
4242
|
+
name,
|
|
4243
|
+
written
|
|
4244
|
+
);
|
|
4245
|
+
return written === null ? undefined : written;
|
|
4246
|
+
};
|
|
4247
|
+
|
|
3894
4248
|
/**
|
|
3895
4249
|
* Rewrite the collected `@custom-media` / `@custom-selector` uses now that all (possibly later-defined) definitions are known; warns on invalid, unknown, or media-type-in-a-non-leading-position custom-media uses.
|
|
3896
4250
|
*/
|
|
@@ -3953,7 +4307,12 @@ class CssParser extends Parser {
|
|
|
3953
4307
|
(value.kind === "type" && use.leading)
|
|
3954
4308
|
) {
|
|
3955
4309
|
module.addPresentationalDependency(
|
|
3956
|
-
new ConstDependency(
|
|
4310
|
+
new ConstDependency(
|
|
4311
|
+
value.kind === "condition"
|
|
4312
|
+
? mediaConditionFor(value.text, use.slot)
|
|
4313
|
+
: value.text,
|
|
4314
|
+
[use.start, use.end]
|
|
4315
|
+
)
|
|
3957
4316
|
);
|
|
3958
4317
|
}
|
|
3959
4318
|
}
|
|
@@ -3961,7 +4320,7 @@ class CssParser extends Parser {
|
|
|
3961
4320
|
}
|
|
3962
4321
|
if (customSelectorUses) {
|
|
3963
4322
|
for (const use of customSelectorUses) {
|
|
3964
|
-
const list =
|
|
4323
|
+
const list = resolveCustomSelector(use.name, new Set());
|
|
3965
4324
|
if (list === undefined) continue;
|
|
3966
4325
|
module.addPresentationalDependency(
|
|
3967
4326
|
new ConstDependency(`:is(${list})`, [use.start, use.end])
|
|
@@ -4039,7 +4398,7 @@ class CssParser extends Parser {
|
|
|
4039
4398
|
parsedKeywords = Object.create(null);
|
|
4040
4399
|
break;
|
|
4041
4400
|
case NodeType.Delim:
|
|
4042
|
-
afterExclamation = A.
|
|
4401
|
+
afterExclamation = A.source(cv) === "!";
|
|
4043
4402
|
break;
|
|
4044
4403
|
case NodeType.Ident: {
|
|
4045
4404
|
if (isGridTemplate) break;
|
|
@@ -4047,7 +4406,7 @@ class CssParser extends Parser {
|
|
|
4047
4406
|
afterExclamation = false;
|
|
4048
4407
|
break;
|
|
4049
4408
|
}
|
|
4050
|
-
const identifier = A.
|
|
4409
|
+
const identifier = A.source(cv);
|
|
4051
4410
|
// `view-transition-name: --foo` / `counter-reset: --foo` — a dashed name scopes as a custom property under `dashedIdents`, not as a plain ident export.
|
|
4052
4411
|
if (
|
|
4053
4412
|
(isViewTransitionProperty || isCounterProperty) &&
|
|
@@ -4058,14 +4417,46 @@ class CssParser extends Parser {
|
|
|
4058
4417
|
}
|
|
4059
4418
|
break;
|
|
4060
4419
|
}
|
|
4420
|
+
const def =
|
|
4421
|
+
isGridProperty || icssDefinitions.size === 0
|
|
4422
|
+
? undefined
|
|
4423
|
+
: icssDefinitions.get(identifier);
|
|
4424
|
+
let resolved = identifier;
|
|
4425
|
+
if (def !== undefined) {
|
|
4426
|
+
if (def.importName) {
|
|
4427
|
+
// The property rides along: its keywords stay unscoped.
|
|
4428
|
+
const reference = /** @type {string[]} */ (
|
|
4429
|
+
getReexport(identifier)
|
|
4430
|
+
);
|
|
4431
|
+
addResolvedExport(
|
|
4432
|
+
identifier,
|
|
4433
|
+
A.start(cv),
|
|
4434
|
+
A.end(cv),
|
|
4435
|
+
CssIcssExportDependency.EXPORT_MODE.RESOLVED_REFERENCE,
|
|
4436
|
+
[reference[0], reference[1], reference[2], declPropertyName]
|
|
4437
|
+
);
|
|
4438
|
+
break;
|
|
4439
|
+
}
|
|
4440
|
+
// `@value` resolves first: what isn't still a name, or is now a
|
|
4441
|
+
// keyword, is substituted as is rather than scoped.
|
|
4442
|
+
resolved =
|
|
4443
|
+
typeof def.value === "string" ? def.value.trim() : "";
|
|
4444
|
+
if (!isSimpleIdentifier(resolved)) {
|
|
4445
|
+
emitICSSSymbol(identifier, A.start(cv), A.end(cv));
|
|
4446
|
+
break;
|
|
4447
|
+
}
|
|
4448
|
+
}
|
|
4061
4449
|
// Values are almost always lowercase already — avoid the copy.
|
|
4062
|
-
const keyword = toLowerCaseIfNeeded(
|
|
4450
|
+
const keyword = toLowerCaseIfNeeded(resolved);
|
|
4063
4451
|
parsedKeywords[keyword] =
|
|
4064
4452
|
typeof parsedKeywords[keyword] !== "undefined"
|
|
4065
4453
|
? parsedKeywords[keyword] + 1
|
|
4066
4454
|
: 0;
|
|
4067
4455
|
const limit = keywords.get(keyword);
|
|
4068
4456
|
if (limit !== undefined && parsedKeywords[keyword] < limit) {
|
|
4457
|
+
if (def !== undefined) {
|
|
4458
|
+
emitICSSSymbol(identifier, A.start(cv), A.end(cv));
|
|
4459
|
+
}
|
|
4069
4460
|
break;
|
|
4070
4461
|
}
|
|
4071
4462
|
emit(A.start(cv), A.end(cv));
|
|
@@ -4098,7 +4489,7 @@ class CssParser extends Parser {
|
|
|
4098
4489
|
}
|
|
4099
4490
|
case NodeType.SimpleBlock: {
|
|
4100
4491
|
const block = /** @type {SimpleBlock} */ (cv);
|
|
4101
|
-
if (A.
|
|
4492
|
+
if (A.value(block) === "[") {
|
|
4102
4493
|
// Collect identifiers until the first non-ident token (`<line-names> = '[' <custom-ident>* ']'`).
|
|
4103
4494
|
for (const inner of A.children(block)) {
|
|
4104
4495
|
if (A.type(inner) === NodeType.Whitespace) continue;
|
|
@@ -4115,7 +4506,7 @@ class CssParser extends Parser {
|
|
|
4115
4506
|
if (
|
|
4116
4507
|
isGridTemplate ||
|
|
4117
4508
|
(isCounterProperty &&
|
|
4118
|
-
|
|
4509
|
+
asciiCaseInsensitiveMatch(A.name(cv), "reversed"))
|
|
4119
4510
|
) {
|
|
4120
4511
|
walkExports(A.children(cv));
|
|
4121
4512
|
}
|
|
@@ -4143,7 +4534,7 @@ class CssParser extends Parser {
|
|
|
4143
4534
|
) => {
|
|
4144
4535
|
const acceptIdent = isKeyframes || isCounterStyle || isContainer;
|
|
4145
4536
|
const acceptString = isKeyframes;
|
|
4146
|
-
for (const cv of A.
|
|
4537
|
+
for (const cv of A.children(at)) {
|
|
4147
4538
|
const cvType = A.type(cv);
|
|
4148
4539
|
if (cvType === NodeType.Whitespace) continue;
|
|
4149
4540
|
if (cvType === NodeType.String) {
|
|
@@ -4162,7 +4553,7 @@ class CssParser extends Parser {
|
|
|
4162
4553
|
break;
|
|
4163
4554
|
}
|
|
4164
4555
|
if (cvType === NodeType.Function) {
|
|
4165
|
-
if (
|
|
4556
|
+
if (asciiCaseInsensitiveMatch(A.name(cv), "local")) {
|
|
4166
4557
|
pure.markLocal();
|
|
4167
4558
|
}
|
|
4168
4559
|
break;
|
|
@@ -4186,7 +4577,7 @@ class CssParser extends Parser {
|
|
|
4186
4577
|
// Rollback point: nested walks append to the shared list; the exit
|
|
4187
4578
|
// truncates back to this length (no per-rule copy).
|
|
4188
4579
|
const savedLocalIdentifierCount = currentRule.localIdentifiers.length;
|
|
4189
|
-
const name = `@${toLowerCaseIfNeeded(A.
|
|
4580
|
+
const name = `@${toLowerCaseIfNeeded(A.name(at))}`;
|
|
4190
4581
|
// The dispatch below is the only place a prelude is rewritten ahead
|
|
4191
4582
|
// of the value visitors, so the marks live exactly as long as it.
|
|
4192
4583
|
if (handledPreludeIdents.size !== 0) handledPreludeIdents.clear();
|
|
@@ -4198,7 +4589,7 @@ class CssParser extends Parser {
|
|
|
4198
4589
|
"'@namespace' is not supported in bundled CSS",
|
|
4199
4590
|
locConverter,
|
|
4200
4591
|
A.start(at),
|
|
4201
|
-
A.
|
|
4592
|
+
A.endOf(Part.name, at)
|
|
4202
4593
|
);
|
|
4203
4594
|
break;
|
|
4204
4595
|
}
|
|
@@ -4209,7 +4600,7 @@ class CssParser extends Parser {
|
|
|
4209
4600
|
source.charCodeAt(atEnd) === CC_SEMICOLON ? atEnd + 1 : atEnd;
|
|
4210
4601
|
const dep = new ConstDependency("", [A.start(at), atRuleEnd]);
|
|
4211
4602
|
module.addPresentationalDependency(dep);
|
|
4212
|
-
const string = A.
|
|
4603
|
+
const string = A.children(at).find(
|
|
4213
4604
|
(v) => A.type(v) !== NodeType.Whitespace
|
|
4214
4605
|
);
|
|
4215
4606
|
if (string && A.type(string) === NodeType.String) {
|
|
@@ -4280,11 +4671,11 @@ class CssParser extends Parser {
|
|
|
4280
4671
|
// `@scope (.x) to (.y)` — walk the prelude as a selector list.
|
|
4281
4672
|
if (
|
|
4282
4673
|
isModules &&
|
|
4283
|
-
|
|
4284
|
-
A.
|
|
4674
|
+
asciiCaseInsensitiveMatch(A.name(at), "scope") &&
|
|
4675
|
+
A.children(at).length > 0
|
|
4285
4676
|
) {
|
|
4286
4677
|
walkSelectorList(
|
|
4287
|
-
A.
|
|
4678
|
+
A.children(at),
|
|
4288
4679
|
/** @type {"local" | "global"} */ (
|
|
4289
4680
|
mode === "local" ? "local" : "global"
|
|
4290
4681
|
)
|
|
@@ -4301,7 +4692,7 @@ class CssParser extends Parser {
|
|
|
4301
4692
|
dashed.active = false;
|
|
4302
4693
|
// `@import` url() is the import target — only walk its prelude for url deps on malformed-import recovery.
|
|
4303
4694
|
if (this.options.url && (name !== "@import" || currentUrlRecovery)) {
|
|
4304
|
-
lastTokenEndForComments = A.
|
|
4695
|
+
lastTokenEndForComments = A.endOf(Part.name, at);
|
|
4305
4696
|
}
|
|
4306
4697
|
// Dashed-ident scoping over the prelude (the Ident / Function visitors emit).
|
|
4307
4698
|
dashed.active = Boolean(
|
|
@@ -4340,19 +4731,16 @@ class CssParser extends Parser {
|
|
|
4340
4731
|
|
|
4341
4732
|
// pure.stack push for block-bearing at-rules (pure-off builds skip
|
|
4342
4733
|
// the frame object — every consumer inside is a no-op then).
|
|
4343
|
-
const
|
|
4344
|
-
const
|
|
4345
|
-
|
|
4346
|
-
const atBlockStart = A.blockStart(at);
|
|
4347
|
-
if (pure.enabled && atHasBlock && atBlockStart !== -1) {
|
|
4734
|
+
const atBlockStart = A.startOf(Part.block, at);
|
|
4735
|
+
const atHasBlock = atBlockStart !== -1;
|
|
4736
|
+
if (pure.enabled && atHasBlock) {
|
|
4348
4737
|
const isAtRulePrelude = isPureBodyAtRule(name);
|
|
4349
4738
|
if (isAtRulePrelude) pure.finalizeSelector();
|
|
4350
4739
|
pure.enterBlock({
|
|
4351
4740
|
isRulePrelude: isAtRulePrelude,
|
|
4352
4741
|
treatAsLeaf: atTreatAsLeaf,
|
|
4353
4742
|
ownSkip: atSkipChildren,
|
|
4354
|
-
|
|
4355
|
-
childRules: atChildRules,
|
|
4743
|
+
rule: at,
|
|
4356
4744
|
preludeStart: A.start(at),
|
|
4357
4745
|
preludeEnd: atBlockStart
|
|
4358
4746
|
});
|
|
@@ -4397,7 +4785,7 @@ class CssParser extends Parser {
|
|
|
4397
4785
|
// One prelude materialization per rule, shared by the scans below
|
|
4398
4786
|
// (null in plain mode, which never reads the array).
|
|
4399
4787
|
const rulePrelude =
|
|
4400
|
-
isModules || mayHaveCustomSelectors ? A.
|
|
4788
|
+
isModules || mayHaveCustomSelectors ? A.children(rule) : null;
|
|
4401
4789
|
// `:--name` custom-selector references (dashed idents never collide with the `:import`/`:export` ICSS preludes below).
|
|
4402
4790
|
if (mayHaveCustomSelectors && rulePrelude !== null) {
|
|
4403
4791
|
scanCustomSelectorUses(rulePrelude);
|
|
@@ -4413,12 +4801,12 @@ class CssParser extends Parser {
|
|
|
4413
4801
|
const secondType = A.type(second);
|
|
4414
4802
|
const rawName =
|
|
4415
4803
|
secondType === NodeType.Ident
|
|
4416
|
-
? A.
|
|
4804
|
+
? A.source(second)
|
|
4417
4805
|
: secondType === NodeType.Function
|
|
4418
|
-
?
|
|
4806
|
+
? rawNameOf(second)
|
|
4419
4807
|
: "";
|
|
4420
|
-
const isImport =
|
|
4421
|
-
if (isImport ||
|
|
4808
|
+
const isImport = asciiCaseInsensitiveMatch(rawName, "import");
|
|
4809
|
+
if (isImport || asciiCaseInsensitiveMatch(rawName, "export")) {
|
|
4422
4810
|
if (topLevel) {
|
|
4423
4811
|
const startColon = A.start(rulePrelude[firstIdx]);
|
|
4424
4812
|
const endAfterBody = processImportOrExport(
|
|
@@ -4429,13 +4817,6 @@ class CssParser extends Parser {
|
|
|
4429
4817
|
module.addPresentationalDependency(
|
|
4430
4818
|
new ConstDependency("", [startColon, endAfterBody])
|
|
4431
4819
|
);
|
|
4432
|
-
if (A.blockStart(rule) !== -1) {
|
|
4433
|
-
A.setBlockEnd(rule, endAfterBody);
|
|
4434
|
-
}
|
|
4435
|
-
A.setEnd(rule, endAfterBody);
|
|
4436
|
-
} else if (A.blockStart(rule) !== -1) {
|
|
4437
|
-
// Nested `:import` / `:export` — leave the body alone.
|
|
4438
|
-
A.setEnd(rule, A.blockEnd(rule));
|
|
4439
4820
|
}
|
|
4440
4821
|
// Don't recurse into the body — handled inline above.
|
|
4441
4822
|
path.skipChildren();
|
|
@@ -4477,7 +4858,7 @@ class CssParser extends Parser {
|
|
|
4477
4858
|
dashed.active = false;
|
|
4478
4859
|
dashed.emit = false;
|
|
4479
4860
|
if (this.options.url && A.childCount(rule) > 0) {
|
|
4480
|
-
lastTokenEndForComments = A.start(A.
|
|
4861
|
+
lastTokenEndForComments = A.start(A.child(0, rule));
|
|
4481
4862
|
}
|
|
4482
4863
|
// Dashed-ident scoping for the deprecated `--foo: { … }` custom-property-set syntax (prelude starts with a dashed-ident).
|
|
4483
4864
|
if (
|
|
@@ -4501,13 +4882,12 @@ class CssParser extends Parser {
|
|
|
4501
4882
|
}
|
|
4502
4883
|
// Pure-mode: report an impure prelude (if leaf-ish) and push the inherited-context frame before walking the body.
|
|
4503
4884
|
if (!pure.enabled) return;
|
|
4504
|
-
const ruleBlockStart = A.
|
|
4885
|
+
const ruleBlockStart = A.startOf(Part.block, rule);
|
|
4505
4886
|
pure.enterBlock({
|
|
4506
4887
|
isRulePrelude: true,
|
|
4507
4888
|
treatAsLeaf: false,
|
|
4508
4889
|
ownSkip: false,
|
|
4509
|
-
|
|
4510
|
-
childRules: A.childRules(rule),
|
|
4890
|
+
rule,
|
|
4511
4891
|
preludeStart: A.start(rule),
|
|
4512
4892
|
preludeEnd: ruleBlockStart !== -1 ? ruleBlockStart : A.end(rule)
|
|
4513
4893
|
});
|
|
@@ -4534,7 +4914,7 @@ class CssParser extends Parser {
|
|
|
4534
4914
|
dashed.active = false;
|
|
4535
4915
|
dashed.emit = false;
|
|
4536
4916
|
// Position `lastTokenEndForComments` just past the `:` so a magic comment before a url() is found (every mode).
|
|
4537
|
-
let colonPos = A.
|
|
4917
|
+
let colonPos = A.endOf(Part.name, decl);
|
|
4538
4918
|
while (
|
|
4539
4919
|
colonPos < source.length &&
|
|
4540
4920
|
source.charCodeAt(colonPos) !== CC_COLON
|
|
@@ -4549,8 +4929,8 @@ class CssParser extends Parser {
|
|
|
4549
4929
|
// Property-name analysis and value exports are CSS-Modules-only; a plain
|
|
4550
4930
|
// stylesheet's declarations need no per-decl name slice / known-property lookup.
|
|
4551
4931
|
if (!isModules) return;
|
|
4552
|
-
const nameStart = A.
|
|
4553
|
-
const nameEnd = A.
|
|
4932
|
+
const nameStart = A.startOf(Part.name, decl);
|
|
4933
|
+
const nameEnd = A.endOf(Part.name, decl);
|
|
4554
4934
|
// Range-based name analysis — the common declaration never
|
|
4555
4935
|
// slices its name out of the source.
|
|
4556
4936
|
/** @type {string | undefined} */
|
|
@@ -4568,7 +4948,7 @@ class CssParser extends Parser {
|
|
|
4568
4948
|
} else {
|
|
4569
4949
|
// Vendor-prefixed, degenerate short, or an escaped name that is
|
|
4570
4950
|
// not dashed after all — rare, string path.
|
|
4571
|
-
declName = A.
|
|
4951
|
+
declName = A.name(decl);
|
|
4572
4952
|
declPropertyName = toLowerCaseIfNeeded(
|
|
4573
4953
|
declName.replace(VENDOR_PREFIX, "")
|
|
4574
4954
|
);
|
|
@@ -4590,8 +4970,18 @@ class CssParser extends Parser {
|
|
|
4590
4970
|
currentRule.hasLocalAnchor &&
|
|
4591
4971
|
(declPropertyName !== undefined
|
|
4592
4972
|
? COMPOSES_PROPERTY.test(declPropertyName)
|
|
4593
|
-
:
|
|
4594
|
-
|
|
4973
|
+
: rangeAsciiCaseInsensitiveMatch(
|
|
4974
|
+
source,
|
|
4975
|
+
nameStart,
|
|
4976
|
+
nameEnd,
|
|
4977
|
+
"composes"
|
|
4978
|
+
) ||
|
|
4979
|
+
rangeAsciiCaseInsensitiveMatch(
|
|
4980
|
+
source,
|
|
4981
|
+
nameStart,
|
|
4982
|
+
nameEnd,
|
|
4983
|
+
"compose-with"
|
|
4984
|
+
));
|
|
4595
4985
|
if (currentDeclComposesSkip) emitComposesWithAnchor(decl);
|
|
4596
4986
|
const skipForComposes = currentDeclComposesSkip;
|
|
4597
4987
|
// `content: counter(name, style)` can name a scoped counter / `@counter-style` from any property, so this isn't driven by the known-property table.
|
|
@@ -4658,7 +5048,7 @@ class CssParser extends Parser {
|
|
|
4658
5048
|
);
|
|
4659
5049
|
if (ignored) return;
|
|
4660
5050
|
let value = normalizeUrl(
|
|
4661
|
-
input.slice(A.
|
|
5051
|
+
input.slice(A.startOf(Part.value, url), A.endOf(Part.value, url)),
|
|
4662
5052
|
false
|
|
4663
5053
|
);
|
|
4664
5054
|
// Ignore `url()`, `url('')` and `url("")`, they are valid by spec
|
|
@@ -4709,8 +5099,8 @@ class CssParser extends Parser {
|
|
|
4709
5099
|
enter: (path) => {
|
|
4710
5100
|
const node = path.node;
|
|
4711
5101
|
const fn = /** @type {FunctionNode} */ (node);
|
|
4712
|
-
const fnNameStart = A.
|
|
4713
|
-
const fnNameEnd = A.
|
|
5102
|
+
const fnNameStart = A.startOf(Part.name, fn);
|
|
5103
|
+
const fnNameEnd = A.endOf(Part.name, fn);
|
|
4714
5104
|
const fnNameLength = fnNameEnd - fnNameStart;
|
|
4715
5105
|
// Functions are the densest value nodes, so the name is matched by raw byte range; only a name carrying an escape (rare) pays the unescaped slice.
|
|
4716
5106
|
/** @type {string | undefined} */
|
|
@@ -4718,18 +5108,19 @@ class CssParser extends Parser {
|
|
|
4718
5108
|
let isLocalFn = false;
|
|
4719
5109
|
let isGlobalFn = false;
|
|
4720
5110
|
if (rangeHasEscape(input, fnNameStart, fnNameEnd)) {
|
|
4721
|
-
escapedName = A.
|
|
4722
|
-
isLocalFn =
|
|
4723
|
-
isGlobalFn =
|
|
5111
|
+
escapedName = A.name(fn);
|
|
5112
|
+
isLocalFn = asciiCaseInsensitiveMatch(escapedName, "local");
|
|
5113
|
+
isGlobalFn =
|
|
5114
|
+
!isLocalFn && asciiCaseInsensitiveMatch(escapedName, "global");
|
|
4724
5115
|
} else if (fnNameLength === 5) {
|
|
4725
|
-
isLocalFn =
|
|
5116
|
+
isLocalFn = rangeAsciiCaseInsensitiveMatch(
|
|
4726
5117
|
input,
|
|
4727
5118
|
fnNameStart,
|
|
4728
5119
|
fnNameEnd,
|
|
4729
5120
|
"local"
|
|
4730
5121
|
);
|
|
4731
5122
|
} else if (fnNameLength === 6) {
|
|
4732
|
-
isGlobalFn =
|
|
5123
|
+
isGlobalFn = rangeAsciiCaseInsensitiveMatch(
|
|
4733
5124
|
input,
|
|
4734
5125
|
fnNameStart,
|
|
4735
5126
|
fnNameEnd,
|
|
@@ -4747,7 +5138,8 @@ class CssParser extends Parser {
|
|
|
4747
5138
|
icssDefinitions.size !== 0
|
|
4748
5139
|
) {
|
|
4749
5140
|
// Without an escape the raw name equals the unescaped one — only the `@value`-lookup path needs the string at all.
|
|
4750
|
-
const fname =
|
|
5141
|
+
const fname =
|
|
5142
|
+
escapedName === undefined ? rawNameOf(fn) : escapedName;
|
|
4751
5143
|
if (
|
|
4752
5144
|
!(dashed.active && isDashedIdentifier(fname)) &&
|
|
4753
5145
|
icssDefinitions.has(fname)
|
|
@@ -4778,21 +5170,21 @@ class CssParser extends Parser {
|
|
|
4778
5170
|
} else if (
|
|
4779
5171
|
escapedName === undefined
|
|
4780
5172
|
? (fnNameLength === 3 &&
|
|
4781
|
-
|
|
5173
|
+
rangeAsciiCaseInsensitiveMatch(
|
|
4782
5174
|
input,
|
|
4783
5175
|
fnNameStart,
|
|
4784
5176
|
fnNameEnd,
|
|
4785
5177
|
"var"
|
|
4786
5178
|
)) ||
|
|
4787
5179
|
(fnNameLength === 5 &&
|
|
4788
|
-
|
|
5180
|
+
rangeAsciiCaseInsensitiveMatch(
|
|
4789
5181
|
input,
|
|
4790
5182
|
fnNameStart,
|
|
4791
5183
|
fnNameEnd,
|
|
4792
5184
|
"style"
|
|
4793
5185
|
))
|
|
4794
|
-
:
|
|
4795
|
-
|
|
5186
|
+
: asciiCaseInsensitiveMatch(escapedName, "var") ||
|
|
5187
|
+
asciiCaseInsensitiveMatch(escapedName, "style")
|
|
4796
5188
|
) {
|
|
4797
5189
|
// `var(--foo, …)` / `style(--foo, …)`: emit the first ident; the fallback doesn't self-emit.
|
|
4798
5190
|
processDashedIdentInVarFunction(fn);
|
|
@@ -4814,13 +5206,13 @@ class CssParser extends Parser {
|
|
|
4814
5206
|
},
|
|
4815
5207
|
[NodeType.Ident](path) {
|
|
4816
5208
|
const node = path.node;
|
|
4817
|
-
//
|
|
4818
|
-
// and ICSS context
|
|
4819
|
-
// no work, and idents are the most common node, so skipping
|
|
4820
|
-
// `value` slice matters. With no `@value
|
|
4821
|
-
// probe can never hit, so it
|
|
4822
|
-
// probe reads two char codes instead of slicing
|
|
4823
|
-
// match,
|
|
5209
|
+
// WHY: a fast exit before slicing the ident value. Outside dashed-ident
|
|
5210
|
+
// scoping and ICSS context — any non-CSS-Modules stylesheet — a bare
|
|
5211
|
+
// ident carries no work, and idents are the most common node, so skipping
|
|
5212
|
+
// the per-ident `value` slice matters. With no `@value` or `:import`
|
|
5213
|
+
// definitions the ICSS probe can never hit, so it does not warrant the
|
|
5214
|
+
// slice either. The dashed probe reads two char codes instead of slicing,
|
|
5215
|
+
// and an escaped dash does not match, as in the string form.
|
|
4824
5216
|
const dashedActive = dashed.active;
|
|
4825
5217
|
const icss = icssActive() && icssDefinitions.size !== 0;
|
|
4826
5218
|
if (!dashedActive && !icss) return;
|
|
@@ -4839,15 +5231,15 @@ class CssParser extends Parser {
|
|
|
4839
5231
|
let j = path.index + 1;
|
|
4840
5232
|
while (
|
|
4841
5233
|
j < count &&
|
|
4842
|
-
A.type(A.
|
|
5234
|
+
A.type(A.child(j, parent)) === NodeType.Whitespace
|
|
4843
5235
|
) {
|
|
4844
5236
|
j++;
|
|
4845
5237
|
}
|
|
4846
|
-
const fromIdent = j < count ? A.
|
|
5238
|
+
const fromIdent = j < count ? A.child(j, parent) : undefined;
|
|
4847
5239
|
if (
|
|
4848
5240
|
fromIdent &&
|
|
4849
5241
|
A.type(fromIdent) === NodeType.Ident &&
|
|
4850
|
-
|
|
5242
|
+
rangeAsciiCaseInsensitiveMatch(
|
|
4851
5243
|
input,
|
|
4852
5244
|
A.start(fromIdent),
|
|
4853
5245
|
A.end(fromIdent),
|
|
@@ -4857,11 +5249,11 @@ class CssParser extends Parser {
|
|
|
4857
5249
|
j++;
|
|
4858
5250
|
while (
|
|
4859
5251
|
j < count &&
|
|
4860
|
-
A.type(A.
|
|
5252
|
+
A.type(A.child(j, parent)) === NodeType.Whitespace
|
|
4861
5253
|
) {
|
|
4862
5254
|
j++;
|
|
4863
5255
|
}
|
|
4864
|
-
const sourceNode = j < count ? A.
|
|
5256
|
+
const sourceNode = j < count ? A.child(j, parent) : undefined;
|
|
4865
5257
|
if (
|
|
4866
5258
|
sourceNode &&
|
|
4867
5259
|
A.type(sourceNode) === NodeType.Ident &&
|
|
@@ -4894,7 +5286,7 @@ class CssParser extends Parser {
|
|
|
4894
5286
|
// Already rewritten as a counter / counter-style name — a second dep would overlap the same range.
|
|
4895
5287
|
if (dashed.counterArgs) return;
|
|
4896
5288
|
// Deferred: only the ICSS probe needs the ident's string value.
|
|
4897
|
-
const identValue = A.
|
|
5289
|
+
const identValue = A.source(node);
|
|
4898
5290
|
if (!icssDefinitions.has(identValue)) return;
|
|
4899
5291
|
// Already scoped by the enclosing `var()` handler.
|
|
4900
5292
|
if (
|
|
@@ -4915,12 +5307,9 @@ class CssParser extends Parser {
|
|
|
4915
5307
|
emitICSSSymbol(identValue, identStart, identEnd);
|
|
4916
5308
|
}
|
|
4917
5309
|
};
|
|
4918
|
-
// `as` selects the top-level production
|
|
4919
|
-
// block's contents,
|
|
4920
|
-
//
|
|
4921
|
-
// (per-source) is passed to `process`. One skip set: selector prelude +
|
|
4922
|
-
// unread value leaves (non-modules only; CSS Modules needs its selectors
|
|
4923
|
-
// and ICSS-captured values).
|
|
5310
|
+
// `as` selects the top-level production of §5.3: a `style` attribute is a
|
|
5311
|
+
// block's contents, anything else a full stylesheet. `as` and `skip` are
|
|
5312
|
+
// per-parse, so only the per-source `locConverter` reaches `process`.
|
|
4924
5313
|
new SourceProcessor()
|
|
4925
5314
|
.use(/** @type {VisitorMap} */ (visitors))
|
|
4926
5315
|
.process(source, {
|