HMR for main process in @electron-forge/plugin-webpack
See original GitHub issuePreflight Checklist
- I have read the contribution documentation for this project.
- I agree to follow the code of conduct that this project follows, as appropriate.
- I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Problem Description
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.
Proposed Solution
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.
Alternatives Considered
–
Additional Information
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.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top GitHub Comments
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.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.