Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

HMR broken using Angular 2.4 #643

Closed
Closed

Description

@ManuelDeLeon

Create a new Angular project with the experimental patch (v0.8.1). The app runs fine the first time but if you update a file (say home.component.html) the browser goes blank and you see a bunch of errors in the console:

EXCEPTION: Error in :0:0 caused by: The selector "app" did not match any elements

Activity

  1. MarkPieszak commented on Feb 3, 2017

    @MarkPieszak
    Contributor

    Did you rename the root component from <app>?
    Check your Views/Home/index.cshtml, and also what your app.component.ts selector is.
    Wasn't able to reproduce this one locally.

  2. ManuelDeLeon commented on Feb 3, 2017

    @ManuelDeLeon
    Author

    Nope.

    This generator can also be run with: yo aspnetcore-spa
    
    
         _-----_     ╭──────────────────────────╮
        |       |    │  Welcome to the ASP.NET  │
        |--(o)--|    │   Core Single-Page App   │
       `---------´   │        generator!        │
        ( _´U`_ )    │                          │
        /___A___\   /│      Version: 0.8.1      │
         |  ~  |     ╰──────────────────────────╯
       __'.___.'__
     ´   `  |° ´ Y `
    
    ? Framework Angular 2.4.5 (experimental)
    ? What type of project do you want to create? project.json (compatible with .NET Core tooling preview 2 and Visual Studio 20
    15)
    ? Do you want to include unit tests? Yes
    

    Ran: cross-env ASPNETCORE_ENVIRONMENT=Development dotnet run
    Then changed home.component.html header to: <h1>Hello, world! XXX</h1>
    Save => blank screen with error.

  3. nikitadmitry commented on Feb 4, 2017

    @nikitadmitry

    When HMR updates modules, it detaches and reattaches changed components. DomRenderer.prototype.detachView removes all component elements which have parentNode defined (for app element it will be body element). As a temporary bypass I use
    ngOnDestroy(): void { document.body.appendChild(document.createElement("app")); }

  4. btmadison commented on Feb 6, 2017

    @btmadison

    I also am seeing this. Thank you @nikitadmitry - I added that line in the ctor of app.component and this has helped resolve the issue for me also.

    I also have not changed the default name app as the selector.

  5. chrisjmccrum commented on Feb 6, 2017

    @chrisjmccrum

    @nikitadmitry Thank you for the interim fix - I'm back in business over here as well

  6. hheexx commented on Feb 6, 2017

    @hheexx

    For me HMR broke with angular 2.4.6.
    We reverted back to 2.4.5 and it works.

  7. SteveSandersonMS commented on Feb 7, 2017

    @SteveSandersonMS
    Member

    Thanks for the report. I've published generator-aspnetcore-spa 0.8.2 which pins to Angular 2.4.5. I'll look at relaxing this versioning restriction when I get a chance to investigate the issue with 2.4.6.

  8. SteveSandersonMS commented on Feb 9, 2017

    @SteveSandersonMS
    Member

    The template is now updated to support HMR with newer Angular 2.x (tested with 2.4.7).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions