feat(@angular-devkit/build-angular): favor ESM over FESM bundles#13650
feat(@angular-devkit/build-angular): favor ESM over FESM bundles#13650filipesilva wants to merge 1 commit into
Conversation
|
using
|
|
@aitboudad can you give me more details about how you tested that so I can take a look? There were some bugs with Build Optimizer and ESM bundles fixed in #13474 that are important for bundle size. I'm mostly testing with |
|
@filipesilva just test any app which use a lazyload route, you may check this one https://github.com/aitboudad/cli-esm-build for example. |
|
@aitboudad thank you, I can see it in that repro. A normal If I go into The main bundle goes from 252kb to 357kb. If I remove the lazy route in |
|
each approach has some side effects, the real fix I think should be landed either in Webpack or Terser. |
77215ca to
27a3c4b
Compare
|
I looked at this a bit today and took a bunch of samples at https://github.com/filipesilva/cli-esm-build. I think what's happening is that FESM "forces" the single big module to stay together even while other modules are concatenated by webpack (via https://webpack.js.org/plugins/module-concatenation-plugin/). The bigger module makes it easier for Terser to optimize. The lazy route forces a number of modules to out of concatenated modules. Without FESM, there are many smaller modules that aren't guaranteed to stick together, so Terser can do less. I need to look further into this. |
|
Relates to #10754 |
|
We've been working on this general problem and we don't think we can switch over to ESM while module concatenation in webpack has so many bailout scenarios, especially around lazy chunks. I'll close this PR for now. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Fix #13635
Blocked by angular/angular#26743, angular/angular#28656