Skip to content

HMR: use environment API to replace ssrLoadModule #274

@lovetingyuan

Description

@lovetingyuan
// appModule = await server.ssrLoadModule(entry)
appModule = await server.environments.ssr.runner.import(entry);

The main issue is that ssrLoadModule causes hot updates to fail.
Since Hono runs in a Node.js environment, deep submodule imports cannot be collected by Vite's moduleGraph, leading to hot updates not taking effect. (This is my guess, but the problem genuinely exists).
We could consider replacing it with the environment API: https://vite.dev/guide/api-environment-frameworks.html#environments-and-frameworks
I've tested this with Vite 7, and it works, even though the entire Hono application is re-run. However, that's still better than hot updates not working at all.


Hono does not update when duplicate routes are registered; instead, it ignores them. This prevents the use of import.meta.hot.accept for fine-grained HMR. related: honojs/hono#4147, honojs/hono#3817

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions