'Angular module federation - share remote component

I am using angular 11 with webpack 5 module federation. I have plans to expose component from remotes.

exposes: {
 "component": ".//src/app/app.component.ts"
}

while importing import {component} from "mfe@component"

I am getting build error "cannot find mmodule "mfe1@component"

how to consume remotely exposed component at design time



Solution 1:[1]

The path you provided is not correct. ./ is missing in the beginning of component name. change it to as shown below.

exposes: {
      "./component": "./src/app/app.component.ts"
 }

Solution 2:[2]

Did you add the remote configuration in webpack.config.js in shell app ?

 remotes: {
     "mfe1": "http://localhost:5000/remoteEntry.js",
 },

Solution 3:[3]

I think it will work only for standalone components which has support from angular 14 onwards, on previous versions you need to expose the module

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wilson Reddy Gajarla
Solution 2 Karthikeyan
Solution 3 Prats