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
{{ message }}
Repository navigation
HMR will drop styles applied to a component if an HTML element in a component is changed #59558
Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
19.0.7
Description
When a template save occurs that changed an HTML element's inner content, such as adding text inside of a <p> tag for example, the styles of that component stop applying. This can temporarily be solved by adding something like a character, for example !, outside of an HTML element.
Though template HMR is new as the default in 19.1, I consider this a regression since the same ng serve command now produces different results.
Minimal Reproduction
Process
(in the 19.1's)
Add or remove any character from text inside of an HTML element. For example, add an ! inside any of the <p> tags.
Observe that all styles no longer apply to that component's template
Observe that if you add a character outside of an HTML element, such as below the comment and above the <p> aka on line 14, that the styles once again apply after an HMR refresh.
Repeat 1-3 as needed.
This is true with changes in either the main.ts inline template or the external template component which is placed inside of main.ts's template. But one breaking or fixing following the steps doesn't seem to fix the other template's issues.
Commands run (including args):
ng serve
Packages added
None beyond Stackblitz starter which was bumped to 19.1.0 for all packages, or a CLI generated app also being bumped from 19.0.6 to 19.1.0 for all packages. Both done manually since I couldn't get the CLI to bump with an ng update.
Reproductions: 2 Stackblitzes and 1 repo
Two Stackblitzes with the default stackblitz configuration, aka serves with "builder": "@angular/build:dev-server",
Repo that is essentially the 19.1 Stackblitz, but using "builder": "@angular-devkit/build-angular:dev-server", as the CLI auto generates to use. Same type of issue occurs.
To get parity I condensed the CLI app to be structured closer to the Stackblitz starters, meaning taking extra configuration out of main.ts and placing the root file and config in there. The builders of the CLI app remain the same since that is what CLI generated apps use.
As for overall changes from general starting states of apps, this consists of one root component with inline template and inline style properties, and then one component with an external template but internal style property.
Potentially related but ruled out of this reproduction: I wonder if another scenario where there is a component with inline template but exterior style impacts anything, but so much was going on already.
I'm not fully sure if this is the same issue: wie are observing that changes in SCSS will not proper be reloaded if the containing component has been lazy loaded. This is still in 19.1.1 and very annoying since right now a full serve restart is needed to see the changes.
@JMS-1, unfortunately, it's difficult to determine the root cause without a minimal reproduction. As a workaround, you can disabling HMR by using --no-hmr.
Actually as I experience it right now HMR is seriously broken in 19.1.0 and 19.1.1 so instead of providing a repro of our specific case I'll wait for 19.1.2 or so before I try to report a regular bug. Currently I can't imagine anyone relying on HMR before 19.1.0 will have any fun working with angular right now.
FYI: with 19.1.3 at least SASS changes will become visible after save. Although it looks as if the app does a full reload. Seems that waiting a bit for more fixes can help...
Activity
alan-agius4 commentedon Jan 16, 2025
Transferring to the FW as this is a runtime issues.
fix(platform-browser): roll back HMR fix
fix(platform-browser): roll back HMR fix (#59557)
fix(platform-browser): roll back HMR fix (angular#59557)
michael-small commentedon Jan 16, 2025
Wow, that was fast. Thank you all.
JMS-1 commentedon Jan 17, 2025
I'm not fully sure if this is the same issue: wie are observing that changes in SCSS will not proper be reloaded if the containing component has been lazy loaded. This is still in 19.1.1 and very annoying since right now a full serve restart is needed to see the changes.
alan-agius4 commentedon Jan 17, 2025
@JMS-1, unfortunately, it's difficult to determine the root cause without a minimal reproduction. As a workaround, you can disabling HMR by using
--no-hmr.JMS-1 commentedon Jan 17, 2025
Actually as I experience it right now HMR is seriously broken in 19.1.0 and 19.1.1 so instead of providing a repro of our specific case I'll wait for 19.1.2 or so before I try to report a regular bug. Currently I can't imagine anyone relying on HMR before 19.1.0 will have any fun working with angular right now.
JMS-1 commentedon Jan 21, 2025
FYI: with 19.1.3 at least SASS changes will become visible after save. Although it looks as if the app does a full reload. Seems that waiting a bit for more fixes can help...
fix(platform-browser): roll back HMR fix (angular#59557)
angular-automatic-lock-bot commentedon Feb 21, 2025
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.