Tip #39[dynamic Module Federation]

Wojciech Trawiński
JavaScript everyday
1 min readSep 21, 2021

Module Federation is undoubtedly a game changer when it comes to micro frontend architecture. Manfred Steyer wrote a great series of articles covering the topic and developed the brilliant package which allows you to easily make use of the technique in question. However, dynamic Module Federation requires more attention than the static version. Recently, Netanel Basal wrote a blog post in which he showed how to conditionally lazy load a given version of an Angular module based on a feature flag. It turns out that you can make use of the proposed solution for dynamic Module Federation as well. Assume that under a given path you want to lazy load an Angular module owned by one of the two micro frontends. The information on which version to load is provided by an API call.

You can accomplish the goal in the following steps:

  • expose a Promise object containing information on the micro frontend’s remoteEntry file location:
  • configure routes with the aid of the Dependency Injection

If you like the tip, please give me some applause 👏

--

--