Skip to content

HMR plans? #3632

Closed
Closed

Description

@rixo

Hey guys!

I've been working on a HMR implementation this summer, building upon the one for v2 in svelte-loader (my clone, demo).

It supports svelte-native (demo) and works in Sapper + Webpack (where I've been using it the most).

I've also just added support for Nollup (plugin, demo). (Would love to do Sapper + Nollup.)

I haven't got much feedback yet, but I run a small test suite on it (with Puppeteer) and it seems to support about every feature of Svelte that I know (apart from transitions maybe, haven't really tested them yet). With Nollup, it has delicious error resilience!

What's the catch? It runs on emulated dev hooks that mess a little bit with the private $$ API. But a few more utilities like $capture_state / $inject_state could address this. There's not so much needed. In essence, it's just hooking on components' m and d, and transferring callbacks, bounds, $$slots and context.

So, what do you think? Are you interested in moving this forward?

Activity

  1. rixo commented on Oct 8, 2019

    @rixo
    ContributorAuthor

    I've published a fork of rollup-plugin-svelte with added HMR support : rollup-plugin-svelte-hot (and a degit-able app template to get started).

    Since it has access to the whole compiler's output (vars in particular), it can bypass current limitations with $capture_state to support preservation of components' local state (same was already done in my fork of svelte-loader). So for now it's my recommended solution for HMR with Rollup (well, Nollup).

    For the future: do you think it's preferable to have a bundler plugin dedicated only to HMR support for Svelte components, or a single plugin that does both compile + HMR like the one I've just posted -- and like official svelte-loader has done until now?

  2. shybyte commented on Oct 12, 2019

    @shybyte

    @rixo I just wanna say thank you! Your app template is exactly what I was looking for!

  3. rixo commented on Oct 25, 2019

    @rixo
    ContributorAuthor

    @shybyte Thanks! Nice to hear some feedback :)

    So, to answer my own question, I deprecated the HMR only plugin in favor of the integrated rollup-plugin-svelte-hot.

    The plugin now features HMR support not only with Nollup, but also with... Rollup itself! Still very very experimental this one though. It uses WIP rollup-plugin-hot.

    For people willing to beta test HMR, please give it a shot!

    See updated svelte-template-hot for details & example.

  4. hasparus commented on Oct 26, 2019

    @hasparus

    Thanks @rixo, I was looking for this issue :)

  5. rixo commented on Dec 20, 2019

    @rixo
    ContributorAuthor

    Update: I've put the links to all my HMR related projects (plugins, templates) in this readme. If you want to try HMR before official support, your best place to start is there.

    If you need help with getting started, you're welcome to drop me a line on Discord or issue (report HMR issues there, not here, since it is not officially supported currently).

  6. antony commented on Apr 9, 2020

    @antony
    Member

    Closing this as I think we should be documenting this in the community site for now, in order to grow the HMR userbase, with a view to HMR becoming an official part of Svelte (as per the roadmap). Thanks for your hard work @rixo !

  7. akaibukai commented on Apr 29, 2020

    @akaibukai

    Hello,
    I tried both your webpack and rollup HMR templates and it's amazing!

    TBH, one of the main selling point of Svelte being the "speed" concerns (small bundle so fast download, without framework runtime so faster execution, etc..) the HMR feature is a very important part of this feeling IMHO.

    I was immediately convinced by Svelte when I first heard of it (and ultimately when I saw Rich's famous Reactivity talk), but until now I didn't have the opportunity to work with..

    But I'm currently testing a small app with Svelte and somehow I find the whole process very slow..
    For example I'm used to work with many differently sized browser (up to 4), and I often work with tiny steps when working with the aesthetics..

    And in the current workflow it takes easily 1 to 2s for the browsers to load upon livereload..
    I know that's ultimately in production it would be a different story..

    But, you know, programmer happiness etc.. Those are really 2 annoying seconds..
    I was thinking to stick with Vue but your plugin and your work mitigate that feeling..

    Thank you!

  8. benmccann commented on May 11, 2020

    @benmccann
    Member

    @antony could you merge sveltejs/integrations#31 then?

  9. antony commented on May 11, 2020

    @antony
    Member

    @benmccann I'm more of a triager than a merger, but I'll try to get it in front of the right people :)

  10. AlbertMarashi commented on May 11, 2020

    @AlbertMarashi

    @antony shouldn't this become part of svelte's main plugins? HMR is a pretty important feature for devs to improve productivity

  11. antony commented on May 11, 2020

    @antony
    Member

    @DominusVilicus it's not as simple as that. I can assure you that it is work in progress, however.

  12. ZaDarkSide commented on Sep 25, 2020

    @ZaDarkSide

    1 year has passed since this issue was first posted, how are we coming along with integrating this into main svelte releases?

  13. antony commented on Sep 25, 2020

    @antony
    Member

    @ZaDarkSide you can read the RFCs, study rixo's work, and engage with the community to keep track of the HMR progress.

  14. ZaDarkSide commented on Sep 27, 2020

    @ZaDarkSide

    Well for me this feature seams to be stuck in development hell, people really need it to be productive...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions