<?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 Shashi Kiran on Medium]]></title>
        <description><![CDATA[Stories by Shashi Kiran on Medium]]></description>
        <link>https://medium.com/@kiranshashi14?source=rss-85f4bafe51e2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CY9QewPGl0ruPRQQgmCpkw.jpeg</url>
            <title>Stories by Shashi Kiran on Medium</title>
            <link>https://medium.com/@kiranshashi14?source=rss-85f4bafe51e2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 22:28:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kiranshashi14/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[How I upgraded to Webpack 5 and Jest 29]]></title>
            <link>https://medium.com/@kiranshashi14/how-i-upgraded-to-webpack-5-and-jest-29-369120f997e7?source=rss-85f4bafe51e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/369120f997e7</guid>
            <category><![CDATA[jest]]></category>
            <category><![CDATA[webpack-5]]></category>
            <category><![CDATA[build-tool]]></category>
            <category><![CDATA[javascript-development]]></category>
            <dc:creator><![CDATA[Shashi Kiran]]></dc:creator>
            <pubDate>Wed, 14 May 2025 06:42:19 GMT</pubDate>
            <atom:updated>2025-05-24T07:25:34.227Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*VPFE6mEx4rD0l4dP.png" /></figure><h3>Background:</h3><h4><strong>1. Performance Improvements</strong></h4><ul><li><strong>Faster builds</strong> and <strong>incremental rebuilds</strong> due to improved caching and algorithms.</li><li><strong>Smaller bundle sizes</strong> with better tree-shaking and code splitting.</li></ul><h4><strong>2. Better Long-Term Support</strong></h4><ul><li>Webpack 4 is no longer actively maintained; Webpack 5 receives security updates, bug fixes, and new features.</li></ul><h4><strong>3. Improved Caching</strong></h4><ul><li>Persistent caching out of the box, reducing build times dramatically after the first build.</li></ul><h4><strong>4. Built-in Asset Modules</strong></h4><ul><li>No need for file-loader, url-loader, or raw-loader—Webpack 5 handles assets natively.</li></ul><h4><strong>5. Enhanced Tree Shaking</strong></h4><ul><li>More aggressive and accurate dead code elimination, resulting in smaller bundles.</li></ul><h4><strong>6. Smarter Code Splitting</strong></h4><ul><li>Improved chunking and splitting logic for more efficient loading.</li></ul><h4><strong>7. Native WebAssembly Support</strong></h4><ul><li>First-class support for WebAssembly modules.</li></ul><h4><strong>8. Better Module Federation</strong></h4><ul><li>Enables micro-frontends and sharing code between builds/applications at runtime.</li></ul><h4><strong>9. Improved Defaults and Strictness</strong></h4><ul><li>Stricter adherence to the ES module spec, helping catch issues early and ensuring future compatibility.</li></ul><h4><strong>10. Reduced Need for Polyfills</strong></h4><ul><li>Webpack 5 no longer automatically polyfills Node.js core modules, making bundles smaller and more browser-focused.</li></ul><h3>❗️Why Upgrade Is Necessary</h3><ul><li><strong>Security:</strong> Only Webpack 5 receives security patches.</li><li><strong>Ecosystem:</strong> Many popular loaders and plugins now only support Webpack 5.</li><li><strong>Future-Proofing:</strong> New features and performance improvements are only available in Webpack 5.</li><li><strong>Compatibility:</strong> Modern libraries and frameworks expect Webpack 5’s module resolution and features.</li><li><strong>Maintenance:</strong> Staying on old versions increases technical debt and upgrade pain later.</li></ul><h3>Steps:</h3><p>To upgrade from Webpack 4 to Webpack 5, you need to:</p><ul><li>Update webpack, webpack-cli, and webpack-dev-server to v5.</li><li>Upgrade plugins/loaders to versions compatible with Webpack 5.</li><li>Remove or replace deprecated plugins (notably, hard-source-webpack-plugin is not compatible with Webpack 5).</li><li>Adjust config for breaking changes (e.g., asset modules, plugin options, etc.).</li></ul><p>Below are the required changes:</p><h4>1. Update package.json dependencies</h4><pre>// ...existing code...<br>&quot;devDependencies&quot;: {<br>// ...existing code...<br>&quot;babel-loader&quot;: &quot;^9.1.3&quot;,<br>&quot;compression-webpack-plugin&quot;: &quot;^11.0.0&quot;,<br>&quot;css-loader&quot;: &quot;^7.1.2&quot;,<br>&quot;webpack&quot;: &quot;^5.91.0&quot;,<br>&quot;webpack-cli&quot;: &quot;^5.1.4&quot;,<br>&quot;webpack-dev-server&quot;: &quot;^5.0.4&quot;,<br>&quot;webpack-manifest-plugin&quot;: &quot;^5.0.1&quot;,<br>&quot;mini-css-extract-plugin&quot;: &quot;^2.7.6&quot;,<br>&quot;compression-webpack-plugin&quot;: &quot;^11.0.0&quot;,<br>&quot;html-webpack-plugin&quot;: &quot;^5.5.3&quot;,<br>&quot;sass-loader&quot;: &quot;^16.0.5&quot;,<br>&quot;style-loader&quot;: &quot;^4.0.0&quot;,<br>&quot;terser-webpack-plugin&quot;: &quot;^5.3.14&quot;,<br>&quot;thread-loader&quot;: &quot;^4.0.4&quot;,<br>&quot;url-loader&quot;: &quot;^4.1.1&quot;,<br>// REMOVE &quot;hard-source-webpack-plugin&quot;<br>// ...existing code...<br>}<br>// ...existing code...</pre><h4>2. Remove hard-source-webpack-plugin from webpack.config.js</h4><pre>// ...existing code...<br>// REMOVE: const HardSourceWebpackPlugin = require(&#39;hard-source-webpack-plugin&#39;);<br>// ...existing code...<br>plugins: [<br>  new webpack.DefinePlugin({ ...DEFINITIONS }),<br>  new HtmlWebpackPlugin({<br>    template: path.resolve(__dirname, &#39;src&#39;, &#39;index.html&#39;)<br>  }),<br>  IS_PROD &amp;&amp;<br>    new WebpackManifestPlugin({<br>      fileName: path.join(&#39;static&#39;, &#39;manifest.json&#39;)<br>    }),<br>  IS_PROD &amp;&amp;<br>    new MiniCssExtractPlugin({<br>      filename: path.join(&#39;static&#39;, &#39;styles&#39;, &#39;[name].[hash:8].css&#39;)<br>    }),<br>  new webpack.HashedModuleIdsPlugin(), // so that file hashes don&#39;t change unexpectedly<br>  IS_PROD &amp;&amp; new CompressionPlugin({ test: /\.(js|css)$/i }),<br>  // REMOVE: new HardSourceWebpackPlugin(),<br>  // REMOVE: new HardSourceWebpackPlugin.ExcludeModulePlugin([...])<br>  // ...existing code...<br>]<br>// ...existing code...</pre><h4>3. Update file-loader/url-loader usage (Webpack 5 has built-in asset modules)</h4><p>Webpack 5 introduces Asset Modules, which replace file-loader, url-loader, and raw-loader. You can now handle assets directly in your webpack.config.js without extra loaders.</p><h4>Example: Replace file-loader/url-loader rules</h4><p><strong>Before (Webpack 4)</strong></p><pre>// ...existing code...<br>{<br>  test: /\.(png|jpe?g|gif|svg)$/i,<br>  use: [<br>    {<br>      loader: &#39;file-loader&#39;,<br>      options: {<br>        name: &#39;static/media/[name].[hash:8].[ext]&#39;<br>      }<br>    }<br>  ]<br>},<br>{<br>  test: /\.(woff2?|eot|ttf|otf)$/i,<br>  loader: &#39;url-loader&#39;,<br>  options: {<br>    limit: 8192,<br>    name: &#39;static/fonts/[name].[hash:8].[ext]&#39;<br>  }<br>}<br>// ...existing code...</pre><p><strong>After (Webpack 5)</strong></p><pre>// ...existing code...<br>{<br>  test: /\.(png|jpe?g|gif|svg)$/i,<br>  type: &#39;asset/resource&#39;,<br>  generator: {<br>    filename: &#39;static/media/[name].[contenthash:8][ext]&#39;<br>  }<br>},<br>{<br>  test: /\.(woff2?|eot|ttf|otf)$/i,<br>  type: &#39;asset&#39;,<br>  parser: {<br>    dataUrlCondition: {<br>      maxSize: 8192 // Same as url-loader limit<br>    }<br>  },<br>  generator: {<br>    filename: &#39;static/fonts/[name].[contenthash:8][ext]&#39;<br>  }<br>}<br>// ...existing code...</pre><h4>4. Add resolve.fallback for Node polyfills (Webpack 5 no longer polyfills Node.js core modules by default)</h4><p>If you use Node.js built-ins (like crypto, stream, etc.) in your client code, add:</p><pre>// ...existing code...<br>module.exports = {<br>  // ...existing code...<br>  resolve: {<br>    fallback: {<br>      &quot;crypto&quot;: false,<br>      &quot;stream&quot;: false,<br>      &quot;buffer&quot;: false,<br>      // add more as needed<br>    }<br>  },<br>// ...existing code...<br>}</pre><h4>5. Update output filename (optional, but recommended for compatibility)</h4><pre>// ...existing code...<br>output: {<br>  path: path.resolve(__dirname, OUT_DIR),<br>  filename: path.join(&#39;static&#39;, &#39;scripts&#39;, &#39;[name].[contenthash:8].js&#39;), // use contenthash instead of hash<br>  publicPath: &#39;/&#39;<br>},<br>// ...existing code...</pre><h4>6. Remove deprecated plugin options and update plugin usage as needed</h4><ul><li>HashedModuleIdsPlugin is now enabled by default in production mode in Webpack 5, but you can keep it for explicitness.</li><li>MiniCssExtractPlugin and HtmlWebpackPlugin options are compatible, but check their docs if you use advanced options.</li></ul><h4>7. Update the named imports from JSON file to default imports.</h4><ul><li>JSON files can only be imported as default exports.</li><li>If you want named exports, you must destructure from the default import:</li></ul><p>How it was working in webpack 4?</p><p>In Webpack 4, named imports from JSON files should not work according to the ES module spec, and only default imports are officially supported. However, there are a few reasons why you might not see an error in your Webpack 4 build:</p><p><strong>1. Loose Module Interop in Babel/Webpack 4</strong><br>Webpack 4 (and Babel, if you use it with certain settings) is more permissive and sometimes allows named imports from CommonJS/default-only modules (including JSON) by creating a synthetic named export for each property of the default export. This is not standard and is not supported in strict ESM environments or in Webpack 5.</p><p><strong>2. babel-plugin-transform-es2015-modules-commonjs</strong><br>If your Babel config uses plugins or presets that enable “loose” or “interop” mode, it may allow named imports from default-only modules by copying properties from the default export to named exports.</p><p><strong>3. Webpack 4 Internal Behavior</strong><br>Webpack 4’s module system is less strict and sometimes allows named imports from JSON or CommonJS modules as a convenience, but this is not spec-compliant and is not carried forward to Webpack 5.</p><p><strong>What Changed in Webpack 5?</strong><br>Webpack 5 enforces the ES module spec more strictly.<br>Named imports from JSON files are now a build error.<br>You must use default imports:</p><p>import config from &#39;conf/config.json&#39;;</p><p>const { defaultScope } = config; // ✅</p><p><strong>Summary:</strong><br>Upgrading to Webpack 5 brings faster builds, smaller bundles, better long-term support, and access to the latest features and ecosystem improvements. It’s essential for security, performance, and future compatibility.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=369120f997e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bunyan Logger- Setting loglevel]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@kiranshashi14/bunyan-logger-setting-loglevel-cff1c30a5ca6?source=rss-85f4bafe51e2------2"><img src="https://cdn-images-1.medium.com/max/736/1*sSuyNzRQqpFbjktPus-4-A.png" width="736"></a></p><p class="medium-feed-snippet">Bunyan is a logging library used for node.js environments, provides capabilities to redirect logs to different streams like files or&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@kiranshashi14/bunyan-logger-setting-loglevel-cff1c30a5ca6?source=rss-85f4bafe51e2------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@kiranshashi14/bunyan-logger-setting-loglevel-cff1c30a5ca6?source=rss-85f4bafe51e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/cff1c30a5ca6</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[bunyan]]></category>
            <category><![CDATA[loglevel]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Shashi Kiran]]></dc:creator>
            <pubDate>Wed, 14 Aug 2024 12:32:28 GMT</pubDate>
            <atom:updated>2024-08-14T13:31:19.835Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[What is ${npm_execpath} ?]]></title>
            <link>https://medium.com/@kiranshashi14/what-is-npm-execpath-24a6beb45be5?source=rss-85f4bafe51e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/24a6beb45be5</guid>
            <category><![CDATA[node]]></category>
            <category><![CDATA[yarn]]></category>
            <category><![CDATA[npm]]></category>
            <dc:creator><![CDATA[Shashi Kiran]]></dc:creator>
            <pubDate>Tue, 16 Jul 2024 17:10:22 GMT</pubDate>
            <atom:updated>2024-07-16T17:10:22.105Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is ${npm_execpath} ?</h3><p>${npm_execpath} is an environment variable that contains the path to the currently running npm executable. It can be used in scripts defined in your package.json to determine which npm executable (either npm itself or another package manager like yarn) is being used to run the script.</p><h3>Use Case in package.json</h3><p>You might use ${npm_execpath} in the scripts section of your package.json to enforce the use of a specific package manager. For example, if you want to ensure that your project is always installed with npm and not yarn, you can add a preinstall script that checks the value of ${npm_execpath}.</p><h3>Example: Enforcing npm</h3><p>Here’s an example of how you can use ${npm_execpath} to enforce the use of npm:</p><pre>{<br>  &quot;name&quot;: &quot;example-project&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;preinstall&quot;: &quot;node -e \&quot;if (process.env.npm_execpath.indexOf(&#39;npm&#39;) === -1) { console.error(&#39;You must use npm to install dependencies&#39;); process.exit(1); }\&quot;&quot;<br>  }<br>}</pre><h3>Example: Enforcing yarn</h3><p>Similarly, if you want to enforce the use of yarn:</p><pre>{<br>  &quot;name&quot;: &quot;example-project&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;preinstall&quot;: &quot;node -e \&quot;if (process.env.npm_execpath.indexOf(&#39;yarn&#39;) === -1) { console.error(&#39;You must use yarn to install dependencies&#39;); process.exit(1); }\&quot;&quot;<br>  }<br>}</pre><h3>Use Case: Package manager agnostic scripts</h3><p>When you are writing scripts in package.json which refers other scripts, then you can use ${npm_execpath} to refer other scripts irrespective of whether npm or yarn is used to run these scripts.</p><pre>&quot;scripts&quot;: {<br>    &quot;build&quot;: &quot;webpack&quot;,<br>    &quot;build:prod&quot;: &quot;NODE_ENV=production ${npm_execpath} run build&quot;<br>  }</pre><p>So here the command build:prod will be translated to below based on package manager used to execute the command.</p><h4>npm:</h4><p>NODE_ENV=production npm run build</p><h4>yarn:</h4><p>NODE_ENV=production yarn run build</p><h3>Summary</h3><ul><li>${npm_execpath} is an environment variable containing the path to the npm executable used to run the current command.</li><li>It can be used in package.json scripts to enforce the use of a specific package manager by checking if the executable path includes npm or yarn.</li><li>This is useful for ensuring consistency in the package manager used for installing dependencies in a project.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24a6beb45be5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improve Angular Application Performance]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@kiranshashi14/improve-angular-performance-1a8e190acd7?source=rss-85f4bafe51e2------2"><img src="https://cdn-images-1.medium.com/max/1024/1*YW4AQDC4zmElBuskwGNcdA.jpeg" width="1024"></a></p><p class="medium-feed-snippet">Tips to improve performance of angular apps</p><p class="medium-feed-link"><a href="https://medium.com/@kiranshashi14/improve-angular-performance-1a8e190acd7?source=rss-85f4bafe51e2------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@kiranshashi14/improve-angular-performance-1a8e190acd7?source=rss-85f4bafe51e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a8e190acd7</guid>
            <category><![CDATA[tips-and-tricks]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Shashi Kiran]]></dc:creator>
            <pubDate>Fri, 28 Jul 2023 09:43:02 GMT</pubDate>
            <atom:updated>2023-10-03T06:50:51.825Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Angular Dependency Injection resolution of services with multiple modules]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@kiranshashi14/angular-dependency-injection-resolution-of-services-with-multiple-modules-babe76753f64?source=rss-85f4bafe51e2------2"><img src="https://cdn-images-1.medium.com/max/1155/1*egFAOdlpUBQPzyl1jb7p7A.png" width="1155"></a></p><p class="medium-feed-snippet">Services with conflicting names from multiple modules</p><p class="medium-feed-link"><a href="https://medium.com/@kiranshashi14/angular-dependency-injection-resolution-of-services-with-multiple-modules-babe76753f64?source=rss-85f4bafe51e2------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@kiranshashi14/angular-dependency-injection-resolution-of-services-with-multiple-modules-babe76753f64?source=rss-85f4bafe51e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/babe76753f64</guid>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[services]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Shashi Kiran]]></dc:creator>
            <pubDate>Thu, 15 Jun 2023 12:52:49 GMT</pubDate>
            <atom:updated>2023-07-31T08:28:07.604Z</atom:updated>
        </item>
    </channel>
</rss>