module-federation / module-federation-examples

Implementation examples of module federation , by the creators of module federation
https://module-federation.io/
MIT License
5.44k stars 1.71k forks source link

angular12-microfrontends - shared deps packaged twice ? #1227

Closed raphael22 closed 2 years ago

raphael22 commented 2 years ago

Hello there. I notice that webpack bundle shared dependencies into main.js but also in polyfills.js : Resulting a 800kb build. image

The way to go would be to set eager to false then ? Down the build half size. image

But we get the eager error image

I'm struggle a bit to find the good configuration for having both world, a shell which consume and expose singleton deps.

nohanna commented 2 years ago

I have the same issue with the polyfills, a simple app will result in a large bundle because of this. The problem is, if you don't have your shared deps added eagerly, you will have to change your app bootstrap. I didn't find a solution yet, but I guess that in Angular, we have to set eager to true for now.

But why is webpack adding everything in main.js and polyfills?

raphael22 commented 2 years ago

@nohanna Good news ! I finally find a solution to make it work with eager: false.

As indicate here I switch from static bootstrap import: import "./bootstrap"; to dynamic one: import('./bootstrap');

Making the final build working with only one copy of deps instead of two. Still struggling to make it work without eager or to bundle some deps to avoid having one endpoint per deps thought.