webpack 5.111.1 → 5.112.1

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 (793) hide show
  1. package/README.md +1 -1
  2. package/bin/webpack.js +13 -7
  3. package/lib/Chunk.js +3 -966
  4. package/lib/Compilation.js +373 -163
  5. package/lib/Compiler.js +31 -44
  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 +21 -13
  25. package/lib/asset/AssetBytesParser.js +12 -10
  26. package/lib/asset/AssetGenerator.js +71 -69
  27. package/lib/asset/AssetModule.js +13 -2
  28. package/lib/asset/AssetModulesPlugin.js +10 -12
  29. package/lib/asset/AssetParser.js +10 -10
  30. package/lib/asset/AssetSourceGenerator.js +23 -15
  31. package/lib/asset/AssetSourceParser.js +12 -10
  32. package/lib/asset/RawDataUrlModule.js +17 -10
  33. package/lib/asset/WebManifestGenerator.js +17 -12
  34. package/lib/asset/WebManifestParser.js +8 -8
  35. package/lib/async-modules/AsyncModuleHelpers.js +12 -5
  36. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
  37. package/lib/async-modules/InferAsyncModulesPlugin.js +9 -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} +6 -6
  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 +13 -19
  47. package/lib/cache/ResolverCachePlugin.js +65 -11
  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} +209 -212
  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} +14 -164
  55. package/lib/config/defaults.js +166 -59
  56. package/lib/config/getClaimedAssetTypes.js +22 -14
  57. package/lib/config/normalization.js +18 -7
  58. package/lib/config/target.js +11 -1
  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 +37 -26
  76. package/lib/context/ContextModuleFactory.js +14 -11
  77. package/lib/context/ContextReplacementPlugin.js +6 -12
  78. package/lib/css/CssGenerator.js +78 -68
  79. package/lib/css/CssInjectStyleRuntimeModule.js +36 -30
  80. package/lib/css/CssLoadingRuntimeModule.js +77 -44
  81. package/lib/css/CssModule.js +37 -29
  82. package/lib/css/CssModulesPlugin.js +129 -45
  83. package/lib/css/CssParser.js +714 -322
  84. package/lib/css/CssServerStylesRuntimeModule.js +3 -3
  85. package/lib/{util → css}/conventions.js +1 -1
  86. package/lib/css/cssMinify.js +110 -37
  87. package/lib/css/data.js +6990 -5125
  88. package/lib/css/syntax-parser.js +20734 -0
  89. package/lib/css/syntax-printer.js +6092 -0
  90. package/lib/css/syntax.js +37 -18686
  91. package/lib/debug/ProfilingPlugin.js +106 -51
  92. package/lib/{DefinePlugin.js → define/DefinePlugin.js} +416 -55
  93. package/lib/{DotenvPlugin.js → define/DotenvPlugin.js} +19 -15
  94. package/lib/{EnvironmentPlugin.js → define/EnvironmentPlugin.js} +6 -4
  95. package/lib/deno/DenoTargetPlugin.js +1 -1
  96. package/lib/dependencies/ConstDependency.js +3 -120
  97. package/lib/dependencies/ContextElementDependency.js +5 -172
  98. package/lib/dependencies/NullDependency.js +3 -37
  99. package/lib/dependencies/{AMDDefineDependency.js → amd/AMDDefineDependency.js} +12 -11
  100. package/lib/dependencies/{AMDDefineDependencyParserPlugin.js → amd/AMDDefineDependencyParserPlugin.js} +10 -11
  101. package/lib/dependencies/{AMDPlugin.js → amd/AMDPlugin.js} +11 -11
  102. package/lib/dependencies/{AMDRequireArrayDependency.js → amd/AMDRequireArrayDependency.js} +15 -13
  103. package/lib/dependencies/{AMDRequireContextDependency.js → amd/AMDRequireContextDependency.js} +11 -10
  104. package/lib/dependencies/{AMDRequireDependenciesBlock.js → amd/AMDRequireDependenciesBlock.js} +7 -6
  105. package/lib/dependencies/{AMDRequireDependenciesBlockParserPlugin.js → amd/AMDRequireDependenciesBlockParserPlugin.js} +14 -11
  106. package/lib/dependencies/{AMDRequireDependency.js → amd/AMDRequireDependency.js} +13 -12
  107. package/lib/dependencies/{AMDRequireItemDependency.js → amd/AMDRequireItemDependency.js} +8 -7
  108. package/lib/dependencies/{AMDRuntimeModules.js → amd/AMDRuntimeModules.js} +3 -3
  109. package/lib/dependencies/{LocalModule.js → amd/LocalModule.js} +8 -4
  110. package/lib/dependencies/{LocalModuleDependency.js → amd/LocalModuleDependency.js} +17 -10
  111. package/lib/dependencies/{LocalModulesHelpers.js → amd/LocalModulesHelpers.js} +1 -1
  112. package/lib/dependencies/{RequireJsStuffPlugin.js → amd/RequireJsStuffPlugin.js} +9 -9
  113. package/lib/dependencies/{UnsupportedDependency.js → amd/UnsupportedDependency.js} +11 -10
  114. package/lib/dependencies/{CommonJsDependencyHelpers.js → commonjs/CommonJsDependencyHelpers.js} +8 -9
  115. package/lib/dependencies/{CommonJsExportRequireDependency.js → commonjs/CommonJsExportRequireDependency.js} +166 -36
  116. package/lib/dependencies/{CommonJsExportsDependency.js → commonjs/CommonJsExportsDependency.js} +15 -14
  117. package/lib/dependencies/{CommonJsExportsParserPlugin.js → commonjs/CommonJsExportsParserPlugin.js} +154 -92
  118. package/lib/dependencies/{CommonJsFullRequireDependency.js → commonjs/CommonJsFullRequireDependency.js} +32 -24
  119. package/lib/dependencies/{CommonJsImportsParserPlugin.js → commonjs/CommonJsImportsParserPlugin.js} +36 -33
  120. package/lib/dependencies/{CommonJsObjectExportDependency.js → commonjs/CommonJsObjectExportDependency.js} +17 -16
  121. package/lib/dependencies/{CommonJsPlugin.js → commonjs/CommonJsPlugin.js} +48 -39
  122. package/lib/dependencies/{CommonJsRequireContextDependency.js → commonjs/CommonJsRequireContextDependency.js} +15 -14
  123. package/lib/dependencies/{CommonJsRequireDependency.js → commonjs/CommonJsRequireDependency.js} +33 -25
  124. package/lib/dependencies/{CommonJsSelfReferenceDependency.js → commonjs/CommonJsSelfReferenceDependency.js} +17 -16
  125. package/lib/dependencies/{ModuleDecoratorDependency.js → commonjs/ModuleDecoratorDependency.js} +16 -15
  126. package/lib/dependencies/{RequireEnsureDependenciesBlock.js → commonjs/RequireEnsureDependenciesBlock.js} +8 -7
  127. package/lib/dependencies/{RequireEnsureDependenciesBlockParserPlugin.js → commonjs/RequireEnsureDependenciesBlockParserPlugin.js} +9 -6
  128. package/lib/dependencies/{RequireEnsureDependency.js → commonjs/RequireEnsureDependency.js} +13 -12
  129. package/lib/dependencies/{RequireEnsureItemDependency.js → commonjs/RequireEnsureItemDependency.js} +7 -6
  130. package/lib/dependencies/{RequireEnsurePlugin.js → commonjs/RequireEnsurePlugin.js} +8 -8
  131. package/lib/dependencies/{RequireHeaderDependency.js → commonjs/RequireHeaderDependency.js} +14 -13
  132. package/lib/dependencies/{RequireIncludeDependency.js → commonjs/RequireIncludeDependency.js} +13 -12
  133. package/lib/dependencies/{RequireIncludeDependencyParserPlugin.js → commonjs/RequireIncludeDependencyParserPlugin.js} +3 -27
  134. package/lib/dependencies/{RequireIncludePlugin.js → commonjs/RequireIncludePlugin.js} +4 -4
  135. package/lib/dependencies/{RequireResolveContextDependency.js → commonjs/RequireResolveContextDependency.js} +11 -10
  136. package/lib/dependencies/{RequireResolveDependency.js → commonjs/RequireResolveDependency.js} +12 -11
  137. package/lib/dependencies/{RequireResolveHeaderDependency.js → commonjs/RequireResolveHeaderDependency.js} +13 -12
  138. package/lib/dependencies/commonjs/TopLevelThisParserPlugin.js +59 -0
  139. package/lib/dependencies/{ContextDependency.js → context/ContextDependency.js} +15 -14
  140. package/lib/dependencies/{ContextDependencyHelpers.js → context/ContextDependencyHelpers.js} +31 -9
  141. package/lib/dependencies/{ContextDependencyTemplateAsId.js → context/ContextDependencyTemplateAsId.js} +3 -3
  142. package/lib/dependencies/{ContextDependencyTemplateAsRequireCall.js → context/ContextDependencyTemplateAsRequireCall.js} +3 -3
  143. package/lib/dependencies/context/ContextElementDependency.js +198 -0
  144. package/lib/dependencies/{ImportMetaContextDependency.js → context/ImportMetaContextDependency.js} +7 -6
  145. package/lib/dependencies/{ImportMetaContextDependencyParserPlugin.js → context/ImportMetaContextDependencyParserPlugin.js} +10 -11
  146. package/lib/dependencies/{ImportMetaContextPlugin.js → context/ImportMetaContextPlugin.js} +5 -5
  147. package/lib/dependencies/{ImportMetaGlobDependency.js → context/ImportMetaGlobDependency.js} +7 -6
  148. package/lib/dependencies/{ImportMetaGlobDependencyParserPlugin.js → context/ImportMetaGlobDependencyParserPlugin.js} +7 -10
  149. package/lib/dependencies/{ImportMetaGlobHelpers.js → context/ImportMetaGlobHelpers.js} +17 -19
  150. package/lib/dependencies/{RequireContextDependency.js → context/RequireContextDependency.js} +7 -6
  151. package/lib/dependencies/{RequireContextDependencyParserPlugin.js → context/RequireContextDependencyParserPlugin.js} +2 -2
  152. package/lib/dependencies/{RequireContextPlugin.js → context/RequireContextPlugin.js} +5 -5
  153. package/lib/dependencies/{CachedConstDependency.js → core/CachedConstDependency.js} +21 -17
  154. package/lib/dependencies/core/ConstDependency.js +131 -0
  155. package/lib/dependencies/{ImportPhase.js → core/ImportPhase.js} +5 -4
  156. package/lib/dependencies/{ModuleDependency.js → core/ModuleDependency.js} +10 -7
  157. package/lib/dependencies/{ModuleDependencyTemplateAsId.js → core/ModuleDependencyTemplateAsId.js} +3 -3
  158. package/lib/dependencies/{ModuleDependencyTemplateAsRequireId.js → core/ModuleDependencyTemplateAsRequireId.js} +2 -2
  159. package/lib/dependencies/{ModuleInitFragmentDependency.js → core/ModuleInitFragmentDependency.js} +10 -9
  160. package/lib/dependencies/core/NullDependency.js +44 -0
  161. package/lib/dependencies/{RuntimeRequirementsDependency.js → core/RuntimeRequirementsDependency.js} +10 -9
  162. package/lib/dependencies/{StaticExportsDependency.js → core/StaticExportsDependency.js} +15 -8
  163. package/lib/dependencies/{CssIcssExportDependency.js → css/CssIcssExportDependency.js} +375 -99
  164. package/lib/dependencies/{CssIcssImportDependency.js → css/CssIcssImportDependency.js} +24 -19
  165. package/lib/dependencies/{CssIcssSymbolDependency.js → css/CssIcssSymbolDependency.js} +13 -12
  166. package/lib/dependencies/{CssImportDependency.js → css/CssImportDependency.js} +15 -11
  167. package/lib/dependencies/{CssUrlDependency.js → css/CssUrlDependency.js} +25 -22
  168. package/lib/dependencies/{CreateRequireParserPlugin.js → esm/CreateRequireParserPlugin.js} +9 -9
  169. package/lib/dependencies/{HarmonyAcceptDependency.js → esm/ESMAcceptDependency.js} +41 -38
  170. package/lib/dependencies/esm/ESMAcceptImportDependency.js +39 -0
  171. package/lib/dependencies/{HarmonyCompatibilityDependency.js → esm/ESMCompatibilityDependency.js} +29 -21
  172. package/lib/dependencies/{HarmonyDetectionParserPlugin.js → esm/ESMDetectionParserPlugin.js} +20 -20
  173. package/lib/dependencies/{HarmonyEvaluatedImportSpecifierDependency.js → esm/ESMEvaluatedImportSpecifierDependency.js} +33 -30
  174. package/lib/dependencies/{HarmonyExportDependencyParserPlugin.js → esm/ESMExportDependencyParserPlugin.js} +60 -89
  175. package/lib/dependencies/{HarmonyExportExpressionDependency.js → esm/ESMExportExpressionDependency.js} +80 -45
  176. package/lib/dependencies/{HarmonyExportHeaderDependency.js → esm/ESMExportHeaderDependency.js} +17 -15
  177. package/lib/dependencies/esm/ESMExportImportedSideEffectDependency.js +37 -0
  178. package/lib/dependencies/{HarmonyExportImportedSpecifierDependency.js → esm/ESMExportImportedSpecifierDependency.js} +146 -133
  179. package/lib/dependencies/{HarmonyExportInitFragment.js → esm/ESMExportInitFragment.js} +48 -30
  180. package/lib/dependencies/{HarmonyExportSpecifierDependency.js → esm/ESMExportSpecifierDependency.js} +78 -37
  181. package/lib/dependencies/{HarmonyExports.js → esm/ESMExports.js} +4 -12
  182. package/lib/dependencies/{HarmonyImportBareSideEffectDependency.js → esm/ESMImportBareSideEffectDependency.js} +21 -13
  183. package/lib/dependencies/{HarmonyImportDependency.js → esm/ESMImportDependency.js} +86 -68
  184. package/lib/dependencies/{HarmonyImportDependencyParserPlugin.js → esm/ESMImportDependencyParserPlugin.js} +104 -100
  185. package/lib/dependencies/{HarmonyImportGuard.js → esm/ESMImportGuard.js} +36 -51
  186. package/lib/dependencies/{HarmonyImportSideEffectDependency.js → esm/ESMImportSideEffectDependency.js} +83 -39
  187. package/lib/dependencies/{HarmonyImportSpecifierDependency.js → esm/ESMImportSpecifierDependency.js} +98 -60
  188. package/lib/dependencies/esm/ESMLiveExportDependency.js +311 -0
  189. package/lib/dependencies/esm/ESMLiveExportParserPlugin.js +862 -0
  190. package/lib/dependencies/esm/ESMModulesPlugin.js +205 -0
  191. package/lib/dependencies/{HarmonyTopLevelThisParserPlugin.js → esm/ESMTopLevelThisParserPlugin.js} +7 -7
  192. package/lib/dependencies/{TopLevelAwaitDependency.js → esm/TopLevelAwaitDependency.js} +12 -18
  193. package/lib/dependencies/{DynamicExports.js → helpers/DynamicExports.js} +5 -7
  194. package/lib/{util → dependencies/helpers}/chainedImports.js +5 -5
  195. package/lib/dependencies/{processExportInfo.js → helpers/processExportInfo.js} +4 -4
  196. package/lib/{util → dependencies/helpers}/traverseDestructuringAssignmentProperties.js +1 -1
  197. package/lib/dependencies/{ImportMetaHotAcceptDependency.js → hmr/ImportMetaHotAcceptDependency.js} +8 -7
  198. package/lib/dependencies/{ImportMetaHotDeclineDependency.js → hmr/ImportMetaHotDeclineDependency.js} +8 -7
  199. package/lib/dependencies/{ModuleHotAcceptDependency.js → hmr/ModuleHotAcceptDependency.js} +8 -7
  200. package/lib/dependencies/{ModuleHotDeclineDependency.js → hmr/ModuleHotDeclineDependency.js} +8 -7
  201. package/lib/dependencies/{HtmlEntryDependency.js → html/HtmlEntryDependency.js} +52 -151
  202. package/lib/dependencies/{HtmlInlineHtmlDependency.js → html/HtmlInlineHtmlDependency.js} +13 -15
  203. package/lib/dependencies/{HtmlInlineScriptDependency.js → html/HtmlInlineScriptDependency.js} +69 -23
  204. package/lib/dependencies/{HtmlInlineStyleDependency.js → html/HtmlInlineStyleDependency.js} +50 -18
  205. package/lib/dependencies/{HtmlSourceDependency.js → html/HtmlSourceDependency.js} +23 -16
  206. package/lib/dependencies/{ImportContextDependency.js → import/ImportContextDependency.js} +24 -10
  207. package/lib/dependencies/{ImportDependency.js → import/ImportDependency.js} +26 -18
  208. package/lib/dependencies/{ImportEagerDependency.js → import/ImportEagerDependency.js} +18 -10
  209. package/lib/dependencies/{ImportParserPlugin.js → import/ImportParserPlugin.js} +22 -25
  210. package/lib/dependencies/{ImportPlugin.js → import/ImportPlugin.js} +4 -4
  211. package/lib/dependencies/{ImportWeakDependency.js → import/ImportWeakDependency.js} +18 -10
  212. package/lib/dependencies/{importOptionsCheck.js → import/importOptionsCheck.js} +2 -2
  213. package/lib/dependencies/{BuildTimeConstDependency.js → import-meta/BuildTimeConstDependency.js} +12 -11
  214. package/lib/dependencies/{ImportMetaMainDependency.js → import-meta/ImportMetaMainDependency.js} +12 -11
  215. package/lib/dependencies/{ImportMetaPlugin.js → import-meta/ImportMetaPlugin.js} +122 -103
  216. package/lib/dependencies/{SystemPlugin.js → system/SystemPlugin.js} +11 -38
  217. package/lib/dependencies/{SystemRuntimeModule.js → system/SystemRuntimeModule.js} +3 -3
  218. package/lib/dependencies/{ImportMetaResolveDependency.js → url/ImportMetaResolveDependency.js} +9 -8
  219. package/lib/dependencies/{URLContextDependency.js → url/URLContextDependency.js} +11 -10
  220. package/lib/dependencies/{URLDependency.js → url/URLDependency.js} +28 -20
  221. package/lib/{url → dependencies/url}/URLParserPlugin.js +17 -19
  222. package/lib/dependencies/{URLPlugin.js → url/URLPlugin.js} +6 -7
  223. package/lib/dependencies/{WebAssemblyExportImportedDependency.js → wasm/WebAssemblyExportImportedDependency.js} +18 -11
  224. package/lib/dependencies/{WebAssemblyImportDependency.js → wasm/WebAssemblyImportDependency.js} +19 -12
  225. package/lib/dependencies/{CreateScriptUrlDependency.js → worker/CreateScriptUrlDependency.js} +12 -11
  226. package/lib/dependencies/{WorkerAndWorkletPlugin.js → worker/WorkerAndWorkletPlugin.js} +82 -53
  227. package/lib/dependencies/{WorkerDependency.js → worker/WorkerDependency.js} +22 -15
  228. package/lib/dependencies/{WorkletDependency.js → worker/WorkletDependency.js} +19 -18
  229. package/lib/{EvalDevToolModulePlugin.js → devtool/EvalDevToolModulePlugin.js} +20 -6
  230. package/lib/{EvalSourceMapDevToolPlugin.js → devtool/EvalSourceMapDevToolPlugin.js} +32 -24
  231. package/lib/devtool/ModuleFilenameHelpers.js +413 -0
  232. package/lib/{SourceMapDevToolModuleOptionsPlugin.js → devtool/SourceMapDevToolModuleOptionsPlugin.js} +10 -3
  233. package/lib/{SourceMapDevToolPlugin.js → devtool/SourceMapDevToolPlugin.js} +155 -27
  234. package/lib/{util → devtool}/generateDebugId.js +1 -1
  235. package/lib/{IgnoreWarningsPlugin.js → diagnostics/IgnoreWarningsPlugin.js} +2 -2
  236. package/lib/{NoEmitOnErrorsPlugin.js → diagnostics/NoEmitOnErrorsPlugin.js} +1 -1
  237. package/lib/diagnostics/WarnCaseSensitiveModulesPlugin.js +64 -0
  238. package/lib/{WarnDeprecatedOptionPlugin.js → diagnostics/WarnDeprecatedOptionPlugin.js} +2 -22
  239. package/lib/diagnostics/WarnNoModeSetPlugin.js +27 -0
  240. package/lib/dll/DelegatedModule.js +23 -21
  241. package/lib/dll/DelegatedModuleFactoryPlugin.js +2 -2
  242. package/lib/dll/DelegatedPlugin.js +1 -1
  243. package/lib/{dependencies → dll}/DelegatedSourceDependency.js +5 -4
  244. package/lib/{dependencies → dll}/DllEntryDependency.js +6 -5
  245. package/lib/dll/DllEntryPlugin.js +3 -3
  246. package/lib/dll/DllModule.js +14 -10
  247. package/lib/dll/DllModuleFactory.js +3 -3
  248. package/lib/dll/DllPlugin.js +18 -6
  249. package/lib/dll/DllReferencePlugin.js +103 -30
  250. package/lib/dll/LibManifestPlugin.js +9 -7
  251. package/lib/electron/ElectronTargetPlugin.js +2 -2
  252. package/lib/{DynamicEntryPlugin.js → entry/DynamicEntryPlugin.js} +3 -3
  253. package/lib/{dependencies → entry}/EntryDependency.js +11 -2
  254. package/lib/{EntryOptionPlugin.js → entry/EntryOptionPlugin.js} +6 -6
  255. package/lib/entry/EntryPlugin.js +75 -0
  256. package/lib/errors/AbstractMethodError.js +1 -1
  257. package/lib/{performance → errors}/AssetsOverSizeLimitWarning.js +2 -2
  258. package/lib/errors/AsyncDependencyToInitialChunkError.js +2 -2
  259. package/lib/errors/BuildCycleError.js +1 -1
  260. package/lib/{WarnCaseSensitiveModulesPlugin.js → errors/CaseSensitiveModulesWarning.js} +4 -56
  261. package/lib/errors/ChunkRenderError.js +1 -1
  262. package/lib/errors/CodeGenerationError.js +1 -1
  263. package/lib/errors/CommentCompilationWarning.js +1 -1
  264. package/lib/errors/ConflictingEntryExportsWarning.js +38 -0
  265. package/lib/{dependencies → errors}/CriticalDependencyWarning.js +4 -3
  266. package/lib/errors/DeprecatedOptionWarning.js +30 -0
  267. package/lib/errors/DllManifestError.js +26 -0
  268. package/lib/{performance → errors}/DuplicatePackagesWarning.js +6 -6
  269. package/lib/{dependencies/HarmonyLinkingError.js → errors/ESMLinkingError.js} +4 -4
  270. package/lib/{performance → errors}/EntrypointsOverSizeLimitWarning.js +2 -2
  271. package/lib/errors/EnvironmentNotSupportAsyncWarning.js +2 -2
  272. package/lib/{ErrorHelpers.js → errors/ErrorHelpers.js} +9 -6
  273. package/lib/errors/ExternalStarReexportError.js +2 -2
  274. package/lib/{library → errors}/FalseIIFEUmdWarning.js +1 -1
  275. package/lib/errors/HookWebpackError.js +6 -5
  276. package/lib/errors/IgnoreErrorModuleFactory.js +3 -3
  277. package/lib/errors/InvalidDependenciesModuleWarning.js +1 -1
  278. package/lib/errors/JSONParseError.js +4 -4
  279. package/lib/{optimize → errors}/MinMaxSizeWarning.js +1 -1
  280. package/lib/errors/ModuleBuildError.js +1 -1
  281. package/lib/errors/ModuleDependencyError.js +2 -2
  282. package/lib/errors/ModuleDependencyWarning.js +2 -2
  283. package/lib/errors/ModuleError.js +1 -1
  284. package/lib/errors/ModuleHashingError.js +1 -1
  285. package/lib/errors/ModuleNotFoundError.js +3 -3
  286. package/lib/errors/ModuleParseError.js +1 -1
  287. package/lib/errors/ModuleRestoreError.js +1 -1
  288. package/lib/errors/ModuleStoreError.js +1 -1
  289. package/lib/errors/ModuleWarning.js +1 -1
  290. package/lib/{performance → errors}/NoAsyncChunksWarning.js +1 -1
  291. package/lib/{WarnNoModeSetPlugin.js → errors/NoModeWarning.js} +2 -19
  292. package/lib/errors/NodeStuffInWebError.js +7 -2
  293. package/lib/errors/PathVariableError.js +31 -0
  294. package/lib/errors/RequireIncludeDeprecationWarning.js +40 -0
  295. package/lib/{performance → errors}/RuntimeInLargeChunkWarning.js +1 -1
  296. package/lib/errors/RuntimeModuleGenerationError.js +51 -0
  297. package/lib/errors/SSRManifestAutoPublicPathWarning.js +24 -0
  298. package/lib/errors/SystemImportDeprecationWarning.js +43 -0
  299. package/lib/errors/UnmergeableEntryExportsError.js +34 -0
  300. package/lib/errors/UnsupportedFeatureWarning.js +1 -1
  301. package/lib/{wasm-sync → errors}/UnsupportedWebAssemblyFeatureError.js +1 -1
  302. package/lib/{wasm-sync → errors}/WebAssemblyInInitialChunkError.js +7 -5
  303. package/lib/errors/WebpackError.js +13 -3
  304. package/lib/esm/ExportWebpackRequireRuntimeModule.js +2 -2
  305. package/lib/esm/ModuleChunkFormatPlugin.js +55 -20
  306. package/lib/esm/ModuleChunkLoadingPlugin.js +3 -3
  307. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +8 -8
  308. package/lib/{ExternalModule.js → externals/ExternalModule.js} +90 -63
  309. package/lib/{ExternalModuleFactoryPlugin.js → externals/ExternalModuleFactoryPlugin.js} +42 -41
  310. package/lib/externals/ExternalsPlugin.js +99 -0
  311. package/lib/fs/FileSystemInfo.js +4642 -0
  312. package/lib/{util → fs}/fs.js +22 -9
  313. package/lib/{AsyncDependenciesBlock.js → graph/AsyncDependenciesBlock.js} +27 -4
  314. package/lib/graph/Chunk.js +985 -0
  315. package/lib/{ChunkGraph.js → graph/ChunkGraph.js} +192 -80
  316. package/lib/{ChunkGroup.js → graph/ChunkGroup.js} +11 -3
  317. package/lib/{DependenciesBlock.js → graph/DependenciesBlock.js} +16 -4
  318. package/lib/graph/Dependency.js +634 -0
  319. package/lib/graph/Entrypoint.js +136 -0
  320. package/lib/{ExportsInfo.js → graph/ExportsInfo.js} +131 -83
  321. package/lib/{HotUpdateChunk.js → graph/HotUpdateChunk.js} +8 -0
  322. package/lib/{ModuleGraph.js → graph/ModuleGraph.js} +44 -33
  323. package/lib/{ModuleGraphConnection.js → graph/ModuleGraphConnection.js} +2 -2
  324. package/lib/{buildChunkGraph.js → graph/buildChunkGraph.js} +169 -76
  325. package/lib/{util → graph}/findGraphRoots.js +15 -9
  326. package/lib/graph/isDependencyKind.js +23 -0
  327. package/lib/hmr/HotModuleReplacement.runtime.js +12 -11
  328. package/lib/{HotModuleReplacementPlugin.js → hmr/HotModuleReplacementPlugin.js} +51 -57
  329. package/lib/hmr/HotModuleReplacementRuntimeModule.js +3 -3
  330. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +25 -26
  331. package/lib/hmr/JavascriptHotModuleReplacementHelper.js +2 -2
  332. package/lib/hmr/LazyCompilationPlugin.js +32 -28
  333. package/lib/html/HtmlGenerator.js +132 -60
  334. package/lib/html/HtmlModule.js +16 -2
  335. package/lib/html/HtmlModulesPlugin.js +184 -87
  336. package/lib/html/HtmlParser.js +511 -160
  337. package/lib/html/builtinEmbeddedRenderer.js +70 -25
  338. package/lib/html/data.js +44 -22
  339. package/lib/html/htmlMinify.js +114 -41
  340. package/lib/html/syntax-parser.js +15795 -0
  341. package/lib/html/syntax-printer.js +1033 -0
  342. package/lib/html/syntax.js +37 -13952
  343. package/lib/html/xmlMinify.js +70 -0
  344. package/lib/ids/ChunkModuleIdRangePlugin.js +2 -2
  345. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  346. package/lib/ids/HashedModuleIdsPlugin.js +32 -5
  347. package/lib/ids/IdHelpers.js +4 -4
  348. package/lib/ids/NaturalChunkIdsPlugin.js +1 -1
  349. package/lib/ids/OccurrenceChunkIdsPlugin.js +6 -5
  350. package/lib/ids/OccurrenceModuleIdsPlugin.js +6 -5
  351. package/lib/{RecordIdsPlugin.js → ids/RecordIdsPlugin.js} +5 -5
  352. package/lib/ids/SyncModuleIdsPlugin.js +3 -3
  353. package/lib/{util → ids}/numberHash.js +1 -1
  354. package/lib/index.js +312 -105
  355. package/lib/{APIPlugin.js → javascript/APIPlugin.js} +31 -37
  356. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -5
  357. package/lib/javascript/BasicEvaluatedExpression.js +9 -9
  358. package/lib/javascript/ChunkHelpers.js +64 -4
  359. package/lib/javascript/CommonJsChunkFormatPlugin.js +5 -13
  360. package/lib/{CompatibilityPlugin.js → javascript/CompatibilityPlugin.js} +7 -7
  361. package/lib/{ConstPlugin.js → javascript/ConstPlugin.js} +75 -8
  362. package/lib/{ExportsInfoApiPlugin.js → javascript/ExportsInfoApiPlugin.js} +5 -5
  363. package/lib/{dependencies → javascript}/ExportsInfoDependency.js +10 -9
  364. package/lib/javascript/JavascriptGenerator.js +32 -27
  365. package/lib/{JavascriptMetaInfoPlugin.js → javascript/JavascriptMetaInfoPlugin.js} +8 -20
  366. package/lib/javascript/JavascriptModule.js +14 -3
  367. package/lib/javascript/JavascriptModulesPlugin.js +441 -214
  368. package/lib/javascript/JavascriptParser.js +318 -144
  369. package/lib/javascript/JavascriptParserHelpers.js +1 -1
  370. package/lib/javascript/MergedEntryExports.js +196 -0
  371. package/lib/javascript/ScopeAnalyzer.js +3924 -13
  372. package/lib/javascript/StartupHelpers.js +6 -6
  373. package/lib/{UseStrictPlugin.js → javascript/UseStrictPlugin.js} +13 -19
  374. package/lib/{dependencies → javascript}/WebpackIsIncludedDependency.js +10 -9
  375. package/lib/{WebpackIsIncludedPlugin.js → javascript/WebpackIsIncludedPlugin.js} +8 -8
  376. package/lib/javascript/data.js +533 -122
  377. package/lib/javascript/jsMinify.js +272 -0
  378. package/lib/javascript/regexp.js +67 -32
  379. package/lib/javascript/syntax-parser.js +19169 -0
  380. package/lib/javascript/syntax-printer-data.js +1099 -0
  381. package/lib/javascript/syntax-printer.js +53878 -0
  382. package/lib/javascript/syntax.js +20 -11274
  383. package/lib/json/JsonData.js +1 -1
  384. package/lib/{dependencies → json}/JsonExportsDependency.js +8 -7
  385. package/lib/json/JsonGenerator.js +24 -16
  386. package/lib/json/JsonModule.js +13 -2
  387. package/lib/json/JsonModulesPlugin.js +1 -1
  388. package/lib/json/JsonParser.js +11 -10
  389. package/lib/json/jsonMinify.js +69 -0
  390. package/lib/library/AbstractLibraryPlugin.js +28 -15
  391. package/lib/library/AmdLibraryPlugin.js +4 -4
  392. package/lib/library/AssignLibraryPlugin.js +28 -12
  393. package/lib/library/EnableLibraryPlugin.js +1 -1
  394. package/lib/library/ExportPropertyLibraryPlugin.js +4 -4
  395. package/lib/library/JsonpLibraryPlugin.js +2 -2
  396. package/lib/library/LibraryTemplatePlugin.js +53 -0
  397. package/lib/library/ModuleLibraryPlugin.js +557 -187
  398. package/lib/library/SystemLibraryPlugin.js +6 -8
  399. package/lib/library/UmdLibraryPlugin.js +3 -4
  400. package/lib/{dependencies → loaders}/LoaderDependency.js +3 -3
  401. package/lib/{dependencies → loaders}/LoaderImportDependency.js +9 -3
  402. package/lib/{LoaderOptionsPlugin.js → loaders/LoaderOptionsPlugin.js} +30 -12
  403. package/lib/{dependencies → loaders}/LoaderPlugin.js +2 -2
  404. package/lib/loaders/LoaderRunner.js +94 -46
  405. package/lib/{LoaderTargetPlugin.js → loaders/LoaderTargetPlugin.js} +2 -2
  406. package/lib/loaders/loadLoader.js +16 -10
  407. package/lib/logging/Logger.js +7 -9
  408. package/lib/logging/ProgressPlugin.js +957 -0
  409. package/lib/{CodeGenerationResults.js → module/CodeGenerationResults.js} +7 -7
  410. package/lib/{Generator.js → module/Generator.js} +33 -23
  411. package/lib/{Module.js → module/Module.js} +121 -53
  412. package/lib/{ModuleFactory.js → module/ModuleFactory.js} +3 -3
  413. package/lib/module/NormalModule.js +2350 -0
  414. package/lib/{NormalModuleFactory.js → module/NormalModuleFactory.js} +64 -71
  415. package/lib/module/NullFactory.js +29 -0
  416. package/lib/{Parser.js → module/Parser.js} +12 -5
  417. package/lib/module/RawModule.js +208 -0
  418. package/lib/{SelfModuleFactory.js → module/SelfModuleFactory.js} +1 -1
  419. package/lib/{util → module}/extractSourceMap.js +71 -20
  420. package/lib/{util → module}/findCaseMismatch.js +4 -4
  421. package/lib/node/CommonJsChunkLoadingPlugin.js +3 -3
  422. package/lib/{dependencies → node}/ExternalModuleDependency.js +8 -7
  423. package/lib/{dependencies → node}/ExternalModuleInitFragment.js +7 -6
  424. package/lib/{dependencies → node}/ExternalModuleInitFragmentDependency.js +14 -9
  425. package/lib/node/NodeEnvironmentPlugin.js +11 -1
  426. package/lib/{NodeStuffPlugin.js → node/NodeStuffPlugin.js} +17 -17
  427. package/lib/node/NodeTargetPlugin.js +1 -1
  428. package/lib/node/NodeWatchFileSystem.js +58 -6
  429. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +7 -7
  430. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +13 -19
  431. package/lib/node/ReadFileCompileWasmPlugin.js +9 -11
  432. package/lib/node/RequireChunkLoadingRuntimeModule.js +7 -7
  433. package/lib/node/nodeConsole.js +6 -7
  434. package/lib/optimize/AggressiveMergingPlugin.js +2 -2
  435. package/lib/optimize/AggressiveSplittingPlugin.js +12 -8
  436. package/lib/{CircularModulesPlugin.js → optimize/CircularModulesPlugin.js} +14 -14
  437. package/lib/optimize/ConcatenatedModule.js +231 -220
  438. package/lib/{ConcatenationScope.js → optimize/ConcatenationScope.js} +39 -6
  439. package/lib/optimize/ConstExportsPlugin.js +7 -7
  440. package/lib/optimize/EnsureChunkConditionsPlugin.js +3 -3
  441. package/lib/{FlagAllModulesAsUsedPlugin.js → optimize/FlagAllModulesAsUsedPlugin.js} +3 -3
  442. package/lib/{FlagDependencyExportsPlugin.js → optimize/FlagDependencyExportsPlugin.js} +23 -28
  443. package/lib/{FlagDependencyUsagePlugin.js → optimize/FlagDependencyUsagePlugin.js} +44 -19
  444. package/lib/{FlagEntryExportAsUsedPlugin.js → optimize/FlagEntryExportAsUsedPlugin.js} +2 -2
  445. package/lib/optimize/FlagIncludedChunksPlugin.js +2 -2
  446. package/lib/optimize/InlineExports.js +12 -7
  447. package/lib/optimize/InnerGraph.js +5 -13
  448. package/lib/optimize/InnerGraphPlugin.js +10 -10
  449. package/lib/optimize/LazyBarrels.js +620 -0
  450. package/lib/{util → optimize}/LazyBucketSortedSet.js +2 -2
  451. package/lib/optimize/LimitChunkCountPlugin.js +16 -7
  452. package/lib/optimize/MangleExportsPlugin.js +5 -5
  453. package/lib/optimize/MergeDuplicateChunksPlugin.js +7 -6
  454. package/lib/optimize/MinChunkSizePlugin.js +9 -6
  455. package/lib/optimize/ModuleConcatenationPlugin.js +28 -22
  456. package/lib/{dependencies → optimize}/PureExpressionDependency.js +11 -10
  457. package/lib/optimize/RealContentHashPlugin.js +18 -13
  458. package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -2
  459. package/lib/optimize/RemoveParentModulesPlugin.js +4 -4
  460. package/lib/optimize/SideEffectsFlagPlugin.js +24 -38
  461. package/lib/optimize/SplitChunksPlugin.js +719 -174
  462. package/lib/{util → optimize}/TupleQueue.js +9 -9
  463. package/lib/optimize/chunkSetIntersections.js +437 -0
  464. package/lib/{util → optimize}/deterministicGrouping.js +17 -17
  465. package/lib/{BannerPlugin.js → output/BannerPlugin.js} +82 -14
  466. package/lib/{CleanPlugin.js → output/CleanPlugin.js} +69 -25
  467. package/lib/{CopyPlugin.js → output/CopyPlugin.js} +144 -70
  468. package/lib/{ManifestPlugin.js → output/ManifestPlugin.js} +91 -17
  469. package/lib/output/SSRManifestPlugin.js +349 -0
  470. package/lib/performance/AnalyzableBailoutsPlugin.js +1 -1
  471. package/lib/performance/AsyncChunkWaterfallsPlugin.js +1 -1
  472. package/lib/performance/BroadContextsPlugin.js +4 -4
  473. package/lib/performance/CacheEffectivenessPlugin.js +2 -3
  474. package/lib/performance/ConflictingResourceHintsPlugin.js +1 -1
  475. package/lib/performance/DuplicateModulesPlugin.js +3 -4
  476. package/lib/performance/DuplicatePackagesPlugin.js +3 -3
  477. package/lib/performance/DynamicExportsPlugin.js +2 -2
  478. package/lib/performance/EvalUsagePlugin.js +4 -6
  479. package/lib/performance/HotspotsPlugin.js +39 -14
  480. package/lib/performance/LargeModulesPlugin.js +2 -3
  481. package/lib/performance/LegacyJavascriptPlugin.js +1 -2
  482. package/lib/performance/MissingSideEffectsPlugin.js +2 -3
  483. package/lib/performance/MissingSourceMapsPlugin.js +5 -6
  484. package/lib/performance/PureAnnotationsPlugin.js +19 -13
  485. package/lib/performance/RedundantDynamicImportsPlugin.js +6 -8
  486. package/lib/performance/ScopeHoistingBailoutsPlugin.js +2 -2
  487. package/lib/performance/SizeLimitsPlugin.js +11 -12
  488. package/lib/performance/TopLevelThisPlugin.js +22 -13
  489. package/lib/performance/UnsplitVendorsPlugin.js +1 -2
  490. package/lib/performance/UnusedAliasesPlugin.js +6 -7
  491. package/lib/performance/UnusedAssetsPlugin.js +5 -5
  492. package/lib/performance/UnusedDefinesPlugin.js +2 -2
  493. package/lib/performance/UnusedExternalsPlugin.js +3 -4
  494. package/lib/performance/UnusedFederationPlugin.js +2 -4
  495. package/lib/performance/UnusedModulesPlugin.js +5 -4
  496. package/lib/performance/getModuleSize.js +1 -1
  497. package/lib/performance/hasOnlyUnusedExports.js +4 -4
  498. package/lib/performance/isOnlyReexported.js +7 -6
  499. package/lib/{AutomaticPrefetchPlugin.js → prefetch/AutomaticPrefetchPlugin.js} +4 -5
  500. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +2 -2
  501. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -1
  502. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +4 -4
  503. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -4
  504. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +4 -4
  505. package/lib/{dependencies → prefetch}/PrefetchDependency.js +1 -1
  506. package/lib/{PrefetchPlugin.js → prefetch/PrefetchPlugin.js} +2 -2
  507. package/lib/prefetch/ResourceHintPlugin.js +66 -45
  508. package/lib/prefetch/ResourceHintRuntimeModule.js +3 -3
  509. package/lib/prefetch/StartupAssetHintRuntimeModule.js +3 -3
  510. package/lib/prefetch/parseResourceHintOptions.js +4 -3
  511. package/lib/{ProvidePlugin.js → provide/ProvidePlugin.js} +7 -7
  512. package/lib/{dependencies → provide}/ProvidedDependency.js +50 -17
  513. package/lib/{IgnorePlugin.js → resolve/IgnorePlugin.js} +30 -13
  514. package/lib/{NormalModuleReplacementPlugin.js → resolve/NormalModuleReplacementPlugin.js} +4 -4
  515. package/lib/{ResolverFactory.js → resolve/ResolverFactory.js} +18 -5
  516. package/lib/resolve/getResolveOptionsKey.js +59 -0
  517. package/lib/rules/BasicEffectRulePlugin.js +1 -1
  518. package/lib/rules/RuleSetCompiler.js +42 -51
  519. package/lib/rules/UseEffectRulePlugin.js +1 -3
  520. package/lib/runtime/AsyncModuleGeneratorRuntimeModule.js +2 -2
  521. package/lib/runtime/AsyncModuleRuntimeModule.js +14 -5
  522. package/lib/runtime/AutoPublicPathRuntimeModule.js +5 -5
  523. package/lib/runtime/BaseUriRuntimeModule.js +3 -3
  524. package/lib/runtime/ChunkNameRuntimeModule.js +2 -2
  525. package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +2 -2
  526. package/lib/runtime/CompatRuntimeModule.js +4 -4
  527. package/lib/runtime/ConcatenationWrapRuntimeModule.js +2 -2
  528. package/lib/runtime/ConstructRequireRuntimeModule.js +2 -2
  529. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
  530. package/lib/runtime/CreateScriptRuntimeModule.js +2 -2
  531. package/lib/runtime/CreateScriptUrlRuntimeModule.js +2 -2
  532. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +6 -6
  533. package/lib/runtime/EnsureChunkRuntimeModule.js +4 -4
  534. package/lib/runtime/GetChunkFilenameRuntimeModule.js +7 -11
  535. package/lib/runtime/GetFullHashRuntimeModule.js +2 -2
  536. package/lib/runtime/GetMainFilenameRuntimeModule.js +4 -4
  537. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +3 -3
  538. package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +3 -3
  539. package/lib/runtime/GlobalRuntimeModule.js +3 -3
  540. package/lib/runtime/HasOwnPropertyRuntimeModule.js +3 -3
  541. package/lib/runtime/HelperRuntimeModule.js +16 -1
  542. package/lib/runtime/LoadScriptRuntimeModule.js +3 -3
  543. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +80 -17
  544. package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +2 -2
  545. package/lib/runtime/NonceRuntimeModule.js +2 -2
  546. package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -4
  547. package/lib/runtime/PublicPathRuntimeModule.js +2 -2
  548. package/lib/runtime/RelativeUrlRuntimeModule.js +2 -2
  549. package/lib/{RuntimeGlobals.js → runtime/RuntimeGlobals.js} +24 -1
  550. package/lib/runtime/RuntimeIdRuntimeModule.js +4 -4
  551. package/lib/{RuntimeModule.js → runtime/RuntimeModule.js} +36 -21
  552. package/lib/{RuntimePlugin.js → runtime/RuntimePlugin.js} +50 -50
  553. package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +2 -2
  554. package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +2 -2
  555. package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -2
  556. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +5 -5
  557. package/lib/runtime/StartupEntrypointRuntimeModule.js +3 -3
  558. package/lib/runtime/SystemContextRuntimeModule.js +2 -2
  559. package/lib/runtime/ToBinaryRuntimeModule.js +3 -3
  560. package/lib/runtime/WorkerRuntimeModule.js +1 -1
  561. package/lib/runtime/baseUri.js +1 -1
  562. package/lib/schemes/DataUriPlugin.js +1 -1
  563. package/lib/schemes/HttpUriPlugin.js +68 -13
  564. package/lib/schemes/VirtualUrlPlugin.js +52 -16
  565. package/lib/serialization/AggregateErrorSerializer.js +4 -4
  566. package/lib/serialization/BinaryMiddleware.js +4 -1
  567. package/lib/serialization/ErrorObjectSerializer.js +2 -5
  568. package/lib/serialization/FileMiddleware.js +3 -3
  569. package/lib/serialization/ObjectMiddleware.js +62 -29
  570. package/lib/serialization/PlainObjectSerializer.js +3 -7
  571. package/lib/serialization/Serializer.js +21 -11
  572. package/lib/serialization/SerializerMiddleware.js +10 -8
  573. package/lib/serialization/SingleItemMiddleware.js +4 -2
  574. package/lib/sharing/ConsumeSharedFallbackDependency.js +9 -1
  575. package/lib/sharing/ConsumeSharedModule.js +18 -14
  576. package/lib/sharing/ConsumeSharedPlugin.js +148 -42
  577. package/lib/sharing/ConsumeSharedRuntimeModule.js +8 -8
  578. package/lib/sharing/ProvideForSharedDependency.js +9 -1
  579. package/lib/sharing/ProvideSharedDependency.js +1 -1
  580. package/lib/sharing/ProvideSharedModule.js +11 -9
  581. package/lib/sharing/ProvideSharedModuleFactory.js +2 -2
  582. package/lib/sharing/ProvideSharedPlugin.js +111 -20
  583. package/lib/sharing/SharePlugin.js +102 -9
  584. package/lib/sharing/ShareRuntimeModule.js +6 -6
  585. package/lib/sharing/resolveMatchedConfigs.js +1 -1
  586. package/lib/{util → sharing}/semver.js +14 -16
  587. package/lib/sharing/utils.js +59 -2
  588. package/lib/stats/DefaultStatsFactoryPlugin.js +57 -54
  589. package/lib/stats/DefaultStatsPresetPlugin.js +3 -7
  590. package/lib/stats/DefaultStatsPrinterPlugin.js +15 -14
  591. package/lib/{MultiStats.js → stats/MultiStats.js} +4 -4
  592. package/lib/{Stats.js → stats/Stats.js} +4 -4
  593. package/lib/stats/StatsFactory.js +208 -37
  594. package/lib/stats/StatsPrinter.js +126 -13
  595. package/lib/{ChunkTemplate.js → template/ChunkTemplate.js} +7 -7
  596. package/lib/{ConditionalInitFragment.js → template/ConditionalInitFragment.js} +3 -3
  597. package/lib/template/DependencyTemplate.js +77 -0
  598. package/lib/{DependencyTemplates.js → template/DependencyTemplates.js} +9 -4
  599. package/lib/template/InitFragment.js +223 -0
  600. package/lib/{MainTemplate.js → template/MainTemplate.js} +11 -11
  601. package/lib/{ModuleInfoHeaderPlugin.js → template/ModuleInfoHeaderPlugin.js} +30 -8
  602. package/lib/{ModuleTemplate.js → template/ModuleTemplate.js} +6 -6
  603. package/lib/{RuntimeTemplate.js → template/RuntimeTemplate.js} +158 -95
  604. package/lib/{Template.js → template/Template.js} +14 -12
  605. package/lib/{TemplatedPathPlugin.js → template/TemplatedPathPlugin.js} +19 -23
  606. package/lib/typescript/TypeScriptPlugin.js +3 -3
  607. package/lib/util/RequestShortener.js +44 -0
  608. package/lib/util/SortableSet.js +87 -22
  609. package/lib/util/SourceProcessor.js +439 -51
  610. package/lib/util/TupleSet.js +27 -27
  611. package/lib/util/WeakTupleMap.js +20 -16
  612. package/lib/util/buildDiagnostics.js +2 -2
  613. package/lib/util/cleverMerge.js +61 -33
  614. package/lib/util/comparators.js +19 -15
  615. package/lib/util/concatenate.js +28 -147
  616. package/lib/util/createMappings.js +111 -0
  617. package/lib/util/dataURL.js +96 -15
  618. package/lib/util/deprecation.js +5 -4
  619. package/lib/util/extractComments.js +118 -0
  620. package/lib/util/formatLocation.js +1 -1
  621. package/lib/util/globUtils.js +198 -20
  622. package/lib/util/haltVisitors.js +51 -0
  623. package/lib/util/handlerKeys.js +2 -2
  624. package/lib/util/identifier.js +117 -1
  625. package/lib/util/implicitTypeLoaderFallback.js +6 -4
  626. package/lib/util/internalSerializables.js +296 -102
  627. package/lib/util/magicComment.js +12 -7
  628. package/lib/util/makeSerializable.js +28 -7
  629. package/lib/util/memoize.js +1 -1
  630. package/lib/util/parseJson.js +2 -2
  631. package/lib/util/preloadModuleType.js +5 -2
  632. package/lib/util/registerExternalSerializer.js +2 -2
  633. package/lib/util/removeBOM.js +1 -1
  634. package/lib/util/runtime.js +1 -1
  635. package/lib/util/serialization.js +35 -28
  636. package/lib/util/source.js +2 -2
  637. package/lib/util/terminalColors.js +161 -0
  638. package/lib/{wasm-async → wasm}/AsyncWasmCompileRuntimeModule.js +5 -5
  639. package/lib/{wasm-async → wasm}/AsyncWasmLoadingRuntimeModule.js +5 -5
  640. package/lib/{wasm-async → wasm}/AsyncWasmModule.js +19 -5
  641. package/lib/{wasm-async → wasm}/AsyncWebAssemblyGenerator.js +17 -9
  642. package/lib/{wasm-async → wasm}/AsyncWebAssemblyJavascriptGenerator.js +24 -15
  643. package/lib/{wasm-async → wasm}/AsyncWebAssemblyModulesPlugin.js +26 -10
  644. package/lib/{wasm-async → wasm}/AsyncWebAssemblyParser.js +14 -12
  645. package/lib/wasm/EnableWasmLoadingPlugin.js +1 -1
  646. package/lib/{wasm-async → wasm}/UniversalCompileAsyncWasmPlugin.js +11 -13
  647. package/lib/wasm/wasmModuleFilename.js +2 -2
  648. package/lib/wasm-sync/SyncWasmModule.js +18 -3
  649. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +8 -8
  650. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +3 -3
  651. package/lib/wasm-sync/WebAssemblyGenerator.js +22 -16
  652. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +28 -21
  653. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +9 -7
  654. package/lib/wasm-sync/WebAssemblyParser.js +15 -17
  655. package/lib/wasm-sync/WebAssemblyUtils.js +6 -5
  656. package/lib/{MultiWatching.js → watch/MultiWatching.js} +3 -3
  657. package/lib/{WatchIgnorePlugin.js → watch/WatchIgnorePlugin.js} +43 -9
  658. package/lib/{Watching.js → watch/Watching.js} +8 -8
  659. package/lib/web/FetchCompileAsyncWasmPlugin.js +12 -18
  660. package/lib/web/FetchCompileWasmPlugin.js +8 -10
  661. package/lib/web/JsonpChunkLoadingPlugin.js +3 -3
  662. package/lib/web/JsonpChunkLoadingRuntimeModule.js +6 -6
  663. package/lib/web/JsonpTemplatePlugin.js +1 -1
  664. package/lib/webpack.js +27 -17
  665. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -3
  666. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -6
  667. package/package.json +57 -36
  668. package/schemas/WebpackOptions.check.js +4 -3
  669. package/schemas/WebpackOptions.d.json.ts +2 -0
  670. package/schemas/WebpackOptions.json +295 -75
  671. package/schemas/plugins/BannerPlugin.check.js +4 -3
  672. package/schemas/plugins/BannerPlugin.json +29 -2
  673. package/schemas/plugins/HtmlGeneratorOptions.check.js +4 -3
  674. package/schemas/plugins/HtmlParserOptions.check.js +4 -3
  675. package/schemas/plugins/IgnorePlugin.check.js +4 -3
  676. package/schemas/plugins/IgnorePlugin.d.json.ts +2 -0
  677. package/schemas/plugins/IgnorePlugin.json +1 -1
  678. package/schemas/plugins/LoaderOptionsPlugin.check.js +4 -3
  679. package/schemas/plugins/ManifestPlugin.check.js +4 -3
  680. package/schemas/plugins/ManifestPlugin.json +3 -3
  681. package/schemas/plugins/ProgressPlugin.check.js +4 -3
  682. package/schemas/plugins/ProgressPlugin.json +2 -7
  683. package/schemas/plugins/SSRManifestPlugin.check.js +7 -0
  684. package/schemas/plugins/SSRManifestPlugin.json +20 -0
  685. package/schemas/plugins/SourceMapDevToolPlugin.check.js +4 -3
  686. package/schemas/plugins/SourceMapDevToolPlugin.json +44 -12
  687. package/schemas/plugins/WatchIgnorePlugin.check.js +4 -3
  688. package/schemas/plugins/WatchIgnorePlugin.json +12 -3
  689. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +4 -3
  690. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +4 -3
  691. package/schemas/plugins/asset/AssetParserOptions.check.js +4 -3
  692. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +4 -3
  693. package/schemas/plugins/container/ContainerPlugin.check.js +4 -3
  694. package/schemas/plugins/container/ContainerPlugin.json +8 -0
  695. package/schemas/plugins/container/ContainerReferencePlugin.check.js +4 -3
  696. package/schemas/plugins/container/ExternalsType.check.js +4 -3
  697. package/schemas/plugins/container/ModuleFederationPlugin.check.js +4 -3
  698. package/schemas/plugins/container/ModuleFederationPlugin.json +40 -0
  699. package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +4 -3
  700. package/schemas/plugins/css/CssGeneratorOptions.check.js +4 -3
  701. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +4 -3
  702. package/schemas/plugins/css/CssModuleParserOptions.check.js +4 -3
  703. package/schemas/plugins/css/CssParserOptions.check.js +4 -3
  704. package/schemas/plugins/debug/ProfilingPlugin.check.js +4 -3
  705. package/schemas/plugins/define/DotenvPluginOptions.check.js +7 -0
  706. package/schemas/plugins/define/DotenvPluginOptions.json +3 -0
  707. package/schemas/plugins/dll/DllPlugin.check.js +4 -3
  708. package/schemas/plugins/dll/DllReferencePlugin.check.js +4 -3
  709. package/schemas/plugins/dll/DllReferencePlugin.json +3 -18
  710. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +4 -3
  711. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +4 -3
  712. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +4 -3
  713. package/schemas/plugins/json/JsonModulesPluginGenerator.check.js +4 -3
  714. package/schemas/plugins/json/JsonModulesPluginParser.check.js +4 -3
  715. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +4 -3
  716. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +4 -3
  717. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +4 -3
  718. package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +4 -3
  719. package/schemas/plugins/output/CleanOptions.check.js +7 -0
  720. package/schemas/plugins/output/CleanOptions.json +3 -0
  721. package/schemas/plugins/schemes/HttpUriPlugin.check.js +4 -3
  722. package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +4 -3
  723. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +4 -3
  724. package/schemas/plugins/sharing/ConsumeSharedPlugin.json +32 -0
  725. package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +4 -3
  726. package/schemas/plugins/sharing/ProvideSharedPlugin.json +32 -0
  727. package/schemas/plugins/sharing/SharePlugin.check.js +4 -3
  728. package/schemas/plugins/sharing/SharePlugin.json +32 -0
  729. package/types.d.ts +20780 -14174
  730. package/lib/LazyBarrel.js +0 -388
  731. package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -39
  732. package/lib/dependencies/HarmonyModulesPlugin.js +0 -192
  733. package/lib/javascript/ChunkFormatHelpers.js +0 -72
  734. package/lib/javascript/grammar.js +0 -5546
  735. package/lib/javascript/parser.js +0 -1500
  736. package/lib/javascript/regexpData.js +0 -51
  737. package/lib/performance/getSourceModules.js +0 -22
  738. package/lib/util/Semaphore.js +0 -65
  739. package/lib/util/objectToMap.js +0 -15
  740. package/schemas/WebpackOptions.check.d.ts +0 -7
  741. package/schemas/_container.json +0 -155
  742. package/schemas/_sharing.json +0 -118
  743. package/schemas/plugins/BannerPlugin.check.d.ts +0 -7
  744. package/schemas/plugins/HtmlGeneratorOptions.check.d.ts +0 -7
  745. package/schemas/plugins/HtmlParserOptions.check.d.ts +0 -7
  746. package/schemas/plugins/IgnorePlugin.check.d.ts +0 -7
  747. package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +0 -7
  748. package/schemas/plugins/ManifestPlugin.check.d.ts +0 -7
  749. package/schemas/plugins/ProgressPlugin.check.d.ts +0 -7
  750. package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +0 -7
  751. package/schemas/plugins/WatchIgnorePlugin.check.d.ts +0 -7
  752. package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +0 -7
  753. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +0 -7
  754. package/schemas/plugins/asset/AssetParserOptions.check.d.ts +0 -7
  755. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +0 -7
  756. package/schemas/plugins/container/ContainerPlugin.check.d.ts +0 -7
  757. package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +0 -7
  758. package/schemas/plugins/container/ExternalsType.check.d.ts +0 -7
  759. package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +0 -7
  760. package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.d.ts +0 -7
  761. package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +0 -7
  762. package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +0 -7
  763. package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +0 -7
  764. package/schemas/plugins/css/CssParserOptions.check.d.ts +0 -7
  765. package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +0 -7
  766. package/schemas/plugins/dll/DllPlugin.check.d.ts +0 -7
  767. package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +0 -7
  768. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +0 -7
  769. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +0 -7
  770. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +0 -7
  771. package/schemas/plugins/json/JsonModulesPluginGenerator.check.d.ts +0 -7
  772. package/schemas/plugins/json/JsonModulesPluginParser.check.d.ts +0 -7
  773. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +0 -7
  774. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +0 -7
  775. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +0 -7
  776. package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +0 -7
  777. package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +0 -7
  778. package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +0 -7
  779. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +0 -7
  780. package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +0 -7
  781. package/schemas/plugins/sharing/SharePlugin.check.d.ts +0 -7
  782. /package/lib/{validateSchema.js → config/validateSchema.js} +0 -0
  783. /package/lib/{util → css}/topologicalSort.js +0 -0
  784. /package/lib/dependencies/{getFunctionExpression.js → helpers/getFunctionExpression.js} +0 -0
  785. /package/lib/{util → externals}/extractUrlAndGlobal.js +0 -0
  786. /package/lib/{util → fs}/StackedCacheMap.js +0 -0
  787. /package/lib/{util → javascript}/StackedMap.js +0 -0
  788. /package/lib/{ModuleProfile.js → module/ModuleProfile.js} +0 -0
  789. /package/lib/{ModuleSourceTypeConstants.js → module/ModuleSourceTypeConstants.js} +0 -0
  790. /package/lib/{ModuleTypeConstants.js → module/ModuleTypeConstants.js} +0 -0
  791. /package/lib/{OptimizationStages.js → optimize/OptimizationStages.js} +0 -0
  792. /package/lib/{util → optimize}/Queue.js +0 -0
  793. /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,15 +63,8 @@ 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" */
