exhibitionist-digital / ultra

Zero-Legacy Deno/React Suspense SSR Framework
https://ultrajs.dev
MIT License
2.99k stars 65 forks source link

feat(hmr): Use HMR in Deno 1.38 to create HMR in Ultra #285

Open cdoremus opened 8 months ago

cdoremus commented 8 months ago

Hot module replacement was just added to the Deno runtime in version 1.38. This should be leveraged to implement HMR in Ultra.

cdoremus commented 8 months ago

The Deno team has repeatedly said that it plans to use this feature to give Fresh client-side HMR and yesterday it gave a hint on how they will do it. In essence, they suggest listening to the "hmr" event and capturing the Event.detail value that contains the path to the file that changed and triggered the event, and sending that information to the front end that would cause a reload of that file (or perhaps the page that uses that file).

To see that demo on the livestream that discussed using the "hmr" event, take a look at: https://youtu.be/5tUDSrnHFPk?t=1857