You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Split out of a Codex review finding on #455. Pre-existing on main — the transition behaves identically there.
Symptom
A component has styles, then loses them — its last inline styles entry is deleted, its array becomes [], or its external stylesheet becomes empty. HMR updates the component, but the old CSS stays applied. Only a full reload clears it.
Cause
The HMR module spreads the existing Class.ɵcmp, so a property it does not emit keeps its previous value. The generator omits styles for BOTH null and an empty array:
So there is no way for the plugin to express "this component now has no styles" — the distinction is erased on the Rust side.
Why the obvious fix is not enough
The review that surfaced this recommended preserving a definitive empty state through compileForHmrSync and emitting styles: []. The first half is a plugin change; the second half is a Rust generator change, and without it the plugin cannot express the state no matter what it passes. Both halves are needed.
Suggested fix
Make the HMR generator emit styles: [] when it is given an empty array, so the spread is overridden, while continuing to omit the property for null (meaning "unknown, leave as-is").
Worth adding endpoint regressions for both transitions, non-empty to empty external and non-empty to empty inline. #455's tests only cover components that were already styleless, so they cannot catch this.
Split out of a Codex review finding on #455. Pre-existing on
main— the transition behaves identically there.Symptom
A component has styles, then loses them — its last inline
stylesentry is deleted, its array becomes[], or its external stylesheet becomes empty. HMR updates the component, but the old CSS stays applied. Only a full reload clears it.Cause
The HMR module spreads the existing
Class.ɵcmp, so a property it does not emit keeps its previous value. The generator omitsstylesfor BOTH null and an empty array:So there is no way for the plugin to express "this component now has no styles" — the distinction is erased on the Rust side.
Why the obvious fix is not enough
The review that surfaced this recommended preserving a definitive empty state through
compileForHmrSyncand emittingstyles: []. The first half is a plugin change; the second half is a Rust generator change, and without it the plugin cannot express the state no matter what it passes. Both halves are needed.Suggested fix
styles: []when it is given an empty array, so the spread is overridden, while continuing to omit the property for null (meaning "unknown, leave as-is").[]rather than null when it knows the component is definitively styleless — fix(vite): resolve @ng/component styles per class #455 already computes that state and currently collapses it to null.Worth adding endpoint regressions for both transitions, non-empty to empty external and non-empty to empty inline. #455's tests only cover components that were already styleless, so they cannot catch this.