Don't warn about Angular's ::ng-deep and :host-context() when optimizing CSS - #20434
Don't warn about Angular's ::ng-deep and :host-context() when optimizing CSS#20434weilinzung wants to merge 2 commits into
::ng-deep and :host-context() when optimizing CSS#20434Conversation
…imizing CSS The filter already ignores `:deep()`, `:slotted()` and `:global()`. Angular's two deep selectors are the same kind of thing — non-standard pseudo-selectors resolved by the framework's compiler before the CSS reaches a browser — but they were not covered, so every Angular component stylesheet using them printed a warning block per occurrence.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. WalkthroughCSS optimization no longer reports unknown pseudo-class and pseudo-element warnings for Vue selectors ( Merge Risk: ⚪ Minimal · up to This localized change suppresses warnings for Angular selectors that are removed before reaching browsers while preserving warnings for genuine unknown selectors; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The changes satisfy issue Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Confidence Score: 5/5The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking issue identified. The change narrowly extends an existing diagnostic filter for two documented framework selectors while leaving optimization output and unrelated warning handling unchanged. Reviews (1): Last reviewed commit: "Add changelog entry" | Re-trigger Greptile |
Fixes #20433.
The warning filter in
optimize.tsalready 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.Angular strips both during view-encapsulation shimming —
::ng-deepvia_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 becausenonStandard.deepSelectorCombinatoris enabled.::ng-deepis 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 425ng-deepwarnings and 2host-contextones.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::host ::ng-deep .a, :host ::ng-deep .b { … }:host-context(.dark) .a { … }:deep(.a) { … }.a::totally-not-real { … }— genuine typoGenerated 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-deepandhost-contextinto their own block rather than extending the existing regex.A minimal reproduction of the original issue is at https://gist.github.com/weilinzung/ace42ceb95c2f47b6747cc1f34f162bd.