<?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 Namdeo Karande on Medium]]></title>
        <description><![CDATA[Stories by Namdeo Karande on Medium]]></description>
        <link>https://medium.com/@namdeokarande?source=rss-cdef68699efd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*u4nr32Yc45v90iqGj9et9w.jpeg</url>
            <title>Stories by Namdeo Karande on Medium</title>
            <link>https://medium.com/@namdeokarande?source=rss-cdef68699efd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:08:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@namdeokarande/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[Micro FrontEnd Application using Angular & React]]></title>
            <link>https://medium.com/@namdeokarande/micro-frontend-application-using-angular-react-876aabd22c69?source=rss-cdef68699efd------2</link>
            <guid isPermaLink="false">https://medium.com/p/876aabd22c69</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Namdeo Karande]]></dc:creator>
            <pubDate>Thu, 12 Dec 2019 12:28:42 GMT</pubDate>
            <atom:updated>2019-12-12T12:28:42.104Z</atom:updated>
            <content:encoded><![CDATA[<p>There has been a rise in various frontend concepts such as accessibility, performance, consistency, security, architecture and user experience, and as such is not just HTML &amp; CSS anymore.</p><p>There is a new term “Micro Frontend” which is said to be inspired by microservices. We can say it is a design approach in which application consists of individual/independent components micro-apps working together. So each application can be of different technology be it React, Angular or Vue which can be easily integrated into a single app.</p><p><strong>Let’s build a Micro-App</strong></p><p>We will build a parent application which will be in angular and two other micro applications(web component) in angular and react respectively. We will have communication with a parent to child components, child to parent &amp; child to child (Angular to React) via parent.</p><p>Our approach will be to use web components which you can read more about here: <a href="https://developer.mozilla.org/en-US/docs/Web/Web_Components">https://developer.mozilla.org/en-US/docs/Web/Web_Components</a>.</p><p>So our end application will look like this -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7SfI5JnN2GN8MtDhCy7v8g.png" /><figcaption>micro-application</figcaption></figure><p>We will need to add a few dependencies to build and run custom elements in angular application.</p><p><strong>Parent app(Angular)</strong></p><p>Create an app as <strong>micro-app</strong> and add dependencies -</p><blockquote>Include CUSTOM_ELEMENTS_SCHEMA in app.module.ts<br> <a href="https://angular.io/api/core/CUSTOM_ELEMENTS_SCHEMA">https://angular.io/api/core/CUSTOM_ELEMENTS_SCHEMA</a></blockquote><p>Add the following content in your app.module.ts file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20203c922e60e746da720d75814d38a8/href">https://medium.com/media/20203c922e60e746da720d75814d38a8/href</a></iframe><p>Add the following content in your app.component.ts file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb5e5e7a4a0ee76616726a4dba97e6d8/href">https://medium.com/media/eb5e5e7a4a0ee76616726a4dba97e6d8/href</a></iframe><p>Add the following content in your app.component.html file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5884d0d0589904bd3c91333a031838c2/href">https://medium.com/media/5884d0d0589904bd3c91333a031838c2/href</a></iframe><p>Include three references(zone.js, customelement.js, es5-adapter.js) in the index.html for angular to detect the changes and to make custom element work. <br>Used bootstrap-4 references for UI components.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f40a284874761a9775d02915747ecce/href">https://medium.com/media/6f40a284874761a9775d02915747ecce/href</a></iframe><p><strong>Angular App(Component 1)</strong></p><p>Add the following dependencies:</p><pre>ng add ngx-build-plus - is a build tool for angular CLI.<br>ng add <a href="http://twitter.com/angular/elements">@angular/elements</a> - provides support for angular elements.<br>npm i -g http-server - save to serve dist folder.</pre><p>Let’s create content which will have an increment button to communicate with parent app &amp; a toggle button to communicate with the react component.</p><p>This angular part of the application will look like this -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*EgUaGil_CAW85CwfL9VdQA.png" /><figcaption>Angular component</figcaption></figure><p>Add the following content in your app.component.ts file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a1176eb7ea37225b037df94e32c3a00/href">https://medium.com/media/5a1176eb7ea37225b037df94e32c3a00/href</a></iframe><p>Add the following content in your app.component.html file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f124bdba046d85a789ae3dea25677d45/href">https://medium.com/media/f124bdba046d85a789ae3dea25677d45/href</a></iframe><p>Add the following content in your app.module.ts to expose our app as a custom element. Notice here, that we have added <strong>AppComponent</strong> inside the “<strong>entryComponents</strong>” array instead of the “<strong>bootstrap</strong>” array, where we generally put in the first component which gets initialized at the time of application launch.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36254f27ab99e894b16302e799dfa803/href">https://medium.com/media/36254f27ab99e894b16302e799dfa803/href</a></iframe><p>Let’s deploy and build the project in a single JS file</p><pre>ng build --prod --output-hashing none --single-bundle true<br>http-server ./dist/angular-app -p 5001</pre><p>After the above step, in case you face the following error:<br>“<em>Data path “.budgets[1].type” should be equal to one of the allowed value”<br></em>just remove/comment this part from angular.json file-</p><pre>{<br>  “type”: “anyComponentStyle”,<br>  “maximumWarning”: “6kb”,<br>  “maximumError”: “10kb”<br>}</pre><p><strong>React App(Component 2)</strong></p><p>Create a react app as <strong>react-app </strong>and eject it to get configuration control to build the project into a single file.</p><p>It has increment button to communicate with parent app and content will look like this -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*Am84PxHLI5dvNJWPXO2INg.png" /></figure><pre>npx create-react-app react-app<br>npm run eject</pre><p>React doesn’t support custom element as angular do so we will need to use HTML Element, which has lifecycle callbacks.</p><p>Add a custom element to the index.js file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c70400c04b78b6ebf03c335eeccb4d3a/href">https://medium.com/media/c70400c04b78b6ebf03c335eeccb4d3a/href</a></iframe><p>Add the following in the app.js file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78205a016f6ce3003f3e5bdded0e1279/href">https://medium.com/media/78205a016f6ce3003f3e5bdded0e1279/href</a></iframe><p>To build it in single js file we have to modify the webpack.config.js or we can use another approach to build single js file:</p><pre>removed - <em>[contenthas:8]</em><br>modified -<br><em>splitChunks: cacheGroups: {<br>  default: false<br>}<br>runtimeChunk: false</em></pre><p>deploy</p><pre>npm run-script build<br>serve -s build</pre><p>Now add the bundled files reference in parent app’s index.html &amp; run the app</p><pre>&lt;script type=&quot;text/javascript&quot; src=&quot;http://localhost:5001/main-es5.js&quot;&gt;&lt;/script&gt;</pre><pre>&lt;script type=&quot;text/javascript&quot; src=&quot;http://localhost:5000/static/js/main.js&quot;&gt;&lt;/script&gt;</pre><p>To deploy</p><pre>ng serve</pre><p>You will see the application running where we have implemented<br>1. Parent to Child — Dropdown filter event from parent app to a child app to react, angular component respectively.<br>2. Child to Parent — Increment counter button event will be calling parent function.<br>3. Angular to React communication(through parent) via a toggle button event.</p><p>You can find source code <a href="https://github.com/namdeok/micro-frontend">here</a> .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=876aabd22c69" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>