Ionic 5 - Angular 11 and Hot Module Replacement

I have added comment to existing issue. Feel free to raise your own. :slight_smile:

1 Like

Let me buy you a drink! Thx

1 Like

I don’t see separatedArgs in my latest CLI version.

Can you please give me the link of existing issue too?

It is in the function createOptionsFromCommandLine. Not the one calling.

Yeah there is no createOptionsFromCommandLine in server.js but this function called in server.js at the mentioned line

there are multiple server.js. I think I used the one in lib (but would have to check).

Ok, that in the different path as there are many server.js path for it \npm\node_modules\@ionic\cli\lib\serve.js line 107:

While I confirm hmr enabled from logs, but it still refreshes the page.

Well, I guess if the module relates to the page shown, you can’t avoid a page reload. Maybe on CSS It should be more relaxed…

And I still have to check a case I seemed to have where the app looses the injected service. Not sure if that was because of HMR or a bug. Either way, an error I have never encountered before.

Tried HTML, SCSS and TypeScript everything refreshes the page

1 Like

Well, too bad. But recompile time beefed up. So some benefit, right? Ideally pages wouldn’t loose state. A refresh aside.

Exactly!
Everything refreshes the page!
I open another issue for that:

Yup. This is happening. So, just be care, it may still be too experimental :slight_smile:

image

Any solution for this in 2022?

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 3 days. Any idea will be appreciated?. .

This is what I did to get HMR running on my setup.

Hacky, but working

Angular HMR feature is not perfect.

I faced that whole app was refreshed beacause of lazy module.