Option to allowlist custom (non-standard) pseudo-classes/elements to suppress "not recognized" warnings

Author: marekdedicCreated Sep 18, 2026Updated Sep 18, 2026

Feature request

When LightningCSS is used as a transformer inside another tool's pipeline (e.g. Vite's css.transformer: 'lightningcss'), it runs over CSS that still contains framework-specific selectors the host tool will compile away later — Svelte's :global(…), Vue's :deep()/:slotted(), etc. LightningCSS emits a warning for each:

[lightningcss] 'global' is not recognized as a valid pseudo-class. Did you mean '::global' (pseudo-element) or is this a typo?

The output is correct (the selectors pass through), but the warnings are pure noise and can number in the hundreds on a real build. Framework plugins currently work around this by monkey-patching the host bundler's logger to filter the messages (e.g. vitejs/vite-plugin-vue#521), which is fragile and duplicated per framework.

I understand the maintainer's position (from #871) that these selectors "should be compiled before reaching LightningCSS." In an ideal pipeline that's true, but the ordering is controlled by the host bundler, not the framework plugin, and isn't always changeable — so the warnings surface regardless.

Proposed solution

An option to tell LightningCSS about known custom selectors so it treats them as valid and stays silent — for example:

javascript
transform({
  filename: 'style.css',
  code,
  // names LightningCSS should accept as pseudo-classes / pseudo-elements
  // without emitting "not recognized" warnings
  customPseudoClasses: ['global', 'deep', 'slotted'],
  // (optionally the pseudo-element equivalent)
})

Integrators (vite-plugin-svelte, plugin-vue, …) could register their framework's selectors once, instead of each patching the bundler's logger.

Alternatives considered

  • Host-side ordering (compile the framework CSS before LightningCSS): correct in principle, but not controllable from the framework plugin in the current Vite pipeline.
  • Logger monkey-patching (plugin-vue #521): works but is fragile, per-framework, and brittle against message-format changes.
  • errorRecovery: downgrades errors to warnings — doesn't suppress the warnings, so it doesn't help here.

Environment

  • lightningcss 1.33.0, via Vite 8 (css.transformer: 'lightningcss') + @sveltejs/vite-plugin-svelte 7.3.0

Source: parcel-bundler/lightningcss