60
- /**
61
- * @import CssModule, {
62
- * CssModuleBuildInfo,
63
- * CssModuleBuildMeta,
64
- * Inheritance
65
- * } from "./CssModule"
66
- */
67
- /** @import { ParserState, PreparsedAst } from "../Parser" */
66
+ /** @import CssModule, { BuiltCssModule, Inheritance } from "./CssModule" */
67
+ /** @import { ParserState, PreparsedAst } from "../module/Parser" */
68
68
  /**
69
69
  * @import {
70
70
  * AtRule,
@@ -77,13 +77,14 @@ const getCommentCompilationWarning = memoize(() =>
77
77
  * Token,
78
78
  * UrlToken,
79
79
  * VisitorMap
80
- * } from "./syntax"
80
+ * } from "./syntax-parser"
81
81
  */
82
82
  /**
83
83
  * @import {
84
84
  * CssAutoOrModuleParserOptions
85
85
  * } from "../../declarations/WebpackOptions"
86
86
  */
87
+ /** @import { MagicCommentOptions } from "../util/magicComment" */
87
88
 
88
89
  /** @typedef {[number, number]} Range */
89
90
  /** @typedef {{ line: number, column: number }} Position */
@@ -96,8 +97,14 @@ const getCommentCompilationWarning = memoize(() =>
96
97
  * out — no `<media-in-parens>` is unconditionally true on every engine).
