<?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 Vishnu Thankappan on Medium]]></title>
        <description><![CDATA[Stories by Vishnu Thankappan on Medium]]></description>
        <link>https://medium.com/@vishnuthankappan?source=rss-d525bc51a5b4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*04GK9eV9QZRHIQuKgLH-MA.jpeg</url>
            <title>Stories by Vishnu Thankappan on Medium</title>
            <link>https://medium.com/@vishnuthankappan?source=rss-d525bc51a5b4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 20:20:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vishnuthankappan/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[Lazy-load module/scripts/styles in Angular — Part 2]]></title>
            <link>https://vishnuthankappan.medium.com/lazy-load-module-scripts-styles-in-angular-part-2-e240520d1545?source=rss-d525bc51a5b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e240520d1545</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[dynamic-loading]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Vishnu Thankappan]]></dc:creator>
            <pubDate>Fri, 03 Dec 2021 11:52:26 GMT</pubDate>
            <atom:updated>2021-12-03T11:55:23.604Z</atom:updated>
            <content:encoded><![CDATA[<h3>Lazy-load module/scripts/styles in Angular — Part 2</h3><h3>Lazy-Load Scripts and CSS in Angular</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xDx_UkvbylAMMGobcrD7Pg.png" /><figcaption>source: <a href="https://images-na.ssl-images-amazon.com/images/I/41cJwDNjTaL._SX331_BO1,204,203,200_.jpg">https://images-na.ssl-images-amazon.com/images/I/41cJwDNjTaL._SX331_BO1,204,203,200_.jpg</a></figcaption></figure><p>How third-party scripts compilation affects the performance of an application and how we can improve the performance of it can be read here:</p><ul><li><a href="https://web.dev/efficiently-load-third-party-javascript/">Efficiently load third-party JavaScript</a></li><li><a href="https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript">Loading Third-Party JavaScript | Web Fundamentals | Google Developers</a></li></ul><p>Here we are going a step further on how we can load a third part script on demand, as-in loading when and where the scripts are actually required.</p><p>So, continuing from the old app what I created in the Part-1 of this series</p><p><a href="https://vishnuthankappan.medium.com/lazy-load-module-script-styles-in-angular-part-1-cf837f835cfe">https://vishnuthankappan.medium.com/lazy-load-module-script-styles-in-angular-part-1-cf837f835cf</a>e</p><h4>Let’s start</h4><ul><li>First we’ll create one component called bootstrap-page using CLI command:</li></ul><blockquote><em>ng g c bootstrapPage</em></blockquote><ul><li>generate a module file for the component using CLI command:</li></ul><blockquote><em>ng g m dynamicLoad — flat</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p9P1TIw_KVAbKcZuQabKgQ.png" /></figure><ul><li>Now implement lazy-loading to the route to this module:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cA6Qz50M_rP1gisNDj0QFA.png" /><figcaption>lazy loaded route</figcaption></figure><ul><li>For this illustration we’ll be integrating <a href="https://getbootstrap.com/">https://getbootstrap.com/</a> into our component.</li><li>Here, we have one script and one style link to make bootstrap work.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*74wBX4Pz7whcDX9fhEVnmA.png" /></figure><ul><li>If we paste the above script and style in index.html it will load as soon as user access the page.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5EyO5OSEFQOE0xl4IcbQCQ.png" /><figcaption>loading script and css in index.html</figcaption></figure><ul><li>Let’s say we don’t want it to load on first page and only want to load as soon as a navigate to bootstrap page.</li><li>Now, rather than using it in index.html file first we will be creating one service called lazy-script-loader.service.ts where we’ll be writing some code to load script dynamically.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0692e6ac2ae0f17b54d6d843b6dbda5/href">https://medium.com/media/c0692e6ac2ae0f17b54d6d843b6dbda5/href</a></iframe><p>Now that the script loader service is ready. Let’s use angular route resolvers.</p><blockquote><strong>In short resolvers take care of tasks that needs to be completed before you navigate to a particular page</strong>. You can find more info in <a href="https://angular.io/api/router/Resolve">https://angular.io/api/router/Resolve</a></blockquote><ul><li>create a resolver service using CLI command</li></ul><blockquote><em>ng g resolver loadbootstrapscript</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*sW2n8k5B2AU21OQRi9lwxw.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/690e11b51efd852c5321712c4179f8a0/href">https://medium.com/media/690e11b51efd852c5321712c4179f8a0/href</a></iframe><p>Now, that the resolver is ready, let’s connect it with a route. a resolver service can be connected like shown in the example below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z599MmQ9Bm9jWdIfq6TzDw.png" /></figure><p>Once you have connected a resolver service to a route, it basically tell the application to execute the connected service before activating the route.</p><p>Now wen you run the application you can see the bootstrap script and styles are not loaded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7tZHDISLgzAUFtKvzYr0w.png" /></figure><p>Now when you click on the “Load Bootstrap button” you can see the bootstrap class has been loaded and applied styles to the buttons. 🥳</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YDNn0YyhBUsTt4-VH4_hjw.png" /></figure><p>And that’s how you can implement lazy loading of scripts and styles in Angular.🥳🥳🥳</p><p>You can refer the entire project here <a href="https://github.com/vishnuramero/lazyloading">https://github.com/vishnuramero/lazyloading</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e240520d1545" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lazy-load module/script/styles in Angular — Part 1]]></title>
            <link>https://vishnuthankappan.medium.com/lazy-load-module-script-styles-in-angular-part-1-cf837f835cfe?source=rss-d525bc51a5b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf837f835cfe</guid>
            <category><![CDATA[lazy-loading]]></category>
            <category><![CDATA[angular-cli]]></category>
            <category><![CDATA[d3js]]></category>
            <category><![CDATA[lazy-load]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Vishnu Thankappan]]></dc:creator>
            <pubDate>Fri, 03 Dec 2021 08:21:19 GMT</pubDate>
            <atom:updated>2021-12-03T10:16:19.186Z</atom:updated>
            <content:encoded><![CDATA[<h3>Lazy-load module/scripts/styles in Angular — Part 1</h3><h3>Lazy-Load a module</h3><p>In this we’ll quickly go through how to lazy-load a component in Angular.</p><ul><li>Create a new angular application using following CLI command</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/963eacc529a8d078190e74705388eb9b/href">https://medium.com/media/963eacc529a8d078190e74705388eb9b/href</a></iframe><p>Prod build on the sample application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KhwiN0YSmqWGEtEX8x2vIg.png" /><figcaption>Prod build on the newly created application</figcaption></figure><p>Now for the sake of illustration lets install d3 charts in the application using</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ee38cd8826c40096d79e567b9b517c0/href">https://medium.com/media/0ee38cd8826c40096d79e567b9b517c0/href</a></iframe><p>Now again run a prod build, now you can see the difference in app bundle size from 219kb to 249kb</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dCauDL8Lji44mmJlGlQguQ.png" /><figcaption>Prod build after installing d3</figcaption></figure><p>Now lets create two more components using following CLI command:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a8d6637e2b13bdddb75635047d6476f/href">https://medium.com/media/8a8d6637e2b13bdddb75635047d6476f/href</a></iframe><p>Now lets add configure d3 chart in DynamicClickLaodPage</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/437a4952c008e5fc6ca6855d5128b531/href">https://medium.com/media/437a4952c008e5fc6ca6855d5128b531/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61371958754625521100ad0b7722f760/href">https://medium.com/media/61371958754625521100ad0b7722f760/href</a></iframe><p>And now call the component from app page</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/362f5575c20134253c520439a45f1f2a/href">https://medium.com/media/362f5575c20134253c520439a45f1f2a/href</a></iframe><blockquote>Now do ng serve and you should be able to see the chart which you created</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lXkmEDKs7SQNdJk2lNf0sw.png" /><figcaption>d3 chart</figcaption></figure><p>Now perform a prod build again and you’ll notice the build size is increased further from 249kb to 272kb as now we are actually importing in into our component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*marhTTRrmVUQl7ndHRcwHQ.png" /><figcaption>prod build after using d3 charts</figcaption></figure><p>Now let’s start with lazy load where we will load the DynamicClickLaodPage component on demand.</p><h4>Step-1</h4><ul><li>Generate a module inside DynamicClickLaodPage component folder.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c76412a3d3a18e7b4891b29ab6f8864/href">https://medium.com/media/7c76412a3d3a18e7b4891b29ab6f8864/href</a></iframe><ul><li>This will generate a module file under DynamicClickLaodPage folder</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*beFWNAgaMUZ2twX9Ai6HIg.png" /><figcaption>Folder structure</figcaption></figure><p>Now remove the declaration of DynamicClickLaodPage from app.module and declare it in DynamicLoadModule</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7364e18df190c5a162c3302f9b5ccca5/href">https://medium.com/media/7364e18df190c5a162c3302f9b5ccca5/href</a></iframe><p>and reconfigure your parent route (in this example app.routing.module.ts ) as below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f464bdd02b72fa40a711f58b240773dc/href">https://medium.com/media/f464bdd02b72fa40a711f58b240773dc/href</a></iframe><p>here, you can see that we are loading DynamicLoadModule when the client hits the route <a href="http://localhost:4200/dynaload"><strong>/dynaload</strong></a></p><p>Now when you do a prod build on the application you will observe that the size the the main bundle has been reduced from 273kb to 245kb. and now you can see a section called Lazy Chunk Files here is our newly created module packed separately and will only be loaded once the user calls the route.</p><blockquote>It wont seem like a big number now, but when enterprise level app comes into picture, trust me 1kb matters. as it directly impacts the FCP and performance of the overall application.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PtIkmyeTsFjzGLdx-QhH-A.png" /><figcaption>pre vs post lazy load</figcaption></figure><p>Now here for demo I’ve create a button on click of which it will navigate to dynaload page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lgi9JcC556U4kg92GETg5g.png" /></figure><p>When you click on the above button the user is navigated dynaload page and on network section you can see dynamic-click module has been loaded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gtCO7aGId8c9l7U3uGx8DQ.png" /><figcaption>dynaload page is loaded on click</figcaption></figure><p>And that’s how you can implement lazy loading of modules in Angular.🥳🥳🥳</p><p>You can also checkout the sample code in <a href="https://github.com/vishnuramero/lazyloading">https://github.com/vishnuramero/lazyloading</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf837f835cfe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Upgrading to Storybook(v 6.3) for Angular 12]]></title>
            <link>https://vishnuthankappan.medium.com/upgrading-to-storybook-v-6-3-for-angular-12-c5ae7eda3dd9?source=rss-d525bc51a5b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5ae7eda3dd9</guid>
            <category><![CDATA[storybook]]></category>
            <category><![CDATA[ui-design]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angular12]]></category>
            <dc:creator><![CDATA[Vishnu Thankappan]]></dc:creator>
            <pubDate>Fri, 25 Jun 2021 03:39:15 GMT</pubDate>
            <atom:updated>2021-06-25T07:42:58.628Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="https://storybook.js.org/docs/angular/get-started/introduction" src="https://cdn-images-1.medium.com/max/1011/0*tzRzfIXCyxkYkrzy.png" /><figcaption>storybook: <a href="https://storybook.js.org/docs/angular/get-started/introduction">https://storybook.js.org/docs/angular/get-started/introduction</a></figcaption></figure><p>This article has few straight forward fixes which the migration document failed to mention or the fixes are in some other documents.</p><h3>Step 1: Storybook Package upgrade</h3><pre>npx sb upgrade</pre><h3>Step 2: Angular and dependency Package upgrade</h3><pre>ng update <a href="http://twitter.com/angular/core">@angular/core</a>@12 <a href="http://twitter.com/angular/cli">@angular/cli</a>@12</pre><pre>**If you are using angular material**<br>ng update <a href="http://twitter.com/angular/material">@angular/material</a></pre><p><strong>Now lets come to the issues:</strong></p><ul><li>when you run the project following the migration guide…</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eM0Qe-kZ1htSrUbF8xPKQw.png" /></figure><p>Fix:</p><p>in your .storybook/main.js add</p><pre>core: {</pre><pre>builder: ‘webpack5’,</pre><pre>},</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*n5iszPZf9oRBBrgO8WrFMw.png" /></figure><p>Second Issue:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PeuH2a1A7KOBnREc3CVPyw.png" /></figure><p>Fix:</p><pre>npm install <a href="http://twitter.com/storybook/builder-webpack5">@storybook/builder-webpack5</a>@next <a href="http://twitter.com/storybook/manager-webpack5">@storybook/manager-webpack5</a>@next — save-dev</pre><ul><li><strong>Error related to localize, even if you have proper configuration in your polyfills.ts file</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5S_INv6ySFIJiH9oZFpKbg.png" /></figure><p>Fix:</p><ul><li>import localize in you config.js/preview.js file inside .storybook</li></ul><pre>import &#39;@angular/localize/init&#39;;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x-J-La6l5NUNglQ7Ify4Yg.png" /></figure><p>That’s all 🥳</p><p>Now run the project and enjoy all new cool features.</p><p><strong>Official Storybook migration guide</strong></p><blockquote><a href="https://storybook.js.org/blog/storybook-6-migration-guide/">https://storybook.js.org/blog/storybook-6-migration-guide/</a></blockquote><p><strong>Whats new in storybook 6.3</strong></p><blockquote><a href="https://storybook.js.org/blog/storybook-6-3/">https://storybook.js.org/blog/storybook-6-3/</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5ae7eda3dd9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Azure Feature Management for Angular Applications]]></title>
            <link>https://vishnuthankappan.medium.com/azure-feature-management-for-angular-applications-7c2876568fd1?source=rss-d525bc51a5b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c2876568fd1</guid>
            <category><![CDATA[feature-management]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <dc:creator><![CDATA[Vishnu Thankappan]]></dc:creator>
            <pubDate>Thu, 15 Apr 2021 04:08:23 GMT</pubDate>
            <atom:updated>2021-04-29T03:48:12.972Z</atom:updated>
            <content:encoded><![CDATA[<h3>Azure dynamic Feature Management for Angular Applications</h3><p>There are times when you are working on big feature and want to test your code compatibility with the other code and there are time when your unfinished code has to be pushed to the main branch to support some other dependent functionalities. The issue is now you want to hide these unfinished functionalities from end user till it’s completed. Here comes Azure feature flag to the rescue, Azure feature flags allows you to enable/disable a feature dynamically rather than hardcoding it in the app.</p><blockquote>A feature flag is a boolean value that you set in an external system. The value is read by your application and determines if a feature is shown or activated.</blockquote><p>Prerequisite:</p><ul><li>Active azure subscription</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*XesDoVVKH4S90qq23dZJgQ.png" /></figure><p>A basic quick start article can be found in</p><ul><li><a href="https://docs.microsoft.com/en-us/azure/azure-app-configuration/manage-feature-flags">https://docs.microsoft.com/en-us/azure/azure-app-configuration/manage-feature-flags</a></li><li><a href="https://microsoft.github.io/AzureTipsAndTricks/blog/tip289.html">https://microsoft.github.io/AzureTipsAndTricks/blog/tip289.html</a></li></ul><p>Azure Feature Management service can be utilised in two flows in an Angular application:</p><ul><li>Element specific</li><li>Route specific</li></ul><h4>Element specific</h4><p>Element specific basically entails enabling/disabling or removing any UI element from the UI.</p><figure><img alt="A basic illustration of Feature configuration service" src="https://cdn-images-1.medium.com/max/1024/1*fUdUPcVrKgsn6e442bSoBQ.png" /><figcaption>A basic illustration of feature configuration workflow</figcaption></figure><p>Let’s First start with creating a service to retrieve value of a key whether its enabled or disabled.</p><p>A sample code snippet will look like this:</p><pre>//will retrieve the value of key<br>//keyName is the name of key you want to get value for</pre><pre>async BetaFeatureCheck(keyName: string)<br>{</pre><pre>const conn = environment.featureURL;//app config read-write key</pre><pre>const client = new AppConfigurationClient(conn);</pre><pre>var val = await client.getConfigurationSetting({</pre><pre>key: &#39;.appconfig.featureflag/&#39; + KeyName,</pre><pre>label: &#39;webapp&#39;,</pre><pre>});</pre><pre>if (val.value != undefined) return JSON.parse(val.value).enabled;<br>else return false;</pre><pre>}</pre><p>the above function will return enabled status (true/false) for a key.</p><p>Let’s say you have one button in UI to hide, here are steps on how it can be done:</p><ul><li>In your ‘ts’ file declare a variable and call the “BetaFeatureCheck” function with an appropriate key.</li></ul><pre>counterButonFeature = this.featureService.BetaFeatureCheck(&#39;Feature-Button&#39;);</pre><ul><li>In your ‘html’ file, you can do something like this:</li></ul><pre>&lt;div  *ngIf=&quot;counterButonFeature|async&quot;&gt;</pre><pre>&lt;button&gt; Feature button &lt;/button&gt;</pre><pre>&lt;/div&gt;</pre><p>So, based on the value you get from variable “counterButonFeature” you can hide/show the above div.</p><h4>Route specific</h4><p>Route specific flows are well suited when you don’t want a particular set of users to have access to a particular route.</p><blockquote>You can remove the menu item from navigation itself using the above mentioned (UI specific) flow, but this case will help if the user tries to access the route manually.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4oMll4Qqgq8pi5qtl81FzA.png" /></figure><ul><li>To achieve this flow we’ll create one custom guard called <strong>FeatureAccessGuard</strong></li></ul><p>Here is a sample snippet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*czZd0PwSp5UxE9tTwB5rbA.png" /><figcaption>create a CanActivate Guard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uL1z5rR6p1yAle4rUd09KQ.png" /><figcaption>FeatureAccessGuard snippet</figcaption></figure><p>Now you can apply this guard on the routes you want to check the access for</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ltbJx8ssod7CyPrb7QA8MQ.png" /></figure><p>So now whenever a user tries to access “/admin” route it will activate feature check.</p><h4>Miscellaneous</h4><p>CRUD operations on keys from Angular app</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8d3cd2f6ef53d55e3c2f52b581310c5/href">https://medium.com/media/d8d3cd2f6ef53d55e3c2f52b581310c5/href</a></iframe><h4>Best Practices for an Enterprise application</h4><p>Even though you can integrate Azure App config in client side, it’s good to build a server-side component to handle communication directly with App Config. Then have the client app communicate with that server-side component, to load the configuration it needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c2876568fd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Compodoc with Angular 11 — Documenting Angular Application]]></title>
            <link>https://vishnuthankappan.medium.com/integrating-compodoc-with-angular-11-documenting-angular-application-9602566fe4c5?source=rss-d525bc51a5b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/9602566fe4c5</guid>
            <category><![CDATA[angular-performance]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[documentation]]></category>
            <category><![CDATA[compodoc]]></category>
            <dc:creator><![CDATA[Vishnu Thankappan]]></dc:creator>
            <pubDate>Fri, 12 Feb 2021 18:40:13 GMT</pubDate>
            <atom:updated>2021-02-12T18:40:13.134Z</atom:updated>
            <content:encoded><![CDATA[<h3>Integrating Compodoc with Angular 11 — Documenting Angular Application</h3><p>Though Angular is an amazing framework to develop a web application, there comes a time when the application becomes soo huge that it’s not easy to understand or map the flow of data or how the app is structured from a birds view. This is the case when enterprise apps come into the scope.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*ldtoPlxBUfA8AeDC.jpg" /></figure><p>I was also a part of team where we faced this issue. As our application got bigger we slowly started loosing control over the bundle size of application which further started impacting page performance and the moment we started debugging the issue we realised that it’s not possible or damn hard to decrease the bundle size or to know how what is causing the performance issues without knowing how the app is structured as a whole.Then after a lots n lots of googling… Here it is… The Saviour “<a href="https://compodoc.app/"><strong>Compodoc</strong></a><strong>”.</strong></p><p><strong><em>Compodoc is sort of a documentation tool for Angular applications. It generates a static documentation of your application which includes modules, components, pipes, guards and many more..</em></strong></p><blockquote>You can directly start with compodoc documentations, but here along with usual installation i’ll go through couple of the bottlenecks which I faced and the fix for it when integrating with an enterprise level application.</blockquote><h4><strong>Let’s start</strong></h4><ul><li>First install compodoc</li></ul><pre>//Global Installation<br>npm install -g @compodoc/compodoc</pre><pre>//Local Installation<br>npm install --save-dev @compodoc/compodoc</pre><ul><li>Define a script task for it in your package.json:</li></ul><blockquote>Here starts the <strong>First</strong> bottleneck:</blockquote><p>As per documentation we have to do</p><pre>&quot;scripts&quot;: {<br>  &quot;compodoc&quot;: &quot;npx compodoc -p tsconfig.app.json src&quot;<br>}</pre><p>But this wont work from angular 9 and above, as the configuration has been shifted from tsconfig.app.json to tsconfig.base.json</p><p>So, now this is what you have to do</p><pre>&quot;scripts&quot;: {<br>  &quot;compodoc&quot;: &quot;npx compodoc -p tsconfig.base.json src&quot;<br>}</pre><p>Now everything is setup, it’s time to run.</p><pre>npm run compodoc</pre><p>And Voila!! it’s starts compiling the app.</p><blockquote>And Suddenly here is the <strong>Second</strong> bottleneck</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dmlSWbPhv32MciGYjJypMg.png" /><figcaption>JavaScript heap out of memory</figcaption></figure><p><strong>Solution</strong>:</p><p><strong>For windows user</strong>: Replace the script with</p><pre>&quot;scripts&quot;: {<br>  “compdoc”: “npx compodoc — max_old_space_size=20480 -p tsconfig.base.json -s”<br>}</pre><p><strong>For Mac users</strong>: Just run the following command before executing compodoc (it’s same for Linux i believe, but never tested)</p><pre>export NODE_OPTIONS=--max-old-space-size=8192<br>npm run compodoc</pre><p>And as soon as you run this, it takes a bit time (depends on your system specifications and the size of your project) to compile all files and as soon as its done you’ll get a localhost address where you can see the entire documentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XlXYNZLi-PXPF79mIIykgQ.png" /><figcaption>compodoc localhost url</figcaption></figure><p>and the documentation will look somewhat like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hwX0JUSvq8DgPV7r.png" /><figcaption>Source - <a href="https://compodoc.app/guides/demo.html">https://compodoc.app/guides/demo.html</a></figcaption></figure><p>That’s all, from here you can analyse all the packages, modules, components, classes and many more and get a proper picture of how your application is structured and you can make decisions on how to move forward in terms of improving you applications size and performance.</p><blockquote><strong>What I did after going through the documentation:</strong></blockquote><ul><li>Came up with more optimised way to modularize couple of components eventually making the app load faster.</li><li>Found few unused modules and components which were not being used anymore, just adding a dead weight to size of application for no reason.</li></ul><p>You can do a lot more with compodoc you can go through rest of the documentation in <a href="https://compodoc.app/guides/demo.html">https://compodoc.app/guides/demo.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9602566fe4c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>