bug(HMR): removing components selectors from a template causes inconsistent behavior with other components in template · Issue #59581 · angular/angular · GitHub
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
bug(HMR): removing components selectors from a template causes inconsistent behavior with other components in template #59581
Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
Yes
Description
Commenting out or entirely removing a component selector (<app-thing />) causes odd behavior.
Take the following example, and imagine I just did ng serve in a fresh CLI generated (19.1.1) app, which had components a/b/c generated as inline template and inline style with the default <p>a works!</p> and so on.
@Component({selector: 'app-root',// templateUrl: './app.component.html', // also applies to externaltemplate: ` <app-a /> <app-b /> <app-c /> {{version.full}} `,styleUrl: './app.component.scss',imports: [AComponent,BComponent,CComponent],})exportclassAppComponent{version=VERSION;}
If I removed <app-a />, the view now only shows the template of <app-b /> and the version. However, this is the rendered body of <app-root>, using either file-based or inline template:
<app-rootng-version="19.1.1"><app-b><p> b works! </p></app-b><app-c></app-c> 19.1.1 </app-root>
Other variants
Removing <app-b />
<app-rootng-version="19.1.1"><app-a><p> a works! </p></app-a><app-c></app-c> 19.1.1</app-root>
Removing <app-c />
<app-rootng-version="19.1.1"><app-a><p> a works! </p></app-a><app-b><p> b works! </p></app-b> 19.1.1</app-root>
Trends:
When removing A or B, C's host element stays but is empty. But when removing C, A and B properly render and there is no C.
Not really an issue with non component HTML elements, such as a <p>stuff</p> tag in the <app-root /> template. And the untagged full version I had for my reference was also fine. However, components still are spotty like above when removed and in the same template as primitive elements or text (edited: clarify).
Please provide a link to a minimal reproduction of the bug
19.1.1 aka I bumped main with the actual latest in the package.json
nightlies-19.1.1+ that points at all the nightlies (edit: and resolved with --force).
My examples I pasted were from main. I observed the same view behavior in 19.1.1 as main but did not check for the exact DOM in 19.1.1. Same story for the nightly but the DOM did look the same at a glance, including the strange C behavior.
Additionally, I didn't look as close as in this reproduction, but the end behavior I initially observed in a large vanilla Angular workspace monorepo of module based apps that I got to what resolves to 19.1.1 for @angular/core.
Activity
fix(compiler-cli): disable tree shaking during HMR (#59595)
fix(compiler-cli): disable tree shaking during HMR (angular#59595)
fix(compiler-cli): disable tree shaking during HMR (angular#59595)
angular-automatic-lock-bot commentedon Feb 20, 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.