97
98
  * @typedef {{ kind: "condition" | "type", text: string } | { kind: "boolean", value: boolean } | { kind: "unsupported" }} CustomMediaValue
98
99
  */
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 */
100
+ /** @typedef {{ node: MediaNode, uses: CustomMediaUse[] }} CustomMediaQuery */
101
+ /** @typedef {CustomMediaValue | { kind: "alias", name: string } | { kind: "or", parts: ({ text: string } | { alias: string } | { query: CustomMediaQuery })[] } | ({ kind: "query" } & CustomMediaQuery)} CustomMediaDefinition */
102
+ /**
103
+ * One `(--name)` a `@media` prelude or a `@custom-media` value asks for. `slot`
104
+ * is what the condition written there joins: nothing, an `and`, or `not` / `or`.
105
+ * @typedef {{ name: string, start: number, end: number, invalid: boolean, leading: boolean, slot: MediaSlot }} CustomMediaUse
106
+ */
107
+ /** @typedef {"alone" | "and" | "or"} MediaSlot */
101
108
  /**
102
109
  * A `@media` prelude captured as its boolean shape, so a `true` / `false`
103
110
  * definition found later can be folded into it. Node ids are recycled per
@@ -125,6 +132,75 @@ const CC_LEFT_CURLY = "{".charCodeAt(0);
125
132
  const CC_LOWER_V = "v".charCodeAt(0);
126
133
  const CC_UPPER_V = "V".charCodeAt(0);
127
134
  const CC_REVERSE_SOLIDUS = "\\".charCodeAt(0);
135
+ const CC_LEFT_PARENTHESIS = "(".charCodeAt(0);
136
+ const CC_RIGHT_PARENTHESIS = ")".charCodeAt(0);
137
+ const CC_QUOTATION_MARK = '"'.charCodeAt(0);
138
+ const CC_APOSTROPHE = "'".charCodeAt(0);
139
+
140
+ // A media condition's top-level keyword: an ASCII word outside every `(…)`.
141
+ const MEDIA_WORD_RE = /[a-z]+/gi;
142
+
143
+ /**
144
+ * A media condition as it can stand in a slot: in parentheses of its own where
145
+ * the slot joins it to others by an operator it does not share, else as written.
146
+ * @param {string} text the condition
147
+ * @param {MediaSlot} slot what the slot joins it to
148
+ * @returns {string} the condition to write there
149
+ */
150
+ const mediaConditionFor = (text, slot) => {
151
+ if (slot === "alone") return text;
152
+ let depth = 0;
153
+ let outside = "";
154
+ let groups = 0;
155
+ for (let i = 0; i < text.length; i++) {
156
+ const code = text.charCodeAt(i);
157
+ if (code === CC_LEFT_PARENTHESIS) {
158
+ if (depth++ === 0) groups++;
159
+ } else if (code === CC_RIGHT_PARENTHESIS) {
160
+ depth--;
161
+ } else if (depth === 0) {
162
+ outside += text[i];
163
+ }
164
+ }
165
+ const words = (outside.match(MEDIA_WORD_RE) || []).map((word) =>
166
+ word.toLowerCase()
167
+ );
168
+ if (groups === 1 && words.length === 0) return text;
169
+ // An `and` chain takes more `and` terms as they are, and nothing else.
170
+ if (slot === "and" && words.every((word) => word === "and")) return text;
171
+ return `(${text})`;
172
+ };
173
+
174
+ /**
175
+ * Each `:--name` a selector list asks for, outside strings and escapes and not
176
+ * after a second `:`, as the offsets of the colon and the name's end.
177
+ * @param {string} list the selector list
178
+ * @returns {{ name: string, start: number, end: number }[]} the names, in order
179
+ */
180
+ const customSelectorNames = (list) => {
181
+ /** @type {{ name: string, start: number, end: number }[]} */
182
+ const found = [];
183
+ for (let i = 0; i < list.length; i++) {
184
+ const code = list.charCodeAt(i);
185
+ if (code === CC_REVERSE_SOLIDUS) {
186
+ i++;
187
+ } else if (code === CC_QUOTATION_MARK || code === CC_APOSTROPHE) {
188
+ for (i++; i < list.length && list.charCodeAt(i) !== code; i++) {
189
+ if (list.charCodeAt(i) === CC_REVERSE_SOLIDUS) i++;
190
+ }
191
+ } else if (
192
+ code === CC_COLON &&
193
+ (i === 0 || list.charCodeAt(i - 1) !== CC_COLON) &&
194
+ list.startsWith("--", i + 1)
195
+ ) {
196
+ let end = i + 3;
197
+ while (end < list.length && /[\w\u0080-\uFFFF-]/.test(list[end])) end++;
198
+ found.push({ name: list.slice(i + 1, end), start: i, end });
199
+ i = end - 1;
200
+ }
201
+ }
202
+ return found;
203
+ };
128
204
 
