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