mfe-webpack-demo
mfe-webpack-demo copied to clipboard
can we have loose coupling between A Host and A Remote?
thanks for the great idea of Module Federation as well as this demo!
I've run this demo and it is cool, however I have some feeling of tight coupling between those concerned web apps, for instance, app-01 public/index.html has to reference to these two dynamically generated remote-entry by WebPack based on options to ModuleFederationPlugin
defined in the other two Remotes respectively, which has added hard-coded dependency between app-01 and app-02, app-03. If any of app-02, app-03 makes change on filename in options to ModuleFederationPlugin
, MF in app-01 will break down unless app-01 is changed accordingly and deployed again.
<head>
<script src="http://localhost:3002/remoteEntry.js"></script>
<script src="http://localhost:3003/remoteEntry.js"></script>
</head>
I am wondering if ModuleFederationPlugin could dynamically insert these two concerned <script>
tags under <head>
in the template public/index.html during execution of Webpacking since HtmlWebpackPlugin comes after ModuleFederationPlugin
Alternatively how about to have a module discovery/registry as a service discovery does on backend, i.e Consul Each Remote will automatically register itself while starting up and A Host can fetch details of A Remote from the module discovery. In this way, A Host is a bit more loosely coupled with A Remote.
Hopefully my thoughts will make sense for you :)
@idavollen noticed the same thing, would be great if this happened automagically .. though I understand if that's not in scope