fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Hot reload for islands

Open notangelmario opened this issue 2 years ago • 9 comments

Is fresh capable of hot reloading while in dev mode? If not, would it be possible?

notangelmario avatar Jun 29 '22 17:06 notangelmario

If by hot reloading you mean the changes appear in your browser when you save a file. Then yes.

fulsomenko avatar Jun 29 '22 17:06 fulsomenko

yes i noticed. but I mean could the framework only refresh the component that needs to be updated? this is considered it is used with preact

notangelmario avatar Jun 29 '22 17:06 notangelmario

It is not capable of doing this now. It may be possible that we can support this for islands in the future, but Fresh will never support this for generic pages, as there is no infrastructure for rendering pages on the client (pages are always server side rendered).

lucacasonato avatar Jun 29 '22 18:06 lucacasonato

well yes, I would not expect hot reloading for prerendered content. but it would be nice for islands

notangelmario avatar Jun 29 '22 21:06 notangelmario

This would be possible by injecting a WebSocket script, and telling the browser to refresh with every change. This would be pretty bare bones, and doesn't maintain state, but hey, it would be a start.

zoeleu avatar Jul 05 '22 19:07 zoeleu

This would be possible by injecting a WebSocket script, and telling the browser to refresh with every change. This would be pretty bare bones, and doesn't maintain state, but hey, it would be a start.

It already does this :)

lucacasonato avatar Jul 05 '22 20:07 lucacasonato

Weird, it's not refreshing when I do changes.

zoeleu avatar Jul 05 '22 21:07 zoeleu

i'm doing some research on how preact handles hot reloading aka preferesh. i'm working on a fix now and will open a pr soon

notangelmario avatar Jul 05 '22 21:07 notangelmario

@matteoturini

Weird, it's not refreshing when I do changes.

If you are using FF - check #694

dector avatar Sep 08 '22 10:09 dector

(Just adding Hot Module Replacement - HMR - here to make it easy for people looking for that in Fresh. Now it will appear in GitHub issue search results.)

It already does this :)

@lucacasonato What do you mean by this? Does it maintain island state? Because if so, it is not currently working for me.

marcelocra avatar Jan 21 '23 02:01 marcelocra

i'm doing some research on how preact handles hot reloading aka preferesh. i'm working on a fix now and will open a pr soon

Do you have any news now?

jiawei397 avatar Sep 06 '23 11:09 jiawei397