Skip to content

HMR Breaks self-referencing components #59632

@Sergiobop

Description

@Sergiobop

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

Related to #59602

Having a nested component make "children" components not render with HMR enabled. When i tried ng serve \--no-hmr everything works as expected.

import { Component, Input } from '@angular/core';

interface Comment {
  id: number;
  author: string;
  text: string;
  children?: Comment[];
}

@Component({
  selector: 'app-comment',
  template: `
    <div class="comment">
      <div class="comment-content">
        <strong>{{ comment.author }}</strong>: {{ comment.text }}
      </div>

      <div class="comment-children">
          <!-- THIS IS NOT RENDERED -->
         @for (children of comment.children; track children.id) {
          <app-comment [comment]="child" />
         }
      </div>
    </div>
  `,
  styles: [
    `
      .comment {
        margin: 10px 0;
        padding-left: 20px;
        border-left: 2px solid #ccc;
      }
      .comment-content {
        margin-bottom: 5px;
      }
      .comment-children {
        margin-top: 10px;
      }
    `,
  ],
})
export class CommentComponent {
  @Input() comment!: Comment;
}

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw


Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 19.1.3
Node: 20.18.0
Package Manager: npm 11.0.0
OS: darwin arm64

Angular: 19.1.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
... service-worker

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.1901.3
@angular-devkit/build-angular      19.1.3
@angular-devkit/core               18.2.8
@angular-devkit/schematics         18.2.8
@angular/cdk                       19.1.0
@angular/cli                       19.1.3
@angular/material                  19.1.0
@angular/material-moment-adapter   19.1.0
@angular/youtube-player            19.1.0
@schematics/angular                19.1.3
rxjs                               7.8.1
typescript                         5.7.3
zone.js                            0.15.0

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions