I have two Angular 14 projects. I'm using the @angular-architects/module-federation
package to create a host and a remote. The issue that I am encountering is that I need to share a library as a singleton, but that library is aliased in the package.json
file. It is not a local library, but rather is a library hosted in two different registries.
For instance, I have something like this in the package.json
files in both projects:
"@myRegistry-1-namespace/ui": "npm:@myRegistry-2-namespace/ui@3.0.0",
And when trying to share it, I have something like this in my webpack.config.js
:
'@myRegistry-1-namespace/ui': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
When I attempt to run the host, I get the following error:
Unsatisfied version 3.0.0 from myproject-host of shared singleton module @myRegistry-1-namespace/ui (required =npm:@myRegistry-2-namespace/ui@3.0.0)
Does anyone know how to get it to recognize the fact that I have the correct versions installed in both projects?
If I set requiredVersion
to false
, the host will load, but the project breaks at runtime (I assume due to the library needing to be a singleton). If I remove the alias in the package.json
files, it also works. However, I need the alias (due to our projects ability to only connect to one of the registries in environments other than my local machine).