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

Commit e8dd808

Browse files
In Angular2Spa, fix HMR with 2.4.6 and relax version dependency to allow arbitrary 2.x again. Fixes #643
1 parent 4f7091c commit e8dd808

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

templates/Angular2Spa/ClientApp/boot-client.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ import { enableProdMode } from '@angular/core';
33
import { platformUniversalDynamic } from 'angular2-universal';
44
import { AppModule } from './app/app.module';
55
import 'bootstrap';
6+
const rootElemTagName = 'app'; // Update this if you change your root component selector
67

78
// Enable either Hot Module Reloading or production mode
89
if (module['hot']) {
910
module['hot'].accept();
10-
module['hot'].dispose(() => { platform.destroy(); });
11+
module['hot'].dispose(() => {
12+
// Before restarting the app, we create a new root element and dispose the old one
13+
const oldRootElem = document.querySelector(rootElemTagName);
14+
const newRootElem = document.createElement(rootElemTagName);
15+
oldRootElem.parentNode.insertBefore(newRootElem, oldRootElem);
16+
platform.destroy();
17+
});
1118
} else {
1219
enableProdMode();
1320
}

templates/Angular2Spa/package-2.4.5.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"test": "karma start ClientApp/test/karma.conf.js"
66
},
77
"dependencies": {
8-
"@angular/common": "2.4.5",
9-
"@angular/compiler": "2.4.5",
10-
"@angular/core": "2.4.5",
11-
"@angular/forms": "2.4.5",
12-
"@angular/http": "2.4.5",
13-
"@angular/platform-browser": "2.4.5",
14-
"@angular/platform-browser-dynamic": "2.4.5",
15-
"@angular/platform-server": "2.4.5",
8+
"@angular/common": "^2.4.5",
9+
"@angular/compiler": "^2.4.5",
10+
"@angular/core": "^2.4.5",
11+
"@angular/forms": "^2.4.5",
12+
"@angular/http": "^2.4.5",
13+
"@angular/platform-browser": "^2.4.5",
14+
"@angular/platform-browser-dynamic": "^2.4.5",
15+
"@angular/platform-server": "^2.4.5",
1616
"@angular/router": "^3.4.5",
1717
"@types/node": "^6.0.42",
1818
"angular2-platform-node": "~2.0.11",

0 commit comments

Comments
 (0)