solid-refresh icon indicating copy to clipboard operation
solid-refresh copied to clipboard

Support Bun's HMR

Open MioYiSama opened this issue 2 months ago • 0 comments

Documentation: https://bun.com/docs/bundler/hot-reloading

Bun implements a client-side HMR API modeled after Vite's import.meta.hot API

So most of the code implemented for Vite can be reused for Bun's implementation.

However, this check is often not needed as Bun will dead-code-eliminate calls to all of the HMR APIs in production builds. For this to work, Bun forces these APIs to be called without indirection. That means the following do not work:

The only thing to consider is that "const hot = import.meta.hot;" cannot work in Bun (which results in "error: import.meta.hot.data cannot be used indirectly."), i.g. _$$refresh("vite", import.meta.hot, _REGISTRY);. All destructured hot calls need to be replaced with import.meta.hot.

MioYiSama avatar Nov 16 '25 02:11 MioYiSama