跪拜 Guibai
← All articles
Frontend

Three Years of Micro-Frontends Ended in a Monolith: Load Time Down 800ms, Dev Efficiency Up 2x

By 涛涛ing ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Micro-frontend architecture promises team autonomy but brings real overhead: slower first paint, fragile cross-app state, and a steep learning curve. When an organization merges teams, the technical cost quickly overwhelms the original benefit, as shown by the 800ms load regression and two-day onboarding for new developers.

Summary

Three business lines ran Vue2, Vue3, and React separately and needed a single admin console. Micro-frontends via qiankun appeared to be the compromise that kept each team on its own stack. In practice, the architecture produced a stream of style overrides, cross-app communication built on EventBus and globals, and multiple copies of libraries like lodash and runtimes. A Vue upgrade broke one sub-app despite shared dependency configuration.

A reorganization merged the three frontend teams into one, removing the need for team autonomy. The team then extracted all business code into a single Vue 3 + Vite repository, switched state to Pinia, resolved styles with scoped CSS, and built an internal UI package. First-screen time fell by 800ms and development efficiency doubled. The advice for smaller teams: use npm packages or iframe first, and only adopt micro-frontends when hundreds of developers need concurrent work.

Takeaways
— qiankun's sandbox does not prevent global CSS from leaking into the main app; a `.modal { z-index: 100 !important; }` in a sub-app broke a main-app modal.
— `strictStyleIsolation` changes DOM structure and can break existing sub-app components.
— Sub-apps needed to run both embedded and standalone, forcing four different auth adapter implementations.
— Cross-app data sync was implemented with EventBus and global variables, resembling poor distributed communication.
— Each sub-app bundled its own lodash and Vue/React runtime, so users downloaded three or four dependency sets.
— A Vue upgrade in the main app caused a sub-app to white-screen due to dependency incompatibility.
— After merging into one Vue3 + Vite monolith with Pinia and scoped CSS, first-screen time fell 800ms and dev efficiency doubled.
Conclusions

The decision to revert was triggered by organizational consolidation, not a technical failure; micro-frontends exist to solve organizational friction, so when that friction disappears, their cost becomes unacceptable.

The experience shows that micro-frontend setup complexity multiplies in edge cases like standalone versus embedded execution, which many teams overlook when choosing the pattern.

Preferring npm packages and iframe for smaller teams aligns with the known trade-off: micro-frontends only pay off at massive scale.

Concepts & terms
qiankun
A popular Chinese micro-frontend framework that lets multiple separately built apps coexist in a single page, providing sandboxing, lifecycle management, and inter-app communication.
strictStyleIsolation
A qiankun option that uses Shadow DOM to fully isolate sub-app styles, but can alter DOM structure and break components that rely on the normal DOM hierarchy.
EventBus
A publish-subscribe mechanism for cross-app or cross-component communication; when used heavily, it leads to hard-to-debug global event flows.
From the discussion

The reversal from micro-frontends back to a monolith draws support, with the 800ms first-screen improvement seen as proof the architecture was at fault. Version drift and duplicate dependencies are cited as the real costs that make micro-frontends uneconomical. A second view adds that micro-frontends are often chosen for their own sake rather than for genuine need.

— The 800ms first-screen improvement validates that the three-year micro-frontend architecture was the bottleneck; reverting to a monolith was a bold and justified move.
— Version drift and duplicate dependencies made micro-frontends a poor trade-off economically.
— Micro-frontends are frequently adopted reflexively, without a real justification for the added complexity.
Featured comments
组合搭配函数

After running it for three years and then splitting it back, that decision takes some guts. The first screen getting faster says it all. With version drift and duplicate dependencies, micro-frontends really don't add up cost-wise.

不服老的小黑哥

That's true. A lot of the time it's just micro-frontends for the sake of micro-frontends.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