angular-architects / module-federation-plugin

MIT License
683 stars 184 forks source link

Native Federation: Shell doesn't load the html of an angular element from microFE. #507

Open dessyg opened 2 months ago

dessyg commented 2 months ago

Hello, I have two test repos with Angular 17 and Native Federation. The micro fe contains a web component, implemented with https://www.npmjs.com/package/@angular/elements. https://github.com/dessyg/mfe1 https://github.com/dessyg/microfe-shell The problem is the shell is that I don't recieve any errors but the web component is loaded with the tags, and no inner html inside it. image

Thanks!

muenchto commented 1 month ago

Hi @dessyg you probably figured it out already, but anyhow: I think the problem might be that you create and define the web-component in the app.component.ts of the mfe1 in ngOnInit(). I dont think this lifecycle hook is guaranteed to be called when you later call this remote standalone component. Hence, the web-component is not created or registered when you use it.

A solution might be to create and define the web-compo in the constructor of app.component.ts.