question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HMR for main process in @electron-forge/plugin-webpack

See original GitHub issue

Preflight 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
b-zurgcommented, Jul 6, 2020

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.

1reaction
b-zurgcommented, Jul 6, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack Plugin - Electron Forge
This plugin makes it easy to set up standard webpack tooling to compile both your main process code and your renderer process code,...
Read more >
HMR for main process in @electron-forge/plugin-webpack
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...
Read more >
@electron-forge/plugin-webpack: Docs & Community | Openbase
This plugin makes it easy to set up standard webpack tooling to compile both your main process code and your renderer process code,...
Read more >
@electron-forge/plugin-webpack - npm package | Snyk
This plugin makes it easy to set up standard webpack tooling to compile both your main process code and your renderer process code,...
Read more >
@electron-forge/plugin-webpack - npm
The Webpack plugin allows you to use standard Webpack tooling to compile both your main process code and your renderer process code with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found