129
205
  // A parsed CSS comment. `loc` is computed on demand — only magic-comment error
130
206
  // warnings read it, so comment-heavy CSS skips the per-comment line/col work.
@@ -208,10 +284,6 @@ const VALUE_AS_ALIAS = /\s+as\s+/;
208
284
  // `@value name value`: end of the name run (first non-space followed by space).
209
285
  const VALUE_NAME_BOUNDARY = /\S\s/;
210
286
  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
287
  // Relative request prefix (`./` or `../`) — `isSelfReferenceRequest` per `from`.
216
288
  const RELATIVE_REQUEST = /^\.{1,2}\//;
217
289
 
@@ -272,10 +344,14 @@ const knownPropertyForRange = (index, input, start, end) => {
272
344
  const hit = index.get(h);
273
345
  if (hit === undefined) return undefined;
274
346
  if (typeof hit === "string") {
275
- return rangeEqualsLowerCase(input, start, end, hit) ? hit : undefined;
347
+ return rangeAsciiCaseInsensitiveMatch(input, start, end, hit)
348
+ ? hit
349
+ : undefined;
276
350
  }
277
351
  for (let i = 0; i < hit.length; i++) {
278
- if (rangeEqualsLowerCase(input, start, end, hit[i])) return hit[i];
352
+ if (rangeAsciiCaseInsensitiveMatch(input, start, end, hit[i])) {
353
+ return hit[i];
354
+ }
279
355
  }
280
356
  return undefined;
281
357
  };
