Skip to content

HMR not working according to the documentation #11028

Closed
@rbasniak

Description

@rbasniak

Versions

Angular CLI: 6.0.5
Node: 8.9.4
OS: win32 x64
Angular: 6.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.5
@angular-devkit/build-angular     0.6.5
@angular-devkit/build-optimizer   0.6.5
@angular-devkit/core              0.6.5
@angular-devkit/schematics        0.6.5
@angular/cli                      6.0.5
@ngtools/webpack                  6.0.5
@schematics/angular               0.6.5
@schematics/update                0.6.5
rxjs                              6.2.0
typescript                        2.7.2
webpack                           4.8.3

Repro steps

  • create new application with cli

  • follow the steps on https://github.com/angular/angular-cli/wiki/stories-configure-hmr

  • one of the steps instructs to edit angular.json serve section according to this:

     "serve": {
        "builder": "@angular-devkit/build-angular:dev-server",
        "options": {
          "hmrWarning": false,
          "browserTarget": "hmrtest:build"
        },
        "configurations": {
          "hmr": {
              "hmr": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.hmr.ts"
                }
              ]
            },
          "production": {
            "browserTarget": "hmrtest:build:production"
          }
        }
      },
    
  • when I do that, there's a lint error telling me that the fileReplacements property is not allowed

  • run the project with ng serve --configuration hmr

Observed behavior

  • project won't compile with the following error:

Schema validation failed with the following errors:
Data path "" should NOT have additional properties(fileReplacements).

Desired behavior

Project compiling and HMR working

Mention any other details that might be useful (optional)

I managed to make it compile using the angular.json from #10668, this way the project runs, and the console prints:

NOTICE: Hot Module Replacement (HMR) is enabled for the dev server.

Also, the in the browser console I can see the message

[HMR] Waiting for update signal from WDS...

But when I make any change in the project, the page is fully reloaded like it does without HMR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions