Basically, when your host starts up it will register all the versions it has into the shared scope. Every time you load a remoteEntry.js
from a remote, the remote will also add their versions to this same scope, but only if that exact version does not exist already.
So for example, if the host shares module-a
at version 1.0.0
. When the host loads it will put module-a:1.0.0
into the shared context. If the remote also shares module-a:1.0.0
it will not put it in the context, because it is already there. If the host was sharing module-a:1.0.1
then the context will now have two versions: the module-a:1.0.0
from the host and module-a:1.0.1
from the remote.
At this point we are just talking about registration... we haven't chosen which version to use, but we are registering all unique versions shared from all remotes and hosts. And basically the first to register it wins.
Now when the version resolution algorithm runs... it will figure out based on all the requirements which version to use. If the algorithm chooses version 1.0.0
of the module, then it will go to the scope and use whatever module is assigned to version 1.0.0
which in this case would be the one from the host, because the host ran first and was able to register it first. If the algorithm picked 1.0.1
it would use the module from the remote. If multiple remotes provided 1.0.1
then it will use the one from the remote that first registered it into the scope.