@@ -292,14 +368,14 @@ const counterFunctionNameIndex = (input, start, end, escapedName) => {
292
368
  // The `target-counter(url, name, style?)` cross-reference forms (Generated Content for Paged Media) name the counter second; print engines read them.
293
369
  if (escapedName !== undefined) {
294
370
  if (
295
- equalsLowerCase(escapedName, "counter") ||
296
- equalsLowerCase(escapedName, "counters")
371
+ asciiCaseInsensitiveMatch(escapedName, "counter") ||
372
+ asciiCaseInsensitiveMatch(escapedName, "counters")
297
373
  ) {
298
374
  return 0;
299
375
  }
300
376
  if (
301
- equalsLowerCase(escapedName, "target-counter") ||
302
- equalsLowerCase(escapedName, "target-counters")
377
+ asciiCaseInsensitiveMatch(escapedName, "target-counter") ||
378
+ asciiCaseInsensitiveMatch(escapedName, "target-counters")
303
379
  ) {
304
380
  return 1;
305
381
  }
@@ -307,13 +383,24 @@ const counterFunctionNameIndex = (input, start, end, escapedName) => {
307
383
  }
308
384
  switch (end - start) {
309
385
  case 7:
310
- return rangeEqualsLowerCase(input, start, end, "counter") ? 0 : -1;
386
+ return rangeAsciiCaseInsensitiveMatch(input, start, end, "counter")
387
+ ? 0
388
+ : -1;
311
389
  case 8:
312
- return rangeEqualsLowerCase(input, start, end, "counters") ? 0 : -1;
390
+ return rangeAsciiCaseInsensitiveMatch(input, start, end, "counters")
391
+ ? 0
392
+ : -1;
313
393
  case 14:
314
- return rangeEqualsLowerCase(input, start, end, "target-counter") ? 1 : -1;
394
+ return rangeAsciiCaseInsensitiveMatch(input, start, end, "target-counter")
395
+ ? 1
396
+ : -1;
315
397
  case 15:
316
- return rangeEqualsLowerCase(input, start, end, "target-counters")
398
+ return rangeAsciiCaseInsensitiveMatch(
399
+ input,
400
+ start,
401
+ end,
402
+ "target-counters"
403
+ )
317
404
  ? 1
318
405
  : -1;
319
406
  default:
@@ -341,7 +428,7 @@ const buildKnownProperties = (options = {}) => {
341
428
  knownProperties.set(
342
429
  property,
343
430
  /** @type {Map<string, number>} */
344
- (CSS_MODULES_KEYWORDS.get(property))
431
+ (getCssModulesKeywords().get(property))
345
432
  );
346
433
  }
347
434
  }
@@ -472,13 +559,13 @@ const gridAreaNames = (input, start, end) => {
472
559
  const names = [];
473
560
  let i = start;
474
561
  while (i < end) {
475
- while (i < end && isWhitespace(input.charCodeAt(i))) i++;
562
+ while (i < end && isAsciiWhitespace(input.charCodeAt(i))) i++;
476
563
  if (i >= end) break;
477
564
  const nameStart = i;
478
565
  let nullCell = true;
479
566
  while (i < end) {
480
567
  const cc = input.charCodeAt(i);
481
- if (isWhitespace(cc)) break;
568
+ if (isAsciiWhitespace(cc)) break;
482
569
  if (cc === CC_REVERSE_SOLIDUS) {
483
570
  i = Math.min(skipEscape(input, i), end);
484
571
  nullCell = false;
@@ -524,32 +611,42 @@ const isPureBodyAtRule = (name) =>
524
611
  name === "@container" ||
525
612
  name === "@scope";
526
613
 
614
+ /**
615
+ * A rule's or function's name as written, escapes kept.
616
+ * @param {AstNode} n at-rule, declaration or function
617
+ * @returns {string} the raw name
618
+ */
619
+ const rawNameOf = (n) =>
620
+ A.source(A.startOf(Part.name, n), A.endOf(Part.name, n));
621
+
622
+ /**
623
+ * @param {AstNode} n an ident, string or hash
624
+ * @returns {string} its value, escapes resolved
625
+ */
626
+ const stringValue = (n) => /** @type {string} */ (A.value(n));
627
+
527
628
  /**
528
629
  * 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
630
+ * @param {AstNode} rule rule with a block
531
631
  * @returns {{ hasDirectDecl: boolean, hasNestedBlock: boolean }} scan result
532
632
  */
533
- const scanRuleBody = (declarations, childRules) => {
534
- let hasDirectDecl = Boolean(declarations && declarations.length > 0);
633
+ const scanRuleBody = (rule) => {
634
+ let hasDirectDecl = A.fieldCount(Field.declarations, rule) > 0;
535
635
  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
- }
636
+ for (let i = 0, count = A.fieldCount(Field.rules, rule); i < count; i++) {
637
+ const child = A.field(i, Field.rules, rule);
638
+ const t = A.type(child);
639
+ if (t === NodeType.QualifiedRule) {
640
+ hasNestedBlock = true;
641
+ } else if (t === NodeType.AtRule) {
642
+ if (A.startOf(Part.block, child) === -1) continue;
643
+ hasNestedBlock = true;
644
+ if (
645
+ !hasDirectDecl &&
646
+ !isPureBodyAtRule(`@${toLowerCaseIfNeeded(rawNameOf(child))}`) &&
647
+ scanRuleBody(child).hasDirectDecl
648
+ ) {
649
+ hasDirectDecl = true;
553
650
  }
554
651
  }
555
652
  }
@@ -564,12 +661,14 @@ const scanRuleBody = (declarations, childRules) => {
564
661
  const parseValueAtRuleParams = (str) => {
565
662
  if (VALUE_IMPORT_FORM.test(str)) {
566
663
  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();
664
+ // Split on the first `from` keyword delimited by CSS whitespace (only
665
+ // ` \t\n\f\r`, not JS `\s`, which also matches U+00A0 valid in a name),
666
+ // so a path or name containing the substring (`./from-colors.css`) isn't it.
667
+ const fromMatch = /^([\s\S]+?)[ \t\n\f\r]+from[ \t\n\f\r]+([\s\S]+)$/i.exec(
668
+ str
669
+ );
670
+ const path = (fromMatch ? fromMatch[2] : "").trim().replace(/['"]/g, "");
671
+ let content = (fromMatch ? fromMatch[1] : str).trim();
573
672
 
574
673
  if (content.startsWith("(") && content.endsWith(")")) {
575
674
  content = content.slice(1, -1);
@@ -666,7 +765,7 @@ const parseImportPrelude = (prelude) => {
666
765
  }
667
766
  if (
668
767
  t === NodeType.Function &&
669
- equalsLowerCase(A.unescapedName(cv), "url")
768
+ asciiCaseInsensitiveMatch(A.name(cv), "url")
670
769
  ) {
671
770
  urlNode = cv;
672
771
  continue;
@@ -681,13 +780,13 @@ const parseImportPrelude = (prelude) => {
681
780
 
682
781
  if (!layerNode && !supportsNode) {
683
782
  if (t === NodeType.Ident) {
684
- if (equalsLowerCase(A.unescaped(cv), "layer")) {
783
+ if (asciiCaseInsensitiveMatch(stringValue(cv), "layer")) {
685
784
  layerNode = cv;
686
785
  continue;
687
786
  }
688
787
  } else if (
689
788
  t === NodeType.Function &&
690
- equalsLowerCase(A.unescapedName(cv), "layer")
789
+ asciiCaseInsensitiveMatch(A.name(cv), "layer")
691
790
  ) {
692
791
  layerNode = cv;
693
792
  continue;
@@ -697,7 +796,7 @@ const parseImportPrelude = (prelude) => {
697
796
  if (
698
797
  !supportsNode &&
699
798
  t === NodeType.Function &&
700
- equalsLowerCase(A.unescapedName(cv), "supports")
799
+ asciiCaseInsensitiveMatch(A.name(cv), "supports")
701
800
  ) {
702
801
  supportsNode = /** @type {FunctionNode} */ (cv);
703
802
  continue;
@@ -723,8 +822,8 @@ const parseIcssImportRequest = (second, rule, source) => {
723
822
  if (A.type(second) === NodeType.Function) {
724
823
  args = A.children(second);
725
824
  } else {
726
- for (const p of A.prelude(rule)) {
727
- if (A.type(p) === NodeType.SimpleBlock && A.blockToken(p) === "(") {
825
+ for (const p of A.children(rule)) {
826
+ if (A.type(p) === NodeType.SimpleBlock && A.value(p) === "(") {
728
827
  args = A.children(p);
729
828
  break;
730
829
  }
@@ -736,7 +835,7 @@ const parseIcssImportRequest = (second, rule, source) => {
736
835
  if (!innerStrToken || A.type(innerStrToken) !== NodeType.String) {
737
836
  const errorPos =
738
837
  A.type(second) === NodeType.Function
739
- ? A.nameEnd(second) + 1
838
+ ? A.endOf(Part.name, second) + 1
740
839
  : A.end(second);
741
840
  return { errorPos };
742
841
  }
@@ -745,6 +844,9 @@ const parseIcssImportRequest = (second, rule, source) => {
745
844
  };
746
845
  };
747
846
 
847
+ /**
848
+ * @extends {Parser<BuiltCssModule>}
849
+ */
748
850
  class CssParser extends Parser {
749
851
  /**
750
852
  * Creates an instance of CssParser.
@@ -830,7 +932,7 @@ class CssParser extends Parser {
830
932
  * themselves. Same-kind redeclarations are silent.
831
933
  * @param {ParserState} state parser state
832
934
  * @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
935
+ * @param {import("../dependencies/css/CssIcssExportDependency").CssExportEntry[]} cssExportEntries all export entries — losers are demoted in place
834
936
  * @returns {void}
835
937
  */
836
938
  _resolveAmbiguousExports(state, declaredExports, cssExportEntries) {
@@ -932,8 +1034,8 @@ class CssParser extends Parser {
932
1034
  * `CssUrlDependency`. Magic comments win over the project-wide default.
933
1035
  * @param {CssUrlDependency} dep dep
934
1036
  * @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
1037
+ * @param {MagicCommentOptions | null | undefined} options parsed comment options
1038
+ * @param {import("../graph/Dependency").DependencyLocation} loc location for warnings
937
1039
  * @returns {void}
938
1040
  */
939
1041
  const applyResourceHintDefaults = (dep, request, options, loc) => {
@@ -960,7 +1062,7 @@ class CssParser extends Parser {
960
1062
  );
961
1063
  };
962
1064
 
963
- const module = state.module;
1065
+ const module = /** @type {CssModule & BuiltCssModule} */ (state.module);
964
1066
 
965
1067
  // Every CSS Modules export declaration is tracked here so `_resolveAmbiguousExports` can arbitrate cross-kind collisions in one pass at end-of-parse: a class silently wins over CSS-scoped kinds (`@keyframes`, `@counter-style`, `@container`, custom property, grid identifier) — matching css-loader / lightning css / postcss-modules — while other pairs (`class` ↔ `id`, `class` ↔ `:export`, `class` ↔ `@value`, …) surface as a warning so the user can resolve them.
966
1068
  /** @typedef {{ kind: string, line: number, column: number, entries: number[] }} DeclarationOfKind */
@@ -1015,7 +1117,7 @@ class CssParser extends Parser {
1015
1117
  // All `:export`-style exports are collected into a single
1016
1118
  // `CssIcssExportDependency` per module (emitted at parse end) instead of one
1017
1119
  // `Dependency` per export — far fewer retained objects on CSS-heavy builds.
1018
- /** @type {import("../dependencies/CssIcssExportDependency").CssExportEntry[]} */
1120
+ /** @type {import("../dependencies/css/CssIcssExportDependency").CssExportEntry[]} */
1019
1121
  const cssExportEntries = [];
1020
1122
  /**
1021
1123
  * @param {number} sl start line
@@ -1023,11 +1125,11 @@ class CssParser extends Parser {
1023
1125
  * @param {number} el end line
1024
1126
  * @param {number} ec end column
1025
1127
  * @param {string} name export name
1026
- * @param {import("../dependencies/CssIcssExportDependency").Value} value value or [localName, importName, request?]
1128
+ * @param {import("../dependencies/css/CssIcssExportDependency").Value} value value or [localName, importName, request?]
1027
1129
  * @param {Range=} range source range to replace, when present
1028
1130
  * @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
1131
+ * @param {import("../dependencies/css/CssIcssExportDependency").ExportMode=} exportMode export mode
1132
+ * @param {import("../dependencies/css/CssIcssExportDependency").ExportType=} exportType export type
1031
1133
  * @returns {void}
1032
1134
  */
1033
1135
  const addCssExport = (
@@ -1120,11 +1222,9 @@ class CssParser extends Parser {
1120
1222
  });
1121
1223
  const knownPropertyIndex = getKnownPropertyIndex(knownProperties);
1122
1224
 
1123
- /** @type {CssModuleBuildMeta} */
1124
- (module.buildMeta).isCssModule = isModules;
1125
- if (/** @type {CssModule} */ (module).exportType === "style") {
1126
- /** @type {CssModuleBuildMeta} */
1127
- (module.buildMeta).needIdInConcatenation = true;
1225
+ module.buildMeta.isCssModule = isModules;
1226
+ if (module.exportType === "style") {
1227
+ module.buildMeta.needIdInConcatenation = true;
1128
1228
  }
1129
1229
 
1130
1230
  const locConverter = new LocConverter(source);
@@ -1165,10 +1265,10 @@ class CssParser extends Parser {
1165
1265
  * @param {Range} range byte range to scan for magic comments
1166
1266
  * @param {number} warnStart start offset of the loc for an invalid-`webpackIgnore` warning (computed lazily)
1167
1267
  * @param {number} warnEnd end offset of that loc
1168
- * @returns {{ ignored: boolean, options: Record<string, EXPECTED_ANY> | null }} parsed options and `webpackIgnore` flag
1268
+ * @returns {{ ignored: boolean, options: MagicCommentOptions | null }} parsed options and `webpackIgnore` flag
1169
1269
  */
1170
1270
  const magicCommentsIn = (range, warnStart, warnEnd) => {
1171
- /** @type {{ options: Record<string, EXPECTED_ANY> | null, errors: (Error & { comment: Comment })[] | null }} */
1271
+ /** @type {{ options: MagicCommentOptions | null, errors: (Error & { comment: Comment })[] | null }} */
1172
1272
  const { options, errors } = parseCommentOptionsInRange(
1173
1273
  /** @type {(Comment & { range: [number, number], value: string })[]} */ (
1174
1274
  comments
@@ -1229,13 +1329,15 @@ class CssParser extends Parser {
1229
1329
  let customMediaQueries;
1230
1330
  /** @type {Map<string, string> | undefined} */
1231
1331
  let customSelectorDefs;
1332
+ /** @type {Map<string, string | null> | undefined} */
1333
+ let customSelectorValues;
1232
1334
  /** @type {{ name: string, start: number, end: number }[] | undefined} */
1233
1335
  let customSelectorUses;
1234
1336
 
1235
1337
  /**
1236
1338
  * Unescape a CSS identifier from a source byte range — for value spans not
1237
1339
  * backed by a single token (string contents, `--` dashed-ident bodies,
1238
- * composed names). Token-backed names use `A.unescaped(node)` instead.
1340
+ * composed names). Token-backed names use `stringValue(node)` instead.
1239
1341
  * @param {number} start start offset
1240
1342
  * @param {number} end end offset
1241
1343
  * @returns {string} the unescaped identifier
@@ -1326,7 +1428,7 @@ class CssParser extends Parser {
1326
1428
  },
1327
1429
  /**
1328
1430
  * 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
1431
+ * @param {{ isRulePrelude: boolean, treatAsLeaf: boolean, ownSkip: boolean, rule: AstNode, preludeStart: number, preludeEnd: number }} opts entry options
1330
1432
  */
1331
1433
  enterBlock(opts) {
1332
1434
  if (!this.enabled) return;
@@ -1334,8 +1436,7 @@ class CssParser extends Parser {
1334
1436
  isRulePrelude,
1335
1437
  treatAsLeaf,
1336
1438
  ownSkip,
1337
- declarations,
1338
- childRules,
1439
+ rule,
1339
1440
  preludeStart,
1340
1441
  preludeEnd
1341
1442
  } = opts;
@@ -1348,13 +1449,10 @@ class CssParser extends Parser {
1348
1449
  isRulePrelude &&
1349
1450
  this.ruleImpure;
1350
1451
  if (reportable) {
1351
- const hasBody = Boolean(declarations || childRules);
1452
+ const hasBody = A.startOf(Part.block, rule) !== -1;
1352
1453
  let leaf = treatAsLeaf || !hasBody;
1353
1454
  if (!leaf && hasBody) {
1354
- const { hasDirectDecl, hasNestedBlock } = scanRuleBody(
1355
- declarations,
1356
- childRules
1357
- );
1455
+ const { hasDirectDecl, hasNestedBlock } = scanRuleBody(rule);
1358
1456
  leaf = hasDirectDecl || !hasNestedBlock;
1359
1457
  }
1360
1458
  if (leaf) this.report(preludeStart, preludeEnd);
@@ -1426,7 +1524,7 @@ class CssParser extends Parser {
1426
1524
 
1427
1525
  /**
1428
1526
  * 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
1527
+ * @param {import("./syntax-parser").CssPath} path walk path at the comment node
1430
1528
  */
1431
1529
  const commentVisitor = (path) => {
1432
1530
  const node = path.node;
@@ -1556,22 +1654,26 @@ class CssParser extends Parser {
1556
1654
  };
1557
1655
 
1558
1656
  // 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]);
1657
+ if (A.startOf(Part.block, rule) === -1) return A.end(second);
1658
+ for (
1659
+ let i = 0, count = A.fieldCount(Field.declarations, rule);
1660
+ i < count;
1661
+ i++
1662
+ ) {
1663
+ const decl = A.field(i, Field.declarations, rule);
1664
+ const valueCount = A.childCount(decl);
1665
+ if (valueCount === 0) continue;
1666
+ const rawStart = A.start(A.child(0, decl));
1667
+ const rawEnd = A.end(A.child(valueCount - 1, decl));
1566
1668
  createDep(
1567
- source.slice(A.nameStart(decl), A.nameEnd(decl)),
1669
+ source.slice(A.startOf(Part.name, decl), A.endOf(Part.name, decl)),
1568
1670
  source.slice(rawStart, rawEnd),
1569
- A.nameEnd(decl),
1671
+ A.endOf(Part.name, decl),
1570
1672
  rawEnd
1571
1673
  );
1572
1674
  }
1573
1675
 
1574
- return skipWhiteLine(source, A.blockEnd(rule));
1676
+ return skipWhiteLine(source, A.endOf(Part.block, rule));
1575
1677
  };
1576
1678
 
1577
1679
  /**
@@ -1611,9 +1713,13 @@ class CssParser extends Parser {
1611
1713
  if (!def || def.importName || typeof def.value !== "string") {
1612
1714
  return undefined;
1613
1715
  }
1614
- const match = SIMPLE_CLASS_OR_ID_VALUE.exec(def.value.trim());
1615
- return match
1616
- ? [/** @type {"." | "#"} */ (match[1]), match[2]]
1716
+ // Only one `.class` / `#id` has a localizable ident knowable without
1717
+ // re-parsing the substitution.
1718
+ const value = def.value.trim();
1719
+ const prefix = value.charAt(0);
1720
+ return (prefix === "." || prefix === "#") &&
1721
+ isSimpleIdentifier(value.slice(1))
1722
+ ? [prefix, value.slice(1)]
1617
1723
  : undefined;
1618
1724
  };
1619
1725
 
@@ -1632,6 +1738,100 @@ class CssParser extends Parser {
1632
1738
  return isDashedIdentifier(value) ? value.slice(2) : undefined;
1633
1739
  };
1634
1740
 
1741
+ /**
1742
+ * Add the entry for an ident naming an imported `@value`, which `CssIcssExportDependency` scopes and names once the import resolves.
1743
+ * @param {string} identifier `@value` name as written
1744
+ * @param {number} start ident start offset
1745
+ * @param {number} end ident end offset
1746
+ * @param {import("../dependencies/css/CssIcssExportDependency").ExportMode} exportMode one of the `RESOLVED_*` modes
1747
+ * @param {import("../dependencies/css/CssIcssExportDependency").Value=} value the reference, when it carries more than `getReexport` gives
1748
+ */
1749
+ const addResolvedExport = (
1750
+ identifier,
1751
+ start,
1752
+ end,
1753
+ exportMode,
1754
+ value = getReexport(identifier)
1755
+ ) => {
1756
+ const { line: sl, column: sc } = locConverter.get(start);
1757
+ const { line: el, column: ec } = locConverter.get(end);
1758
+ addCssExport(
1759
+ sl,
1760
+ sc,
1761
+ el,
1762
+ ec,
1763
+ identifier,
1764
+ value,
1765
+ [start, end],
1766
+ true,
1767
+ exportMode
1768
+ );
1769
+ };
1770
+
1771
+ /**
1772
+ * 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.
1773
+ * @param {string} identifier ident as written in the source
1774
+ * @param {number} start ident start offset
1775
+ * @param {number} end ident end offset
1776
+ * @param {string | undefined} kind export kind for conflict tracking, undefined for a usage
1777
+ * @param {import("../dependencies/css/CssIcssExportDependency").ExportType} exportType export type
1778
+ */
1779
+ const addLocalizedExport = (identifier, start, end, kind, exportType) => {
1780
+ const def =
1781
+ icssDefinitions.size === 0
1782
+ ? undefined
1783
+ : icssDefinitions.get(identifier);
1784
+ if (def !== undefined && def.importName) {
1785
+ addResolvedExport(
1786
+ identifier,
1787
+ start,
1788
+ end,
1789
+ CssIcssExportDependency.EXPORT_MODE.RESOLVED_NAME
1790
+ );
1791
+ return;
1792
+ }
1793
+ const { line: sl, column: sc } = locConverter.get(start);
1794
+ const { line: el, column: ec } = locConverter.get(end);
1795
+ let name = identifier;
1796
+ let exportMode = CssIcssExportDependency.EXPORT_MODE.ONCE;
1797
+ if (def !== undefined) {
1798
+ const value = typeof def.value === "string" ? def.value.trim() : "";
1799
+ if (isSimpleIdentifier(value)) {
1800
+ name = value;
1801
+ } else {
1802
+ exportMode = CssIcssExportDependency.EXPORT_MODE.NONE;
1803
+ this._emitWarning(
1804
+ state,
1805
+ CssIcssExportDependency.notSimpleIdentifierMessage(
1806
+ identifier,
1807
+ value
1808
+ ),
1809
+ locConverter,
1810
+ start,
1811
+ end
1812
+ );
1813
+ }
1814
+ }
1815
+ if (
1816
+ kind !== undefined &&
1817
+ exportMode === CssIcssExportDependency.EXPORT_MODE.ONCE
1818
+ ) {
1819
+ recordDeclaration(name, kind, sl, sc);
1820
+ }
1821
+ addCssExport(
1822
+ sl,
1823
+ sc,
1824
+ el,
1825
+ ec,
1826
+ name,
1827
+ getReexport(identifier),
1828
+ [start, end],
1829
+ true,
1830
+ exportMode,
1831
+ exportType
1832
+ );
1833
+ };
1834
+
1635
1835
  /**
1636
1836
  * 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
1837
  * @param {FunctionNode} fn parsed local/global function node
@@ -1642,7 +1842,7 @@ class CssParser extends Parser {
1642
1842
  // Replace `local(` / `global(` (and a leading `:` for the `:local(`/`:global(` selector form) with empty.
1643
1843
  const fnStart = A.start(fn);
1644
1844
  const isColon = input.charCodeAt(fnStart - 1) === CC_COLON;
1645
- const openEnd = A.nameEnd(fn) + 1;
1845
+ const openEnd = A.endOf(Part.name, fn) + 1;
1646
1846
  module.addPresentationalDependency(
1647
1847
  new ConstDependency("", [isColon ? fnStart - 1 : fnStart, openEnd])
1648
1848
  );
@@ -1650,19 +1850,23 @@ class CssParser extends Parser {
1650
1850
  if (type === 1) {
1651
1851
  for (const cv of A.children(fn)) {
1652
1852
  if (A.type(cv) !== NodeType.Ident) continue;
1653
- let identifier = A.unescaped(cv);
1853
+ let identifier = stringValue(cv);
1854
+ if (!isDashedIdentifier(identifier)) {
1855
+ addLocalizedExport(
1856
+ identifier,
1857
+ A.start(cv),
1858
+ A.end(cv),
1859
+ declarationKind,
1860
+ CssIcssExportDependency.EXPORT_TYPE.NORMAL
1861
+ );
1862
+ continue;
1863
+ }
1654
1864
  // Cursor reads instead of `A.loc` — no location objects allocated.
1655
1865
  const { line: sl, column: sc } = locConverter.get(A.start(cv));
1656
1866
  const { line: el, column: ec } = locConverter.get(A.end(cv));
1657
- const isDashedIdent = isDashedIdentifier(identifier);
1658
- if (isDashedIdent) identifier = identifier.slice(2);
1867
+ identifier = identifier.slice(2);
1659
1868
  if (declarationKind !== undefined) {
1660
- recordDeclaration(
1661
- identifier,
1662
- isDashedIdent ? "custom property" : declarationKind,
1663
- sl,
1664
- sc
1665
- );
1869
+ recordDeclaration(identifier, "custom property", sl, sc);
1666
1870
  }
1667
1871
  addCssExport(
1668
1872
  sl,
@@ -1674,9 +1878,7 @@ class CssParser extends Parser {
1674
1878
  [A.start(cv), A.end(cv)],
1675
1879
  true,
1676
1880
  CssIcssExportDependency.EXPORT_MODE.ONCE,
1677
- isDashedIdent
1678
- ? CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
1679
- : CssIcssExportDependency.EXPORT_TYPE.NORMAL
1881
+ CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
1680
1882
  );
1681
1883
  }
1682
1884
  }
@@ -1696,13 +1898,13 @@ class CssParser extends Parser {
1696
1898
  */
1697
1899
  const processLocalAtRule = (atRule, options, kind) => {
1698
1900
  let found = false;
1699
- for (const cv of A.prelude(atRule)) {
1901
+ for (const cv of A.children(atRule)) {
1700
1902
  const cvType = A.type(cv);
1701
1903
  if (cvType === NodeType.Whitespace) continue;
1702
1904
 
1703
1905
  if (cvType === NodeType.String) {
1704
1906
  if (!found && options.string) {
1705
- const value = A.unescaped(cv);
1907
+ const value = stringValue(cv);
1706
1908
  const { line: sl, column: sc } = locConverter.get(A.start(cv));
1707
1909
  const { line: el, column: ec } = locConverter.get(A.end(cv));
1708
1910
  recordDeclaration(value, kind, sl, sc);
@@ -1725,26 +1927,18 @@ class CssParser extends Parser {
1725
1927
 
1726
1928
  if (cvType === NodeType.Ident) {
1727
1929
  if (!found && options.identifier) {
1728
- const identifier = A.unescaped(cv);
1930
+ const identifier = stringValue(cv);
1729
1931
  if (
1730
1932
  options.identifier instanceof RegExp &&
1731
1933
  options.identifier.test(identifier)
1732
1934
  ) {
1733
1935
  continue;
1734
1936
  }
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,
1937
+ addLocalizedExport(
1743
1938
  identifier,
1744
- getReexport(identifier),
1745
- [A.start(cv), A.end(cv)],
1746
- true,
1747
- CssIcssExportDependency.EXPORT_MODE.ONCE,
1939
+ A.start(cv),
1940
+ A.end(cv),
1941
+ kind,
1748
1942
  CssIcssExportDependency.EXPORT_TYPE.NORMAL
1749
1943
  );
1750
1944
  found = true;
@@ -1755,10 +1949,10 @@ class CssParser extends Parser {
1755
1949
 
1756
1950
  if (cvType === NodeType.Function) {
1757
1951
  const fn = /** @type {FunctionNode} */ (cv);
1758
- const fname = A.unescapedName(fn);
1759
- const type = equalsLowerCase(fname, "local")
1952
+ const fname = A.name(fn);
1953
+ const type = asciiCaseInsensitiveMatch(fname, "local")
1760
1954
  ? 1
1761
- : equalsLowerCase(fname, "global")
1955
+ : asciiCaseInsensitiveMatch(fname, "global")
1762
1956
  ? 2
1763
1957
  : undefined;
1764
1958
  if (!found && type) {
@@ -1770,7 +1964,8 @@ class CssParser extends Parser {
1770
1964
  if (
1771
1965
  this.options.dashedIdents &&
1772
1966
  isLocalMode() &&
1773
- (equalsLowerCase(fname, "var") || equalsLowerCase(fname, "style"))
1967
+ (asciiCaseInsensitiveMatch(fname, "var") ||
1968
+ asciiCaseInsensitiveMatch(fname, "style"))
1774
1969
  ) {
1775
1970
  processDashedIdentInVarFunction(fn);
1776
1971
  }
@@ -1914,7 +2109,7 @@ class CssParser extends Parser {
1914
2109
  if (!rangeIsDashedIdentifier(input, identStart, identEnd)) {
1915
2110
  // `var(v)` where `@value v: --foo` names the same property `var(--foo)`
1916
2111
  // does, so it is scoped here rather than substituted verbatim.
1917
- const dashedName = localizableDashedValue(A.value(identNode));
2112
+ const dashedName = localizableDashedValue(A.source(identNode));
1918
2113
  if (dashedName !== undefined) {
1919
2114
  handledDashedValueIdents.add(identStart);
1920
2115
  emitNamedDashedIdentExport(dashedName, identStart, identEnd);
@@ -1930,7 +2125,12 @@ class CssParser extends Parser {
1930
2125
  if (
1931
2126
  j >= fv.length ||
1932
2127
  A.type(fv[j]) !== NodeType.Ident ||
1933
- !rangeEqualsLowerCase(input, A.start(fv[j]), A.end(fv[j]), "from")
2128
+ !rangeAsciiCaseInsensitiveMatch(
2129
+ input,
2130
+ A.start(fv[j]),
2131
+ A.end(fv[j]),
2132
+ "from"
2133
+ )
1934
2134
  ) {
1935
2135
  emitDashedIdentExport(identStart, identEnd);
1936
2136
  return;
@@ -2065,7 +2265,7 @@ class CssParser extends Parser {
2065
2265
  if (isLocal) {
2066
2266
  while (
2067
2267
  trailStart > 0 &&
2068
- isWhitespace(source.charCodeAt(trailStart - 1))
2268
+ isAsciiWhitespace(source.charCodeAt(trailStart - 1))
2069
2269
  ) {
2070
2270
  trailStart--;
2071
2271
  }
@@ -2091,8 +2291,8 @@ class CssParser extends Parser {
2091
2291
  }
2092
2292
  const attrNameNode = attrParts[ai];
2093
2293
  if (!attrNameNode || A.type(attrNameNode) !== NodeType.Ident) return;
2094
- const attrName = A.unescaped(attrNameNode);
2095
- if (!equalsLowerCase(attrName, "class")) return;
2294
+ const attrName = stringValue(attrNameNode);
2295
+ if (!asciiCaseInsensitiveMatch(attrName, "class")) return;
2096
2296
  ai++;
2097
2297
  while (
2098
2298
  ai < attrParts.length &&
@@ -2103,11 +2303,11 @@ class CssParser extends Parser {
2103
2303
  // `=` or `~=` (two `Delim` tokens for the latter).
2104
2304
  const op1 = attrParts[ai];
2105
2305
  if (!op1 || A.type(op1) !== NodeType.Delim) return;
2106
- const op1v = A.value(op1);
2306
+ const op1v = A.source(op1);
2107
2307
  if (op1v === "~") {
2108
2308
  ai++;
2109
2309
  const op2 = attrParts[ai];
2110
- if (!op2 || A.type(op2) !== NodeType.Delim || A.value(op2) !== "=") {
2310
+ if (!op2 || A.type(op2) !== NodeType.Delim || A.source(op2) !== "=") {
2111
2311
  return;
2112
2312
  }
2113
2313
  } else if (op1v !== "=") {
@@ -2161,7 +2361,7 @@ class CssParser extends Parser {
2161
2361
  if (!this.options.customIdents) return;
2162
2362
  for (const cv of cvs) {
2163
2363
  if (A.type(cv) !== NodeType.Ident) continue;
2164
- const name = A.unescaped(cv);
2364
+ const name = stringValue(cv);
2165
2365
  if (isDashedIdentifier(name)) continue;
2166
2366
  const start = A.start(cv);
2167
2367
  const end = A.end(cv);
@@ -2189,11 +2389,11 @@ class CssParser extends Parser {
2189
2389
  * @returns {void}
2190
2390
  */
2191
2391
  const emitCounterIdent = (node, reservedFrom) => {
2192
- const name = A.unescaped(node);
2392
+ const name = stringValue(node);
2193
2393
  if (isDashedIdentifier(name)) return;
2194
2394
  const reserved =
2195
2395
  /** @type {Map<string, number>} */
2196
- (CSS_MODULES_KEYWORDS.get(reservedFrom));
2396
+ (getCssModulesKeywords().get(reservedFrom));
2197
2397
  if (reserved.has(toLowerCaseIfNeeded(name))) return;
2198
2398
  const start = A.start(node);
2199
2399
  const end = A.end(node);
@@ -2284,9 +2484,9 @@ class CssParser extends Parser {
2284
2484
  if (!next) break;
2285
2485
  const nextType = A.type(next);
2286
2486
  if (nextType === NodeType.Ident) {
2287
- const raw = A.value(next);
2288
- const isLocal = equalsLowerCase(raw, "local");
2289
- if (isLocal || equalsLowerCase(raw, "global")) {
2487
+ const raw = A.source(next);
2488
+ const isLocal = asciiCaseInsensitiveMatch(raw, "local");
2489
+ if (isLocal || asciiCaseInsensitiveMatch(raw, "global")) {
2290
2490
  const id = isLocal ? "local" : "global";
2291
2491
  // Bare `:local` / `:global`: switch the segment (and top-level persistent) mode and strip the marker.
2292
2492
  const afterIsWhitespace = stripBareMarker(
@@ -2314,9 +2514,9 @@ class CssParser extends Parser {
2314
2514
  }
2315
2515
  } else if (nextType === NodeType.Function) {
2316
2516
  const fn = /** @type {FunctionNode} */ (next);
2317
- const rawName = A.unescapedName(fn);
2318
- const isLocal = equalsLowerCase(rawName, "local");
2319
- if (isLocal || equalsLowerCase(rawName, "global")) {
2517
+ const rawName = A.name(fn);
2518
+ const isLocal = asciiCaseInsensitiveMatch(rawName, "local");
2519
+ if (isLocal || asciiCaseInsensitiveMatch(rawName, "global")) {
2320
2520
  // `:local(…)` / `:global(…)`: scope mode to the args and strip the `:name(` … `)` wrapper.
2321
2521
  stripFunctionMarker(v, fn, isLocal);
2322
2522
  walkSelectorList(
@@ -2332,12 +2532,12 @@ class CssParser extends Parser {
2332
2532
  }
2333
2533
  case NodeType.Function: {
2334
2534
  // `::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);
2535
+ const fnNameStart = A.startOf(Part.name, v);
2336
2536
  if (
2337
2537
  segmentMode === "local" &&
2338
2538
  (input.charCodeAt(fnNameStart) === CC_LOWER_V ||
2339
2539
  input.charCodeAt(fnNameStart) === CC_UPPER_V) &&
2340
- VIEW_TRANSITION_PART_PSEUDO.test(A.unescapedName(v))
2540
+ VIEW_TRANSITION_PART_PSEUDO.test(A.name(v))
2341
2541
  ) {
2342
2542
  walkViewTransitionPart(A.children(v));
2343
2543
  break;
@@ -2347,12 +2547,12 @@ class CssParser extends Parser {
2347
2547
  break;
2348
2548
  }
2349
2549
  case NodeType.Hash: {
2350
- if (A.typeFlag(v) !== "id" || segmentMode !== "local") {
2550
+ if (!A.flag(Flag.id, v) || segmentMode !== "local") {
2351
2551
  break;
2352
2552
  }
2353
2553
  // ID selectors emit the ICSS export but aren't a `composes:` anchor.
2354
2554
  const idValueStart = A.start(v) + 1;
2355
- const idName = A.unescaped(v);
2555
+ const idName = stringValue(v);
2356
2556
  const { line: idSl, column: idSc } = locConverter.get(A.start(v));
2357
2557
  const { line: idEl, column: idEc } = locConverter.get(A.end(v));
2358
2558
  recordDeclaration(idName, "id", idSl, idSc);
@@ -2372,7 +2572,7 @@ class CssParser extends Parser {
2372
2572
  }
2373
2573
  case NodeType.SimpleBlock: {
2374
2574
  const block = /** @type {SimpleBlock} */ (v);
2375
- const bt = A.blockToken(block);
2575
+ const bt = A.value(block);
2376
2576
  if (bt === "[") {
2377
2577
  // Attribute selectors `[class="foo"]` localize only in local mode.
2378
2578
  if (segmentMode === "local") handleAttributeSelector(block);
@@ -2383,7 +2583,7 @@ class CssParser extends Parser {
2383
2583
  break;
2384
2584
  }
2385
2585
  case NodeType.Delim: {
2386
- const delim = A.value(v);
2586
+ const delim = A.source(v);
2387
2587
  if (delim === "&") {
2388
2588
  // Pure-mode: a nesting `&` inherits a pure ancestor's purity.
2389
2589
  if (topLevel && pure.ancestorHadLocal()) pure.markLocal();
@@ -2394,7 +2594,7 @@ class CssParser extends Parser {
2394
2594
  if (!next || A.type(next) !== NodeType.Ident) break;
2395
2595
  if (segmentMode === "local") {
2396
2596
  // `.<ident>` in local mode is a class selector (dep covers the ident bytes only).
2397
- const name = A.unescaped(next);
2597
+ const name = stringValue(next);
2398
2598
  // Cursor reads instead of `A.loc` — this is the hottest export site.
2399
2599
  const { line: sl, column: sc } = locConverter.get(A.start(next));
2400
2600
  const { line: el, column: ec } = locConverter.get(A.end(next));
@@ -2415,7 +2615,7 @@ class CssParser extends Parser {
2415
2615
  pure.markLocal();
2416
2616
  } else if (icssDefinitions.size !== 0) {
2417
2617
  // `.<ident>` in global mode: not localized, but the ident may be `@value`-defined and need ICSS rewrite.
2418
- const ident = A.value(next);
2618
+ const ident = A.source(next);
2419
2619
  if (!isDashedIdentifier(ident) && icssDefinitions.has(ident)) {
2420
2620
  emitICSSSymbol(ident, A.start(next), A.end(next));
2421
2621
  }
@@ -2427,7 +2627,7 @@ class CssParser extends Parser {
2427
2627
  case NodeType.Ident: {
2428
2628
  // A bare `@value`-defined ident stands in for a selector; only worth the slice when definitions exist.
2429
2629
  if (icssDefinitions.size === 0) break;
2430
- const ident = A.value(v);
2630
+ const ident = A.source(v);
2431
2631
  if (isDashedIdentifier(ident) || !icssDefinitions.has(ident)) {
2432
2632
  break;
2433
2633
  }
@@ -2440,6 +2640,19 @@ class CssParser extends Parser {
2440
2640
  ? localizableSelectorValue(ident)
2441
2641
  : undefined;
2442
2642
  if (localizable === undefined) {
2643
+ if (
2644
+ segmentMode === "local" &&
2645
+ /** @type {IcssDefinition} */ (icssDefinitions.get(ident))
2646
+ .importName
2647
+ ) {
2648
+ addResolvedExport(
2649
+ ident,
2650
+ identStart,
2651
+ identEnd,
2652
+ CssIcssExportDependency.EXPORT_MODE.RESOLVED_SELECTOR
2653
+ );
2654
+ break;
2655
+ }
2443
2656
  emitICSSSymbol(ident, identStart, identEnd);
2444
2657
  break;
2445
2658
  }
@@ -2564,7 +2777,7 @@ class CssParser extends Parser {
2564
2777
  * @returns {void}
2565
2778
  */
2566
2779
  const finishTopLevelRule = (node, blockBearing) => {
2567
- if (!blockBearing || A.declarations(node) || A.childRules(node)) {
2780
+ if (!blockBearing || A.startOf(Part.block, node) !== -1) {
2568
2781
  allowImport = false;
2569
2782
  }
2570
2783
  pure.markSeenTopLevelRule();
@@ -2758,7 +2971,7 @@ class CssParser extends Parser {
2758
2971
  }
2759
2972
  if (
2760
2973
  A.type(cv) === NodeType.Ident &&
2761
- equalsLowerCase(A.value(cv), "global")
2974
+ asciiCaseInsensitiveMatch(A.source(cv), "global")
2762
2975
  ) {
2763
2976
  fromSource = { kind: "global" };
2764
2977
  phase = "done";
@@ -2775,9 +2988,9 @@ class CssParser extends Parser {
2775
2988
  }
2776
2989
 
2777
2990
  if (A.type(cv) === NodeType.Ident) {
2778
- const identValue = A.value(cv);
2991
+ const identValue = A.source(cv);
2779
2992
  if (
2780
- equalsLowerCase(identValue, "from") &&
2993
+ asciiCaseInsensitiveMatch(identValue, "from") &&
2781
2994
  classNames.length > 0 &&
2782
2995
  nextNonWhitespace(group, i + 1) < group.length
2783
2996
  ) {
@@ -2794,7 +3007,7 @@ class CssParser extends Parser {
2794
3007
 
2795
3008
  if (A.type(cv) === NodeType.Function) {
2796
3009
  const fn = /** @type {FunctionNode} */ (cv);
2797
- const isGlobal = equalsLowerCase(A.unescapedName(fn), "global");
3010
+ const isGlobal = asciiCaseInsensitiveMatch(A.name(fn), "global");
2798
3011
  for (const inner of A.children(fn)) {
2799
3012
  if (A.type(inner) === NodeType.Ident) {
2800
3013
  classNames.push({
@@ -2841,10 +3054,10 @@ class CssParser extends Parser {
2841
3054
  let resumeAt = A.end(decl);
2842
3055
  if (source.charCodeAt(A.end(decl)) === CC_SEMICOLON) {
2843
3056
  resumeAt = A.end(decl) + 1;
2844
- while (isWhitespace(source.charCodeAt(resumeAt))) resumeAt++;
3057
+ while (isAsciiWhitespace(source.charCodeAt(resumeAt))) resumeAt++;
2845
3058
  }
2846
3059
  module.addPresentationalDependency(
2847
- new ConstDependency("", [A.nameStart(decl), resumeAt])
3060
+ new ConstDependency("", [A.startOf(Part.name, decl), resumeAt])
2848
3061
  );
2849
3062
  };
2850
3063
 
@@ -2854,26 +3067,36 @@ class CssParser extends Parser {
2854
3067
  * @param {string | undefined} escapedName the unescaped function name when it carries an escape, undefined for the raw byte-range path
2855
3068
  */
2856
3069
  const emitUrlFunction = (fn, escapedName) => {
2857
- const fnNameStart = A.nameStart(fn);
2858
- const fnNameEnd = A.nameEnd(fn);
3070
+ const fnNameStart = A.startOf(Part.name, fn);
3071
+ const fnNameEnd = A.endOf(Part.name, fn);
2859
3072
  let isUrlOrSrc;
2860
3073
  let isImageSet = false;
2861
3074
  if (escapedName !== undefined) {
2862
3075
  isUrlOrSrc =
2863
- equalsLowerCase(escapedName, "url") ||
2864
- equalsLowerCase(escapedName, "src");
3076
+ asciiCaseInsensitiveMatch(escapedName, "url") ||
3077
+ asciiCaseInsensitiveMatch(escapedName, "src");
2865
3078
  if (!isUrlOrSrc) isImageSet = IMAGE_SET_FUNCTION.test(escapedName);
2866
3079
  } else {
2867
3080
  const nameLength = fnNameEnd - fnNameStart;
2868
3081
  isUrlOrSrc =
2869
3082
  nameLength === 3 &&
2870
- (rangeEqualsLowerCase(input, fnNameStart, fnNameEnd, "url") ||
2871
- rangeEqualsLowerCase(input, fnNameStart, fnNameEnd, "src"));
3083
+ (rangeAsciiCaseInsensitiveMatch(
3084
+ input,
3085
+ fnNameStart,
3086
+ fnNameEnd,
3087
+ "url"
3088
+ ) ||
3089
+ rangeAsciiCaseInsensitiveMatch(
3090
+ input,
3091
+ fnNameStart,
3092
+ fnNameEnd,
3093
+ "src"
3094
+ ));
2872
3095
  if (!isUrlOrSrc) {
2873
3096
  // Suffix probe first, so only a vendor-prefixed `…-image-set` pays the slice + regex.
2874
3097
  isImageSet =
2875
3098
  nameLength >= 9 &&
2876
- rangeEqualsLowerCase(
3099
+ rangeAsciiCaseInsensitiveMatch(
2877
3100
  input,
2878
3101
  fnNameEnd - 9,
2879
3102
  fnNameEnd,
@@ -2973,18 +3196,18 @@ class CssParser extends Parser {
2973
3196
  "Any '@import' rules must precede all other rules",
2974
3197
  locConverter,
2975
3198
  A.start(at),
2976
- A.nameEnd(at)
3199
+ A.endOf(Part.name, at)
2977
3200
  );
2978
3201
  return;
2979
3202
  }
2980
3203
  const importStart = A.start(at);
2981
- const importNameEnd = A.nameEnd(at);
3204
+ const importNameEnd = A.endOf(Part.name, at);
2982
3205
  // We only accept `;`-terminated @import; block / EOF / `}` ends are silent bails.
2983
3206
  if (source.charCodeAt(A.end(at)) !== CC_SEMICOLON) return;
2984
3207
 
2985
3208
  // Walk the prelude in spec order (URL → layer? → supports? → media query); anything else joins the media query.
2986
3209
  const { urlNode, layerNode, supportsNode } = parseImportPrelude(
2987
- A.prelude(at)
3210
+ A.children(at)
2988
3211
  );
2989
3212
 
2990
3213
  const semi = A.end(at) + 1; // position past `;`
@@ -3006,7 +3229,7 @@ class CssParser extends Parser {
3006
3229
  let url;
3007
3230
  if (A.type(urlNode) === NodeType.Ident) {
3008
3231
  // URL given as identifier — resolve via CSS Modules `@value`.
3009
- const identName = A.value(urlNode);
3232
+ const identName = A.source(urlNode);
3010
3233
  const def = icssDefinitions.get(identName);
3011
3234
  if (!def) {
3012
3235
  this._emitWarning(
@@ -3045,7 +3268,7 @@ class CssParser extends Parser {
3045
3268
  } else if (A.type(urlNode) === NodeType.Url) {
3046
3269
  const ut = /** @type {UrlToken} */ (urlNode);
3047
3270
  url = normalizeUrl(
3048
- input.slice(A.contentStart(ut), A.contentEnd(ut)),
3271
+ input.slice(A.startOf(Part.value, ut), A.endOf(Part.value, ut)),
3049
3272
  false
3050
3273
  );
3051
3274
  } else if (A.type(urlNode) === NodeType.String) {
@@ -3100,7 +3323,7 @@ class CssParser extends Parser {
3100
3323
  if (A.type(layerNode) === NodeType.Function) {
3101
3324
  // `layer(<ident>)` — extract content between `(` and `)`.
3102
3325
  const fn = /** @type {FunctionNode} */ (layerNode);
3103
- layer = input.slice(A.nameEnd(fn) + 1, A.end(fn) - 1).trim();
3326
+ layer = input.slice(A.endOf(Part.name, fn) + 1, A.end(fn) - 1).trim();
3104
3327
  } else {
3105
3328
  // Bare `layer` ident — anonymous layer.
3106
3329
  layer = "";
@@ -3111,18 +3334,18 @@ class CssParser extends Parser {
3111
3334
  let supports;
3112
3335
  if (supportsNode) {
3113
3336
  supports = input
3114
- .slice(A.nameEnd(supportsNode) + 1, A.end(supportsNode) - 1)
3337
+ .slice(A.endOf(Part.name, supportsNode) + 1, A.end(supportsNode) - 1)
3115
3338
  .trim();
3116
3339
  }
3117
3340
 
3118
3341
  // 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
3342
  const lastPrefixPart = supportsNode || layerNode || urlNode;
3120
3343
  const afterIdx =
3121
- /** @type {AstNode[]} */ (A.prelude(at)).indexOf(lastPrefixPart) + 1;
3122
- const nextIdx = nextNonWhitespace(A.prelude(at), afterIdx);
3344
+ /** @type {AstNode[]} */ (A.children(at)).indexOf(lastPrefixPart) + 1;
3345
+ const nextIdx = nextNonWhitespace(A.children(at), afterIdx);
3123
3346
  const mediaStart =
3124
- nextIdx < A.prelude(at).length
3125
- ? A.start(A.prelude(at)[nextIdx])
3347
+ nextIdx < A.children(at).length
3348
+ ? A.start(A.children(at)[nextIdx])
3126
3349
  : A.end(at);
3127
3350
  /** @type {undefined | string} */
3128
3351
  let media;
@@ -3170,7 +3393,7 @@ class CssParser extends Parser {
3170
3393
  */
3171
3394
  const handleValueAtRule = (at) => {
3172
3395
  const start = A.start(at);
3173
- const nameEnd = A.nameEnd(at);
3396
+ const nameEnd = A.endOf(Part.name, at);
3174
3397
  const semi = A.end(at);
3175
3398
  const atRuleEnd =
3176
3399
  source.charCodeAt(semi) === CC_SEMICOLON ? semi + 1 : semi;
@@ -3296,7 +3519,7 @@ class CssParser extends Parser {
3296
3519
  return ident;
3297
3520
  }
3298
3521
  if (A.type(k) !== NodeType.Ident) return undefined;
3299
- const v = A.value(k);
3522
+ const v = A.source(k);
3300
3523
  if (!isDashedIdentifier(v)) return undefined;
3301
3524
  ident = v;
3302
3525
  }
@@ -3318,13 +3541,13 @@ class CssParser extends Parser {
3318
3541
  new ConstDependency("", [start, ruleEnd])
3319
3542
  );
3320
3543
 
3321
- const prelude = A.prelude(at);
3544
+ const prelude = A.children(at);
3322
3545
  let i = 0;
3323
3546
  while (i < prelude.length && A.type(prelude[i]) === NodeType.Whitespace) {
3324
3547
  i++;
3325
3548
  }
3326
3549
  if (i >= prelude.length || A.type(prelude[i]) !== NodeType.Ident) return;
3327
- const name = A.value(prelude[i]);
3550
+ const name = A.source(prelude[i]);
3328
3551
  if (!isDashedIdentifier(name)) return;
3329
3552
  i++;
3330
3553
 
@@ -3371,10 +3594,17 @@ class CssParser extends Parser {
3371
3594
  return { kind: "alias", name: nested };
3372
3595
  }
3373
3596
  }
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;
3597
+ // A reference anywhere else is captured as a `@media` prelude is, and
3598
+ // folded once every name it reads is known.
3599
+ if (hasCustomMediaRef(prelude, vs, ve)) {
3600
+ /** @type {CustomMediaUse[]} */
3601
+ const uses = [];
3602
+ const node = captureMediaQuery(prelude, vs, ve, uses);
3603
+ for (const use of uses) {
3604
+ if (use.invalid) return CUSTOM_MEDIA_UNSUPPORTED;
3605
+ }
3606
+ return { kind: "query", node, uses };
3607
+ }
3378
3608
  if (A.type(first) === NodeType.SimpleBlock) {
3379
3609
  return { kind: "condition", text: valueText };
3380
3610
  }
@@ -3382,14 +3612,14 @@ class CssParser extends Parser {
3382
3612
  const s = A.start(first);
3383
3613
  const e = A.end(first);
3384
3614
  if (ve - vs === 1) {
3385
- if (rangeEqualsLowerCase(input, s, e, "true")) {
3615
+ if (rangeAsciiCaseInsensitiveMatch(input, s, e, "true")) {
3386
3616
  return CUSTOM_MEDIA_TRUE;
3387
3617
  }
3388
- if (rangeEqualsLowerCase(input, s, e, "false")) {
3618
+ if (rangeAsciiCaseInsensitiveMatch(input, s, e, "false")) {
3389
3619
  return CUSTOM_MEDIA_FALSE;
3390
3620
  }
3391
3621
  }
3392
- if (rangeEqualsLowerCase(input, s, e, "not")) {
3622
+ if (rangeAsciiCaseInsensitiveMatch(input, s, e, "not")) {
3393
3623
  // `not (…)` is a media condition (wrap so it stays a media-in-parens);
3394
3624
  // `not <type>` is a media type.
3395
3625
  let j = vs + 1;
@@ -3405,7 +3635,7 @@ class CssParser extends Parser {
3405
3635
 
3406
3636
  // Comma list → `(seg1 or seg2 …)`; supported only when every segment is a
3407
3637
  // media-in-parens (or a name standing for one).
3408
- /** @type {({ text: string } | { alias: string })[]} */
3638
+ /** @type {({ text: string } | { alias: string } | { query: CustomMediaQuery })[]} */
3409
3639
  const parts = [];
3410
3640
  let ok = true;
3411
3641
  /** @type {AstNode[]} */
@@ -3431,15 +3661,26 @@ class CssParser extends Parser {
3431
3661
  else parts.push({ alias: nested });
3432
3662
  return;
3433
3663
  }
3664
+ // Any other condition is one group in the `or`; a media type is none.
3434
3665
  if (
3435
- A.type(f) === NodeType.Ident &&
3436
- rangeEqualsLowerCase(input, A.start(f), A.end(f), "not") &&
3437
- !hasCustomMediaRef(seg, a, b)
3666
+ A.type(f) !== NodeType.SimpleBlock &&
3667
+ !(
3668
+ A.type(f) === NodeType.Ident &&
3669
+ rangeAsciiCaseInsensitiveMatch(input, A.start(f), A.end(f), "not")
3670
+ )
3438
3671
  ) {
3672
+ ok = false;
3673
+ return;
3674
+ }
3675
+ if (!hasCustomMediaRef(seg, a, b)) {
3439
3676
  parts.push({ text: `(${text})` });
3440
3677
  return;
3441
3678
  }
3442
- ok = false;
3679
+ /** @type {CustomMediaUse[]} */
3680
+ const uses = [];
3681
+ const node = captureMediaCondition(seg, a, b, uses, true);
3682
+ if (uses.some((use) => use.invalid)) ok = false;
3683
+ else parts.push({ query: { node, uses } });
3443
3684
  };
3444
3685
  for (let k = vs; k < ve; k++) {
3445
3686
  if (A.type(prelude[k]) === NodeType.Comma) {
@@ -3480,15 +3721,26 @@ class CssParser extends Parser {
3480
3721
  let ok = true;
3481
3722
  let anyTrue = false;
3482
3723
  for (const part of def.parts) {
3483
- if (!("alias" in part)) {
3724
+ if ("text" in part) {
3484
3725
  texts.push(part.text);
3485
3726
  continue;
3486
3727
  }
3487
- const inner = resolveCustomMediaValue(part.alias, resolving);
3728
+ const inner =
3729
+ "alias" in part
3730
+ ? resolveCustomMediaValue(part.alias, resolving)
3731
+ : resolveCustomMediaQuery(
3732
+ part.query.node,
3733
+ part.query.uses,
3734
+ resolving
3735
+ );
3488
3736
  // 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;
3737
+ if (inner.kind === "boolean") {
3738
+ anyTrue = anyTrue || inner.value;
3739
+ } else if (inner.kind === "condition") {
3740
+ texts.push(mediaConditionFor(inner.text, "or"));
3741
+ } else {
3742
+ ok = false;
3743
+ }
3492
3744
  }
3493
3745
  value = !ok
3494
3746
  ? CUSTOM_MEDIA_UNSUPPORTED
@@ -3501,6 +3753,8 @@ class CssParser extends Parser {
3501
3753
  text:
3502
3754
  texts.length === 1 ? texts[0] : `(${texts.join(" or ")})`
3503
3755
  };
3756
+ } else if (def.kind === "query") {
3757
+ value = resolveCustomMediaQuery(def.node, def.uses, resolving);
3504
3758
  } else {
3505
3759
  value = def;
3506
3760
  }
@@ -3509,6 +3763,35 @@ class CssParser extends Parser {
3509
3763
  return value;
3510
3764
  };
3511
3765
 
3766
+ /**
3767
+ * What a `@custom-media` value reading other names resolves to: the value
3768
+ * folded once each name resolves, or unsupported where one does not.
3769
+ * @param {MediaNode} node the captured value
3770
+ * @param {CustomMediaUse[]} uses the names it reads
3771
+ * @param {Set<string>} resolving names currently being resolved
3772
+ * @returns {CustomMediaValue} what it resolves to
3773
+ */
3774
+ const resolveCustomMediaQuery = (node, uses, resolving) => {
3775
+ for (const use of uses) {
3776
+ const inner = resolveCustomMediaValue(use.name, resolving);
3777
+ if (
3778
+ inner.kind === "unsupported" ||
3779
+ (inner.kind === "type" && !use.leading)
3780
+ ) {
3781
+ return CUSTOM_MEDIA_UNSUPPORTED;
3782
+ }
3783
+ }
3784
+ const folded = foldMediaNode(node, resolving);
3785
+ if (typeof folded === "boolean") {
3786
+ return folded ? CUSTOM_MEDIA_TRUE : CUSTOM_MEDIA_FALSE;
3787
+ }
3788
+ // A query led by a media type stands for a type, as one written out does.
3789
+ const condition =
3790
+ folded.charCodeAt(0) === CC_LEFT_PARENTHESIS ||
3791
+ /^not\s*\(/i.test(folded);
3792
+ return { kind: condition ? "condition" : "type", text: folded };
3793
+ };
3794
+
3512
3795
  /**
3513
3796
  * Whether a node is the media keyword `word` (media queries are ASCII
3514
3797
  * case-insensitive).
@@ -3518,7 +3801,7 @@ class CssParser extends Parser {
3518
3801
  */
3519
3802
  const isMediaKeyword = (node, word) =>
3520
3803
  A.type(node) === NodeType.Ident &&
3521
- rangeEqualsLowerCase(input, A.start(node), A.end(node), word);
3804
+ rangeAsciiCaseInsensitiveMatch(input, A.start(node), A.end(node), word);
3522
3805
 
3523
3806
  /**
3524
3807
  * First significant index in `tokens[from…to)`.
@@ -3569,7 +3852,7 @@ class CssParser extends Parser {
3569
3852
  const hasCustomMediaRefIn = (node) => {
3570
3853
  const count = A.childCount(node);
3571
3854
  for (let k = 0; k < count; k++) {
3572
- const child = A.childAt(node, k);
3855
+ const child = A.child(k, node);
3573
3856
  const type = A.type(child);
3574
3857
  if (type !== NodeType.SimpleBlock && type !== NodeType.Function) {
3575
3858
  continue;
@@ -3626,9 +3909,10 @@ class CssParser extends Parser {
3626
3909
  * @param {number} to one past the last index
3627
3910
  * @param {boolean} leading whether the term starts a top-level query
3628
3911
  * @param {CustomMediaUse[]} uses the prelude's use list, appended to
3912
+ * @param {MediaSlot} slot what the term is joined to
3629
3913
  * @returns {MediaNode} the captured term
3630
3914
  */
3631
- const captureMediaInParens = (tokens, from, to, leading, uses) => {
3915
+ const captureMediaInParens = (tokens, from, to, leading, uses, slot) => {
3632
3916
  const a = mediaTrimStart(tokens, from, to);
3633
3917
  const b = mediaTrimEnd(tokens, a, to);
3634
3918
  if (a >= b) return { kind: "text", text: "" };
@@ -3644,13 +3928,20 @@ class CssParser extends Parser {
3644
3928
  start: A.start(block),
3645
3929
  end: A.end(block),
3646
3930
  invalid: mediaExtra.hasExtra,
3647
- leading
3931
+ leading,
3932
+ slot
3648
3933
  };
3649
3934
  uses.push(use);
3650
3935
  return { kind: "ref", text, use };
3651
3936
  }
3652
3937
  const children = A.children(block);
3653
- const inner = captureMediaCondition(children, 0, children.length, uses);
3938
+ const inner = captureMediaCondition(
3939
+ children,
3940
+ 0,
3941
+ children.length,
3942
+ uses,
3943
+ true
3944
+ );
3654
3945
  return inner.kind === "text"
3655
3946
  ? { kind: "text", text }
3656
3947
  : { kind: "group", operand: inner };
@@ -3663,33 +3954,46 @@ class CssParser extends Parser {
3663
3954
  * @param {number} from first index
3664
3955
  * @param {number} to one past the last index
3665
3956
  * @param {CustomMediaUse[]} uses the prelude's use list, appended to
3957
+ * @param {boolean} alone whether nothing outside joins the condition
3666
3958
  * @returns {MediaNode} the captured condition
3667
3959
  */
3668
- const captureMediaCondition = (tokens, from, to, uses) => {
3960
+ const captureMediaCondition = (tokens, from, to, uses, alone) => {
3669
3961
  const a = mediaTrimStart(tokens, from, to);
3670
3962
  const b = mediaTrimEnd(tokens, a, to);
3671
3963
  if (a >= b) return { kind: "text", text: "" };
3672
3964
  if (isMediaKeyword(tokens[a], "not")) {
3673
3965
  return {
3674
3966
  kind: "not",
3675
- operand: captureMediaInParens(tokens, a + 1, b, false, uses)
3967
+ operand: captureMediaInParens(tokens, a + 1, b, false, uses, "or")
3676
3968
  };
3677
3969
  }
3970
+ let isOr = false;
3971
+ let single = true;
3972
+ for (let i = a; i < b; i++) {
3973
+ if (isMediaKeyword(tokens[i], "or")) isOr = true;
3974
+ if (
3975
+ isMediaKeyword(tokens[i], "and") ||
3976
+ isMediaKeyword(tokens[i], "or")
3977
+ ) {
3978
+ single = false;
3979
+ }
3980
+ }
3981
+ /** @type {MediaSlot} */
3982
+ const slot = single && alone ? "alone" : isOr ? "or" : "and";
3678
3983
  /** @type {MediaNode[]} */
3679
3984
  const terms = [];
3680
- let isOr = false;
3681
3985
  let start = a;
3682
3986
  for (let i = a; i <= b; i++) {
3683
- const atEnd = i === b;
3684
3987
  if (
3685
- !atEnd &&
3988
+ i !== b &&
3686
3989
  !isMediaKeyword(tokens[i], "and") &&
3687
3990
  !isMediaKeyword(tokens[i], "or")
3688
3991
  ) {
3689
3992
  continue;
3690
3993
  }
3691
- if (!atEnd && isMediaKeyword(tokens[i], "or")) isOr = true;
3692
- terms.push(captureMediaInParens(tokens, start, i, start === a, uses));
3994
+ terms.push(
3995
+ captureMediaInParens(tokens, start, i, start === a, uses, slot)
3996
+ );
3693
3997
  start = i + 1;
3694
3998
  }
3695
3999
  if (terms.length === 1) return terms[0];
@@ -3715,7 +4019,9 @@ class CssParser extends Parser {
3715
4019
  (!isMediaKeyword(tokens[a], "not") ||
3716
4020
  rest >= b ||
3717
4021
  A.type(tokens[rest]) !== NodeType.SimpleBlock);
3718
- if (!startsWithType) return captureMediaCondition(tokens, a, b, uses);
4022
+ if (!startsWithType) {
4023
+ return captureMediaCondition(tokens, a, b, uses, true);
4024
+ }
3719
4025
  // `[not | only]? <type> [and <condition-without-or>]?` — the type itself is
3720
4026
  // never constant, so only the `and` chain after it can fold.
3721
4027
  let split = b;
@@ -3729,7 +4035,9 @@ class CssParser extends Parser {
3729
4035
  kind: "typed",
3730
4036
  text: mediaText(tokens, a, mediaTrimEnd(tokens, a, split)),
3731
4037
  rest:
3732
- split === b ? null : captureMediaCondition(tokens, split + 1, b, uses)
4038
+ split === b
4039
+ ? null
4040
+ : captureMediaCondition(tokens, split + 1, b, uses, false)
3733
4041
  };
3734
4042
  };
3735
4043
 
@@ -3739,7 +4047,7 @@ class CssParser extends Parser {
3739
4047
  * @param {AtRule} at the `@media` at-rule
3740
4048
  */
3741
4049
  const collectMediaQuery = (at) => {
3742
- const prelude = A.prelude(at);
4050
+ const prelude = A.children(at);
3743
4051
  const start = mediaTrimStart(prelude, 0, prelude.length);
3744
4052
  const end = mediaTrimEnd(prelude, start, prelude.length);
3745
4053
  if (start >= end || !hasCustomMediaRef(prelude, start, end)) return;
@@ -3777,7 +4085,9 @@ class CssParser extends Parser {
3777
4085
  const value = resolveCustomMediaValue(node.use.name, resolving);
3778
4086
  if (node.use.invalid) return node.text;
3779
4087
  if (value.kind === "boolean") return value.value;
3780
- if (value.kind === "condition") return value.text;
4088
+ if (value.kind === "condition") {
4089
+ return mediaConditionFor(value.text, node.use.slot);
4090
+ }
3781
4091
  if (value.kind === "type" && node.use.leading) return value.text;
3782
4092
  return node.text;
3783
4093
  }
@@ -3842,7 +4152,7 @@ class CssParser extends Parser {
3842
4152
  new ConstDependency("", [start, ruleEnd])
3843
4153
  );
3844
4154
 
3845
- const prelude = A.prelude(at);
4155
+ const prelude = A.children(at);
3846
4156
  let i = 0;
3847
4157
  while (i < prelude.length && A.type(prelude[i]) === NodeType.Whitespace) {
3848
4158
  i++;
@@ -3857,7 +4167,7 @@ class CssParser extends Parser {
3857
4167
  ) {
3858
4168
  return;
3859
4169
  }
3860
- const name = A.value(nameNode);
4170
+ const name = A.source(nameNode);
3861
4171
  if (!isDashedIdentifier(name)) return;
3862
4172
  const list = input.slice(A.end(nameNode), end).trim();
3863
4173
  if (list.length === 0) return;
@@ -3878,10 +4188,10 @@ class CssParser extends Parser {
3878
4188
  next &&
3879
4189
  A.type(next) === NodeType.Ident &&
3880
4190
  A.end(t) === A.start(next) &&
3881
- isDashedIdentifier(A.value(next))
4191
+ isDashedIdentifier(A.source(next))
3882
4192
  ) {
3883
4193
  (customSelectorUses || (customSelectorUses = [])).push({
3884
- name: A.value(next),
4194
+ name: A.source(next),
3885
4195
  start: A.start(t),
3886
4196
  end: A.end(next)
3887
4197
  });
@@ -3892,6 +4202,43 @@ class CssParser extends Parser {
3892
4202
  }
3893
4203
  };
3894
4204
 
4205
+ /**
4206
+ * The selector list a `@custom-selector` name stands for, each name it reads
4207
+ * written as `:is(…)` in turn, memoized; undefined when unknown or on a cycle.
4208
+ * @param {string} name the dashed ident
4209
+ * @param {Set<string>} resolving names currently being resolved
4210
+ * @returns {string | undefined} the list
4211
+ */
4212
+ const resolveCustomSelector = (name, resolving) => {
4213
+ const cached = customSelectorValues && customSelectorValues.get(name);
4214
+ if (cached !== undefined) return cached === null ? undefined : cached;
4215
+ const list = customSelectorDefs && customSelectorDefs.get(name);
4216
+ if (list === undefined || resolving.has(name)) return undefined;
4217
+ resolving.add(name);
4218
+ /** @type {string | null} */
4219
+ let written = "";
4220
+ let at = 0;
4221
+ for (const found of customSelectorNames(list)) {
4222
+ if (!customSelectorDefs || !customSelectorDefs.has(found.name)) {
4223
+ continue;
4224
+ }
4225
+ const inner = resolveCustomSelector(found.name, resolving);
4226
+ if (inner === undefined) {
4227
+ written = null;
4228
+ break;
4229
+ }
4230
+ written += `${list.slice(at, found.start)}:is(${inner})`;
4231
+ at = found.end;
4232
+ }
4233
+ if (written !== null) written += list.slice(at);
4234
+ resolving.delete(name);
4235
+ (customSelectorValues || (customSelectorValues = new Map())).set(
4236
+ name,
4237
+ written
4238
+ );
4239
+ return written === null ? undefined : written;
4240
+ };
4241
+
3895
4242
  /**
3896
4243
  * 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
4244
  */
@@ -3954,7 +4301,12 @@ class CssParser extends Parser {
3954
4301
  (value.kind === "type" && use.leading)
3955
4302
  ) {
3956
4303
  module.addPresentationalDependency(
3957
- new ConstDependency(value.text, [use.start, use.end])
4304
+ new ConstDependency(
4305
+ value.kind === "condition"
4306
+ ? mediaConditionFor(value.text, use.slot)
4307
+ : value.text,
4308
+ [use.start, use.end]
4309
+ )
3958
4310
  );
3959
4311
  }
3960
4312
  }
@@ -3962,7 +4314,7 @@ class CssParser extends Parser {
3962
4314
  }
3963
4315
  if (customSelectorUses) {
3964
4316
  for (const use of customSelectorUses) {
3965
- const list = customSelectorDefs && customSelectorDefs.get(use.name);
4317
+ const list = resolveCustomSelector(use.name, new Set());
3966
4318
  if (list === undefined) continue;
3967
4319
  module.addPresentationalDependency(
3968
4320
  new ConstDependency(`:is(${list})`, [use.start, use.end])
@@ -4040,7 +4392,7 @@ class CssParser extends Parser {
4040
4392
  parsedKeywords = Object.create(null);
4041
4393
  break;
4042
4394
  case NodeType.Delim:
4043
- afterExclamation = A.value(cv) === "!";
4395
+ afterExclamation = A.source(cv) === "!";
4044
4396
  break;
4045
4397
  case NodeType.Ident: {
4046
4398
  if (isGridTemplate) break;
@@ -4048,7 +4400,7 @@ class CssParser extends Parser {
4048
4400
  afterExclamation = false;
4049
4401
  break;
4050
4402
  }
4051
- const identifier = A.value(cv);
4403
+ const identifier = A.source(cv);
4052
4404
  // `view-transition-name: --foo` / `counter-reset: --foo` — a dashed name scopes as a custom property under `dashedIdents`, not as a plain ident export.
4053
4405
  if (
4054
4406
  (isViewTransitionProperty || isCounterProperty) &&
@@ -4059,14 +4411,46 @@ class CssParser extends Parser {
4059
4411
  }
4060
4412
  break;
4061
4413
  }
4414
+ const def =
4415
+ isGridProperty || icssDefinitions.size === 0
4416
+ ? undefined
4417
+ : icssDefinitions.get(identifier);
4418
+ let resolved = identifier;
4419
+ if (def !== undefined) {
4420
+ if (def.importName) {
4421
+ // The property rides along: its keywords stay unscoped.
4422
+ const reference = /** @type {string[]} */ (
4423
+ getReexport(identifier)
4424
+ );
4425
+ addResolvedExport(
4426
+ identifier,
4427
+ A.start(cv),
4428
+ A.end(cv),
4429
+ CssIcssExportDependency.EXPORT_MODE.RESOLVED_REFERENCE,
4430
+ [reference[0], reference[1], reference[2], declPropertyName]
4431
+ );
4432
+ break;
4433
+ }
4434
+ // `@value` resolves first: what isn't still a name, or is now a
4435
+ // keyword, is substituted as is rather than scoped.
4436
+ resolved =
4437
+ typeof def.value === "string" ? def.value.trim() : "";
4438
+ if (!isSimpleIdentifier(resolved)) {
4439
+ emitICSSSymbol(identifier, A.start(cv), A.end(cv));
4440
+ break;
4441
+ }
4442
+ }
4062
4443
  // Values are almost always lowercase already — avoid the copy.
4063
- const keyword = toLowerCaseIfNeeded(identifier);
4444
+ const keyword = toLowerCaseIfNeeded(resolved);
4064
4445
  parsedKeywords[keyword] =
4065
4446
  typeof parsedKeywords[keyword] !== "undefined"
4066
4447
  ? parsedKeywords[keyword] + 1
4067
4448
  : 0;
4068
4449
  const limit = keywords.get(keyword);
4069
4450
  if (limit !== undefined && parsedKeywords[keyword] < limit) {
4451
+ if (def !== undefined) {
4452
+ emitICSSSymbol(identifier, A.start(cv), A.end(cv));
4453
+ }
4070
4454
  break;
4071
4455
  }
4072
4456
  emit(A.start(cv), A.end(cv));
@@ -4099,7 +4483,7 @@ class CssParser extends Parser {
4099
4483
  }
4100
4484
  case NodeType.SimpleBlock: {
4101
4485
  const block = /** @type {SimpleBlock} */ (cv);
4102
- if (A.blockToken(block) === "[") {
4486
+ if (A.value(block) === "[") {
4103
4487
  // Collect identifiers until the first non-ident token (`<line-names> = '[' <custom-ident>* ']'`).
4104
4488
  for (const inner of A.children(block)) {
4105
4489
  if (A.type(inner) === NodeType.Whitespace) continue;
@@ -4116,7 +4500,7 @@ class CssParser extends Parser {
4116
4500
  if (
4117
4501
  isGridTemplate ||
4118
4502
  (isCounterProperty &&
4119
- equalsLowerCase(A.unescapedName(cv), "reversed"))
4503
+ asciiCaseInsensitiveMatch(A.name(cv), "reversed"))
4120
4504
  ) {
4121
4505
  walkExports(A.children(cv));
4122
4506
  }
@@ -4144,7 +4528,7 @@ class CssParser extends Parser {
4144
4528
  ) => {
4145
4529
  const acceptIdent = isKeyframes || isCounterStyle || isContainer;
4146
4530
  const acceptString = isKeyframes;
4147
- for (const cv of A.prelude(at)) {
4531
+ for (const cv of A.children(at)) {
4148
4532
  const cvType = A.type(cv);
4149
4533
  if (cvType === NodeType.Whitespace) continue;
4150
4534
  if (cvType === NodeType.String) {
@@ -4163,7 +4547,7 @@ class CssParser extends Parser {
4163
4547
  break;
4164
4548
  }
4165
4549
  if (cvType === NodeType.Function) {
4166
- if (equalsLowerCase(A.unescapedName(cv), "local")) {
4550
+ if (asciiCaseInsensitiveMatch(A.name(cv), "local")) {
4167
4551
  pure.markLocal();
4168
4552
  }
4169
4553
  break;
@@ -4187,7 +4571,7 @@ class CssParser extends Parser {
4187
4571
  // Rollback point: nested walks append to the shared list; the exit
4188
4572
  // truncates back to this length (no per-rule copy).
4189
4573
  const savedLocalIdentifierCount = currentRule.localIdentifiers.length;
4190
- const name = `@${toLowerCaseIfNeeded(A.unescapedName(at))}`;
4574
+ const name = `@${toLowerCaseIfNeeded(A.name(at))}`;
4191
4575
  // The dispatch below is the only place a prelude is rewritten ahead
4192
4576
  // of the value visitors, so the marks live exactly as long as it.
4193
4577
  if (handledPreludeIdents.size !== 0) handledPreludeIdents.clear();
@@ -4199,7 +4583,7 @@ class CssParser extends Parser {
4199
4583
  "'@namespace' is not supported in bundled CSS",
4200
4584
  locConverter,
4201
4585
  A.start(at),
4202
- A.nameEnd(at)
4586
+ A.endOf(Part.name, at)
4203
4587
  );
4204
4588
  break;
4205
4589
  }
@@ -4210,12 +4594,11 @@ class CssParser extends Parser {
4210
4594
  source.charCodeAt(atEnd) === CC_SEMICOLON ? atEnd + 1 : atEnd;
4211
4595
  const dep = new ConstDependency("", [A.start(at), atRuleEnd]);
4212
4596
  module.addPresentationalDependency(dep);
4213
- const string = A.prelude(at).find(
4597
+ const string = A.children(at).find(
4214
4598
  (v) => A.type(v) !== NodeType.Whitespace
4215
4599
  );
4216
4600
  if (string && A.type(string) === NodeType.String) {
4217
- /** @type {CssModuleBuildInfo} */
4218
- (module.buildInfo).charset = source
4601
+ module.buildInfo.charset = source
4219
4602
  .slice(A.start(string) + 1, A.end(string) - 1)
4220
4603
  .toUpperCase();
4221
4604
  }
@@ -4281,11 +4664,11 @@ class CssParser extends Parser {
4281
4664
  // `@scope (.x) to (.y)` — walk the prelude as a selector list.
4282
4665
  if (
4283
4666
  isModules &&
4284
- equalsLowerCase(A.unescapedName(at), "scope") &&
4285
- A.prelude(at).length > 0
4667
+ asciiCaseInsensitiveMatch(A.name(at), "scope") &&
4668
+ A.children(at).length > 0
4286
4669
  ) {
4287
4670
  walkSelectorList(
4288
- A.prelude(at),
4671
+ A.children(at),
4289
4672
  /** @type {"local" | "global"} */ (
4290
4673
  mode === "local" ? "local" : "global"
4291
4674
  )
@@ -4302,7 +4685,7 @@ class CssParser extends Parser {
4302
4685
  dashed.active = false;
4303
4686
  // `@import` url() is the import target — only walk its prelude for url deps on malformed-import recovery.
4304
4687
  if (this.options.url && (name !== "@import" || currentUrlRecovery)) {
4305
- lastTokenEndForComments = A.nameEnd(at);
4688
+ lastTokenEndForComments = A.endOf(Part.name, at);
4306
4689
  }
4307
4690
  // Dashed-ident scoping over the prelude (the Ident / Function visitors emit).
4308
4691
  dashed.active = Boolean(
@@ -4341,19 +4724,16 @@ class CssParser extends Parser {
4341
4724
 
4342
4725
  // pure.stack push for block-bearing at-rules (pure-off builds skip
4343
4726
  // 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) {
4727
+ const atBlockStart = A.startOf(Part.block, at);
4728
+ const atHasBlock = atBlockStart !== -1;
4729
+ if (pure.enabled && atHasBlock) {
4349
4730
  const isAtRulePrelude = isPureBodyAtRule(name);
4350
4731
  if (isAtRulePrelude) pure.finalizeSelector();
4351
4732
  pure.enterBlock({
4352
4733
  isRulePrelude: isAtRulePrelude,
4353
4734
  treatAsLeaf: atTreatAsLeaf,
4354
4735
  ownSkip: atSkipChildren,
4355
- declarations: atDecls,
4356
- childRules: atChildRules,
4736
+ rule: at,
4357
4737
  preludeStart: A.start(at),
4358
4738
  preludeEnd: atBlockStart
4359
4739
  });
@@ -4398,7 +4778,7 @@ class CssParser extends Parser {
4398
4778
  // One prelude materialization per rule, shared by the scans below
4399
4779
  // (null in plain mode, which never reads the array).
4400
4780
  const rulePrelude =
4401
- isModules || mayHaveCustomSelectors ? A.prelude(rule) : null;
4781
+ isModules || mayHaveCustomSelectors ? A.children(rule) : null;
4402
4782
  // `:--name` custom-selector references (dashed idents never collide with the `:import`/`:export` ICSS preludes below).
4403
4783
  if (mayHaveCustomSelectors && rulePrelude !== null) {
4404
4784
  scanCustomSelectorUses(rulePrelude);
@@ -4414,12 +4794,12 @@ class CssParser extends Parser {
4414
4794
  const secondType = A.type(second);
4415
4795
  const rawName =
4416
4796
  secondType === NodeType.Ident
4417
- ? A.value(second)
4797
+ ? A.source(second)
4418
4798
  : secondType === NodeType.Function
4419
- ? A.name(second)
4799
+ ? rawNameOf(second)
4420
4800
  : "";
4421
- const isImport = equalsLowerCase(rawName, "import");
4422
- if (isImport || equalsLowerCase(rawName, "export")) {
4801
+ const isImport = asciiCaseInsensitiveMatch(rawName, "import");
4802
+ if (isImport || asciiCaseInsensitiveMatch(rawName, "export")) {
4423
4803
  if (topLevel) {
4424
4804
  const startColon = A.start(rulePrelude[firstIdx]);
4425
4805
  const endAfterBody = processImportOrExport(
@@ -4430,13 +4810,6 @@ class CssParser extends Parser {
4430
4810
  module.addPresentationalDependency(
4431
4811
  new ConstDependency("", [startColon, endAfterBody])
4432
4812
  );
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
4813
  }
4441
4814
  // Don't recurse into the body — handled inline above.
4442
4815
  path.skipChildren();
@@ -4478,7 +4851,7 @@ class CssParser extends Parser {
4478
4851
  dashed.active = false;
4479
4852
  dashed.emit = false;
4480
4853
  if (this.options.url && A.childCount(rule) > 0) {
4481
- lastTokenEndForComments = A.start(A.childAt(rule, 0));
4854
+ lastTokenEndForComments = A.start(A.child(0, rule));
4482
4855
  }
4483
4856
  // Dashed-ident scoping for the deprecated `--foo: { … }` custom-property-set syntax (prelude starts with a dashed-ident).
4484
4857
  if (
@@ -4502,13 +4875,12 @@ class CssParser extends Parser {
4502
4875
  }
4503
4876
  // Pure-mode: report an impure prelude (if leaf-ish) and push the inherited-context frame before walking the body.
4504
4877
  if (!pure.enabled) return;
4505
- const ruleBlockStart = A.blockStart(rule);
4878
+ const ruleBlockStart = A.startOf(Part.block, rule);
4506
4879
  pure.enterBlock({
4507
4880
  isRulePrelude: true,
4508
4881
  treatAsLeaf: false,
4509
4882
  ownSkip: false,
4510
- declarations: A.declarations(rule),
4511
- childRules: A.childRules(rule),
4883
+ rule,
4512
4884
  preludeStart: A.start(rule),
4513
4885
  preludeEnd: ruleBlockStart !== -1 ? ruleBlockStart : A.end(rule)
4514
4886
  });
@@ -4535,7 +4907,7 @@ class CssParser extends Parser {
4535
4907
  dashed.active = false;
4536
4908
  dashed.emit = false;
4537
4909
  // Position `lastTokenEndForComments` just past the `:` so a magic comment before a url() is found (every mode).
4538
- let colonPos = A.nameEnd(decl);
4910
+ let colonPos = A.endOf(Part.name, decl);
4539
4911
  while (
4540
4912
  colonPos < source.length &&
4541
4913
  source.charCodeAt(colonPos) !== CC_COLON
@@ -4550,8 +4922,8 @@ class CssParser extends Parser {
4550
4922
  // Property-name analysis and value exports are CSS-Modules-only; a plain
4551
4923
  // stylesheet's declarations need no per-decl name slice / known-property lookup.
4552
4924
  if (!isModules) return;
4553
- const nameStart = A.nameStart(decl);
4554
- const nameEnd = A.nameEnd(decl);
4925
+ const nameStart = A.startOf(Part.name, decl);
4926
+ const nameEnd = A.endOf(Part.name, decl);
4555
4927
  // Range-based name analysis — the common declaration never
4556
4928
  // slices its name out of the source.
4557
4929
  /** @type {string | undefined} */
@@ -4569,7 +4941,7 @@ class CssParser extends Parser {
4569
4941
  } else {
4570
4942
  // Vendor-prefixed, degenerate short, or an escaped name that is
4571
4943
  // not dashed after all — rare, string path.
4572
- declName = A.unescapedName(decl);
4944
+ declName = A.name(decl);
4573
4945
  declPropertyName = toLowerCaseIfNeeded(
4574
4946
  declName.replace(VENDOR_PREFIX, "")
4575
4947
  );
@@ -4591,8 +4963,18 @@ class CssParser extends Parser {
4591
4963
  currentRule.hasLocalAnchor &&
4592
4964
  (declPropertyName !== undefined
4593
4965
  ? COMPOSES_PROPERTY.test(declPropertyName)
4594
- : rangeEqualsLowerCase(source, nameStart, nameEnd, "composes") ||
4595
- rangeEqualsLowerCase(source, nameStart, nameEnd, "compose-with"));
4966
+ : rangeAsciiCaseInsensitiveMatch(
4967
+ source,
4968
+ nameStart,
4969
+ nameEnd,
4970
+ "composes"
4971
+ ) ||
4972
+ rangeAsciiCaseInsensitiveMatch(
4973
+ source,
4974
+ nameStart,
4975
+ nameEnd,
4976
+ "compose-with"
4977
+ ));
4596
4978
  if (currentDeclComposesSkip) emitComposesWithAnchor(decl);
4597
4979
  const skipForComposes = currentDeclComposesSkip;
4598
4980
  // `content: counter(name, style)` can name a scoped counter / `@counter-style` from any property, so this isn't driven by the known-property table.
@@ -4633,7 +5015,18 @@ class CssParser extends Parser {
4633
5015
  !(dashed.active && declIsDashed) &&
4634
5016
  icssDefinitions.has(declName)
4635
5017
  ) {
4636
- emitICSSSymbol(declName, nameStart, nameEnd);
5018
+ // `themeColor: blue` names the same custom property that
5019
+ // `var(themeColor)` resolves to, so scope it under the dashed
5020
+ // name the value holds instead of substituting it verbatim.
5021
+ const dashedName =
5022
+ this.options.dashedIdents && effectiveLocalMode
5023
+ ? localizableDashedValue(declName)
5024
+ : undefined;
5025
+ if (dashedName !== undefined) {
5026
+ emitNamedDashedIdentExport(dashedName, nameStart, nameEnd);
5027
+ } else {
5028
+ emitICSSSymbol(declName, nameStart, nameEnd);
5029
+ }
4637
5030
  }
4638
5031
  }
4639
5032
  },
@@ -4659,7 +5052,7 @@ class CssParser extends Parser {
4659
5052
  );
4660
5053
  if (ignored) return;
4661
5054
  let value = normalizeUrl(
4662
- input.slice(A.contentStart(url), A.contentEnd(url)),
5055
+ input.slice(A.startOf(Part.value, url), A.endOf(Part.value, url)),
4663
5056
  false
4664
5057
  );
4665
5058
  // Ignore `url()`, `url('')` and `url("")`, they are valid by spec
@@ -4710,8 +5103,8 @@ class CssParser extends Parser {
4710
5103
  enter: (path) => {
4711
5104
  const node = path.node;
4712
5105
  const fn = /** @type {FunctionNode} */ (node);
4713
- const fnNameStart = A.nameStart(fn);
4714
- const fnNameEnd = A.nameEnd(fn);
5106
+ const fnNameStart = A.startOf(Part.name, fn);
5107
+ const fnNameEnd = A.endOf(Part.name, fn);
4715
5108
  const fnNameLength = fnNameEnd - fnNameStart;
4716
5109
  // 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
5110
  /** @type {string | undefined} */
@@ -4719,18 +5112,19 @@ class CssParser extends Parser {
4719
5112
  let isLocalFn = false;
4720
5113
  let isGlobalFn = false;
4721
5114
  if (rangeHasEscape(input, fnNameStart, fnNameEnd)) {
4722
- escapedName = A.unescapedName(fn);
4723
- isLocalFn = equalsLowerCase(escapedName, "local");
4724
- isGlobalFn = !isLocalFn && equalsLowerCase(escapedName, "global");
5115
+ escapedName = A.name(fn);
5116
+ isLocalFn = asciiCaseInsensitiveMatch(escapedName, "local");
5117
+ isGlobalFn =
5118
+ !isLocalFn && asciiCaseInsensitiveMatch(escapedName, "global");
4725
5119
  } else if (fnNameLength === 5) {
4726
- isLocalFn = rangeEqualsLowerCase(
5120
+ isLocalFn = rangeAsciiCaseInsensitiveMatch(
4727
5121
  input,
4728
5122
  fnNameStart,
4729
5123
  fnNameEnd,
4730
5124
  "local"
4731
5125
  );
4732
5126
  } else if (fnNameLength === 6) {
4733
- isGlobalFn = rangeEqualsLowerCase(
5127
+ isGlobalFn = rangeAsciiCaseInsensitiveMatch(
4734
5128
  input,
4735
5129
  fnNameStart,
4736
5130
  fnNameEnd,
@@ -4748,7 +5142,8 @@ class CssParser extends Parser {
4748
5142
  icssDefinitions.size !== 0
4749
5143
  ) {
4750
5144
  // 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;
5145
+ const fname =
5146
+ escapedName === undefined ? rawNameOf(fn) : escapedName;
4752
5147
  if (
4753
5148
  !(dashed.active && isDashedIdentifier(fname)) &&
4754
5149
  icssDefinitions.has(fname)
@@ -4779,21 +5174,21 @@ class CssParser extends Parser {
4779
5174
  } else if (
4780
5175
  escapedName === undefined
4781
5176
  ? (fnNameLength === 3 &&
4782
- rangeEqualsLowerCase(
5177
+ rangeAsciiCaseInsensitiveMatch(
4783
5178
  input,
4784
5179
  fnNameStart,
4785
5180
  fnNameEnd,
4786
5181
  "var"
4787
5182
  )) ||
4788
5183
  (fnNameLength === 5 &&
4789
- rangeEqualsLowerCase(
5184
+ rangeAsciiCaseInsensitiveMatch(
4790
5185
  input,
4791
5186
  fnNameStart,
4792
5187
  fnNameEnd,
4793
5188
  "style"
4794
5189
  ))
4795
- : equalsLowerCase(escapedName, "var") ||
4796
- equalsLowerCase(escapedName, "style")
5190
+ : asciiCaseInsensitiveMatch(escapedName, "var") ||
5191
+ asciiCaseInsensitiveMatch(escapedName, "style")
4797
5192
  ) {
4798
5193
  // `var(--foo, …)` / `style(--foo, …)`: emit the first ident; the fallback doesn't self-emit.
4799
5194
  processDashedIdentInVarFunction(fn);
@@ -4840,15 +5235,15 @@ class CssParser extends Parser {
4840
5235
  let j = path.index + 1;
4841
5236
  while (
4842
5237
  j < count &&
4843
- A.type(A.childAt(parent, j)) === NodeType.Whitespace
5238
+ A.type(A.child(j, parent)) === NodeType.Whitespace
4844
5239
  ) {
4845
5240
  j++;
4846
5241
  }
4847
- const fromIdent = j < count ? A.childAt(parent, j) : undefined;
5242
+ const fromIdent = j < count ? A.child(j, parent) : undefined;
4848
5243
  if (
4849
5244
  fromIdent &&
4850
5245
  A.type(fromIdent) === NodeType.Ident &&
4851
- rangeEqualsLowerCase(
5246
+ rangeAsciiCaseInsensitiveMatch(
4852
5247
  input,
4853
5248
  A.start(fromIdent),
4854
5249
  A.end(fromIdent),
@@ -4858,11 +5253,11 @@ class CssParser extends Parser {
4858
5253
  j++;
4859
5254
  while (
4860
5255
  j < count &&
4861
- A.type(A.childAt(parent, j)) === NodeType.Whitespace
5256
+ A.type(A.child(j, parent)) === NodeType.Whitespace
4862
5257
  ) {
4863
5258
  j++;
4864
5259
  }
4865
- const sourceNode = j < count ? A.childAt(parent, j) : undefined;
5260
+ const sourceNode = j < count ? A.child(j, parent) : undefined;
4866
5261
  if (
4867
5262
  sourceNode &&
4868
5263
  A.type(sourceNode) === NodeType.Ident &&
@@ -4895,7 +5290,7 @@ class CssParser extends Parser {
4895
5290
  // Already rewritten as a counter / counter-style name — a second dep would overlap the same range.
4896
5291
  if (dashed.counterArgs) return;
4897
5292
  // Deferred: only the ICSS probe needs the ident's string value.
4898
- const identValue = A.value(node);
5293
+ const identValue = A.source(node);
4899
5294
  if (!icssDefinitions.has(identValue)) return;
4900
5295
  // Already scoped by the enclosing `var()` handler.
4901
5296
  if (
@@ -4919,25 +5314,22 @@ class CssParser extends Parser {
4919
5314
  // `as` selects the top-level production of §5.3: a `style` attribute is a
4920
5315
  // block's contents, anything else a full stylesheet. `as` and `skip` are
4921
5316
  // per-parse, so only the per-source `locConverter` reaches `process`.
4922
- new SourceProcessor()
4923
- .use(/** @type {VisitorMap} */ (visitors))
4924
- .process(source, {
4925
- as: /** @type {"stylesheet" | "block-contents"} */ (this.options.as),
4926
- // Non-modules parses skip selector preludes, but `@custom-selector` expansion needs them, so keep them when the file may use one.
4927
- skip: isModules
4928
- ? undefined
4929
- : mayHaveCustomSelectors
4930
- ? SKIP_NON_MODULES_KEEP_SELECTORS
4931
- : SKIP_NON_MODULES,
4932
- locConverter
4933
- });
5317
+ new SourceProcessor().use(visitors).process(source, {
5318
+ as: /** @type {"stylesheet" | "block-contents"} */ (this.options.as),
5319
+ // Non-modules parses skip selector preludes, but `@custom-selector` expansion needs them, so keep them when the file may use one.
5320
+ skip: isModules
5321
+ ? undefined
5322
+ : mayHaveCustomSelectors
5323
+ ? SKIP_NON_MODULES_KEEP_SELECTORS
5324
+ : SKIP_NON_MODULES,
5325
+ locConverter
5326
+ });
4934
5327
 
4935
5328
  if (customMediaQueries || customSelectorUses) {
4936
5329
  resolveCustomMediaAndSelectors();
4937
5330
  }
4938
5331
 
4939
- /** @type {BuildInfo} */
4940
- (module.buildInfo).strict = true;
5332
+ module.buildInfo.strict = true;
4941
5333
 
4942
5334
  // Topologically sort the `composes … from` files and tag each file's first import dep with `sourceOrder` for cascade-correct load order (cycles keep their natural position).
4943
5335
  if (composesFirstFileImport.size > 1) {
@@ -4951,7 +5343,7 @@ class CssParser extends Parser {
4951
5343
  );
4952
5344
  }
4953
5345
 
4954
- const buildMeta = /** @type {BuildMeta} */ (state.module.buildMeta);
5346
+ const buildMeta = module.buildMeta;
4955
5347
 
4956
5348
  buildMeta.exportsType = this.options.namedExports ? "namespace" : "default";
4957
5349
  buildMeta.defaultObject = this.options.namedExports