Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotreloading of for/if/body, formatted strings, literals, component props, nested rsx #2258

Draft
wants to merge 44 commits into
base: main
Choose a base branch
from

Conversation

jkelleyrtp
Copy link
Member

@jkelleyrtp jkelleyrtp commented Apr 5, 2024

Hotreload the contents of for loops, if chains, component bodies, props, and any literals discovered in rsx! or under the #[component] macro.

This is breaking since we need to open a bunch of APIs making this no longer compatible with all the support crates in 0.5. Anyways, plan is to ship by end of april so it's fine that we keep this PR out here for a while.

Specifics/todos:

  • rewrite hotreload logic to allow collecting nested templates
  • Hotreload logic for ifmt
  • enable hotreload for textnodes
  • enable hotreload for component props
  • enable nested rsx! (focusing on props that are rsx)
  • A more stable way of assigning IDs to literals/ifmts
  • enable hotreload for generic literals (numbers, &str, etc)
  • final passthru for cleanliness

Demo:

hotreload_strings.mov
props_reloaded_too.mov

@jkelleyrtp jkelleyrtp changed the title Hotreloading of for loops Hotreloading of for loops Apr 6, 2024
@jkelleyrtp jkelleyrtp changed the title Hotreloading of for loops Hotreloading of for loops and if chains Apr 6, 2024
@jkelleyrtp jkelleyrtp changed the title Hotreloading of for loops and if chains Hotreloading of for/if/body Apr 6, 2024
@jkelleyrtp jkelleyrtp added this to the 0.6.0: Fullstack milestone Apr 6, 2024
@jkelleyrtp jkelleyrtp added the breaking This is a breaking change label Apr 9, 2024
@jkelleyrtp
Copy link
Member Author

jkelleyrtp commented Apr 9, 2024

This is done, actually, but since it requires breaking changes to core, I'm gonna keep it open until we're ready to start merging break PRs.

I have since expanded the scope of this PR to include anything that seems feasibly hotreloadable.

This includes literals anywhere we can find them in components and global signals.

So you could in theory hotreload the majority of basic stuff:

#[component]
fn comp() {
    // Hot reload the value of x
    let x = 0;

    // Hot reload the value of 0
    if x == 0 {
        return rsx! {
            div { "Hello" }
        }
    }

    rsx! {
        // Or hot reload the iterator start and end
        for i in 0..10 {
            div { "World" }
        }
    }
}

My ultimate goal with all this work is to slap a little UI designer frontend on top that we can plug into devtools. This would let you do storybooks and UI construction without ever recompiling. Drag-and-drop UI builder, app route reloading, integration with gen AI etc.

Eventually eventually, get cranelift JIT up and running and then hotreload components themselves.

With the eventual cranelift work, we basically have Dart's hotreload engine and then can probably start to strip out the manual template-based hotreloading. I don't want to get too crazy with hotreloading now since that work will probably make most of this work moot, but the timelines there are much longer.

@jkelleyrtp jkelleyrtp changed the title Hotreloading of for/if/body Hotreloading of for/if/body, formatted strings, literals, and component props Apr 9, 2024
@jkelleyrtp jkelleyrtp changed the title Hotreloading of for/if/body, formatted strings, literals, and component props Hotreloading of for/if/body, formatted strings, literals, component props, nested rsx Apr 10, 2024
@DogeDark
Copy link
Member

Will this include hot reloading for workspaces? Would massively speed up components in combo with a manganis issue fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This is a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants