How to build a Vue-based micro-frontends infrastructure
· 1170
Wajdi Alkayal Wajdi Alkayal

How to build a Vue-based micro-frontends infrastructure

Micro-frontends with iframes have cons


  1. Development cycle: If you don’t have a well-written infrastructure, you will have some issues with things like the HMR, running local environments, running a QA environment, and the CI process.
  2. Shared state: Managing state when you have iframe needs some infrastructure, to know if a certain data is needed across iframes, or between child-frame and a parent-host.
  3. Routing: Sharing routes and permissions between the host application and its children, or among the children is difficult.
  4. Load time: When not done right, the loading time of iframes can be quite slow, and there are probably duplicate libraries across iframes.
  5. Confidence: Running an operation from one frame to the host or another frame needs to have some level of abstraction, and you don’t always have the “confidence” that the operation you wanted to run is running or will run in another context.

The advantages of micro-frontends with iframes

  1. Once your infra is complete, your development cycle can be amazing!
    Working with HMR, different versions of the same framework / another framework, managing stupid-simple state for a micro-app instead of a bloated gigantic state of a huge app, you can have dynamic environments and replace small pieces of your app without deploying everything, and test several pieces from different versions together.
  2. Once your infra is complete, routing isn’t a problem at all.
    You can merge routes from different applications, dynamically, and it can work great.
  3. With CDN caching, shared resources, and memory cleanup when an iframe dies, loading times can improve.
  4. Security-first: Iframes force you to build more secure applications since some data needs domain validation and sharing information about the user may require them to run under the same domain.
  5. Complete isolation: The isolation of iframes makes it easier to make sure that the CSS of one app will not affect other apps, and it makes it easier to manage isolated small scopes of state and translation files (i18n).
  6. Separated processes: The browser creates a completely separate process for iframe scope, so you can feel safer if an internal stack overflow of a micro-application will not affect the behavior of the host-application, and vice-versa.

The missing piece of micro-frontends infrastructure

What is @microf/* ?

The assumptions of the plugins

Host application initial load:

The host is routed to an internal route of a micro-app:

An internal route change happens at the child application:

Host routed to an existing micro-app route:


Related Posts
Graphic design
09 June
The Power of Email Marketing
03 June
Photography
01 June

WMK Tech Copyright © 2024. All rights reserved