feat: add remoteHmrStrategy option to control cross-federation HMR#654
Merged
gioboa merged 6 commits intomodule-federation:mainfrom May 3, 2026
Merged
Conversation
gioboa
reviewed
Apr 26, 2026
7a86c48 to
64b6ca2
Compare
Auto-detect frameworks with native HMR support (React, Vue, Svelte, Solid) from the Vite plugin pipeline. When detected, suppress the broadcast/relay mechanism and let Vite's native HMR handle updates. Detection checks plugin names: vite:react-refresh, vite:react-swc:refresh, vite:vue, vite-plugin-svelte, solid. The explicit remoteHmrStrategy config option is kept as an override for edge cases. Default behavior for setups without a recognized framework plugin is unchanged (full-reload).
64b6ca2 to
6a4d369
Compare
Only React has cross-federation HMR plumbing (the shared /@react-refresh proxy from module-federation#653). Vue, Svelte, and Solid have native HMR but no equivalent cross-federation mechanism — suppressing broadcast/relay for them would leave users with no HMR at all. Trimmed tests accordingly.
Framework-agnostic name so adding Vue/Svelte/Solid later is just appending to the supportedPlugins list.
commit: |
Merge remoteHmrStrategy into remoteHmr per review feedback. true enables auto-detected native HMR, 'full-reload' forces broadcast/relay.
Contributor
Author
|
Good idea, have changed it accordingly. |
gioboa
reviewed
Apr 29, 2026
Contributor
Author
Collaborator
|
I'm testing different versions on that repo. I run my test with the correct one. |
gioboa
reviewed
Apr 30, 2026
Collaborator
gioboa
left a comment
There was a problem hiding this comment.
Nice call btw. I am wondering if we can patch that plug-in somehow 🤔
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Close #592
Summary
Addresses #592 — auto-detects React and suppresses the broadcast/relay mechanism so Vite's native HMR (React Fast Refresh) handles cross-federation updates instead of full page reloads.
Problem
When
dev.remoteHmris enabled,pluginDevRemoteHmrunconditionally relays remote file changes as{ type: 'full-reload' }to the host browser. With React Fast Refresh (and the shared/@react-refreshproxy from #653), the component updates fine via native HMR — then the relay immediately nukes it with a full page reload.Solution
Auto-detect React from the Vite plugin pipeline. When
vite:react-refreshorvite:react-swc:refreshis present, suppress the broadcast (remote side) and relay (host side) so React Fast Refresh handles it.Only React is supported for now — it's the only framework with cross-federation HMR plumbing (the shared
/@react-refreshproxy from #653). Vue, Svelte, Solid have native HMR but no equivalent shared-runtime proxy yet, so they stay on full-reload. Easy to extend once the plumbing exists.An explicit
dev.remoteHmrStrategyescape hatch is available:'full-reload': Force broadcast/relay even with React'native': Force native HMR even without a detected frameworkundefined(default): Auto-detectBackwards compatibility
Testing