I have an angular 10 project that I opened at work.
after a while, when I saw that HMR added to angular 11 I upgraded the project by trying to work with HMR.
Since it didn't, I opened a brand new angular project. checked that HMR working. I moved all components, services, modules, styles (without node folder of course) and launched it using ng serve --hmr and it failed to work again. the page is being refreshed.
I am on this 2 days. Any idea will be appreciated? thank you. my package JSON is:
{
"name": "date-manager-ui",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~11.2.4",
"@angular/cdk": "^11.2.3",
"@angular/common": "~11.2.4",
"@angular/compiler": "~11.2.4",
"@angular/core": "~11.2.4",
"@angular/forms": "~11.2.4",
"@angular/material": "^11.2.3",
"@angular/platform-browser": "~11.2.4",
"@angular/platform-browser-dynamic": "~11.2.4",
"@angular/router": "~11.2.4",
"angular2-text-mask": "^9.0.0",
"bootstrap": "^4.6.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1102.3",
"@angular/cli": "~11.2.3",
"@angular/compiler-cli": "~11.2.4",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.1.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.1.5"
}
}
update: i opened a new brand angular 11 project, ran with --hmr. i written alert() at AppComponent's ngOnInit. i see that on each save, ngOnInit is called ( alert pops up). so, all code, ajax calls will be executed. isnt hmr suppose to bypass that? if all code under ngOnInit executed, how hmr is helpful. what am i missing here?
export class AppComponent {
title = 'AppTest';
ngOnInit(): void {
alert();
}
}