DioxusLabs / dioxus

Fullstack app framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
21.44k stars 826 forks source link

Hotreload doesn't pierce through macro contents #2438

Closed ThomasCartier closed 5 months ago

ThomasCartier commented 5 months ago

[Linux, Debian testing]

Hi, When launching my fullstack app with dx serve --hot-reload --platform fullstack or any variant of this,

I get the console log telling me

Dioxus @ v0.5.0-alpha.2 [17:24:29]

> Hot Reload Mode: RSX
> Watching: [ src, assets, assets ]
> Custom index.html: None
> Serve index.html on 404: True

> Build Features: [ server ]
> Build Profile: Debug
> Build took: 19112 millis

Listening on 127.0.0.1:8080 spinning up hot reloading hot reloading ready 🔥 Hot Reload WebSocket connected 🔮 Finding updates since last compile... finished 😳 Hot Reload WebSocket disconnected And the hot reload doesn't work.

I have to manually relaunch the dx command at each change in the rsx block.

It only occurs when I change the text of a p block for example. As if only changing text from a block was not caught.

A change from

p { "Hello world"} to p { "Hello world 2"}

won't trigger anything, but a change from

p { class: "mb-3 text-center",
     {translate!(i18, "messages.hello_world")}
}

to

p { class: "mb-3 text-center",
     {translate!(i18, "messages.hello_world2")}
}

will.

Is it a normal behavior?

Thanks

luveti commented 5 months ago

Hello, I recommend upgrading to the latest stable version of Dioxus, version 0.5.1. I've personally been using the git version, as fixes are constantly being pushed.

My guess is that the change that triggers the reload is actually a full rebuild, and not an instant template update.

I also recommend keeping dioxus-cli up to date by occasionally running cargo install dioxus-cli.

It may not hurt to try a dx clean as well to see if that fixes things.

ThomasCartier commented 5 months ago

@luveti thanks, I just uploaded to 0.5.4, but the issue remains: any change that is not textual is taken into account for the recompiling, but textual changes are not caught. :-(

jkelleyrtp commented 5 months ago

The issue here is you're modifying code in a macro which we can't figure out if should be hotreloaded or not.

This PR https://github.com/DioxusLabs/dioxus/pull/2258 is adding an entirely new, more powerful form of hotreloading, but still wouldn't work with the contents of macros. We do have longer term plans to ship actual, legitimate horeloading of Rust code but that's not available in any form, yet.

With #2258 you could use an I18 { src: "something.2" } component which would receive hotreloading treatment via its props, but nothing yet is plumbed for i18n in the way you're trying to use today.

ThomasCartier commented 5 months ago

Nice! I will hold my breath and keep enjoying Dioxus as it is right now

ThomasCartier commented 5 months ago

Nice! I will hold my breath and keep enjoying Dioxus as it is right now