materiahq / ngx-monaco-editor

Monaco Editor Library for Angular v6 and above
MIT License
159 stars 35 forks source link

Fix for HMR when working in Electron #13

Closed gorunovanton closed 5 years ago

gorunovanton commented 5 years ago

Hello! Thank you for this library, it helped me a lot.

I faced some troubles using this package in Electron with enabled HMR option. Every time i change my code, HMR instead of performing hotswap for changes just reloads whole page with this messages in console:

[HMR] Cannot apply update. Need to do a full reload! [HMR] TypeError: window.amdRequire.config is not a function

I made a little investigation of the problem and found that this happens when I'm using MonacoEditorLoaderService in my main Angular module (to add json-schema) .

I analyzed MonacoEditorLoaderService class and I suppose that it is unnecessary to modify (window).amdRequire and (window).require when this service is being created for a second time because global state in "window" global variable is already set. So I made this simple fix.

jmarc-roy commented 5 years ago

Hi @gorunovanton, Thanks a lot for your contribution. I will release your fix this week.

jmarc-roy commented 5 years ago

Done in v2.0.7 !