zamotany / module-federation-repack

38 stars 12 forks source link

Should fast refresh hmr work? #6

Open tom-sherman opened 2 years ago

tom-sherman commented 2 years ago

I see it's disabled right now, enabling it works for the host app but not the remotes.

Is this expected? Is there a way to get it to work?

zamotany commented 2 years ago

Yes this is expected. Based on my knowledge it's not possible without some magic trickery inside Re.Pack and generated code. To me the cost and shakiness of such support is not really worth it and I would suggest to develop apps/containers in standalone more for HMR.

tom-sherman commented 2 years ago

I think there's some prior art on the web: https://github.com/module-federation/module-federation-examples/blob/master/react-hmr/README.md

Is there anything that can be taken and ported to native? Would this model work? Or is there some drawback in repack that prevents it?

zamotany commented 2 years ago

Looks like the example from the link is missing some files/implementation.

Aside from that, Re.Pack has custom Webpack HMR client. The default one doesn't work for React Native. The main problem with HMR in MF is that we would need to be able to differentiate if the update should do HMR in which container. Right now, I'm not sure where would the potential blocker be. It might be Webpack, Re.Pack or @pmmmwh/react-refresh-webpack-plugin problem or a combination of them.