Webpack HMR is not implemented for the main process when using @electron-forge/plugin-webpack. The docs currently state that "It is unfortunately impossible to do hot module reloading inside a renderer preload script, WebWorkers, and the main process itself". This is however does not seem to hold for the main process at least, for example electron-webpack is capable of hot reloading the main process.
Implement HMR for the main process similarly to electron-webpack. I tried to look at exactly how it works but I'm not comfortable enough yet with HMR internals to implement this by myself.
In #682, the idea of reloading the main process was dismissed because of the administrative burden of killing, making sure it's stopped, and restarting electron would mean for electron-forge. Implementing HMR would both improve upon that idea from a DX point of view, while eliminating the problem of restarting the process.
As I see, the only difficulty with HMR in the main process would be that users need to be aware that they need to clean up and reconfigure IPC listeners on updates, however this doesn't interfere with any current behavior, and in fact if users don't module.hot.accept updates, the fallback behavior would be exactly the same as now.
This is unlikely to be worked on by the maintainers unless it's sponsored. However, we'd be happy to review a pull request implementing this feature.
As a side-note I migrated from electron-webpack to electron-forge a while back and although it technically supports hot reloading it has a host of issues with it and I found the experience quite buggy.
@b-zurg thank you for your insight. Could you please clarify whether the issues are with electron-webpack or with electron-forge? It was a little ambiguously worded. ;) To be honest I鈥檓 at the early stages of a new project and haven鈥檛 worked much with either tool yet.
Could you also please tell me what kind issues and bugs you encountered?
Sorry, I had many issues with electron-webpack. I have a windows machine, which may have exacerbated some of the issues, but some examples I remember is zombie node processes existing after the end of a dev session or if it crashed, to very large webpack logs clogging up vscode and making it unusable and no real way to change the webpack settings, to the old version of webpack that the project was on and its configuration with happypack actually being extremely resource intensive and such.
This project is much better maintained, gives more flexibility, is on the latest version of webpack (which makes a huge difference) and everything I've needed to I've been able to configure. If you want to use electron-builder and not the publishers that's also totally possible by simply using the compiled code.
Thanks for the info @b-zurg!
Most helpful comment
Sorry, I had many issues with electron-webpack. I have a windows machine, which may have exacerbated some of the issues, but some examples I remember is zombie node processes existing after the end of a dev session or if it crashed, to very large webpack logs clogging up vscode and making it unusable and no real way to change the webpack settings, to the old version of webpack that the project was on and its configuration with happypack actually being extremely resource intensive and such.
This project is much better maintained, gives more flexibility, is on the latest version of webpack (which makes a huge difference) and everything I've needed to I've been able to configure. If you want to use
electron-builderand not the publishers that's also totally possible by simply using the compiled code.