tailwindcss/packages/@tailwindcss-node/src
Wei f723e834ad
Don't warn about Angular's ::ng-deep and :host-context() when optimizing CSS (#20434)
Fixes #20433.

The warning filter in `optimize.ts` already ignores `:deep()`,
`:slotted()` and `:global()`. Angular's two deep selectors are the same
kind of thing — non-standard pseudo-selectors that the framework's
compiler resolves before the CSS reaches a browser — but they aren't
covered, so every Angular component stylesheet using them prints a
warning block per occurrence.

```
Found 2 warnings while optimizing generated CSS:

Issue #1:
│ :host ::ng-deep .some-child, :host
┆        ^-- 'ng-deep' is not recognized as a valid pseudo-element. Did you mean ':ng-deep' (pseudo-class) or is this a typo?
```

Angular strips both during view-encapsulation shimming — `::ng-deep` via
`_shadowDeepSelectors = /(?:>>>)|(?:\/deep\/)|(?:::ng-deep)/g`, and
`:host-context()` in the same pass — so neither ever reaches a browser.

Worth noting that `/deep/` and `>>>`, Angular's two other spellings of
the deep selector, already pass silently because
`nonStandard.deepSelectorCombinator` is enabled. `::ng-deep` is the only
one that warns, and it's the spelling the Angular docs use — so in
practice every Angular codebase hits this. On the workspace where I ran
into it (7 Angular apps), a production build printed 425 `ng-deep`
warnings and 2 `host-context` ones.

## Test plan

There's no automated coverage here because the warning path is behind
`process.env.NODE_ENV !== 'test'`, so a spy sees nothing under Vitest
regardless of the filter — the same reason #20277 shipped without one.
Instead I ran the file before and after the change against Lightning CSS
1.33.0 directly, counting emitted warning blocks:

| Input | Before | After |
| --- | --- | --- |
| `:host ::ng-deep .a, :host ::ng-deep .b { … }` | 1 | 0 |
| `:host-context(.dark) .a { … }` | 1 | 0 |
| `:deep(.a) { … }` | 0 | 0 |
| `.a::totally-not-real { … }` — genuine typo | 1 | **1** |

Generated CSS is byte-identical before and after; only the warning is
suppressed. Genuine unknown pseudo-selectors still warn, so the typo
hint the message exists for is preserved.

Happy to restructure this if you'd prefer the predicate extracted so it
can be unit-tested, or to split `ng-deep` and `host-context` into their
own block rather than extending the existing regex.

A minimal reproduction of the original issue is at
https://gist.github.com/weilinzung/ace42ceb95c2f47b6747cc1f34f162bd.

---------

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2026-08-31 10:14:54 +00:00
..
compile.ts format 2026-04-20 13:12:24 +02:00
env.ts fix: allow process.env.DEBUG to be a boolean in @tailwindcss/node (#18485) 2025-07-11 11:51:50 -04:00
esm-cache.loader.mts Fix crash when using @tailwindcss/vite using deno v2.8.x (#20245) 2026-06-16 16:03:27 +02:00
get-module-dependencies.ts Support loading config files via @config (#14239) 2024-09-02 18:03:16 +02:00
index.cts fix(node): prefer Module#registerHooks over Module#register (#20028) 2026-05-11 14:25:28 +00:00
index.ts move localRequire to else branch 2026-05-12 11:19:48 +02:00
instrumentation.test.ts add margin of error to the test 2026-06-25 19:23:36 +02:00
instrumentation.ts Improve internal instrumentation module (#20119) 2026-05-26 23:20:39 +02:00
normalize-path.ts Resolve @import in core (#14446) 2024-09-23 17:05:55 +02:00
optimize.ts Don't warn about Angular's ::ng-deep and :host-context() when optimizing CSS (#20434) 2026-08-31 10:14:54 +00:00
require-cache.cts Support loading config files via @config (#14239) 2024-09-02 18:03:16 +02:00
require-cache.ts Cleanup noisy test output (#20015) 2026-05-06 11:10:17 +02:00
source-maps.test.ts Fix internal source map warnings (#19788) 2026-03-12 12:21:00 +01:00
source-maps.ts Fix internal source map warnings (#19788) 2026-03-12 12:21:00 +01:00
urls.test.ts Vite: Don't rebase urls that appear to be aliases (#16078) 2025-01-31 15:23:32 +01:00
urls.ts Cleanup inconsistencies related to (regex) escapes (#19804) 2026-03-15 22:04:58 +01:00