Proposal to improve react-hmr (or add some important info) #2658
Replies: 2 comments 4 replies
-
@nickrobillard Hello. If you have somehow achieved HMR between host and remote, can you send a PR with the changes or create an example repo? |
Beta Was this translation helpful? Give feedback.
-
@burhanuday Sorry if I repeat some things but as I mentioned, I have found that the limitation of Webpack HMR with WMF only comes into the picture when a single app or host is bidirectional (ie: when the host or an app defines both "exposes" and "remotes"). To this point, keeping each app unidirectional is how NX achieves "HMR everywhere" when you create a WMF app using their setup commands. For HMR to "work everywhere", a single app - either the host or any of the sub-apps - cannot define both "exposes" and "remotes". It's that simple. :) And this is quite easy to accomplish, especially when using monorepos. I hope this makes sense. So for your react-hmr example, we could easily make |
Beta Was this translation helpful? Give feedback.
-
I would like to point out some findings related to the react-hmr example. There is a note that says only
liveReload
is supported in the host. While this is very true in this example, I have found the reason for this is because theremote1
app is bi-directional - meaning it has "exposes" and "remotes". If sub-apps only have "exposes", then HMR works everywhere - in the host and in all sub-apps. I have found that this kind of design can be fairly easy to accomplish. For example, as an alternative, one can share react and other npm dependencies via WMF "shared" conf, instead of sharing them vialibs
app "exposes". Thenremote1
app would not need to have "remotes". I think in many cases, especially when using mono-repos (consider a local custom lib that you want to re-use or share), it is quite feasible to avoid bi-directional sub-apps.I realize there are likely other reasons for sharing react and other deps via "exposes" that I am not thinking about, so please let me know if I am missing something. I would be happy to add a new example, or maybe modify
react-hmr
somehow - either by changing the way it works, or just by adding a note in the README. Any ideas?cc @burhanuday (I tagged you because it looks like you did most of the original work for react-hmr.)
Beta Was this translation helpful? Give feedback.
All reactions