feat(plugin-vite): enable main process hot restart via exported API#4210
Open
bglgwyng wants to merge 4 commits intoelectron:nextfrom
Open
feat(plugin-vite): enable main process hot restart via exported API#4210bglgwyng wants to merge 4 commits intoelectron:nextfrom
bglgwyng wants to merge 4 commits intoelectron:nextfrom
Conversation
Add restartApp()/onAppRestart() to @electron-forge/core-utils as an explicit API for triggering Electron app restarts. The Vite plugin calls restartApp() in its closeBundle hook when the main process bundle is rebuilt. The start API registers the actual restart logic via onAppRestart(). Also backport the duplicate restart guard (!lastSpawned.restarted) to the stdin handler. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The stdin 'rs' handler now calls restartApp() instead of duplicating the kill→respawn logic, so all restart requests flow through the single onAppRestart callback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevent unnecessary terminal cursor manipulation when the Electron app has not been spawned yet. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add `hotRestart` option to VitePluginConfig (default: false). The main process restart is now only enabled when explicitly configured. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5 tasks
Author
|
I just tested it and it's really ready now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces #4168 with a clean branch based on
next.restartApp()/onAppRestart()to@electron-forge/core-utilsas an explicit API for triggering Electron app restartsrestartApp()in itscloseBundlehook when the main process bundle is rebuiltstartAPI registers the actual restart logic viaonAppRestart()rsstdin handler also goes throughrestartApp(), so there's a single restart pathhotRestart: truein the Vite plugin configBackground
Main process hot restart for the Vite plugin has been requested and attempted multiple times:
process.stdin.emit('data', 'rs')EventEmitter-based approachpluginHotRestart('restart')but left it commented outThis PR implements the approach suggested in #3380 and unblocks the commented-out code in #3583.
Test plan
ViteConfig.spec.tstests pass (hot restart plugin only included whenhotRestart: true)vite.base.config.spec.tstests passhotRestart: truein Vite plugin config, modify main process code, verify app restartshotRestartconfig, verify no auto-restart on main process changes🤖 Generated with Claude Code