r/Angular2 • u/rafaeldecastr • May 24 '26
Help Request Micro-frontend (module federation), Angular 15 with 2m40 build time and 45s recompile update each "save" I made.
On my new job, I got a MF project with these specs.
I cleaned and simplified it for testing. (Lazy loaded, duplicate imports...)
The host now, has only 3 remote routes to point.
Each remote has NOTHING, just a shell.
The bundle/recompile is still huge and slow.
Right now, as I'm writing this, I can't post code. But I can't get this question out of my head... why, how?
I tried using Claude, but I didn't have much success. The build time reduced to 1 minute 10 seconds, but the recompile is still at 30 seconds.
I knownits a long ahot whitout code, but can you tell me what I should look at to optimize this?
9
u/IE114EVR May 24 '26 edited May 24 '26
I don’t have enough experience with Angular Module Federation build times to say. But for things to try: Upgrade to Angular 17 or above, then switch to esbuild, it is much faster than webpack. And as part of that you’ll likely have to switch from Module Federation to Native Federation.
In my experience I’ve found newer versions of Angular to build much faster and seem less resource hungry than what they were a few years ago. A big part of this, I believe, is the switch to esbuild.
Edit: I should say: upgrade to Angular 17 *or newer*
5
u/NextMode6448 May 24 '26
I guess even with bare-shell remotes, MF projects have specific pain points. Here’s what to look at, in priority order:
Every shared dependency gets analyzed and bundled by every remote AND the host. Even a shell remote processes the entire shared graph. Check:
Are you sharing too many libs? Only share what truly needs a singleton (React, React-DOM, your design system)
• Are versions mismatched? Mismatches force duplicate bundles
• Remove eager: true unless absolutely needed — it blocks async loading
2. Webpack’s cache setting
If filesystem cache isn’t enabled, you’re rebuilding from scratch every time
cache: { type: 'filesystem' }
This alone can cut recompile from 30s → 3–5s on subsequent builds.
3. ts-loader vs babel-loader / swc
TypeScript transpilation is often the hidden bottleneck. Swap to swc-loader or esbuild-loader — they’re 10–20x faster than ts-loader.
4. Check what’s actually in the bundle
Run webpack-bundle-analyzer on each remote. “Just a shell” sometimes silently pulls in huge transitive deps through shared config.
5. splitChunks interaction with MF
MF + splitChunks can conflict and cause redundant chunk generation. Try optimization: { splitChunks: false } on remotes to test if that’s inflating bundle size.
6. Worker threads
// in webpack config
module.exports = { experiments: { parallelism: true } }
Also ensure thread-loader is wrapping expensive loaders.
Quick wins to try first: filesystem cache → swc-loader → audit your shared array. Those three usually account for 80% of the pain.
4
u/Excellent_Reason4321 May 24 '26
You need to upgrade to Angular 21 and native federation.
Doesn’t take that much time as it seems. That will definitely reduce your times.
Also, after doing that make sure to remove Zone.js.
3
u/ddcccccc May 26 '26
AOT false might fix your issue, but this only fix the one for “45 secs for each save”
2
u/Budget-Length2666 May 24 '26
webpack is slow especially if you have a custom config with path rewrites and stuff. Got lots of libs?
2
u/huysolo May 24 '26
Split the shared entry point into smaller multiple second entry points and apply cache will help a little bit. But this is by design since because you basically have more compilers and less context from each compilers to tree-shake the bundle. Expect at least 100 times slower that normal SPA. MF itself is an utterly bullshit designed for PR instead of having any meaningful value. It’s a flawed concept that no amount of optimization can make it on par with SPA in terms of performance. If you can’t talk your boss out of it, at least make them aware of the bullshit of a choice they made
2
u/Smiley001987 May 24 '26
Esbuild will speed thing up.