shellscape/jsx-email

Vite HMR not working

Closed this issue · 2 comments

  • Component or Package Name: jsx-email
  • Component or Package Version: 1.12.0
  • Operating System (or Browser): Edge + Firefox
  • Node Version: 22
  • Link to reproduction (⚠️ read below): Issue present in the base StackBlitz https://stackblitz.com/fork/jsx-email-repro

Expected Behavior

Vite should HMR update where possible

Actual Behavior

Vite always issues a jarring page reload
image

Additional Information

Because the preview uses the render method (https://jsx.email/docs/core/render), it'll always repopulate the iframe in which the result is displayed. That in turn causes Vite to perform a refresh. (as an aside, I've tested the preview on a number of machines, both physical and virtual, and wouldn't really classify the reload as "jarring.") And for what it's worth, using render provides a 1:1 between actual output and what's in the preview - something alternatives don't guarantee. Accuracy there is more important than a minor inconvenience in the preview.

Last we looked into it, the iframe content update and refresh was a limitation of Vite. If that's changed or there's a workaround, or you're passionate about improving the experience, we'd very much welcome a contribution.

Closing for now as this is working as it should within current Vite limitations. If anyone has more info or a fix that's been overlooked, please ping and we'll reopen.