Skip to content

Support HMR when updating main.ts process #858

@pattobrien

Description

@pattobrien

Clear and concise description of the problem

When building a complex Electron app that has a lot of logic in the main process, it becomes a less-than-ideal DevX to have the entire application either a) completely restart on every change to the main process or b) require a manual restart after changes.

On the other hand, full-stack app frameworks like Tanstack Start support HMR across the entire stack, by utilizing the latest Vite APIs for both SSR and Client-side environments.

It would be great if electron-vite could support HMR in the main and preload processes, in addition to the existing renderer HMR support.

Suggested solution

There have been projects like vite-node that have proven the ability to enable HMR in non-frontend apps. The vite-node solution in particular has laid the foundation for the new vite Environment API, which can be used by the electron-vite project to enable HMR in server-side apps.

The main process would need to be broken up into parts that would be able to be hot reloaded (e.g. changes to ipc handler implementations) and state that would persist between hot reloads.

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions