<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aukevanoost on Medium]]></title>
        <description><![CDATA[Stories by Aukevanoost on Medium]]></description>
        <link>https://medium.com/@auke997?source=rss-e4d5267b0297------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UZmyW3sPT4GEifDXl0KJFA.png</url>
            <title>Stories by Aukevanoost on Medium</title>
            <link>https://medium.com/@auke997?source=rss-e4d5267b0297------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 23:28:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@auke997/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Tweaking native-federation | Part II: Sharing externals]]></title>
            <link>https://medium.com/@auke997/tweaking-native-federation-part-ii-sharing-externals-a4e1d3711230?source=rss-e4d5267b0297------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4e1d3711230</guid>
            <category><![CDATA[native-federation]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <dc:creator><![CDATA[Aukevanoost]]></dc:creator>
            <pubDate>Tue, 06 Jan 2026 12:27:42 GMT</pubDate>
            <atom:updated>2026-03-01T10:56:51.106Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This article series is meant to provide a peek under the hood of native federation, as well as some tips and tricks on how you can optimize your native-federation architecture setup. This part will show how to optimally share externals.</em></p><p>Read the other parts here:</p><ul><li>Part 1: <a href="https://medium.com/@auke997/tweaking-native-federation-e2d514366d08">https://medium.com/@auke997/tweaking-native-federation-e2d514366d08</a></li></ul><p><strong><em>Note: </em></strong><em>Currently, the most supported builder is the Angular one so I will use that one for the examples. We are planning on supporting more builders in the future.</em></p><p>One last mention, this article series contains an up-to-date explanation of the native-federation builder (&gt;21.0.0, and &gt;20.3.0). All core concepts of native-federation can be found in the enterprise-angular e-book from <a href="https://medium.com/u/a63cf309191b">Manfred Steyer</a>.</p><p><a href="https://www.angulararchitects.io/en/ebooks/micro-frontends-and-moduliths-with-angular/">https://www.angulararchitects.io/en/ebooks/micro-frontends-and-moduliths-with-angular/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*I-gji6-JTypHYpkn" /><figcaption>Photo by <a href="https://unsplash.com/@silverkblack?utm_source=medium&amp;utm_medium=referral">Vitaly Gariev</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>While the previous part explained the basic components of native federation, this part will dive deeper in the features released in ‘v21.0.4’. These features allows for sharing externals to the max.. but what does that mean?</p><p>To follow along you can setup an Angular remote with native federation installed. Alternatively, I prepared a repository here:</p><p><a href="https://github.com/Aukevanoost/native-federation-examples-ng/tree/tweaking-nf/dep-sharing">GitHub - Aukevanoost/native-federation-examples-ng at tweaking-nf/dep-sharing</a></p><h3>The basics</h3><p>Micro frontends can share externals in native federation to prevent code duplication. To really see the benefit of this, we’ll start with a micro frontend that is not sharing any externals:</p><pre>// projects/mfe1/federation.config.js<br><br>const { withNativeFederation, share } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br>  name: &#39;mfe1&#39;,<br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br>  shared: {<br>    // no sharing<br>  },<br>  skip: []<br>});</pre><p>When the ng build mfe1 command runs, the dist/mfe1/browser folder will be populated with the micro frontend and a manifest file. (the remoteEntry.json ) This file is important since it shows what’s being shared by the micro frontend and currently it’s.. nothing.</p><pre>// dist/mfe1/browser/remoteEntry.json<br>{<br>  &quot;name&quot;: &quot;mfe1&quot;,<br>  &quot;shared&quot;: [],<br>  &quot;exposes&quot;: [<br>    {<br>      &quot;key&quot;: &quot;./Component&quot;,<br>      &quot;outFileName&quot;: &quot;Component-5EECHNWY.js&quot;<br>    }<br>  ]<br>}</pre><p>This is good since, the ESbuild and angular plugin will compress this file to the smallest bundle possible. All unused code is removed and only the essentials are included into this single bundle. However, when we want to create another micro frontend, native federation will bundle Angular again in that second micro frontend leading to duplicate code… For two micro frontends this might not be a big deal but how about five, six or twenty?</p><p>Secondly, this also means that Angular (state) is also not being shared between the micro frontends which includes the injection context. (I generally advise against sharing state though) Now, how do we solve this? Let’s try to share the Angular core library:</p><pre>// projects/mfe1/federation.config.js<br><br>const { withNativeFederation, share } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br>  name: &#39;mfe1&#39;,<br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br>  shared: {<br>    ...share({<br>      &quot;@angular/core&quot;: { <br>        singleton: true, <br>        strictVersion: true, <br>        requiredVersion: &#39;auto&#39; <br>      }<br>    })<br>  },<br>  skip: []<br>});</pre><p>This will result in Angular being extracted from the micro frontend and bundled into a separate file. After the build ran again, the remoteEntry is significantly different:</p><pre>// dist/mfe1/browser/remoteEntry.json<br>{<br>  &quot;name&quot;: &quot;mfe1&quot;,<br>  &quot;shared&quot;: [<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core.AbRbEARs0K.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core/event-dispatch-contract.min.js&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core_event_dispatch_contract_min_js.0fe5hMBbIz.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core/primitives/di&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core_primitives_di.NxFFDSa_NF.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core/primitives/event-dispatch&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core_primitives_event_dispatch.8BTvFGqMkI.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core/primitives/signals&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core_primitives_signals.TdNLEFoKMG.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core/rxjs-interop&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core_rxjs_interop.V01fBJixWh.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    {<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: false,<br>      &quot;requiredVersion&quot;: &quot;0.0.0&quot;,<br>      &quot;packageName&quot;: &quot;@nf-internal/chunk-PVTTTEYM&quot;,<br>      &quot;outFileName&quot;: &quot;chunk-PVTTTEYM.js&quot;<br>    },<br>    // Other chunks omitted for clarity<br>  ],<br>  &quot;exposes&quot;: [<br>    {<br>      &quot;key&quot;: &quot;./Component&quot;,<br>      &quot;outFileName&quot;: &quot;Component-5V6B6VHU.js&quot;<br>    }<br>  ]<br>}</pre><p>In the remoteEntry file, we’ll see some entry points and some internal chunks. By default “includeSecondaries” is set to true, which leads to the “share” helper investigating the angular/core library and exporting the secondary entrypoints (like “@angular/core/primitives/di”).</p><p>All discovered shared code between these “externals” is put into separately shared chunks by ESbuild to improve performance. Now how does Native federation know which secondary entrypoints to take? Usually by scanning the package.json in the node_modules dependency.</p><p>Now we can disable the secondaries like this:</p><pre>const { withNativeFederation, share } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br>  name: &#39;mfe1&#39;,<br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br>  shared: {<br>    ...share({<br>      &quot;@angular/core&quot;: { <br>        singleton: true, <br>        strictVersion: true, <br>        requiredVersion: &#39;auto&#39;, <br>        includeSecondaries: false <br>      }<br>    })<br>  },<br>skip: []<br>});</pre><p>Which will result into something like this:</p><pre>{<br>  &quot;name&quot;: &quot;mfe1&quot;,<br>  &quot;shared&quot;: [<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core.1iUQTNxTxD.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;auto&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    }<br>  ],<br>  &quot;exposes&quot;: [<br>    {<br>      &quot;key&quot;: &quot;./Component&quot;,<br>      &quot;outFileName&quot;: &quot;Component-5V6B6VHU.js&quot;<br>    }<br>  ]<br>}</pre><p>Now, but when you run this code using ng serve mfe1 , it crashes?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tFx4XoU8iAM0M27G_nx-eQ.png" /><figcaption>A crash in the browser</figcaption></figure><p>This is actually a flaw/feature in ESbuild. As explained in the previous part, the micro frontend is bundled separately from the externals. Therefore, when ESbuild bundles the micro frontend, it treats “@angular/core” as an external, and for ESbuild that means “@angular/core/*” so also “@angular/core/primitives/signals” which the browser now tries to import at runtime. However, the importmap only works with exact matches so it wont look for the code in “@angular/core” resulting in a crash.</p><p><strong><em>note:</em></strong><em> This error only occurs if secondary entrypoints are used or imported that are not being shared like in the example above.</em></p><h3>Wildcard exports</h3><p>Some packages use wildcard exports, RxJs is a fine example for this as you can see in their exported package.json (look for the ‘internal’ export):</p><pre>{<br>  &quot;name&quot;: &quot;rxjs&quot;,<br>  &quot;version&quot;: &quot;7.8.2&quot;,<br>  &quot;description&quot;: &quot;Reactive Extensions for modern JavaScript&quot;,<br>  &quot;main&quot;: &quot;./dist/cjs/index.js&quot;,<br>  &quot;module&quot;: &quot;./dist/esm5/index.js&quot;,<br>  &quot;es2015&quot;: &quot;./dist/esm/index.js&quot;,<br>  &quot;types&quot;: &quot;index.d.ts&quot;,<br>  &quot;typesVersions&quot;: {<br>    &quot;&gt;=4.2&quot;: {<br>      &quot;*&quot;: [<br>        &quot;dist/types/*&quot;<br>      ]<br>    }<br>  },<br>  &quot;sideEffects&quot;: false,<br>  &quot;exports&quot;: {<br>    &quot;.&quot;: {<br>      &quot;types&quot;: &quot;./dist/types/index.d.ts&quot;,<br>      &quot;node&quot;: &quot;./dist/cjs/index.js&quot;,<br>      &quot;require&quot;: &quot;./dist/cjs/index.js&quot;,<br>      &quot;es2015&quot;: &quot;./dist/esm/index.js&quot;,<br>      &quot;default&quot;: &quot;./dist/esm5/index.js&quot;<br>    },<br>    &quot;./ajax&quot;: {<br>      &quot;types&quot;: &quot;./dist/types/ajax/index.d.ts&quot;,<br>      &quot;node&quot;: &quot;./dist/cjs/ajax/index.js&quot;,<br>      &quot;require&quot;: &quot;./dist/cjs/ajax/index.js&quot;,<br>      &quot;es2015&quot;: &quot;./dist/esm/ajax/index.js&quot;,<br>      &quot;default&quot;: &quot;./dist/esm5/ajax/index.js&quot;<br>    },<br>    &quot;./fetch&quot;: {<br>      &quot;types&quot;: &quot;./dist/types/fetch/index.d.ts&quot;,<br>      &quot;node&quot;: &quot;./dist/cjs/fetch/index.js&quot;,<br>      &quot;require&quot;: &quot;./dist/cjs/fetch/index.js&quot;,<br>      &quot;es2015&quot;: &quot;./dist/esm/fetch/index.js&quot;,<br>      &quot;default&quot;: &quot;./dist/esm5/fetch/index.js&quot;<br>    },<br>    &quot;./operators&quot;: {<br>      &quot;types&quot;: &quot;./dist/types/operators/index.d.ts&quot;,<br>      &quot;node&quot;: &quot;./dist/cjs/operators/index.js&quot;,<br>      &quot;require&quot;: &quot;./dist/cjs/operators/index.js&quot;,<br>      &quot;es2015&quot;: &quot;./dist/esm/operators/index.js&quot;,<br>      &quot;default&quot;: &quot;./dist/esm5/operators/index.js&quot;<br>    },<br>    &quot;./testing&quot;: {<br>      &quot;types&quot;: &quot;./dist/types/testing/index.d.ts&quot;,<br>      &quot;node&quot;: &quot;./dist/cjs/testing/index.js&quot;,<br>      &quot;require&quot;: &quot;./dist/cjs/testing/index.js&quot;,<br>      &quot;es2015&quot;: &quot;./dist/esm/testing/index.js&quot;,<br>      &quot;default&quot;: &quot;./dist/esm5/testing/index.js&quot;<br>    },<br>    &quot;./webSocket&quot;: {<br>      &quot;types&quot;: &quot;./dist/types/webSocket/index.d.ts&quot;,<br>      &quot;node&quot;: &quot;./dist/cjs/webSocket/index.js&quot;,<br>      &quot;require&quot;: &quot;./dist/cjs/webSocket/index.js&quot;,<br>      &quot;es2015&quot;: &quot;./dist/esm/webSocket/index.js&quot;,<br>      &quot;default&quot;: &quot;./dist/esm5/webSocket/index.js&quot;<br>    },<br>    &quot;./internal/*&quot;: {<br>      &quot;types&quot;: &quot;./dist/types/internal/*.d.ts&quot;,<br>      &quot;node&quot;: &quot;./dist/cjs/internal/*.js&quot;,<br>      &quot;require&quot;: &quot;./dist/cjs/internal/*.js&quot;,<br>      &quot;es2015&quot;: &quot;./dist/esm/internal/*.js&quot;,<br>      &quot;default&quot;: &quot;./dist/esm5/internal/*.js&quot;<br>    },<br>    &quot;./package.json&quot;: &quot;./package.json&quot;<br>  },<br>  &quot;config&quot;: {<br>    &quot;commitizen&quot;: {<br>      &quot;path&quot;: &quot;cz-conventional-changelog&quot;<br>    }<br>  },<br>  // The rest is omitted for clarity<br>}</pre><p>A wildcard (*) means “all files in this folder are fair game” which is nice for easy exporting of smaller submodules.. until you need to export all of them as separate entrypoints/externals in your remoteEntry file. This is one of the reasons why “ignoreUnusedDeps” exist.</p><p>By default it is not possible to use wildcard (or Glob) exports at runtime because when we export RxJs:</p><pre>const { withNativeFederation, share } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br>  name: &#39;mfe1&#39;,<br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br>  shared: {<br>    ...share({<br>      &quot;rxjs&quot;:  { <br>        singleton: true, <br>        strictVersion: true, <br>        requiredVersion: &#39;auto&#39;<br>      }<br>    })<br><br>  },<br>  skip: [<br>    // &#39;rxjs/ajax&#39;,<br>    // &#39;rxjs/fetch&#39;,<br>    &#39;rxjs/testing&#39;,<br>    // &#39;rxjs/webSocket&#39;,<br>    (pkg) =&gt; pkg.startsWith(&#39;vanilla-native-federation&#39;),<br>  ]<br>});</pre><p>Only the non-wildcard exports are included? Besides that, Native federation has also excluded most entrypoints like “testing” for convenience (as you can see in the SKIP array). Let’s see what this config produces in the exported remoteEntry metadata file:</p><pre>{<br>  &quot;name&quot;: &quot;mfe1&quot;,<br>  &quot;shared&quot;: [<br>    {<br>      &quot;packageName&quot;: &quot;rxjs&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs.7eDkF4IOMS.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.2&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;rxjs/ajax&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs_ajax.NpZd2JbL7a.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.2&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;rxjs/fetch&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs_fetch.L1wq58Q0wx.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.2&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;rxjs/operators&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs_operators._XyEK9YZce.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.2&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;rxjs/webSocket&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs_webSocket.t06ynecuVB.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.2&quot;<br>    },<br>    {<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: false,<br>      &quot;requiredVersion&quot;: &quot;0.0.0&quot;,<br>      &quot;packageName&quot;: &quot;@nf-internal/chunk-Z66JL3RI&quot;,<br>      &quot;outFileName&quot;: &quot;chunk-Z66JL3RI.js&quot;<br>    },<br>    // other chunks omitted<br><br>  ],<br>  &quot;exposes&quot;: [<br>    {<br>      &quot;key&quot;: &quot;./Component&quot;,<br>      &quot;outFileName&quot;: &quot;Component-CWNUCOSQ.js&quot;<br>    }<br>  ]<br>}</pre><p>As you can see, only the hardcoded exports are included in the final remoteEntry. If we import something from the main RxJs bundle, there won’t be any issue since it is now nicely exported.</p><pre>// projects/mfe1/src/app/app.component.ts<br><br>import { Component, signal } from &#39;@angular/core&#39;;<br>import { RouterOutlet } from &#39;@angular/router&#39;;<br>import { of } from &#39;rxjs&#39;;<br>@Component({<br>  selector: &#39;app-mfe1&#39;,<br>  imports: [RouterOutlet],<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.scss&#39;],<br>})<br>export class AppComponent {<br>  title = signal(&#39;mfe1&#39;);<br>  test = of(&quot;test&quot;);<br>}</pre><p>But when we change to the internal export:</p><pre>// projects/mfe1/src/app/app.component.ts<br><br>import { Component, signal } from &#39;@angular/core&#39;;<br>import { RouterOutlet } from &#39;@angular/router&#39;;<br>import { of } from &#39;rxjs/internal/observable/of&#39;;<br><br>@Component({<br>  selector: &#39;app-mfe1&#39;,<br>  imports: [RouterOutlet],<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.scss&#39;],<br>})<br>export class AppComponent {<br>  title = signal(&#39;mfe1&#39;);<br>  test = of(&quot;test&quot;);<br>}</pre><p>Suddenly the crash is happening again…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*87WptY6_vzjGZrwZ07XQsQ.png" /><figcaption>The crash is happening again for RxJs</figcaption></figure><p>Since native-federation version 21.0.4, it is possible to solve this by allowing the builder to process “glob” exports!</p><pre>const { withNativeFederation, share } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br>  name: &#39;mfe1&#39;,<br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br>  shared: {<br>    ...share({<br>      &quot;rxjs&quot;:  { <br>        singleton: true, <br>        strictVersion: true, <br>        requiredVersion: &#39;auto&#39;,<br>        includeSecondaries: {resolveGlob: true}<br>      }<br>    })<br>  },<br>  skip: [<br>    // &#39;rxjs/ajax&#39;,<br>    // &#39;rxjs/fetch&#39;,<br>    &#39;rxjs/testing&#39;,<br>    // &#39;rxjs/webSocket&#39;,<br>    (pkg) =&gt; pkg.startsWith(&#39;vanilla-native-federation&#39;),<br>  ]<br>});</pre><p>But this comes with a cost, since now everything that within the glob/wildcard is exported as separate bundle (remember? all files in the internal folder are fair game now… Recursively):</p><pre>{<br>  &quot;name&quot;: &quot;mfe1&quot;,<br>  &quot;shared&quot;: [<br>    {<br>      &quot;packageName&quot;: &quot;rxjs&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs.Q2t-6f4C03-dev.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.2&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;rxjs/ajax&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs_ajax.0X_cwHIB_5-dev.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.2&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;rxjs/fetch&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs_fetch.eyUs0yz8cj-dev.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.2&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;rxjs/operators&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs_operators.ZMXAn4kcoj-dev.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.2&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;rxjs/webSocket&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs_webSocket.andTnNxDzj-dev.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.2&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;rxjs/internal/AnyCatcher&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs_internal_AnyCatcher.LFIs5MAGLP-dev.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.0&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;rxjs/internal/AsyncSubject&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs_internal_AsyncSubject.eeP6d3K2Qp-dev.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.0&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;rxjs/internal/BehaviorSubject&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs_internal_BehaviorSubject.ugi0QclFx8-dev.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.0&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;rxjs/internal/Notification&quot;,<br>      &quot;outFileName&quot;: &quot;rxjs_internal_Notification.5q--4WuFDH-dev.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~7.8.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;7.8.0&quot;<br>    },<br>    // And about 380 entries more... I think we get the picture. <br>  ],<br>  &quot;exposes&quot;: [<br>    {<br>      &quot;key&quot;: &quot;./Component&quot;,<br>      &quot;outFileName&quot;: &quot;Component.js&quot;,<br>      &quot;dev&quot;: {<br>        &quot;entryPoint&quot;: &quot;/home/auke/Projects/Personal/native-federation-examples-ng/projects/mfe1/src/bootstrap.ts&quot;<br>      }<br>    }<br>  ],<br>  &quot;buildNotificationsEndpoint&quot;: &quot;/@angular-architects/native-federation:build-notifications&quot;<br>}</pre><p>We can avoid this by allowing native-federation to check which entries are being used! This is done by an older feature called “ignoreUnusedDeps” and it helps to only share what you’re actually using.</p><pre>const { withNativeFederation, share } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br><br>  name: &#39;mfe1&#39;,<br><br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br><br>  shared: {<br>    ...share({<br>      &quot;rxjs&quot;:  { <br>        singleton: true, <br>        strictVersion: true, <br>        requiredVersion: &#39;auto&#39;,<br>        includeSecondaries: {resolveGlob: true}<br>      }<br>    })<br><br>  },<br>  skip: [<br>    // &#39;rxjs/ajax&#39;,<br>    // &#39;rxjs/fetch&#39;,<br>    &#39;rxjs/testing&#39;,<br>    // &#39;rxjs/webSocket&#39;,<br>    (pkg) =&gt; pkg.startsWith(&#39;vanilla-native-federation&#39;),<br>  ],<br>  features: {<br>    ignoreUnusedDeps: true<br>  }<br>});</pre><p>Finally, it is also possible to exclude certain parts of the glob that you are sure of you won’t use:</p><pre>const { withNativeFederation, share } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br><br>  name: &#39;mfe1&#39;,<br><br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br><br>  shared: {<br>    ...share({<br>      &quot;rxjs&quot;:  { <br>        singleton: true, <br>        strictVersion: true, <br>        requiredVersion: &#39;auto&#39;,<br>        includeSecondaries: {resolveGlob: true, skip: [&#39;rxjs/internal/testing/*&#39;]}<br>      }<br>    })<br><br>  },<br>  skip: [<br>    // &#39;rxjs/ajax&#39;,<br>    // &#39;rxjs/fetch&#39;,<br>    &#39;rxjs/testing&#39;,<br>    // &#39;rxjs/webSocket&#39;,<br>    (pkg) =&gt; pkg.startsWith(&#39;vanilla-native-federation&#39;),<br>  ],<br>});</pre><h3>Pseudo-treeshaking</h3><p>Why would anyone use “rxjs/internal/*” instead of just using the main “rxjs” entrypoint? The answer is simple! When you’re sharing an external, you’re losing the ability to treeshake that library… Because ESbuild has no idea what to include and what to exclude. It only knows which micro frontends use what at runtime. That means that the “rxjs” entrypoint contains well.. everything. Which is bad for performance if you’re only using the “of” object. Therefore, only using an internal export of that particular object might improve performance. I call this process pseudo-treeshaking.</p><p>In general, it really helps to think about which externals you really want to share, and what parts you (don’t) want to share. If only one micro frontend is using a single or two objects of RxJs, why bother sharing that dependency at all? It’ll save you a couple of bytes at most.</p><p>The real answer to know which dependencies to share and how is to measure the overall performance, and just try to find out what works for your architecture.</p><h3>The downside of treeshaking</h3><p>Let’s talk a bit about the downsides and caveats regarding dependency treeshaking. Because it might not be benefitial for all dependencies you share. While it is nice to keep your micro frontend bundles as small as possible and only share what you’re actually using, it comes with a cost.</p><p>Let’s say you have two micro frontends with each a different Angular version, ‘21.0.1’ and ‘21.0.2’. The orchestrator will make sure that, <em>if you allow it to</em>, both micro frontends will use ‘v21.0.2&#39;. But what if the micro frontend that shares v21.0.2 is not using the import * from @angular/core/rxjs-interop entrypoint? When that happens, and the “ignoreUnusedDeps” is enabled, the secondary entrypoint is also <em>not</em> being shared by that micro frontend:</p><pre>const { withNativeFederation, share } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br>  name: &#39;mfe1&#39;,<br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br>  shared: {<br>    ...share({<br>      &quot;@angular/core&quot;: { <br>        singleton: true, <br>        strictVersion: true, <br>        requiredVersion: &#39;auto&#39;<br>      }<br>    })<br>  },<br>  skip: [],<br>  features: {<br>    ignoreUnusedDeps: true<br>  }<br>});</pre><p>Resulting in a remoteEntry.json that looks like this:</p><pre>{<br>  &quot;name&quot;: &quot;mfe1&quot;,<br>  &quot;shared&quot;: [<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core.ylV3hbXXny.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core/primitives/di&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core_primitives_di.vSzwlX8M91.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core/primitives/signals&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core_primitives_signals.TrU7pSvgfp.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    // chunks omitted<br>  ],<br>  &quot;exposes&quot;: [<br>    {<br>      &quot;key&quot;: &quot;./Component&quot;,<br>      &quot;outFileName&quot;: &quot;Component-MPEZFG3D.js&quot;<br>    }<br>  ]<br>}</pre><p>Sure, some primitives are included but the @angular/core/rxjs-interop entrypoint is missing. This is okay for that particular micro frontend because it is <strong>not using the entrypoint.</strong> But what if the other micro frontend is? Then it <em>will </em>expose the entrypoint from its own Angular which in this case is the “v21.0.1”. That means that Angular is being torn apart with some entrypoints being 21.0.1 and some being 21.0.2.</p><p>This is a very error-prone situation where you generally don’t want to be. Therefore, it is best to opt-out of the “ignoreUnusedDeps” feature for core libraries like Angular to make sure all secondary entrypoints are shared and from the same external:</p><pre>const { withNativeFederation, share } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br>  name: &#39;mfe1&#39;,<br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br>  shared: {<br>    ...share({<br>      &quot;@angular/core&quot;: { <br>        singleton: true, <br>        strictVersion: true, <br>        requiredVersion: &#39;auto&#39;,<br>        includeSecondaries: {keepAll: true}<br>      }<br>    })<br>  },<br>  skip: [ ],<br>  features: {<br>    ignoreUnusedDeps: true<br>  }<br>});</pre><p>The “keepAll” setting will bring back the unused secondary entrypoints from that particular package:</p><pre>{<br>  &quot;name&quot;: &quot;mfe1&quot;,<br>  &quot;shared&quot;: [<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core.DPw1KVtmMc.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core/event-dispatch-contract.min.js&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core_event_dispatch_contract_min_js.3l1Naextzf.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core/primitives/di&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core_primitives_di.4EDGu_v0C7.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core/primitives/event-dispatch&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core_primitives_event_dispatch.X_FP7X5JTv.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core/primitives/signals&quot;,<br>      &quot;outFileName&quot;: &quot;_angular_core_primitives_signals.MIhqYQtnnw.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;@angular/core/rxjs-interop&quot;,   // Siuuuu<br>      &quot;outFileName&quot;: &quot;_angular_core_rxjs_interop.EEexvsIBbs.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;^21.0.6&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;21.0.6&quot;<br>    },<br>    // chunks omitted<br>  ],<br>  &quot;exposes&quot;: [<br>    {<br>      &quot;key&quot;: &quot;./Component&quot;,<br>      &quot;outFileName&quot;: &quot;Component-MPEZFG3D.js&quot;<br>    }<br>  ]<br>}</pre><p>So there you have it, these flags introduced in v21.0.4 allow you to tweak the externals to your likings. These pair nicely with the existing “shareAll” helper.</p><h3>Just share everything</h3><p>If you just want to share all dependencies, you can use the “shareAll” helper which will iterate through your root package.json and execute the “share” helper for all the packages found in the “dependencies” property.</p><pre>const { withNativeFederation, share } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br>  name: &#39;mfe1&#39;,<br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br>  shared: {<br>    ...shareAll({ singleton: true, strictVersion: true, requiredVersion: &#39;auto&#39; }),<br>  },<br>  skip: [ ],<br>  features: {<br>    ignoreUnusedDeps: true<br>  }<br>});</pre><p>However, this might be a bit too aggressive. If you want to skip certain packages like ‘vanilla-native-federation’ you can add a lambda to filter out all entrypoints that starts with that package name, or if you want to filter out specific entrypoints like “rxjs/testing” you can also provide the full name in the “skip” array:</p><pre>const { withNativeFederation, share } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br>  name: &#39;mfe1&#39;,<br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br>  shared: {<br>    ...shareAll(<br>      { <br>        singleton: true, <br>        strictVersion: true, <br>        requiredVersion: &#39;auto&#39; <br>      }<br>    )<br>  },<br>  skip: [<br>    &#39;rxjs/ajax&#39;,<br>    &#39;rxjs/fetch&#39;,<br>    &#39;rxjs/testing&#39;,<br>    &#39;rxjs/webSocket&#39;,<br>    (pkg) =&gt; pkg.startsWith(&#39;vanilla-native-federation&#39;),<br>    // Add further packages you don&#39;t need at runtime<br>  ],<br>  features: {<br>    ignoreUnusedDeps: true<br>  }<br>});</pre><h3>shareAll overrides</h3><p>Now that we’ve seen all parts individually, it is time to see how it all comes together. So suppose you want to finetune your micro frontend to process only the externals that you want to share. You can use overrides for specific packages that contain different rules than the “default”.</p><pre>const { withNativeFederation, share } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br>  name: &#39;mfe1&#39;,<br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br>  shared: {<br>    ...shareAll(<br>      { <br>        singleton: true, <br>        strictVersion: true, <br>        requiredVersion: &#39;auto&#39; <br>      }, <br>      {<br>        overrides: {<br>          &quot;@angular/core&quot;: { <br>            singleton: true, <br>            strictVersion: true, <br>            requiredVersion: &#39;auto&#39;, <br>            includeSecondaries: {keepAll: true} <br>          },<br>          &quot;rxjs&quot;:  { <br>            singleton: true, <br>            strictVersion: true, <br>            requiredVersion: &#39;auto&#39;,<br>            includeSecondaries: {resolveGlob: true}<br>          }<br>        }<br>      }<br>    )<br>  },<br>  skip: [<br>    &#39;rxjs/ajax&#39;,<br>    &#39;rxjs/fetch&#39;,<br>    &#39;rxjs/testing&#39;,<br>    &#39;rxjs/webSocket&#39;,<br>    (pkg) =&gt; pkg.startsWith(&#39;vanilla-native-federation&#39;),<br>    // Add further packages you don&#39;t need at runtime<br>  ],<br>  features: {<br>    ignoreUnusedDeps: true<br>  }<br>});</pre><p><strong><em>note:</em></strong><em> To make things clear. “skip” is not skipping the external entirely. (if that would happen, the micro frontend wouldn’t be able to run on it’s own) But rather it is only skipping the sharing of the external. All skipped entrypoints are bundled into the micro frontend or other external entrypoints.</em></p><h3>Final words</h3><p>The goal of this article was to show you how you can optimally share the externals of your native-federation setup. Now it is up to you to measure and find out what combination works best for you! We will continue to evolve the externals sharing system but for now, this is how it works.</p><p>In the next article I will explain the different build types of externals and how they might help in the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4e1d3711230" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tweaking native-federation]]></title>
            <link>https://medium.com/@auke997/tweaking-native-federation-e2d514366d08?source=rss-e4d5267b0297------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2d514366d08</guid>
            <category><![CDATA[native-federation]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <dc:creator><![CDATA[Aukevanoost]]></dc:creator>
            <pubDate>Tue, 30 Dec 2025 10:32:59 GMT</pubDate>
            <atom:updated>2026-06-20T08:16:06.265Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This article series is meant to provide a peek under the hood of native federation, as well as some tips and tricks on how you can optimize your native-federation architecture setup.</em></p><h4>Before we start, here is some good-to-know information:</h4><p>The goal of native-federation is very simple: “sharing dependencies between micro frontends”, thus improving the performance of your webapp overal. And to do it, it will extract those dependencies into separate bundles.</p><p>To do this, native federation is,<em> like module federation v2 </em>[<a href="https://github.com/module-federation/core/discussions/2397">1</a>], built upon the principle of 2 components: A “build-time” part (the builder) and a “runtime” part (the orchestrator). If you are new to native-federation and want to know more about why you would want to use Native federation, I’d recommend this absolute classic:</p><p><a href="https://www.angulararchitects.io/blog/announcing-native-federation-1-0/">Announcing Native Federation 1.0 - ANGULARarchitects</a></p><p>Previously, I have written an article series on how to optimally use the orchestrator and how it works. It was initially only for monoliths but the concepts are the same when you migrate from an SPA aplication. you can find that series here:</p><p><a href="https://medium.com/@auke997/migrating-a-stateful-monolith-to-micro-frontends-using-native-federation-0572a1e181b4">Migrating a stateful monolith to micro frontends using native federation.</a></p><p>To complement that article series, this one is provided for the “builder”. If you want to know more about how native-federation works in the browser, I recommend reading the first article of that series to know more about how native-federation works before continuing this one.</p><p><strong><em>Note: </em></strong><em>Currently, the most supported builder is the Angular one so I will use that one for the examples. We are planning on supporting more builders in the future.</em></p><p>One last mention, this article series contains an up-to-date explanation of the native-federation (v3+) builder (@angular-architects/native-federation &gt;21.1.0 and &gt;20.3.0), but all core concepts of native-federation can be found in the enterprise-angular e-book from <a href="https://medium.com/u/a63cf309191b">Manfred Steyer</a></p><p><a href="https://www.angulararchitects.io/en/ebooks/micro-frontends-and-moduliths-with-angular/">[Free eBook] Enterprise Angular: Micro Frontends &amp; Moduliths</a></p><p>Now, let’s get started!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rCa1bHhzvPrWrhSp" /><figcaption>Photo by <a href="https://unsplash.com/@deernagedd?utm_source=medium&amp;utm_medium=referral">Mattttt ttttttaM</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>The basics</h3><p>The first step to optimizing native-federation is to know how it works. So what’s happening when you add native-federation to your micro frontend repository? You can see by creating a new Angular project and by running the following commands:</p><pre># Angular setup<br>$ npm install -g @angular/cli<br>$ ng new &lt;your-workspace&gt; --no-create-application<br>$ ng g app &lt;your-project&gt;<br><br># Native-federation setup<br>$ npm install @angular-architects/native-federation<br>$ ng add @angular-architects/native-federation:init --project &lt;your-project&gt; --port 4201 --type remote</pre><p>Alternatively, I prepared a repository here:</p><p><a href="https://github.com/Aukevanoost/native-federation-examples-ng/tree/tweaking-nf/starter">https://github.com/Aukevanoost/native-federation-examples-ng/tree/tweaking-nf/starter</a></p><p>The most important changes are in the angular.json: Two new builders have been added, one for ng serve, and one for ng build .</p><pre>{<br> &quot;$schema&quot;: &quot;./node_modules/@angular/cli/lib/config/schema.json&quot;,<br> &quot;version&quot;: 1,<br> &quot;newProjectRoot&quot;: &quot;projects&quot;,<br> &quot;projects&quot;: {<br>  &quot;mfe1&quot;: {<br>   &quot;projectType&quot;: &quot;application&quot;,<br>   &quot;root&quot;: &quot;projects/mfe1&quot;,<br>   // [...] Settings<br>   &quot;architect&quot;: {<br><br>    // Here we see a new builder!<br>    &quot;build&quot;: {<br>     &quot;builder&quot;: &quot;@angular-architects/native-federation:build&quot;,<br>     &quot;options&quot;: {<br>       &quot;cacheExternalArtifacts&quot;: false<br>     },<br>     &quot;configurations&quot;: {<br>      &quot;production&quot;: {<br>       &quot;target&quot;: &quot;mfe1:esbuild:production&quot;<br>      },<br>      &quot;development&quot;: {<br>       &quot;target&quot;: &quot;mfe1:esbuild:development&quot;,<br>       &quot;dev&quot;: true<br>      }<br>     },<br>     &quot;defaultConfiguration&quot;: &quot;production&quot;<br>    },<br><br>    // Here we also see a new builder!<br>    &quot;serve&quot;: {<br>     &quot;builder&quot;: &quot;@angular-architects/native-federation:build&quot;,<br>     &quot;options&quot;: {<br>      &quot;target&quot;: &quot;mfe1:serve-original:development&quot;,<br>      &quot;cacheExternalArtifacts&quot;: false,<br>      &quot;rebuildDelay&quot;: 0,<br>      &quot;dev&quot;: true,<br>      &quot;port&quot;: 0<br>     }<br>    },<br><br>    // The original builder was renamed to &quot;esbuild&quot;!<br>    &quot;esbuild&quot;: {<br>     &quot;builder&quot;: &quot;@angular/build:application&quot;,<br>     &quot;options&quot;: {<br>      &quot;outputPath&quot;: &quot;dist/mfe1&quot;,<br>      &quot;verbose&quot;: false,<br>      &quot;index&quot;: &quot;projects/mfe1/src/index.html&quot;,<br>      &quot;browser&quot;: &quot;projects/mfe1/src/main.ts&quot;,<br>      &quot;polyfills&quot;: [<br>       &quot;es-module-shims&quot;<br>      ],<br>      &quot;tsConfig&quot;: &quot;projects/mfe1/tsconfig.app.json&quot;,<br>      &quot;inlineStyleLanguage&quot;: &quot;scss&quot;,<br>      &quot;assets&quot;: [<br>       {<br>        &quot;glob&quot;: &quot;**/*&quot;,<br>        &quot;input&quot;: &quot;projects/mfe1/public&quot;<br>       }<br>      ],<br>      &quot;styles&quot;: [<br>       &quot;projects/mfe1/src/styles.scss&quot;<br>      ],<br>      &quot;scripts&quot;: []<br>     },<br>     &quot;configurations&quot;: {<br>      &quot;production&quot;: {<br>       &quot;budgets&quot;: [<br>        {<br>         &quot;type&quot;: &quot;initial&quot;,<br>         &quot;maximumWarning&quot;: &quot;500kB&quot;,<br>         &quot;maximumError&quot;: &quot;1MB&quot;<br>        },<br>        {<br>         &quot;type&quot;: &quot;anyComponentStyle&quot;,<br>         &quot;maximumWarning&quot;: &quot;4kB&quot;,<br>         &quot;maximumError&quot;: &quot;8kB&quot;<br>        }<br>       ],<br>       &quot;outputHashing&quot;: &quot;all&quot;<br>      },<br>      &quot;development&quot;: {<br>       &quot;optimization&quot;: false,<br>       &quot;extractLicenses&quot;: false,<br>       &quot;sourceMap&quot;: true<br>      }<br>     },<br>     &quot;defaultConfiguration&quot;: &quot;production&quot;<br>    },<br><br>    // And finally the original serve<br>    &quot;serve-original&quot;: {<br>     &quot;builder&quot;: &quot;@angular/build:dev-server&quot;,<br>     &quot;configurations&quot;: {<br>      &quot;production&quot;: {<br>       &quot;buildTarget&quot;: &quot;mfe1:esbuild:production&quot;<br>      },<br>      &quot;development&quot;: {<br>       &quot;buildTarget&quot;: &quot;mfe1:esbuild:development&quot;<br>      }<br>     },<br>     &quot;defaultConfiguration&quot;: &quot;development&quot;,<br>     &quot;options&quot;: {<br>      &quot;port&quot;: 4201<br>     }<br>    }<br>    // [...] Other builders<br>   }<br>  // [...] Other projects<br>  }<br> }<br>}</pre><p>Now let’s take some native-federation options from the “serve” builder and understand them a bit better:</p><pre>&quot;options&quot;: {<br>  &quot;target&quot;: &quot;mfe1:serve-original:development&quot;,<br><br>  // Enable caching of externals over multiple builds. This will be explained <br>  // in detail in one of the following sections. <br>  &quot;cacheExternalArtifacts&quot;: false,    <br>  <br>  // Allows for throttling. In volatile settings during runtime where multiple file<br>  // saves keep triggering the rebuilds, the nf builder can become a bit overwelmed. <br>  // This option tells the builder to wait until idle for an x amount of ms.<br>  // this allows nf to only rebuild when needed. <br>  // for example: 500 (ms).<br>  &quot;rebuildDelay&quot;: 0,      <br><br>  // Will enable some devtools like source maps and raw unminified files.            <br>  &quot;dev&quot;: true,<br><br>  // Allows you to set a port, will override the &quot;serve-original&quot; port<br>  &quot;port&quot;: 0<br>}</pre><h3>Diving into the builder process</h3><p>The “verbose” properrty in the “esbuild” builder (in the angular.json) allows you to debug the native federation build and see what is happening behind the scenes. When set to true, the builder will show the performed steps!</p><pre>aukevanoost:~/native-federation-examples-ng$ ng build mfe1<br> DBG!  00:00:755.334ms - To load the federation config.<br> INFO  Building federation artefacts<br> DBG!  00:01:451.652ms - [build artifacts] - To bundle all mappings and exposed.<br> INFO  Preparing shared npm packages for the platform browser<br> NOTE  This only needs to be done once, as results are cached<br> NOTE  Skip packages you don&#39;t want to share in your federation config<br> DBG!  00:04:199.646ms - [build artifacts] - To bundle all shared browser externals<br> DBG!  00:05:654.005ms - To build the artifacts.<br><br> *** debug messages omitted for clarity ***<br><br>Initial chunk files   | Names         |  Raw size | Estimated transfer size<br>polyfills-G7GBCUTJ.js | polyfills     |  36.72 kB |                11.96 kB<br>main-EBCRGQM7.js      | main          |   2.79 kB |                 1.16 kB<br>chunk-2NFLSA4Y.js     | -             | 449 bytes |               449 bytes<br>styles-5INURTSO.css   | styles        |   0 bytes |                 0 bytes<br><br>                      | Initial total |  39.95 kB |                13.58 kB<br><br>Lazy chunk files      | Names         |  Raw size | Estimated transfer size<br>chunk-5MOS6PT2.js     | bootstrap     |  19.97 kB |                 5.28 kB<br><br>Application bundle generation complete. [1.377 seconds] - 2025-xx-xxTxx:xx:xx.xxxZ<br><br>Output location: /path/to/native-federation-examples-ng/dist/mfe1</pre><p>So what does this tell us? We can see a couple of timestamps (4 to be precise) before the “angular builder” starts <em>(because native-federation is just a decorator over the Angular builder that performs some preparation and enhancements).</em> The timestamps show how long it took to process every step of the builder.</p><p>The native-federation builder can be divided into 4 steps:</p><ol><li>Load and process the config file (federation.config.js). <br>(Duration: 755ms)</li><li>Process and bundle the exposed modules and shared mappings. <br>(Duration: 1s and 451 ms)</li><li>Process and bundle the externals.<br>(Duration: 4s and 199ms)</li><li>Run the Angular builder.<br>(Duration: 1s and 377 ms)</li></ol><p>There are of course some other extra steps but these are the 4 main steps.</p><p><strong>What are all these steps?</strong><br>The “exposed modules” are the<em> final micro frontends</em>, the “shared-mappings” are internal libraries that are converted to shared bundles, and the “externals” are the dependencies (like RxJs and Angular) that are bundled to be reused. By bundling all these parts separately from each other, we can share and reuse JavaScript modules (like the externals) to improve performance.</p><h3>Configuring the builder</h3><p>Okay, now we kinda know what the builder does, but how does it know what dependencies to bundle? You can configure the output of the builder in the “federation.config.js”. The initial file might look similar to this:</p><pre>const { withNativeFederation, shareAll } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br>  name: &#39;mfe1&#39;,<br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br>  shared: {<br>    ...shareAll({ singleton: true, strictVersion: true, requiredVersion: &#39;auto&#39; }),<br>  },<br>  skip: [<br>    &#39;rxjs/ajax&#39;,<br>    &#39;rxjs/fetch&#39;,<br>    &#39;rxjs/testing&#39;,<br>    &#39;rxjs/webSocket&#39;,<br>    (pkg) =&gt; pkg.startsWith(&#39;vanilla-native-federation&#39;),<br>    // Add further packages you don&#39;t need at runtime<br>  ],<br>  features: {<br>    ignoreUnusedDeps: true<br>  }<br>});</pre><p>The name is important because it is used as an unique identifier for your “remote”. According to the native-federation spec:</p><blockquote>A <strong>remote</strong> (a.k.a. micro frontend) is a collection of “exposed modules” and “externals” that represents a subdomain within your application/architecture.</blockquote><p>It is therefore recommended to have a remote per team/subdomain. But that’s for another discussion :).</p><p><strong>The name property</strong><br>A remote name should have a similar name to npm packages like “mfe1” or “@org/mfe1”, but alternatively “team/mfe1” is also acceptable.</p><p><strong>The exposes property</strong><br>The exposed components are used as custom imports to the exposed bundle file. In this example, the bootstrap.ts file will be bundled into an ESM bundle that is accessible at runtime under the mfe1/./Component path. The codesnippet below shows the final import path in the “import-map” without externals:</p><pre>{<br>  &quot;imports&quot;:{<br>    &quot;mfe1/./Component&quot;: &quot;./component.js&quot;<br>  }<br>}</pre><p><strong>The shared property:</strong><br>By default, if you leave this property empty, it will not share any dependencies. That means that all dependencies will be bundled into a single “component.js” file. This can be beneficial since this allows ESbuild to fully optimize and treeshake the file, only the <em>used code </em>will be included in the bundle and all “dead code” is removed [<a href="https://esbuild.github.io/apiatree-shaking">2</a>]. For a single micro frontend this is the best solution, but for setups with multiple micro frontends, this will result in a lot of code duplication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*4fNhSek3d9cR72rUT0olwg.png" /><figcaption>Example: Breaking up modules will create smaller bundles</figcaption></figure><p>Therefore, it might be beneficial to extract the dependencies into multiple bundles that can be reused.</p><p>The “shareAll” helper function will iterate through the root package.json (only the “dependencies” property) and bundle all node_modules into separate files. Secondly, for every package, the “share” helper function will find out which secondary entrypoints exist and it will create separate bundles for those as well.</p><p>Let’s first see what happens when we only share Angular core:</p><pre>const { withNativeFederation, shareAll } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br>  name: &#39;mfe1&#39;,<br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br>  shared: {<br>    ...share({ <br>      &quot;@angular/core&quot;: { singleton: true, strictVersion: true, requiredVersion: &#39;auto&#39; }<br>    }),<br>  },<br>  skip: [],<br>  features: {<br>    ignoreUnusedDeps: false<br>  }<br>});</pre><p>The upper federation.config.js would result in an importmap like shown below:</p><pre>{<br>  &quot;imports&quot;: {<br>    // Exposed component<br>    &quot;mfe1/./Component&quot;: &quot;./component.js&quot;,<br>    // Shared Angular core dependency<br>    &quot;@angular/core&quot;:&quot;./_angular_core.js&quot;,<br>    &quot;@angular/core/event-dispatch-contract.min.js&quot;:&quot;./_angular_core_event_dispatch_contract_min_js.js&quot;,<br>    &quot;@angular/core/primitives/di&quot;:&quot;./_angular_core_primitives_di.js&quot;,<br>    &quot;@angular/core/primitives/event-dispatch&quot;:&quot;./_angular_core_primitives_event_dispatch.js&quot;,<br>    &quot;@angular/core/primitives/signals&quot;:&quot;./_angular_core_primitives_signals.js&quot;,<br>    &quot;@angular/core/rxjs-interop&quot;:&quot;./_angular_core_rxjs_interop.js&quot;<br>  }<br>}</pre><p>As you can see, all imports from the shared external are mapped to single (ESM bundle) javascript files. This allows them to be reused by multiple micro frontends.</p><p><strong>The skip property</strong><br>When the shareAll property is used, it is possible to skip certain packages from being treated as external. A reason could be because ESM support is insufficient to create a separate bundle (especially with packages bundled in commonjs format), in this case the packages can be bundled into the micro frontends instead.</p><p><strong><em>Note: </em></strong><em>it will look for the full name of the package/secondary-entry-point. If you only want to skip “@angular/core/rxjs-interop” you can add it to the skip list, but if you want to skip all of “@angular/core”, you’ll have to use a lambda filter like “(pkg) =&gt; pkg.startsWith(‘@angular/core’)”</em></p><p><strong>The features property<br></strong>This property allows you to opt-in to extra features like “ignoreUnusedDeps”. For example, it might be that you’re using a monorepo setup with a lot of dependencies, in this case the “ignoreUnusedDeps” feature can be used to share only the externals that are used by your application/exposed modules.</p><h3>Caching</h3><p>Bundling all external node_modules every time you run a ng serveor ng build command can become tedious and time consuming. Therefore, <em>as mentioned before,</em> it is possible to enable “externals caching” by setting the “cacheExternalArtifacts” to true in the Angular workspace file (this can be configured per project and builder). When set to true, it will cache the bundled externals per micro frontend in the ./node_modules/.cache/native-federation/&lt;project-name&gt; folder, the “project-name” is defined in the federation.config.js. When the builder is run with caching enabled, it will output something a little bit different:</p><pre>aukevanoost:~/native-federation-examples-ng$ ng build mfe1<br> DBG!  00:00:387.914ms - To load the federation config.<br> INFO  Building federation artefacts<br> DBG!  00:00:779.642ms - [build artifacts] - To bundle all mappings and exposed.<br> DBG!  Checksum of browser-shared matched, Skipped artifact bundling<br> DBG!  00:00:008.745ms - [build artifacts] - To bundle all shared browser externals<br> DBG!  00:00:788.998ms - To build the artifacts.<br><br> *** debug messages omitted for clarity ***<br><br>Initial chunk files   | Names         |  Raw size | Estimated transfer size<br>polyfills-G7GBCUTJ.js | polyfills     |  36.72 kB |                11.96 kB<br>main-EBCRGQM7.js      | main          |   2.79 kB |                 1.16 kB<br>chunk-2NFLSA4Y.js     | -             | 449 bytes |               449 bytes<br>styles-5INURTSO.css   | styles        |   0 bytes |                 0 bytes<br><br>                      | Initial total |  39.95 kB |                13.58 kB<br><br>Lazy chunk files      | Names         |  Raw size | Estimated transfer size<br>chunk-5MOS6PT2.js     | bootstrap     |  19.97 kB |                 5.28 kB<br><br>Application bundle generation complete. [0.779 seconds] - 2025-12-30T09:58:04.330Z<br><br>Output location: /path/to/native-federation-examples-ng/dist/mfe1</pre><p>That seems a lot faster than before! So what happened? Apparently a checksum matched, allowing native-federation to reuse the artifacts (bundles) created by the previous run. The metadata of the artifacts can be found in a meta json file in the cache folder e.g. browser-shared.meta.json which includes the following data:</p><pre>{<br>   &quot;checksum&quot;:&quot;071b3e8776554ee81b8266b5ae574e2e4f6db39f253ee7bb680a1a25c79ae237&quot;,<br>   &quot;externals&quot;:[<br>      {<br>         &quot;packageName&quot;:&quot;@angular/core&quot;,<br>         &quot;outFileName&quot;:&quot;_angular_core.CH1f-PL9lh.js&quot;,<br>         &quot;requiredVersion&quot;:&quot;^21.0.6&quot;,<br>         &quot;singleton&quot;:true,<br>         &quot;strictVersion&quot;:true,<br>         &quot;version&quot;:&quot;21.0.6&quot;<br>      },<br>      {<br>         &quot;packageName&quot;:&quot;@angular/core/primitives/di&quot;,<br>         &quot;outFileName&quot;:&quot;_angular_core_primitives_di.63DUUDHkzv.js&quot;,<br>         &quot;requiredVersion&quot;:&quot;^21.0.6&quot;,<br>         &quot;singleton&quot;:true,<br>         &quot;strictVersion&quot;:true,<br>         &quot;version&quot;:&quot;21.0.6&quot;<br>      },<br>      {<br>         &quot;packageName&quot;:&quot;@angular/core/primitives/signals&quot;,<br>         &quot;outFileName&quot;:&quot;_angular_core_primitives_signals.5PqDyOp3np.js&quot;,<br>         &quot;requiredVersion&quot;:&quot;^21.0.6&quot;,<br>         &quot;singleton&quot;:true,<br>         &quot;strictVersion&quot;:true,<br>         &quot;version&quot;:&quot;21.0.6&quot;<br>      },<br>      {<br>         &quot;singleton&quot;:false,<br>         &quot;strictVersion&quot;:false,<br>         &quot;requiredVersion&quot;:&quot;0.0.0&quot;,<br>         &quot;version&quot;:&quot;0.0.0&quot;,<br>         &quot;packageName&quot;:&quot;@nf-internal/chunk-IXOA6WTM&quot;,<br>         &quot;outFileName&quot;:&quot;chunk-IXOA6WTM.js&quot;<br>      },<br>      {<br>         &quot;singleton&quot;:false,<br>         &quot;strictVersion&quot;:false,<br>         &quot;requiredVersion&quot;:&quot;0.0.0&quot;,<br>         &quot;version&quot;:&quot;0.0.0&quot;,<br>         &quot;packageName&quot;:&quot;@nf-internal/chunk-WDE5IQ2F&quot;,<br>         &quot;outFileName&quot;:&quot;chunk-WDE5IQ2F.js&quot;<br>      },<br>      {<br>         &quot;singleton&quot;:false,<br>         &quot;strictVersion&quot;:false,<br>         &quot;requiredVersion&quot;:&quot;0.0.0&quot;,<br>         &quot;version&quot;:&quot;0.0.0&quot;,<br>         &quot;packageName&quot;:&quot;@nf-internal/chunk-2VMXMS7J&quot;,<br>         &quot;outFileName&quot;:&quot;chunk-2VMXMS7J.js&quot;<br>      }<br>   ],<br>   &quot;files&quot;:[<br>      &quot;_angular_core.CH1f-PL9lh.js&quot;,<br>      &quot;_angular_core_primitives_di.63DUUDHkzv.js&quot;,<br>      &quot;chunk-IXOA6WTM.js&quot;,<br>      &quot;_angular_core_primitives_signals.5PqDyOp3np.js&quot;,<br>      &quot;chunk-WDE5IQ2F.js&quot;,<br>      &quot;chunk-2VMXMS7J.js&quot;<br>   ]<br>}</pre><p>The checksum is the most important property here, it is generated from a list of all externals in the build, including their respective version:</p><pre>deps:@angular/core@21.0.6:@angular/core/primitives/di@21.0.6:@angular/core/primitives/signals@21.0.6</pre><p>This way, until at least one of the packages in the build changes, all externals are cached and reused saving precious seconds (or even minutes) of build-time.</p><p><strong>Build types</strong><br>For shared node_modules (externals), there are 3 different types of bundling: ‘default’, ‘separate’ and in the newest version (&gt;<a href="https://github.com/angular-architects/module-federation-plugin/releases/tag/21.0.4">21.0.4</a> and &gt;20.3.0) of native-federation also ‘package’. The ‘default’ build type bundles all externals in 1 single build, so 1 metadata file in total. “package” will bundle each external individually which will result in a meta file per external, you can set the build type in the remoteEntry.json:</p><pre>const { withNativeFederation, share } = require(&#39;@angular-architects/native-federation/config&#39;);<br><br>module.exports = withNativeFederation({<br>  name: &#39;mfe1&#39;,<br>  exposes: {<br>    &#39;./Component&#39;: &#39;./projects/mfe1/src/bootstrap.ts&#39;,<br>  },<br>  shared: {<br>    ...share({<br>      &quot;@angular/core&quot;: { <br>        singleton: true, <br>        strictVersion: true, <br>        requiredVersion: &#39;auto&#39;,<br>        build: &#39;package&#39;,<br>      }<br>    })<br>  },<br>  skip: [ ],<br>  features: {<br>    ignoreUnusedDeps: true<br>  }<br>});</pre><p>This is mostly an edge case but can come in handy if you want to bundle each external separately.</p><p><strong>Corrupted cache</strong><br>Whenever your build or cache becomes corrupt for whatever reason, you can simply remove the node_modules/.cache folder and all bundles will be re-created.</p><h3>In conclusion</h3><p>This small introductory article showed the different components necessary for native-federation to build production ready micro frontends. We’ve looked at the different components in the federation.config.js, and steps that are performed in the native-federation build. Finally, when used correctly, caching can improve performance by skipping already bundled stale files like externals.</p><p>The next article will take a look at how <em>pseudo-treeshaking</em> can be leveraged to optimize the amount of externals that are shared and why this could be important…</p><p>You can find the article here:</p><p><a href="https://medium.com/@auke997/tweaking-native-federation-part-ii-sharing-externals-a4e1d3711230">Tweaking native-federation | Part II: Sharing externals</a></p><p><em>See you there!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2d514366d08" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part IV: Robust communication between micro frontends within native federation]]></title>
            <link>https://medium.com/@auke997/part-iv-robust-communication-between-micro-frontends-within-native-federation-5f9282ecc727?source=rss-e4d5267b0297------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f9282ecc727</guid>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[native-federation]]></category>
            <category><![CDATA[eventbus]]></category>
            <dc:creator><![CDATA[Aukevanoost]]></dc:creator>
            <pubDate>Thu, 11 Sep 2025 15:02:11 GMT</pubDate>
            <atom:updated>2026-04-15T10:10:49.284Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the fourth and final article in the series <em>“migrating a stateful monolith to micro frontend architecture using native federation”. </em>In this article, a simple event-streaming data structure will be explored to allow robust communication between micro frontends. As a bonus, this article also proposes a more robust form of initialization for the orchestrator rather than the previous mentioned “custom events” strategy.</p><p>Before we start, it is important to know that this is also a rather advanced article that shows how you can fine-tune native-federation to meet the requirements of your enterprise micro frontend architecture. The other parts can be found below:</p><ul><li><a href="https://medium.com/@auke997/migrating-a-stateful-monolith-to-micro-frontends-using-native-federation-0572a1e181b4">Part I: Migrating a stateful monolith to micro frontend architecture using native federation.</a></li><li><a href="https://medium.com/@auke997/part-ii-composing-your-own-native-federation-orchestrator-7fac2d0ea62e">Part II: Composing your own native-federation orchestrator</a></li><li><a href="https://medium.com/@auke997/part-iii-improving-cache-utilization-in-native-federation-1e4b696f3426">Part III: Improving Cache Utilization in Native Federation</a></li></ul><p>This article series is using the official <a href="https://github.com/native-federation/orchestrator">native federation</a> orchestrator, introduced in native-federation v4, but fully backwards compatible. The remotes also use the official <a href="https://www.npmjs.com/package/@softarc/native-federation">native-federation builder</a> to build. The code and examples can be found here:</p><ul><li><strong>Orchestrator examples</strong>: <a href="https://github.com/Aukevanoost/native-federation-examples/blob/orchestrator/src/race/orchestrator.ts">https://github.com/aukevanoost/native-federation-examples/blob/orchestrator/src/race/orchestrator.ts</a></li><li><strong>(Angular) remote examples: </strong><a href="https://github.com/Aukevanoost/native-federation-examples/blob/remotes/projects/events/src/app/app.component.ts">https://github.com/aukevanoost/native-federation-examples/blob/remotes/projects/events/src/app/app.component.ts</a></li><li><strong>Orchestrator:</strong> <a href="https://github.com/native-federation/orchestrator">https://github.com/native-federation/orchestrator</a></li></ul><p>With all of the formalities out of the way, let’s dig in!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*reIUXhlrezE0UTjP" /><figcaption>Photo by <a href="https://unsplash.com/@ballonandon?utm_source=medium&amp;utm_medium=referral">Ben Allan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Micro-frontend communication strategies</h3><p>Micro-frontends enable development teams to have their own playground where they can do whatever they want/need without any interference with the other parts/teams of the application. However, some parts of the mfe architecture (like guard rails) require to be coordinated centrally to avoid this interference and potential incompatibility between the micro-frontends. Luca researched and defined these decisions into four categories: <em>Definition, Composition, Routing </em>and<em> Communication </em>(Source: <a href="https://lucamezzalira.com/2019/12/22/micro-frontends-decisions-framework/">his article</a> and <a href="https://www.buildingmicrofrontends.com/book">book</a>). While the first 3 probably require another article (series), the fourth focuses on how micro-frontends should communicate with each other:</p><blockquote>… “When we decide to have multiple micro-frontends on the same page we need to decide how (and if) a micro-frontend should notify when an event or a user interaction happens for coordinating changes in other micro-frontends.” …<br> <em>- Luca Mezzalira</em></blockquote><p>Luca suggested the use of <a href="https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent">(custom) events</a> (which we used so far to notify the host that the orchestrator was done initializing) or an event-emitter library. Florian also mentioned the event emitters as a possibility for micro-frontend communication in <a href="https://microfrontends.art/">his book</a>, since they’re not strictly timed and the event emitter will not break if no listeners were registered. While custom events are browser native and work great! They do have their drawbacks which I will come back to in the “hands on” section.</p><h4>Proposed communication channel</h4><p>In this part of the series, I will introduce the default “event registry” (a pub-sub object) that is provided by the vanilla-native-federation library. It will be more than capable to send and receive events between the micro frontends (retroactively) without any dependency on a library or framework.</p><pre>&lt;script src=&quot;https://unpkg.com/@softarc/native-federation-orchestrator@4.0.0/quickstart.mjs&quot;&gt;&lt;/script&gt;</pre><h4>Using a custom library/approach</h4><p>The native-federation default event registry is meant for simple communication between micro frontends. When your setup requires more performance, extra (complex) behavior, or the use of a specific technique like <a href="https://rxjs.dev/">RxJs</a> or <a href="https://redux.js.org/">Redux</a>, it is recommended to go for a custom solution that also handles (event-based) asynchronous communication. it is recommended for the custom implementation to go for a lightweight solution that is easy to use. There are tons of them like <a href="https://github.com/antonisPanos/waiter-js?tab=readme-ov-file">waiter-js</a> or <a href="https://github.com/ai/nanoevents">nanoevents</a>.</p><h3>The practical part: Upgrading our orchestrator</h3><p>Let’s start with what we already know, the simple <a href="https://github.com/Aukevanoost/native-federation-examples/blob/orchestrator/src/simple/index.html">setup from Part II</a> where the orchestrator initializes native-federation. Whenever the orchestrator is done, it will send a custom event notifying the host that the remotes are ready to be loaded. But what if the orchestrator is finished before the host has any chance of registering the event listeners? Below is the initial situation:</p><pre>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Shell&lt;/title&gt;<br>    &lt;meta name=&quot;piral&quot; content=&quot;https://feed.piral.cloud/api/v1/native-federation/vnf&quot; /&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;mfe-simple&gt;&lt;/mfe-simple&gt;<br><br>    &lt;script type=&quot;esms-options&quot;&gt; { &quot;shimMode&quot;: true }&lt;/script&gt;<br><br>    &lt;!-- es-module-shim might cause some non-determinism here --&gt;<br>    &lt;script type=&quot;module-shim&quot;&gt;  <br>      window.addEventListener(<br>        &quot;mfe-loader-available&quot;,<br>        (e) =&gt; e.detail.loadRemoteModule(&quot;@tractor-store/simple&quot;, &quot;./bootstrap&quot;);,<br>        { once: true }<br>      );<br>    &lt;/script&gt;<br><br>    &lt;!-- even though the orchestrator is defined later, the order is not guaranteed --&gt;<br>    &lt;script src=&quot;./orchestrator.js&quot;&gt;&lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>As can be seen in the code snippet above, the &lt;script type=”module-shim”&gt; script is registering a listener to the “mfe-loader-available” event. Which is dispatched by the orchestrator:</p><pre>import &quot;es-module-shims&quot;;   // import for polyfills (resolves module-shim)<br><br>import { initFederation } from &quot;@softarc/native-federation-orchestrator&quot;;<br>import { useShimImportMap } from &quot;@softarc/native-federation-orchestrator/options&quot;;<br><br>(async () =&gt; {<br>  const feedServiceUrl = document.querySelector(`meta[name=&quot;piral&quot;]`)?.getAttribute(&quot;content&quot;)!;<br><br>  const { loadRemoteModule } = await initFederation(feedServiceUrl, {<br>    logLevel: &quot;debug&quot;,<br>    ...useShimImportMap({ shimMode: true }),<br>  } as NFOptions);<br><br>  // Dispatches the event<br>  window.dispatchEvent(<br>    new CustomEvent(&quot;mfe-loader-available&quot;, {<br>      detail: { loadRemoteModule }<br>    })<br>  );<br>})();</pre><h4>The ‘initialization’ race condition</h4><p>To resolve the “race condition”, it is good to first define the term. It might mean slightly different things in different languages, contexts and communities but in essence, it is a flaky bug that only occurs <em>sometimes </em>in distributed systems. The reason for this is usually 2 threads that manage the same shared memory or are dependent on each other. This could result in an timing issue where program 1 might wait for an action that program 2 has already performed! Thus potentially waiting forever (read a clearer explanation at <a href="https://link.springer.com/rwe/10.1007/978-0-387-09766-4_36">springer</a> as well).</p><p>In our case, it means that the possibility exists that the “mfe-loader-available” event was already dispatched by the orchestrator before the listeners were even registrered, causing the listeners to wait forever. Now how do we fix this? We could do this by guaranteeing that the listeners were registered before the orchestrator is done initializing. But how? The MDN docs show us that apparently there are multiple “script types” in HTML:</p><blockquote>Scripts without <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script#async">async</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script#defer">defer</a> or type=&quot;module&quot; attributes, as well as inline scripts without the type=&quot;module&quot; attribute, are fetched and executed immediately before the browser continues to parse the page.<br><em>- </em><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script#notes"><em>mdn docs</em></a></blockquote><p>As shown in the code snippet before, the non-determinism occurs on the type=&quot;module-shim&quot; attribute which is dependent on the <a href="https://www.npmjs.com/package/es-module-shims">es-module-shims</a> package. That could mean that, hypothetically, this issue could be solved by extracting the <a href="https://www.npmjs.com/package/es-module-shims">es-module-shims</a> package from the orchestrator. If we remove all the attributes as well, we can force the browser to download and process the es-module-shims package before processing the orchestrator. But this still doesn’t 100% guarantee the correct order of execution since the listeners are still type=”module”:</p><pre>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Shell&lt;/title&gt;<br>    &lt;meta name=&quot;piral&quot; content=&quot;https://feed.piral.cloud/api/v1/native-federation/vnf&quot; /&gt;<br>    <br>    &lt;script type=&quot;esms-options&quot;&gt;{&quot;shimMode&quot;: true }&lt;/script&gt;<br><br>    &lt;!-- forcing the browser to first load and process the shims library --&gt;<br>    &lt;script src=&quot;https://ga.jspm.io/npm:es-module-shims@2.6.2/dist/es-module-shims.js&quot;&gt;&lt;/script&gt;<br><br>    &lt;!-- Register subscription --&gt;<br>    &lt;script type=&quot;module-shim&quot;&gt;  <br>      window.addEventListener(<br>        &quot;mfe-loader-available&quot;,<br>        (e) =&gt; e.detail.loadRemoteModule(&quot;@tractor-store/simple&quot;, &quot;./bootstrap&quot;);,<br>        { once: true }<br>      );<br>    &lt;/script&gt;<br><br>    &lt;!-- Dispatches the event --&gt;<br>    &lt;script src=&quot;./orchestrator.js&quot;&gt;&lt;/script&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;mfe-events&gt;&lt;/mfe-events&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><h4>Using an event registry (which supports streaming)</h4><p>To completely resolve the issue and guarantee that the event won’t be missed, the vanilla-native-federation orchestrator provides a simple registry that allows registering (register and emit) and subscribing (onReady and on) to simple events:</p><pre>// import { NFEventRegistry } from &quot;@softarc/native-federation-orchestrator/registry&quot;;<br><br>// here&#39;s the contract you import <br>export type NFEventRegistry = {<br>  register&lt;T&gt;(type: string, resource: T | NFEventProvider&lt;T&gt;): Promise&lt;void&gt;;<br>  onReady&lt;T&gt;(type: string, callback: NFEventConsumer&lt;T&gt;): NFEventUnsubscribe;<br>  emit&lt;T&gt;(type: string, data: T): void;<br>  on&lt;T&gt;(type: string, callback: NFEventConsumer&lt;NFEventData&lt;T&gt;&gt;): NFEventUnsubscribe;<br>  clear(type?: string): void;<br>};<br><br>declare global {<br>  interface Window {<br>    __NF_REGISTRY__: NFEventRegistry;<br>  }<br>}</pre><p>The registry can easily be integrated by placing the script tag <strong>as early as possible</strong> in the HTML file. This even allows the orchestrator to be loaded asynchronously:</p><pre>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Shell&lt;/title&gt;<br>    &lt;meta name=&quot;piral&quot; content=&quot;https://feed.piral.cloud/api/v1/native-federation/vnf&quot; /&gt;<br>    <br>    &lt;!-- Event registry --&gt;<br>    &lt;script src=&quot;https://unpkg.com/vanilla-native-federation@1.0.0/init-registry.mjs&quot;&gt;&lt;/script&gt;<br><br>    &lt;script type=&quot;esms-options&quot;&gt;{ &quot;shimMode&quot;: true }&lt;/script&gt;<br><br>    &lt;!-- Register subscription --&gt;<br>    &lt;script type=&quot;module-shim&quot;&gt;<br>      window.__NF_REGISTRY__.onReady(&#39;orch.init-ready&#39;, ({ loadRemoteModule }) =&gt; {<br>        loadRemoteModule(&quot;@tractor-store/events&quot;, &quot;./bootstrap&quot;);<br>      });<br>    &lt;/script&gt;<br><br>    &lt;!-- Register event --&gt;<br>    &lt;script async src=&quot;./orchestrator.js&quot;&gt;&lt;/script&gt;  <br><br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;mfe-events&gt;&lt;/mfe-events&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>Instead of subscribing to an event, the module-shim scripts now subscribes to an eventHandler in the __NF_REGISTRY__ which can also retroactively resolve the promise. The “mfe-loader-available” event can easily be registered in the orchestrator after the init is finished:</p><pre>import &quot;es-module-shims&quot;;<br><br>import { initFederation } from &quot;@softarc/native-federation-orchestrator&quot;;<br>import { NFEventRegistry } from &quot;@softarc/native-federation-orchestrator/registry&quot;;<br>import {<br>  NFOptions,<br>  useShimImportMap,<br>  sessionStorageEntry,<br>} from &quot;@softarc/native-federation-orchestrator/options&quot;;<br><br>// Helps the orchestrator to assume the existence of the registry<br>declare global {<br>  interface Window {<br>    __NF_REGISTRY__: NFEventRegistry;<br>  }<br>}<br><br>(async () =&gt; {<br>  const feedServiceUrl = document.querySelector(`meta[name=&quot;piral&quot;]`)?.getAttribute(&quot;content&quot;)!;<br>  <br>  // Await initialization<br>  const { loadRemoteModule } = await initFederation(feedServiceUrl, {<br>    logLevel: &quot;debug&quot;,<br>    storage: sessionStorageEntry,<br>    ...useShimImportMap({ shimMode: true }),<br>  } as NFOptions);<br><br>  // old behavior<br>  // window.dispatchEvent(<br>  //   new CustomEvent(&quot;mfe-loader-available&quot;, {<br>  //     detail: { loadRemoteModule },<br>  //   })<br>  // );<br>    <br>  // New resource ready event dispatch in the central registry:<br>  if ((window as any).__NF_REGISTRY__ !== undefined) {<br>    ((window as any).__NF_REGISTRY__ as NFEventRegistry).register(&quot;orch.init-ready&quot;, {<br>      loadRemoteModule,<br>    });<br>  }<br>})();</pre><h4>Communication between micro frontends:</h4><p>To avoid the abovementioned race condition when building a robust micro frontends communication strategy, the same registry can be leveraged. Below is an example of an Angular component, but the registry is framework agnostic:</p><pre>import { Component, signal } from &#39;@angular/core&#39;;<br>import { NFEventRegistry } from &#39;@softarc/native-federation-orchestrator/registry&#39;;<br><br>declare global {<br>  interface Window {<br>    __NF_REGISTRY__: NFEventRegistry;<br>  }<br>}<br><br>@Component({<br>  selector: &#39;simple&#39;,<br>  imports: [],<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.scss&#39;],<br>})<br>export class AppComponent {<br>  title = signal(&#39;Events micro frontend&#39;);<br>  clickCount = signal(0);<br><br>  handleClick() {<br>    if (!window.__NF_REGISTRY__) {<br>      console.warn(&#39;__NF_REGISTRY__ is missing&#39;);<br>      return;<br>    }<br>    const count = this.clickCount() + 1;<br>    this.clickCount.set(count);<br><br>    // note that for events &quot;emit&quot; is used instead of register, <br>    // this should be paired with &quot;on&quot; instead of &quot;onReady&quot;.<br>    window.__NF_REGISTRY__.emit(&#39;events-mfe:clicked&#39;, {<br>      meta: { count },<br>      component: &#39;AppComponent&#39;,<br>    });<br>  }<br><br>  handleAction(action: string) {<br>    if (!window.__NF_REGISTRY__) {<br>      console.warn(&#39;__NF_REGISTRY__ is missing&#39;);<br>      return;<br>    }<br><br>    window.__NF_REGISTRY__.emit(&#39;events-mfe:request-action&#39;, {<br>      meta: { action },<br>      component: &#39;AppComponent&#39;,<br>    });<br>  }<br>}</pre><p>Other micro frontends can register to these events and act upon them. It is recommended to use a common pattern for the event-stream name like ‘&lt;micro-frontend&gt;:&lt;event-type&gt;’:</p><pre>declare global {<br>  interface Window {<br>    __NF_REGISTRY__: NFEventRegistry;<br>  }<br>}<br><br>let amountOfClicks = 0;<br>// on for events, onReady for resources<br>const unsubscribeA = window.__NF_REGISTRY__.on(&quot;events-mfe:clicked&quot;, (event) =&gt; {<br>  console.log(&quot;Event clicked:&quot;, event.data);<br>  amountOfClicks++;<br>  if (amountOfClicks === 3) {<br>    console.log(&quot;Received 3 clicks, unsubscribing from further &#39;clicked&#39; events.&quot;);<br>    unsubscribeA();<br>  }<br>});<br><br>const unsubscribeB = window.__NF_REGISTRY__.on(&quot;events-mfe:request-action&quot;, (event) =&gt; {<br>  console.log(&quot;An action needs to be performed!&quot;, event.data);<br>  // Handle event<br>});<br><br>// unsubscribeB(); // Call this to stop listening to request-action events</pre><h3>Summarizing</h3><p>This article showed the potential and drawbacks of the browser native ‘custom events’ and upgraded the orchestrator with a small vanilla js pubsub event registry. The event registry allowed the host, micro frontends and orchestrator to communicate with each other using events.</p><p>It is fine for lightweight use but on heavy use or when specific framework integration is necessary, it might make more sense to go for a custom solution. To keep it as decoupled and agnostic as possible, it would make sense to hook the “Event bus” to an easy accessible element like the Window object just like the __NF_REGISTRY__ in the <a href="https://github.com/native-federation/orchestrator">orchestrator</a> library.</p><h4>Read more</h4><p>There are loads of articles about (micro frontend) communication patterns, I listed a few down that I particularly liked:</p><ul><li><a href="https://medium.com/ifood-engineering/cross-micro-frontends-communication-dbca37802b60">https://medium.com/ifood-engineering/cross-micro-frontends-communication-dbca37802b60</a></li><li><a href="https://medium.com/@thorstensuckow/contracted-events-for-micro-frontend-communication-8e05769d9a74">https://medium.com/@thorstensuckow/contracted-events-for-micro-frontend-communication-8e05769d9a74</a></li><li><a href="https://martinfowler.com/articles/micro-frontends.html#Cross-applicationCommunication">https://martinfowler.com/articles/micro-frontends.html#Cross-applicationCommunication</a></li><li><a href="https://blog.bitsrc.io/communication-between-micro-frontends-67a745c6cfbe">https://blog.bitsrc.io/communication-between-micro-frontends-67a745c6cfbe</a></li></ul><p>You made it through the series! I hope you enjoyed this series and learned a thing or two. Come say hi or find more information about recent activities in the native-federation community in our new Github organization! <br><a href="https://github.com/orgs/native-federation/discussions">https://github.com/orgs/native-federation/discussions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f9282ecc727" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part III: Improving Cache Utilization in Native Federation]]></title>
            <link>https://medium.com/@auke997/part-iii-improving-cache-utilization-in-native-federation-1e4b696f3426?source=rss-e4d5267b0297------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e4b696f3426</guid>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[native-federation]]></category>
            <dc:creator><![CDATA[Aukevanoost]]></dc:creator>
            <pubDate>Sat, 30 Aug 2025 11:32:50 GMT</pubDate>
            <atom:updated>2026-04-15T09:41:45.733Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the third article in the series <em>“migrating a stateful monolith to micro frontend architecture using native federation”. </em>This article will explain how caching can be leveraged to optimize the load time of the host application and minimize the performance penalty of using micro frontends in a stateful SSR monolith.</p><p><em>Before we start, it is important to know that this also is a rather advanced article that shows how you can fine-tune native-federation to meet the requirements of your enterprise micro frontend architecture.</em></p><p>The other parts can be found below:</p><ul><li><a href="https://medium.com/@auke997/migrating-a-stateful-monolith-to-micro-frontends-using-native-federation-0572a1e181b4">Part I: Migrating a stateful monolith to micro frontend architecture using native federation.</a></li><li><a href="https://medium.com/@auke997/part-ii-composing-your-own-native-federation-orchestrator-7fac2d0ea62e">Part II: Composing your own native-federation orchestrator</a></li><li><a href="https://medium.com/@auke997/part-iv-robust-communication-between-micro-frontends-within-native-federation-5f9282ecc727">Part IV: Robust communication between micro frontends within native federation</a></li></ul><p>This article series is using the official <a href="https://github.com/native-federation/orchestrator">native federation</a> orchestrator, introduced in native-federation v4, but fully backwards compatible. The remotes also use the official <a href="https://www.npmjs.com/package/@softarc/native-federation">native-federation builder</a> to build. The code and examples can be found here:</p><ul><li><a href="https://github.com/Aukevanoost/native-federation-examples/tree/orchestrator"><strong>Orchestrators examples:</strong> https://github.com/Aukevanoost/native-federation-examples/tree/orchestrator</a></li><li><strong>(Angular) </strong><a href="https://github.com/Aukevanoost/native-federation-examples/tree/orchestrator"><strong>remotes examples:</strong> https://github.com/Aukevanoost/native-federation-examples/tree/remotes</a></li><li><strong>Orchestrator: </strong><a href="https://github.com/native-federation/orchestrator">https://github.com/native-federation/orchestrator</a></li></ul><p>In this article, the basic custom orchestrator from part II will be reused to show the caching potential of micro frontends but first, let’s go over some basic concepts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*loJgXXhCMFeS6Jk9" /><figcaption>Photo by <a href="https://unsplash.com/@arumvisuals?utm_source=medium&amp;utm_medium=referral">Arum Visuals</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>What are browser import-maps?</h4><p>As mentioned in Part I. The thing that makes native-federation stand out is the use of “import maps” (check also the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap">mdn docs</a>), a browser native feature that allows the browser to map <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules">ES module</a> imports (like import {of} from &quot;rxjs&quot;;) to a JavaScript file. Let’s start with an example that represent a small website with a couple of ES modules spread amongst two “shape” directories:</p><pre>📁 public/<br>├── 📄 index.html<br>├── 📄 index.js<br>└── 📁 modules/<br>    ├── 📁 shapes/<br>    │   ├── 📄 square.js<br>    │   └── 📄 circle.js<br>    └── 📁 other-shapes/<br>        └── 📄 circle.js</pre><p>In this example, the index.html contains an importmap that maps the following modules:</p><pre>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;script type=&quot;importmap&quot;&gt;<br>      {<br>        &quot;imports&quot;: {<br>          &quot;square&quot;: &quot;./modules/shapes/square.js&quot;,<br>          &quot;circle&quot;: &quot;./modules/shapes/circle.js&quot;<br>        },<br>        &quot;scopes&quot;: {<br>          &quot;./modules/shapes/&quot;: {<br>            &quot;circle&quot;: &quot;./modules/other-shapes/circle.js&quot;<br>          }<br>        }<br>      }<br>    &lt;/script&gt;<br>    &lt;script type=&quot;module&quot; src=&quot;./index.js&quot;&gt;&lt;/script&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;&lt;/body&gt;<br>&lt;/html&gt;</pre><p>The “scopes” property here is a pretty interesting feature here:</p><blockquote>“..You can use the scopes key to provide mappings that are only used if the script importing the module (the caller) contains a particular URL path…”<br>-<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap#scoped_module_specifier_maps"><em> Mdn docs</em></a></blockquote><p>So in our example, If the ./index.js file imports the square and circle module, it will import both files from the “shapes” directory. The reason is that the “imports” property in the importmap acts as the “global” scope. So it will map imports (like ‘square’) to physical (ESM) files (like ‘square.js’).</p><p>However, when I import the circle module <em>from the </em><em>square module</em>, the importmap will recognize that the <em>importer</em> (square in this case) is from a certain scope (the path to the folder in which the caller/importer resides, so “/modules/shapes/”). So instead of using the circle module from the “shapes” directory, it will use the circle module from the “other-shapes” directory.</p><p><strong><em>Important</em></strong><em>: We call this type of overriding “precedence”, and in CS language this rule would be called: “the specific scope mappings have precedence over the global “imports” mapping. The more specific the “scope”, the more precedence it has over other scopes or imports. <br></em><strong><em>Important:</em></strong><em> the key in the scope property refers to the path (partially or fully) of the direct caller/importer of the modules defined in the scope.</em></p><p>Now why is this good? this means you can create trees of module imports that operate completely separated from other module import trees. Like ./ng19/core.js will import ./ng19/http.js and ./ng20/core.js will only import ./ng20/http.js without the risk of version mismatch.</p><p>A downside to importmaps is, that only one version of a module can be imported at once. So we’ll have to leverage “scoping” tricks to allow multiple versions to be imported from a certain module like angular.</p><h4>The version resolver:</h4><p>The version resolver is an essential component of the <a href="https://github.com/native-federation/orchestrator">native-federation</a> orchestrator. A full explanation of the version resolver can be found in the <a href="https://github.com/native-federation/orchestrator/blob/main/docs/version-resolver.md">docs</a>. But in short, when native-federation retrieves the manifest, it will first download all the available remoteEntry.json metadata files. Then it will calculate for each shared external (a dependency to be imported like square or circle) which version leads to the least amount of downloads. Then it will put that version in the global scope, the rest of the incompatible versions will be put in their own scope to prevent compatibility issues.</p><p><strong>How does it determine the least amount of downloads? </strong><br>Every external in the remoteEntry.json contains a “version” and “requiredVersion”, whereas the requiredVersion is a <a href="https://semver.org/spec/v1.0.0.html">semver</a> range of versions that the specific remote is compatible with</p><p><em>for example: </em><em>{ version: &quot;21.1.2&quot;, requiredVersion: &quot;^21.1.0&quot;}.</em></p><p>If a version is put in the global scope, it only needs to be downloaded once and can then be reused by all modules that need it. Therefore, it will calculate for every version how many incompatible versions it needs to put in the “scopes” object, since these need to be downloaded separately. As tie breaker, it just takes the latest version.</p><p>There are a lot more if’s, but’s and maybies here, so for an in depth explanation, <a href="https://github.com/native-federation/orchestrator/blob/main/docs/version-resolver.md">check the docs</a>!</p><h4>Leveraging the cache</h4><p>When different micro frontends are loaded into an host that is <em>not an SPA</em>, every new page reroute will result in a new fresh “initFederation” call. Consequently, the subsequent page refreshes after routing from page to page, will result in the version resolver recalculating the shared externals over and over again, not to mention that if different pages use different manifests, there is a big chance that different versions are chosen on different pages. This leads to a lot of unnecessary downloads of JS files.</p><p>By default, the orchestrator’s cache uses the “globalThisStorage” which stores the dependencies in the DOM tree, you can find them when you type in “__NATIVE_FEDERATION__” in your console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HRcSs_oWQi_FKaZUC8k4lQ.png" /><figcaption>Cache shown in browser console</figcaption></figure><p>This type of caching is fine for SPA applications, but not for SSR host applications. Therefore, it is also possible to switch to sessionStorage, localStorage or even your own custom cache (see <a href="https://github.com/native-federation/orchestrator/blob/main/docs/config.md#-5-storageconfig">docs</a>):</p><pre>import &quot;es-module-shims&quot;;<br><br>import { initFederation } from &quot;@softarc/native-federation-orchestrator&quot;;<br>import {<br>  consoleLogger,<br>  NFOptions,<br>  sessionStorageEntry,<br>  useShimImportMap,<br>} from &quot;@softarc/native-federation-orchestrator/options&quot;;<br><br>(async () =&gt; {<br>  try {<br>    const feedServiceUrl = document.querySelector(`meta[name=&quot;piral&quot;]`)?.getAttribute(&quot;content&quot;)!;<br><br>    const options: NFOptions = {<br>      logLevel: &quot;debug&quot;,<br>      logger: consoleLogger,<br>      storage: sessionStorageEntry,          //  Switch to sessionStorage<br>      ...useShimImportMap({ shimMode: true }),<br>    };<br>    const { loadRemoteModule, initRemoteEntry } = await initFederation(feedServiceUrl, options);<br><br>    window.dispatchEvent(<br>      new CustomEvent(&quot;mfe-loader-available&quot;, {<br>        detail: {<br>          loadRemoteModule,<br>          initRemoteEntry,<br>        },<br>      }),<br>    );<br>  } catch (error) {<br>    console.error(&quot;Orchestrator initialization failed:&quot;, error);<br>  }<br>})();</pre><p>This forces the orchestrator to, <em>before initialization,</em> first retrieve the processed remotes from cache and determine which remotes are missing and which have already been processed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gu6owfioZKEByYBDpsuJUQ.png" /><figcaption>Remotes taken from cache after refresh</figcaption></figure><p>In the network tab below is visible that the JS files loaded from the previous page have been cached and reused to prevent redundant file downloads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rekBp_oPhOrR4kC-2PSR4w.png" /><figcaption>Network tab showing cached JS files</figcaption></figure><p>This feature can be pretty powerful when combined with an SSR host.</p><p><strong><em>Important:</em></strong><em> The importmap is created eagerly but the files are not yet downloaded. They will be downloaded and used whenever the module is loaded with</em><em> loadRemoteModule() .</em></p><h4>Eager vs Lazy loading</h4><p><em>So why generate the importmap eagerly?</em> Importmaps become immutable after the first import call from an ESM module or <em>&lt;script type=&quot;module&quot;&gt;</em> tag. Therefore, it is not possible to alter it after initialization. This means that during initialization, it is best to calculate the optimal import map (least downloads). Another problem with lazy initialization of the importmap, is that: <br><em>If eagerly loaded remote A requires version 1 of a dependency and lazy loaded remotes B and C require version 2 of that remote, it would have been better to globally import version 2. But since that information is not yet available. It might be “cheaper” to initially download and calculate all metadata in advance than to lazily initialize modules on the fly. </em><br>Therefore, the default behavior is to eagerly process the manifest at the first page load.</p><p><em>But that doesn’t mean that it is not possible!</em></p><p>After the initialization, the orchestrator exposes a lazy method that allows remoteEntry files to be initialized later on. <strong><em>Note: </em></strong><em>You might need to use the es-module-shims package (with shimMode: true) to bypass the immutable-import-map issue. This might be fixed in the future.</em></p><pre>import &quot;es-module-shims&quot;;<br><br>import { initFederation } from &quot;@softarc/native-federation-orchestrator&quot;;<br>import {<br>  consoleLogger,<br>  NFOptions,<br>  sessionStorageEntry,<br>  useShimImportMap,<br>} from &quot;@softarc/native-federation-orchestrator/options&quot;;<br><br>(async () =&gt; {<br>  try {<br>    const feedServiceUrl = document.querySelector(`meta[name=&quot;piral&quot;]`)?.getAttribute(&quot;content&quot;)!;<br><br>    const { <br>      loadRemoteModule, // fn: &lt;TModule = unknown&gt;(remoteName: string, exposedModule: string) =&gt; Promise&lt;TModule&gt;<br>      initRemoteEntry   // fn: (remoteEntryUrl: string, remoteName?: string) =&gt; Promise&lt;LazyInitFederationResult&gt;<br>    } = await initFederation(feedServiceUrl, {<br>      logLevel: &quot;debug&quot;,<br>      logger: consoleLogger,<br>      storage: sessionStorageEntry,<br>      ...useShimImportMap({ shimMode: true }),<br>    } as NFOptions);<br><br><br>    await initRemoteEntry(&quot;https://example.com/remoteEntry.json&quot;, &quot;@team/mfe&quot;);<br><br>    window.dispatchEvent(<br>      new CustomEvent(&quot;mfe-loader-available&quot;, {<br>        detail: {<br>          loadRemoteModule,<br>          initRemoteEntry,<br>        },<br>      })<br>    );<br>  } catch (error) {<br>    console.error(&quot;Orchestrator initialization failed:&quot;, error);<br>  }<br>})();</pre><p><strong>Good to know:</strong> As mentioned before, you need to use the es-module-shims package for the lazy initialization of remotes. Also, the lazy initialization has different rules than the regular initFederation. Since we want to preserve the existing importmap, we cannot alter the existing mapped imports during the initRemoteEntry. So it will only append another complementary import map with the changes. This means that if version 19 was chosen as the globally shared external and the lazily loaded module requires version 20, it is forced to scope the external. In other words, only new module mappings can be added.</p><h4>Tweaking the caching behavior</h4><p>Besides the storage used for caching, there are a couple of other “hyperparameters” that can be used to tweak the behavior of the orchestrator even further! (find the final <a href="https://github.com/Aukevanoost/native-federation-examples/blob/orchestrator/src/caching/orchestrator.ts">code here</a>)</p><pre>import &quot;es-module-shims&quot;;<br><br>import { initFederation } from &quot;vanilla-native-federation&quot;;<br>import {<br>  consoleLogger,<br>  NFOptions,<br>  sessionStorageEntry,<br>  useShimImportMap,<br>} from &quot;vanilla-native-federation/options&quot;;<br><br>(async () =&gt; {<br>  try {<br>    const feedServiceUrl = document.querySelector(`meta[name=&quot;piral&quot;]`)?.getAttribute(&quot;content&quot;)!;<br><br>    const { loadRemoteModule, initRemoteEntry } = await initFederation(feedServiceUrl, {<br>      logLevel: &quot;debug&quot;,<br>      logger: consoleLogger,<br>      profile: {                    // Optimizing to a caching profile<br>        latestSharedExternal: false,<br>        overrideCachedRemotes: &quot;init-only&quot;,<br>        overrideCachedRemotesIfURLMatches: true,<br>      },<br>      storage: sessionStorageEntry,<br>      ...useShimImportMap({ shimMode: true }),<br>    } as NFOptions);<br><br>    window.dispatchEvent(<br>      new CustomEvent(&quot;mfe-loader-available&quot;, {<br>        detail: {<br>          loadRemoteModule,<br>          initRemoteEntry,<br>        },<br>      })<br>    );<br>  } catch (error) {<br>    console.error(&quot;Orchestrator initialization failed:&quot;, error);<br>  }<br>})();</pre><p><strong>latestSharedExternal<br></strong>When this option is set to “false” (which is the default setting), the version resolver will choose the most compatible version (least downloads), but when changed to “true”, it will choose the latest version available as globally shared version. This ensures that the latest version is preferred but might result in more downloads.</p><p><strong>overrideCachedRemotes<br></strong>This option defines the behavior of the By default this setting is set to “init-only”. The idea behind this setting is that usually — <em>like with a discovery feed</em> — the version of the remote is present in the url of the remoteEntry.json in the manifest:</p><pre>{<br>  &quot;@tractor-store/config&quot;: &quot;https://assets.piral.cloud/pilets/vnf/@tractor-store/config/1.1.0/remoteEntry.json&quot;,<br>  &quot;@tractor-store/explore&quot;: &quot;https://assets.piral.cloud/pilets/vnf/@tractor-store/explore/1.0.0/remoteEntry.json&quot;,<br>  &quot;@tractor-store/simple&quot;: &quot;https://assets.piral.cloud/pilets/vnf/@tractor-store/simple/1.0.0/remoteEntry.json&quot;<br>}</pre><p>This is a good thing, the assumption is: <em>as long as the version didn’t change, the code and externals also didn’t change. </em>Therefore, the orchestrator can cache the exposed modules and externals of the remote until the url of the remote changes. Upon the next init, the orchestrator will compare the URLs and override the remotes if the url is different. The override process consists of 3 steps:</p><ol><li>Purge all cached metadata related to that specific remote</li><li>Mark all shared externals where the remote’s version was removed as ‘needs recalculation of shared version.’</li><li>Start the initialization as normal.</li></ol><p>This process causes a rewrite of the existing importmap when performed on a lazy-init after the main importmap was initialized, hence it is not possible/recommended with the lazy-init (so 2 lazy inits of the same remote in the same session). Therefore, by default this option is set to ‘init-only’. But it can be changed to ‘always’ or ‘never’. If the option is set to never, the cached remotes are always skipped instead of overridden.</p><p><strong>overrideCachedRemotesIfURLMatches<br></strong>This final option allows the override to be performed even if the remote’s URL matches the cached URL of the remoteEntry. For performance reasons this option is ‘false’ by default.</p><ul><li>More options can be found in the <a href="https://github.com/topicusonderwijs/vanilla-native-federation/blob/main/docs/config.md">docs</a>.</li></ul><p>So with the profile settings focussed on overriding, as shown in the code snippet above, the behavior of the orchestrator looks a bit different. The overrideCachedRemotes setting is now set to true, hence all remotes are overridden:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tlUk6ejq396vlt7IcetGzw.png" /><figcaption>Overriding cached remote entries</figcaption></figure><h4>Conclusion</h4><p>This article showed an in-depth view on how caching can be leveraged to minimize the amount of JS to be downloaded. This can help greatly when creating performant micro frontend architectures. Especially when combined with a (legacy) monolithic SSR host that requires full page refreshes when switching between routes/pages.</p><p>For further optimization, the federation.config.js in the remotes can be tweaked to choose specific externals to share globally or skip specific externals. Find more info about the different options can be found in the official native-federation <a href="https://www.npmjs.com/package/@softarc/native-federation">docs</a>, the <a href="https://medium.com/@auke997/tweaking-native-federation-e2d514366d08">tweaking-federation series</a>, as well as the (angular focussed) <a href="https://www.angulararchitects.io/en/blog/native-federation-just-got-better-performance-dx-and-simplicity/">article series</a> by Manfred Steyer.</p><p>But why stop here? The next and final part discusses further optimizations of the orchestrator and mfe communication patterns.</p><p><a href="https://medium.com/@auke997/part-iv-robust-communication-between-micro-frontends-within-native-federation-5f9282ecc727">Part IV: Robust communication between micro frontends within native federation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e4b696f3426" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part II: Composing your own native-federation orchestrator]]></title>
            <link>https://medium.com/@auke997/part-ii-composing-your-own-native-federation-orchestrator-7fac2d0ea62e?source=rss-e4d5267b0297------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fac2d0ea62e</guid>
            <category><![CDATA[native-federation]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <dc:creator><![CDATA[Aukevanoost]]></dc:creator>
            <pubDate>Sun, 24 Aug 2025 12:33:20 GMT</pubDate>
            <atom:updated>2026-04-15T08:20:34.834Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the second article in the series <em>“migrating a stateful monolith to micro frontend architecture using native federation”. </em>This article will explain the possibilities of the <a href="https://github.com/native-federation/orchestrator">native federation orchestrator </a>like adding logging or usage with a micro frontend discovery feed.</p><p><em>Before we start, it is important to know that this is rather advanced article that shows how you can fine-tune native-federation to meet the requirements of your enterprise micro frontend architecture. The other parts can be found below:</em></p><ul><li><a href="https://medium.com/@auke997/migrating-a-stateful-monolith-to-micro-frontends-using-native-federation-0572a1e181b4">Part I: Migrating a stateful monolith to micro frontend architecture using native federation.</a></li><li><a href="https://medium.com/@auke997/part-iii-improving-cache-utilization-in-native-federation-1e4b696f3426">Part III: Improving Cache Utilization in Native Federation</a></li><li><a href="https://medium.com/@auke997/part-iv-robust-communication-between-micro-frontends-within-native-federation-5f9282ecc727">Part IV: Robust communication between micro frontends within native federation</a></li></ul><h4>Recap, what is an orchestrator?</h4><p>An micro frontend orchestrator can be seen as some kind of power strip connected to your (monolithic) host application that allows micro frontends to be plugged and unplugged on demand (a.k.a. mounting). I’d like to think of mental models like “module federation” or “native federation” as the type of power plug you’re using. Like here in Europe, we are using the “type C europlug”. These federation types (or any other mental model) serve two major goals:</p><ol><li>Providing the ability to share dependencies (externals) over multiple micro frontends (remotes).</li><li>Provide a standardized uniform way of loading and mounting remote modules into a (host) web application.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hj6N_x-THrLlDYcrMfaKcA.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/@sash2s/">Саша Алалыкин</a></figcaption></figure><p>Since not all host/shell applications (read, web pages) have tools or JavaScript to support micro frontends out of the box, it is necessary to have a script that can act like an orchestrator for you. The mounting logic can be delegated to this script. All that the host needs to do is call the “initialize” function and the “loadRemoteModule” whenever the micro frontend is needed (lazy loading). There are a couple of orchestrators out there but this series focusses on the official native-federation orchestrator.</p><p>So first things first, the code and examples can be found here:</p><ul><li><a href="https://github.com/Aukevanoost/native-federation-examples/tree/orchestrator"><strong>Orchestrators:</strong> https://github.com/Aukevanoost/native-federation-examples/tree/orchestrator</a></li><li><strong>(Angular) </strong><a href="https://github.com/Aukevanoost/native-federation-examples/tree/orchestrator"><strong>remotes:</strong> https://github.com/Aukevanoost/native-federation-examples/tree/remotes</a></li><li><strong>the orchestrator: </strong><a href="https://github.com/native-federation/orchestrator">https://github.com/native-federation/orchestrator</a></li></ul><h4>What is a discovery feed?</h4><p>As briefly mentioned before, this article will be using a “feed service” to fetch the remotes from. A <em>micro frontend discovery feed</em> is a concept within the micro frontend community . It provides a way to store, expose, cache and distribute micro frontends so that they can easily be loaded into any web application. A nice article describing the Piral feed service which is used in this example can be found <a href="https://dev.to/florianrappl/micro-frontend-discovery-the-driver-for-scalability-oai">here</a>. For now, the inner workings of a feed mostly exceeds the scope of this article.</p><p><strong><em>Note</em></strong><em>: The discovery feed is used to host the micro frontends for convenience, a feed is not required for this setup. Alternatively, it is possible to host the remotes with a manifest.json somewhere that contains the names and locations of the available micro frontends.</em></p><h4>Using an orchestrator</h4><p>The previous article presented on a high level how the (<a href="https://github.com/native-federation/orchestrator/blob/main/src/quickstart.ts">quickstart</a>) native-federation orchestrator could be leveraged to load remotes into any HTML page. The example below shows that same code snippet but slightly modified to fetch the manifest from an external location (the feed):</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;My Application&lt;/title&gt;<br><br>    &lt;!-- 1. Define your micro frontends (remotes) --&gt;<br>    &lt;meta<br>      name=&quot;mfe-feed&quot;<br>      content=&quot;https://feed.piral.cloud/api/v1/native-federation/vnf&quot;<br>    /&gt;<br>    &lt;!-- 2. Handle loaded modules --&gt;<br>    &lt;script&gt;<br>      window.addEventListener(<br>        &quot;mfe-loader-available&quot;,<br>        (e) =&gt; {<br>          // Load your remote modules, a remote can have multiple modules<br>          e.detail.loadRemoteModule(&quot;@tractor-store/simple&quot;, &quot;./bootstrap&quot;);<br>        },<br>        { once: true }<br>      );<br>    &lt;/script&gt;<br><br>    &lt;!-- 3. Include the orchestrator runtime --&gt;<br>    &lt;script src=&quot;https://unpkg.com/@softarc/native-federation-orchestrator@4.0.0/quickstart.mjs&quot;&gt;&lt;/script&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;!-- 4. Use your loaded components --&gt;<br>    &lt;h1&gt;Micro frontend:&lt;/h1&gt;<br>    &lt;mfe-simple&gt;&lt;/mfe-simple&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>When opened in the browser, this will show a freshly mounted Angular micro frontend. While this is cool and all, we are barely scratching the surface here… The following sections will build up to a <em>custom orchestrator</em> that can:</p><ol><li>Inject custom logging implementations.</li><li>Pass environment variables to the remotes.</li><li>Use feature flags to load specific versions of the remote.</li></ol><h4>Creating a simple orchestrator</h4><p>Let’s start with a custom variant of the orchestrator. It will perform the same steps as the quickstart orchestrator, only it makes use of the <a href="https://github.com/guybedford/es-module-shims">es-module-shim</a> package to provide support for browsers that don’t understand import-maps.</p><p><strong><em>Note: </em></strong><em>The recommended way to use a custom orchestrator in your host application, is to treat it as a separate application and to place the source code of the orchestrator in a separate repository. Then it’s possible to host the minified dist of the orchestrator somewhere on a cdn or static file hosting. This way you can easily import the file just like the ‘quickstart’ variant.</em></p><p>The code snippet below illustrates a simple “orchestrator.js” and can also be found <a href="https://github.com/Aukevanoost/native-federation-examples/blob/orchestrator/src/simple/orchestrator.ts">here</a>:</p><pre>import &quot;es-module-shims&quot;;<br><br>import { initFederation } from &quot;@softarc/native-federation-orchestrator&quot;;<br>import { NFOptions, useShimImportMap } from &quot;@softarc/native-federation-orchestrator/options&quot;;<br><br>(async () =&gt; {<br>  try {<br>    // 1. Get url of manifest from html file<br>    const feedServiceUrl = document<br>      .querySelector(`meta[name=&quot;piral&quot;]`)<br>      ?.getAttribute(&quot;content&quot;)!;<br><br>    // 2. Initialize federation<br>    const { loadRemoteModule } = await initFederation( <br>      feedServiceUrl, <br>      {                                           // Configuration<br>        ...useShimImportMap({ shimMode: true }),    // Add legacy-browser support (for es-module-shims)<br>      } as NFOptions<br>    );<br><br>    // 3. Dispatch custom event when initialization is finished. <br>    window.dispatchEvent(<br>      new CustomEvent(&quot;mfe-loader-available&quot;, {<br>        detail: {<br>          loadRemoteModule,<br>        },<br>      })<br>    );<br>  } catch (error) {<br>    console.error(&quot;Orchestrator initialization failed:&quot;, error);<br>  }<br>})();</pre><p><strong>Adding custom logging</strong><br>Now that the base has been established, it is time to add some custom logging, the logger can easily be passed to the options next to the “useShimImportMap” option:</p><pre>   // [...] previous code<br><br>    const consoleLogger = {<br>      debug: (step: number, msg: string, _err?: any) =&gt; console.log(`[${step}]: ${msg}`),<br>      error: (step: number, msg: string, _err?: any) =&gt; console.error(`[${step}]: ${msg}`),<br>      warn: (step: number, msg: string, _err?: any) =&gt; console.warn(`[${step}]: ${msg}`),<br>    };<br>    // [...]<br>    const { loadRemoteModule } = await initFederation(feedServiceUrl, {<br>      logLevel: &quot;debug&quot;,<br>      logger: consoleLogger,  // the consoleLogger is also exported from &quot;@softarc/native-federation-orchestrator/options&quot;; <br>      ...useShimImportMap({ shimMode: true }),<br>    } as NFOptions)</pre><p>Now, what is the “step” argument you might ask? This is a convenient helper for debugging purposes. Currently, the “init” flow — <em>which is executed on ‘initFederation()’</em> — is divided into 6 steps:</p><ol><li>get-remote-entries (metadata files)</li><li>process-remote-entries</li><li>determine-shared-externals</li><li>generate-import-map</li><li>commit-changes (to a persistent browser cache)</li><li>expose-module-loader</li></ol><p>This way, it is easy to know at which step the error occurred, all changes made are stored in memory until persisted in step 5. So if anything goes wrong before step 5, the cache does not become corrupted.</p><p><strong>Passing environment variables<br></strong>Micro frontends might need to run in different environments, just like your host app! But how can you create remotes that are configurable at runtime? Our solution was to create a bootstrap/mount function that provides the environment variables from a central location. For now the config is determined by the host but this could come from the <a href="https://docs.piral.cloud/general/09-config-management">feed service</a> or another central API or service.</p><p>Let’s start by updating our `loadRemoteModule()` function. By creating a wrapper function in the orchestrator that receives the module loader and some environment variables, we can pass the environments to the remote by calling the exposed “bootstrap” function from the remote’s entrypoint (find the code <a href="https://github.com/Aukevanoost/native-federation-examples/blob/8a83a27e72fb737117e726ab2e46b76d16bdb0f1/src/config/orchestrator.ts#L34-L49">here</a>).</p><pre>function createBootstrapper(<br>  loadRemoteModule: LoadRemoteModule,<br>  remoteInfoRepo: ForRemoteInfoStorage,<br>  env: EnvironmentConfig,<br>): LoadRemoteModule {<br>  return async &lt;TModule = unknown&gt;(remoteName: string, exposedModule: string): Promise&lt;TModule&gt; =&gt; {<br>    const module = await loadRemoteModule&lt;BootstrapModule&gt;(remoteName, exposedModule);<br><br>    env.scopeUrl = (remoteInfoRepo.tryGet(remoteName) as Optional&lt;RemoteInfo&gt;)<br>      .map((info) =&gt; info.scopeUrl)<br>      .orElse(&quot;/&quot;);<br><br>    console.log(module);<br>    return module.bootstrap(env, loadRemoteModule) as TModule;<br>  };<br>}</pre><p>Great! We can use this bootstrapper to create our custom remote “mount” function. Since the orchestrator is built to be modular and allows access to its internal adapters and steps, the exposed ‘adapters’ object returned by initFederation allows access to all internal ‘handlers’:</p><pre>    const { loadRemoteModule, adapters } = await initFederation(feedServiceUrl, {<br>      logLevel: &quot;debug&quot;,<br>      logger: consoleLogger,<br>      ...useShimImportMap({ shimMode: true }),<br>    } as NFOptions);<br><br>    const bootstrapper = createBootstrapper(<br>      loadRemoteModule as LoadRemoteModule&lt;BootstrapModule&gt;,<br>      adapters.remoteInfoRepo,<br>      env<br>    );<br><br>    window.dispatchEvent(<br>      new CustomEvent(&quot;mfe-loader-available&quot;, {<br>        detail: {<br>          mount: bootstrapper,<br>        },<br>      })<br>    );</pre><p>Now —<em> if we store our environment variables in localStorage</em> — We can use the environment variables as basis for our initFederation! This allows us to fetch the remote’s version based on configuration settings like the provided tag (latest or next).</p><p>This change in the orchestrator allows for mounting remotes that can behave differently based on the environment they are loaded in. The full implementation can be found below or at the <a href="https://github.com/Aukevanoost/native-federation-examples/blob/orchestrator/src/config/orchestrator.ts">repo</a>. (complementary code for the remotes can be found <a href="https://github.com/Aukevanoost/native-federation-examples/blob/remotes/projects/config/src/bootstrap.ts">here</a>).</p><pre>import &quot;es-module-shims&quot;;<br><br>import { initFederation, LoadRemoteModule } from &quot;@softarc/native-federation-orchestrator&quot;;<br>import {<br>  NFOptions,<br>  Logger,<br>  useShimImportMap,<br>} from &quot;@softarc/native-federation-orchestrator/options&quot;;<br>import {<br>  ForRemoteInfoStorage,<br>  Optional,<br>  RemoteInfo,<br>} from &quot;@softarc/native-federation-orchestrator/sdk&quot;;<br><br>export interface BootstrapModule {<br>  bootstrap: (config: Record&lt;string, any&gt;, loadRemoteModule: LoadRemoteModule) =&gt; unknown;<br>}<br><br>/**<br> * Configuration interface for the micro frontend environment.<br> * This configuration can be cached and used to customize behavior.<br> */<br>export interface EnvironmentConfig {<br>  production?: boolean;<br>  domain?: string; // The url of the current domain (host/shell)<br>  scopeUrl?: string; // Base URL for micro frontends<br>  tag?: string; // latest or next?<br>}<br><br>/**<br> * Creates a bootstrapper function for a micro frontend<br> * module that includes environment configuration.<br> */<br>function createBootstrapper(<br>  loadRemoteModule: LoadRemoteModule,<br>  remoteInfoRepo: ForRemoteInfoStorage,<br>  env: EnvironmentConfig,<br>): LoadRemoteModule {<br>  return async &lt;TModule = unknown&gt;(remoteName: string, exposedModule: string): Promise&lt;TModule&gt; =&gt; {<br>    const module = await loadRemoteModule&lt;BootstrapModule&gt;(remoteName, exposedModule);<br><br>    env.scopeUrl = (remoteInfoRepo.tryGet(remoteName) as Optional&lt;RemoteInfo&gt;)<br>      .map((info) =&gt; info.scopeUrl)<br>      .orElse(&quot;/&quot;);<br><br>    console.log(module);<br>    return module.bootstrap(env, loadRemoteModule) as TModule;<br>  };<br>}<br><br>/**<br> * Retrieves the cached environment configuration from local storage.<br> * (Conveniently sets the default values if not present)<br> */<br>function getCachedEnvironmentConfig(): EnvironmentConfig {<br>  const configString = localStorage.getItem(&quot;__NATIVE_FEDERATION__.settings&quot;);<br><br>  if (!configString) {<br>    const configString = JSON.stringify({<br>      tag: &quot;latest&quot;,<br>      domain: &quot;https://localhost:4201&quot;,<br>      production: false,<br>    });<br>    localStorage.setItem(&quot;__NATIVE_FEDERATION__.settings&quot;, configString);<br>  }<br><br>  return JSON.parse(configString!);<br>}<br><br>/**<br> * An IIFE that auto-executes the orchestrator when the file is imported.<br> */<br>(async () =&gt; {<br>  let feedServiceUrl = document.querySelector(`meta[name=&quot;piral&quot;]`)?.getAttribute(&quot;content&quot;)!;<br>  const env = getCachedEnvironmentConfig();<br>  if (env.tag) feedServiceUrl += &quot;?tag=&quot; + env.tag;<br><br>  /**<br>   * A custom logger<br>   */<br>  const consoleLogger: Logger = {<br>    debug: (step: number, msg: string, _err?: any) =&gt; console.log(`[${step}]: ${msg}`),<br>    error: (step: number, msg: string, _err?: any) =&gt; console.error(`[${step}]: ${msg}`),<br>    warn: (step: number, msg: string, _err?: any) =&gt; console.warn(`[${step}]: ${msg}`),<br>  };<br><br>  const { loadRemoteModule, adapters } = await initFederation(feedServiceUrl, {<br>    logLevel: &quot;debug&quot;,<br>    logger: consoleLogger,<br>    ...useShimImportMap({ shimMode: true }),<br>  } as NFOptions);<br><br>  const bootstrapper = createBootstrapper(loadRemoteModule, adapters.remoteInfoRepo, env);<br><br>  window.dispatchEvent(<br>    new CustomEvent(&quot;mfe-loader-available&quot;, {<br>      detail: {<br>        mount: bootstrapper,<br>      },<br>    }),<br>  );<br>})();</pre><p><strong><em>Note: </em></strong><em>Although this example is reusing the environment variables at multiple remotes, usually it is recommended to have different environment variables (like API urls and the “scopeUrl”) per remote.</em></p><p>This does mean the index.html also needs to be adjusted slightly:</p><pre>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Shell&lt;/title&gt;<br>    &lt;meta name=&quot;piral&quot; content=&quot;https://feed.piral.cloud/api/v1/native-federation/vnf&quot; /&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;./style.css&quot; /&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;h1&gt;Micro frontend:&lt;/h1&gt;<br>    &lt;mfe-config&gt;&lt;/mfe-config&gt;<br><br>    &lt;script type=&quot;esms-options&quot;&gt;<br>      { &quot;shimMode&quot;: true }<br>    &lt;/script&gt;<br><br>    &lt;script type=&quot;module-shim&quot;&gt;<br>      window.addEventListener(<br>        &quot;mfe-loader-available&quot;,<br>        (e) =&gt; {<br>          // Mounting the remote modules:<br>          e.detail.mount(&quot;@tractor-store/config&quot;, &quot;./bootstrap&quot;);<br>        },<br>        { once: true }<br>      );<br>    &lt;/script&gt;<br><br>    &lt;!-- Url to your orchestrator --&gt;<br>    &lt;script src=&quot;./config/orchestrator.js&quot;&gt;&lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>When this orchestrator is served, you’ll see that the remote entry is loaded from the Piral feed based on which tag was selected (enabling feature flags). You can see the difference by checking the “tag” and “scopeUrl” properties. 1.1.0 being the latest version and 1.2.0 the next version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*av3S5cM7K8m5i7CqcqUANQ.png" /><figcaption>Screenshot from the ‘config’ orchestrator after running ‘npm run start’</figcaption></figure><h4>Conclusion</h4><p>This article walked you through the possibilities of fine-tuning native-federation to your own environment and likings. The created custom orchestrator allowed remotes to be fetched from any remote location and allowed environment variables to be passed on from the host application. Of course, there are a lot more options to tweak and optimize the orchestrator, a full list can be found at the docs:</p><p><a href="https://github.com/topicusonderwijs/vanilla-native-federation/blob/main/docs/config.md">vanilla-native-federation/docs/config.md at main · topicusonderwijs/vanilla-native-federation</a></p><p>The next part will cover caching optimization. What would you like to know?</p><p><a href="https://medium.com/@auke997/part-iii-improving-cache-utilization-in-native-federation-1e4b696f3426">Part III: Improving Cache Utilization in Native Federation</a></p><p>See you there…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fac2d0ea62e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating a stateful monolith to micro frontends using native federation.]]></title>
            <link>https://medium.com/@auke997/migrating-a-stateful-monolith-to-micro-frontends-using-native-federation-0572a1e181b4?source=rss-e4d5267b0297------2</link>
            <guid isPermaLink="false">https://medium.com/p/0572a1e181b4</guid>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[native-federation]]></category>
            <dc:creator><![CDATA[Aukevanoost]]></dc:creator>
            <pubDate>Sun, 10 Aug 2025 15:14:44 GMT</pubDate>
            <atom:updated>2026-04-15T06:24:04.874Z</atom:updated>
            <content:encoded><![CDATA[<h3>Part I: Migrating a stateful monolith to micro frontend architecture using native federation.</h3><p>It seems like everyone is talking about it nowadays, micro frontends is the notion of breaking a big application — <em>usually a Single Page Application</em> — into multiple smaller applications. Only, what if you don’t have a SPA? What if you’re stuck with a Stateful monolith like Java Servlet Pages (JSP), PHP, or Rails? How do you start? What do you need? In this series, I will walk you through a solution of how the strangler Fig pattern (see <a href="https://martinfowler.com/bliki/StranglerFigApplication.html">Martin Fowler’s article</a>) combined with <a href="https://www.npmjs.com/package/@angular-architects/native-federation">native federation</a> can be leveraged to overcome the differences between a stateful monolith and stateless micro frontends.</p><p>This article will get you familiar with the concepts and issues regarding using native-federation in a stateful monolith. If you’re new to the concept of “native-federation”, I highly recommend reading the article of <a href="https://blog.angular.dev/micro-frontends-with-angular-and-native-federation-7623cfc5f413">Manfred Steyer</a> (the inventor of native-federation) about micro frontends using native-federation to get up-to-speed on what it is and how to use it! While the examples are mostly using the Angular framework, native federation is not limited to the Angular framework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q44zeA57Zoge-nmd" /><figcaption>Photo by <a href="https://unsplash.com/@d_mccullough?utm_source=medium&amp;utm_medium=referral">Daniel McCullough</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>What do micro frontends need?<br></strong>Usually, a micro frontend architecture consists of 2 basic components:</p><ol><li>The application that loads the micro frontends.</li><li>At least one micro frontend.</li></ol><p>Conveniently, these are called host and remote respectfully. However, usually the host takes care of the integration (also known as orchestration) of micro frontends, this is where it gets a bit complex with a non-JavaScript host since there is by default no JavaScript to support the orchestration. That is where the <strong>orchestrator</strong> comes into play! The orchestrator is depicted as “vanilla-native-federation.js” in the diagram below:</p><figure><img alt="Sequence diagram of how native-federation works" src="https://cdn-images-1.medium.com/max/731/1*emrSFkIsg6bOy0YL33Ijdg.png" /><figcaption>Sequence diagram of how native-federation works</figcaption></figure><p>The diagram might look a bit chaotic but it shows the basic steps that are performed in native federation:</p><ol><li>Fetch a manifest.json</li><li>Fetch the “remoteEntry.json” metadata files.</li><li>Fetch the remote’s (MFE) JavaScript files.</li></ol><p>Now why would we do this instead of directly loading SPA applications in our monolith? The short answer is “it’s more efficient”. Native-federation has only one goal: “<em>damage control”</em>. When you load multiple JavaScript applications in a single webpage, there is a lot of overhead (Even with treeshaking). Native-federation tries to prevent this by bundling dependencies (external node modules) as separate bundles so they can be imported by multiple micro frontends.</p><p><strong>Now native-federation works</strong><br>Let’s break down the 3 native federation steps! This first part assumes the presence of a CDN with already prepared native-federation remotes (micro frontends). The folder structure can be seen below:</p><pre>📁 public/<br>├── 📄 manifest.json<br>├── 📁 mfe1/<br>│   ├── 📄 remoteEntry.json<br>│   ├── 📄 button.js<br>│   ├── 📄 dep-a.js<br>│   └── 📄 dep-b.js<br>└── 📁 mfe2/<br>    ├── 📄 remoteEntry.json<br>    ├── 📄 module-b.js<br>    ├── 📄 module-c.js<br>    ├── 📄 dep-b.js<br>    └── 📄 dep-c.js</pre><p>First of all, what is this manifest? It is a small JSON file that tells us which remotes are available and where to find them:</p><pre>{<br>  &quot;team/mfe1&quot;: &quot;http://my-cdn.com/mfe1/remoteEntry.json&quot;,<br>  &quot;team/mfe2&quot;: &quot;http://my-cdn.com/mfe2/remoteEntry.json&quot;<br>}</pre><p>This way, the orchestrator knows the presence of these 2 micro frontends and where to find them! The next step will be to fetch the remoteEntry JSON files which include the following format:</p><pre>{<br>  &quot;name&quot;: &quot;team/mfe1&quot;,<br>  &quot;exposes&quot;: [<br>    {<br>      &quot;key&quot;: &quot;./Button&quot;,<br>      &quot;outFileName&quot;: &quot;button.js&quot;<br>    }<br>  ],<br>  &quot;shared&quot;: [<br>    {<br>      &quot;packageName&quot;: &quot;dep-a&quot;,<br>      &quot;outFileName&quot;: &quot;dep-a.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~2.1.0&quot;,<br>      &quot;singleton&quot;: false,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;2.1.1&quot;<br>    },<br>    {<br>      &quot;packageName&quot;: &quot;dep-b&quot;,<br>      &quot;outFileName&quot;: &quot;dep-b.js&quot;,<br>      &quot;requiredVersion&quot;: &quot;~2.1.0&quot;,<br>      &quot;singleton&quot;: true,<br>      &quot;strictVersion&quot;: true,<br>      &quot;version&quot;: &quot;2.1.2&quot;<br>    }<br>  ]<br>}</pre><p>The<strong> remoteEntry.json</strong> is very important! It can be seen as the <em>metadata</em> file of the micro frontend. As can be seen in the JSON file, a remote can expose multiple ES modules (in the exposes array), as well as multiple external dependencies used by these exposed modules (in the shared array).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OjhcxpnkafLSLuQBHfnb7Q.jpeg" /><figcaption>Native federation domain</figcaption></figure><p><em>In native-federation terminology, the shared modules are called “exposed modules” or “remote modules” and the dependencies are called “externals”.</em></p><p>Native-federation provides a couple of properties with the externals in the remoteEntry.json (in the ‘shared’ array). A full description of the following options can be found at the <a href="https://github.com/native-federation/native-federation-core">official native federation repository</a> but the properties configure the following:</p><ul><li><strong>requiredVersion:</strong> The acceptable range of versions that this remote is compatible with.</li><li><strong>singleton:</strong> Should the orchestrator share this external with other remotes or use it only for this remote?</li><li><strong>strictVersion:</strong> Does the remote accept versions of this external that are outside of the accepted range (requiredVersion).</li><li><strong>version:</strong> The version of the external.</li><li><strong>shareScope: </strong>Do you want to share this for only a certain scope or group of micro frontends, like “ng21” for all Angular 21 micro frontends.</li></ul><p>The orchestrator uses these properties to determine which dependencies can be reused among multiple remotes to save precious resources. Note that in the remoteEntry.json, only the filenames of the shared externals are mentioned. That is because the location (folder) of the remoteEntry.json metadata file marks the “scope” of a remote. In this case the scope is “http://my-cdn.com/mfe1/” and all files defined in the remoteEntry.json are imported from that specific path.</p><h4><strong>Integrating the orchestrator in your monolith</strong></h4><p><em>This article series is using the official v4 </em><a href="https://github.com/native-federation/orchestrator"><em>orchestrator</em></a><em>. Not the current classic runtime. The difference is that the classic runtime, which is installed by default, doesn’t support version ranges when sharing dependencies. While the v4 orchestrator is already stable, the rest of v4 is still in beta, read all about it in </em><a href="https://github.com/orgs/native-federation/discussions/16"><em>the announcement</em></a><em>!</em></p><p>Let’s see some code. The following snippet shows how the <a href="https://github.com/native-federation/orchestrator">orchestrator</a> runtime can be leveraged to load micro frontends into any HTML page with minimal effort.</p><p><em>It is worth noting that for (enterprise) production environments, it is better to host your own custom variant of the vnf orchestrator. This allows you to implement custom logic like logging and caching.</em></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;My Application&lt;/title&gt;<br><br>    &lt;!-- 1. Define your micro frontends (remotes) --&gt;<br>    &lt;script type=&quot;application/json&quot; id=&quot;mfe-manifest&quot;&gt;<br>      {<br>        &quot;team/mfe1&quot;: &quot;http://my-cdn.com/mfe1/remoteEntry.json&quot;,<br>        &quot;team/mfe2&quot;: &quot;http://my-cdn.com/mfe2/remoteEntry.json&quot;<br>      }<br>    &lt;/script&gt;<br><br>    &lt;!-- 2. Handle loaded modules --&gt;<br>    &lt;script&gt;<br>      window.addEventListener(<br>        &#39;mfe-loader-available&#39;,<br>        e =&gt; {<br>          // Load your remote modules, a remote can have multiple modules<br>          e.detail.loadRemoteModule(&#39;team/mfe1&#39;, &#39;./Button&#39;);<br>        },<br>        { once: true }<br>      );<br>    &lt;/script&gt;<br><br>    &lt;!-- 3. Include the orchestrator runtime --&gt;<br>    &lt;script src=&quot;https://unpkg.com/@softarc/native-federation-orchestrator@4.0.0/quickstart.mjs&quot;&gt;&lt;/script&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;!-- 4. Use your loaded components --&gt;<br>    &lt;my-button&gt;Click me!&lt;/my-button&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>So what is happening here? First of all, we can assume that the “./Button” component exposed by the “team/mfe1” remote is a<a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements"> custom element</a>. 6</p><ol><li><strong>Defining the manifest:</strong> For convenience it is placed directly into the HTML file but it can of course also be fetched from a remote location.</li><li><strong>Handling the loaded modules:</strong> Once the orchestrator is done initializing the page (that is, calculating which dependencies are shared with which remotes and registering the JS files to be imported), it sends a custom event called “mfe-loader-available” to the window object. The event listener shown in the code snippet awaits the event and uses the “loadRemoteModule” function provided in the event to load the button module as soon as the orchestrator is done initializing.</li><li><strong>Importing the orchestrator:</strong> This step is placed below the eventListener on purpose to avoid the event being send before the listener was attached. It uses the <a href="https://github.com/native-federation/orchestrator/blob/main/src/quickstart.ts">quickstart</a> variant of the native-federation v4 orchestrator which is readily available for testing and demo purposes.</li><li><strong>Using the custom element: </strong>The HTML tag can be placed at the location where the remote is supposed to be rendered in the DOM tree. As soon as the custom element is registered, it is rendered in the webpage.</li></ol><p>An example of a vanilla JS custom element can be seen below:</p><pre>// Importing dependencies<br>import * from &#39;dep-a&#39;;<br>import * from &#39;dep-b&#39;;<br><br>// Custom element<br>(function() {<br>  class MfeButton extends HTMLElement {<br>    connectedCallback() {<br>      this.innerHTML = `<br>        &lt;style&gt;<br>          button {<br>            padding: 8px 16px;<br>            border: none;<br>            border-radius: 4px;<br>            background: #007bff;<br>            color: white;<br>            cursor: pointer;<br>            font-size: 14px;<br>          }<br>          button:hover { background: #0056b3; }<br>        &lt;/style&gt;<br>        &lt;button onclick=&quot;this.dispatchEvent(new CustomEvent(&#39;click&#39;, {bubbles: true}))&quot;&gt;<br>          ${this.textContent}<br>        &lt;/button&gt;<br>      `;<br>    }<br>  }<br><br>  customElements.define(&#39;my-button&#39;, MfeButton);<br>})();</pre><p><strong>Final words<br></strong>This article showed how an orchestrator can be leveraged in combination with native federation to load micro frontends into any HTML page regardless of how this page is composed or rendered on the server. The micro frontends are orchestrated and loaded client-side to provide minimal interference with the host application. To maintain this minimal interference with the host/shell application, it is recommended to use <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components">webcomponents</a> which include the abovementioned custom elements and shadowDOM API’s.</p><p>Now that the foundation is set, the coming articles will dive deeper into the different topics regarding loading micro frontends into stateful monoliths. like caching, the orchestrator under the hood, concrete examples and potential optimizations. You can check the other parts here!</p><ul><li><a href="https://medium.com/@auke997/part-ii-composing-your-own-native-federation-orchestrator-7fac2d0ea62e">Part II: Composing your own native-federation orchestrator</a></li><li><a href="https://medium.com/@auke997/part-iii-improving-cache-utilization-in-native-federation-1e4b696f3426">Part III: Improving Cache Utilization in Native Federation</a></li><li><a href="https://medium.com/@auke997/part-iv-robust-communication-between-micro-frontends-within-native-federation-5f9282ecc727">Part IV: Robust communication between micro frontends within native federation</a></li></ul><p>What would you like to know?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0572a1e181b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>