<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: RelativeCI</title>
    <description>The latest articles on DEV Community by RelativeCI (@relative-ci).</description>
    <link>https://dev.to/relative-ci</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F8653%2F9422febb-4963-43ea-b2d4-9b6bc1097cb1.png</url>
      <title>DEV Community: RelativeCI</title>
      <link>https://dev.to/relative-ci</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/relative-ci"/>
    <language>en</language>
    <item>
      <title>Why web application size matters</title>
      <dc:creator>Vio</dc:creator>
      <pubDate>Sun, 25 Aug 2024 14:31:57 +0000</pubDate>
      <link>https://dev.to/relative-ci/why-web-application-size-matters-51bc</link>
      <guid>https://dev.to/relative-ci/why-web-application-size-matters-51bc</guid>
      <description>&lt;p&gt;Based on &lt;a href="https://almanac.httparchive.org/en/2022/page-weight" rel="noopener noreferrer"&gt;Web Almanac&lt;/a&gt;, the median page weight of websites increased 221% for desktop and 594% for mobile page loads between June 2012 and June 2022. In Web Almanac's report, in 2022 most of the page weight was contributed by images while the cost of JavaScript was roughly half of images. CSS and mobile contributed to size as well but in relatively minimal amounts. It is safe to say that the web is becoming more bloated each year. The question is, why does web application size matter and what can you do about it?&lt;/p&gt;

&lt;h2&gt;
  
  
  Most users access internet through mobile
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo9658pcvrglna61c9e1h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo9658pcvrglna61c9e1h.png" alt="Mobile traffic share" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is not only the size of websites that is growing but the usage of the web as well. According to &lt;a href="https://explodingtopics.com/blog/mobile-internet-traffic" rel="noopener noreferrer"&gt;Josh Howarth&lt;/a&gt;'s data from June 2024, &lt;strong&gt;60% of global website traffic comes from mobile devices&lt;/strong&gt; while 92.3% of internet users access it via their mobile phones. The global estimate for mobile usage alone is that there are 4.32 billion mobile users of which a large proportion (close to 70%) is from the African market.&lt;/p&gt;

&lt;p&gt;As a developer using a fast broadband connection or better, it is easy to forget that most people occasionally use slow and potentially unreliable mobile connections. The theme of mobile usage ties back to size as it highlights the importance of designing your websites mobile friendly.&lt;/p&gt;

&lt;p&gt;Web application size is a significant part of this given not only because of loading costs but in addition hardware related costs as it is well understood that big JavaScript payloads have their cost especially on mobile as shown by &lt;a href="https://timkadlec.com/2014/09/js-parse-and-execution-time/" rel="noopener noreferrer"&gt;Tim Kadlec&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To simulate a slow connection easily, consider using &lt;a href="https://developer.chrome.com/docs/devtools/settings/throttling" rel="noopener noreferrer"&gt;throttling at Chrome DevTools&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Slow sites lead to decreased user satisfaction on e-commerce
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;+2% conversion increase when improving the page loading time with 1s&lt;br&gt;
&lt;a href="https://www.slideshare.net/devonauerswald/walmart-pagespeedslide" rel="noopener noreferrer"&gt;Walmart technical deep dive into Web Performance&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It is well understood that larger sites lead to decreased user satisfaction on e-commerce as discussed by &lt;a href="https://www.researchgate.net/publication/350600983_On_Latency_of_E-Commerce_Platforms" rel="noopener noreferrer"&gt;Basalla et al. in "On Latency of E-Commerce Platforms"&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;In other words, by improving the latency of your e-commerce site, you will likely have more satisfied customers while generating better revenue. This realization is one of the reasons why particularly e-commerce focused companies invest on performance related work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Performant sites have better search visibility
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;-24% abandonment decrease when all Core Vitals thresholds are met&lt;br&gt;
&lt;a href="https://blog.chromium.org/2020/05/the-science-behind-web-vitals.html" rel="noopener noreferrer"&gt;The Science Behind Web Vitals&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Web application performance is a part of technical Search Engine Optimization (SEO) as explained by &lt;a href="https://journals.iau.ir/article_699935_43613255a003781df5a1f54a415a1eed.pdf" rel="noopener noreferrer"&gt;Eslamdoust in An overview of search engine optimization techniques&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The good thing is that unlike other SEO related factors, it is one of the easiest to optimize if you have the technical know-how.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to address web application size?
&lt;/h2&gt;

&lt;p&gt;Web application size can be addressed in multiple different ways at different levels. Often there are low-hanging fruits, such as image optimization (using &lt;a href="https://caniuse.com/?search=webp" rel="noopener noreferrer"&gt;WebP&lt;/a&gt; or &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading" rel="noopener noreferrer"&gt;deferring loading&lt;/a&gt; are good ideas for example), while other types of optimizations require larger refactoring.&lt;/p&gt;

&lt;p&gt;The main question is to consider which data should be provided to the client and when. Many of the latest approaches, such as &lt;a href="https://jasonformat.com/islands-architecture/" rel="noopener noreferrer"&gt;islands architecture&lt;/a&gt; or &lt;a href="https://ieeexplore.ieee.org/document/10388344" rel="noopener noreferrer"&gt;resumability&lt;/a&gt;, build on this observation.&lt;/p&gt;

&lt;p&gt;In short, consider the following steps:&lt;br&gt;
    1. Analyze the current situation using a service like &lt;a href="https://pagespeed.web.dev/" rel="noopener noreferrer"&gt;Google's PageSpeed Insights&lt;/a&gt;, &lt;a href="https://gtmetrix.com/" rel="noopener noreferrer"&gt;GTmetrix&lt;/a&gt;, or &lt;a href="https://www.sitespeed.io/" rel="noopener noreferrer"&gt;sitespeed.io&lt;/a&gt;. &lt;a href="https://relative-ci.com/" rel="noopener noreferrer"&gt;RelativeCI&lt;/a&gt; allows you to track the application size from inside out from the bundle perspective helping you to understand the composition of your application while avoiding regressions.&lt;br&gt;
    2. Go through the proposed improvements&lt;br&gt;
    3. Prioritize the work based on impact and complexity before adding it to the backlog&lt;br&gt;
    4. Address the issues and repeat the process until you have reached a good spot&lt;/p&gt;

&lt;p&gt;Once you have application size on your radar, it is a good idea to keep on monitoring from different angles to make sure you remain in a good spot. Some of the improvements will likely take a longer while to implement as not all performance work is easy but simultaneously your users will thank for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;As mentioned early on, website and application size is a growing problem. The problem is compounded by the fact that an increasing amount of usage occurs on mobile and often in contexts where connection speed is limited.&lt;/p&gt;

&lt;p&gt;You can set your application apart by acknowledging the issue and doing something about it. It is not only about the fact that it is a good thing to do but also about improving the visibility of your site as performance is a part of technical SEO while making your application faster and snappier to use.&lt;/p&gt;




&lt;h2&gt;
  
  
  Understand your application bundle size
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://app.relative-ci.com/signup?utm_source=dev.to&amp;amp;utm_medium=why&amp;amp;utm_content=join"&gt;Setup now&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://app.relative-ci.com/projects/V1bXuieJbYttHCS75L8G?utm_source=dev.to&amp;amp;utm_medium=why&amp;amp;utm_content=join"&gt;View example&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe5n2cnao1jp19n1uafu6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe5n2cnao1jp19n1uafu6.png" alt="RelativeCI bundle analyzer" width="800" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>webperf</category>
      <category>bundlesize</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Identify and fix bundle npm duplicate dependencies</title>
      <dc:creator>Vio</dc:creator>
      <pubDate>Sun, 28 Apr 2024 15:59:58 +0000</pubDate>
      <link>https://dev.to/relative-ci/identify-and-fix-bundle-npm-duplicate-dependencies-28nj</link>
      <guid>https://dev.to/relative-ci/identify-and-fix-bundle-npm-duplicate-dependencies-28nj</guid>
      <description>&lt;p&gt;Modern web applications are becoming more complex and rely on an increasing number of dependencies. The larger the dependency tree is, the more likely it is to encounter version conflicts, bundle duplicate dependencies, ship unnecessary code, and negatively impact user performance.&lt;/p&gt;

&lt;p&gt;On the front-end side, modern web applications include a median of &lt;strong&gt;98&lt;/strong&gt; direct and transitive dependencies in the bundle, a growth of &lt;strong&gt;108%&lt;/strong&gt; in the last three years.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why the bundle contains duplicate dependencies
&lt;/h2&gt;

&lt;p&gt;When multiple other dependencies and/or the application depend on a package, &lt;strong&gt;npm&lt;/strong&gt; resolves the dependency tree, and if a common version does not satisfy all the semver queries, it installs multiple instances of the same package. By installing multiple instances of the same dependency, &lt;strong&gt;npm&lt;/strong&gt; meets the dependent package.json and avoids breaking existing functionality.&lt;/p&gt;

&lt;p&gt;If the duplicate package is a front-end dependency, it is bundled multiple times. This increases the size of the bundle, negatively impacting the application's web performance and, in some cases, causing JavaScript runtime errors (ex: &lt;a href="https://legacy.reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react" rel="noopener noreferrer"&gt;Duplicate React&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.npmjs.com/about-semantic-versioning" rel="noopener noreferrer"&gt;About semantic versioning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://semver.npmjs.com" rel="noopener noreferrer"&gt;semver&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;p&gt;Here's an example of how the bundle can contain duplicate dependencies. In an application that depends on &lt;code&gt;@ant-design/icons@4.7.0&lt;/code&gt; (resolved to &lt;code&gt;v4.7.0&lt;/code&gt;) and &lt;code&gt;antd@4.24.14&lt;/code&gt;, &lt;strong&gt;npm&lt;/strong&gt; installs two different instances of &lt;code&gt;@ant-design/icons&lt;/code&gt; because &lt;code&gt;antd@4.24.14&lt;/code&gt; depends on &lt;code&gt;@ant-design/icons@^4.7.0&lt;/code&gt; (resolved to &lt;code&gt;v4.8.1&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"example-app"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;package&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;information&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@ant-design"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"4.7.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"antd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"4.24.14"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm list @ant-design/icons

example-fix-npm-dependencies@1.0.0 repo
├── @ant-design/icons@4.7.0
└─┬ antd@4.24.14
  └── @ant-design/icons@4.8.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As a result, the bundle includes two versions of the same dependency:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fruq3xxge67h93vg9hgwn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fruq3xxge67h93vg9hgwn.png" alt="Bundle analysis - duplicate packages" width="798" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to identify duplicate dependencies
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;RelativeCI&lt;/strong&gt; analyzes the bundle stats modules data, extracts the list of bundled dependencies, and identifies duplicate dependency instances. It presents the information as custom insights, metrics, and a list that you can filter and sort to discover the regressions quickly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Duplicate packages insight
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;duplicate packages insight&lt;/strong&gt; shows the status and result of the duplicate packages analysis, allowing you to easily identify when there are regressions (new duplicate instances) or improvements (removed duplicates). The insight information is available on the bundle analysis report summary, job list, and all the integration summaries.&lt;/p&gt;

&lt;p&gt;Bundle analysis - duplicate packages insight&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmy3yxce0zyd87c45hl6m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmy3yxce0zyd87c45hl6m.png" alt="Bundle analysis - duplicate packages insight" width="800" height="207"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Bundle analysis list - duplicate packages insight&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo149rkc9xqgwv4s244z3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo149rkc9xqgwv4s244z3.png" alt="Bundle analysis list - duplicate packages insight" width="800" height="122"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;GitHub Pull Request Comment - Duplicate packages insight&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ua4j6iqkm5oi7jjmjqw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ua4j6iqkm5oi7jjmjqw.png" alt="GitHub Pull Request Comment - Duplicate packages insight" width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Duplicate packages metric
&lt;/h3&gt;

&lt;p&gt;The number of duplicate packages is shown as a distinct &lt;a href="https://relative-ci.com/documentation/metrics-and-data/#duplicate-packages" rel="noopener noreferrer"&gt;metric&lt;/a&gt; on the report summary, the job list, and all the integration summaries.&lt;/p&gt;

&lt;p&gt;Bundle analysis summary - duplicate packages metric&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr42b28pef4dqcleib6na.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr42b28pef4dqcleib6na.png" alt="Bundle analysis summary - duplicate packages metric" width="800" height="184"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Bundle analysis list - duplicate packages metric&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdzz74p8t3mrpxyc6oded.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdzz74p8t3mrpxyc6oded.png" alt="Bundle analysis list - duplicate packages metric" width="800" height="122"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also use the metric as a condition on the &lt;a href="https://relative-ci.com/documentation/setup/configure/integrations/github-commit-status-review/#configure" rel="noopener noreferrer"&gt;GitHub Commit Status Review&lt;/a&gt; or the &lt;a href="https://relative-ci.com/documentation/setup/configure/integrations/slack-notification/#send-slack-notifications-based-on-rules" rel="noopener noreferrer"&gt;Slack notification&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Bundle analysis review flow&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fam8h1rcbmoyla3153fqg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fam8h1rcbmoyla3153fqg.png" alt="Bundle analysis review flow" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Duplicate packages data
&lt;/h3&gt;

&lt;p&gt;To see the list of duplicate packages, go to the &lt;strong&gt;Packages&lt;/strong&gt; section of the bundle analysis report and filter the results by the &lt;strong&gt;Duplicate&lt;/strong&gt; filter. This will give you an overview of all the duplicate dependencies and their impact on the bundle size.&lt;/p&gt;

&lt;p&gt;Bundle analysis - packages&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flb4dsmnrhu8prfoc2rs3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flb4dsmnrhu8prfoc2rs3.png" alt="Bundle analysis - packages" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How to fix npm duplicate dependencies
&lt;/h2&gt;

&lt;p&gt;The appropriate strategies for resolving &lt;strong&gt;npm&lt;/strong&gt; duplicate dependencies may vary depending on your setup, dependencies, and versions. However, the following methods can help you eliminate duplicate packages, reduce bundle size, and enhance your application's web performance.&lt;/p&gt;
&lt;h3&gt;
  
  
  Run npm dedupe
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.npmjs.com/cli/commands/npm-dedupe" rel="noopener noreferrer"&gt;npm dedupe&lt;/a&gt; can help quickly fix any existing issues in the &lt;code&gt;package-lock.json&lt;/code&gt; file by flattening the dependency tree and regenerating the &lt;code&gt;package-lock.json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example, the app dependency depends on &lt;code&gt;@ant-design/icons@^4.6.0&lt;/code&gt;, and the correct semver resolution should be &lt;code&gt;4.8.1&lt;/code&gt;, though the &lt;code&gt;package-lock.json&lt;/code&gt; resolves to &lt;code&gt;4.6.0&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm explain @ant-design/icons

@ant-design/icons@4.6.0
node_modules/@ant-design/icons
  @ant-design/icons@&lt;span class="s2"&gt;"^4.6.0"&lt;/span&gt; from the root project

@ant-design/icons@4.8.1
node_modules/antd/node_modules/@ant-design/icons
  @ant-design/icons@&lt;span class="s2"&gt;"^4.7.0"&lt;/span&gt; from antd@4.24.14
  node_modules/antd
    antd@&lt;span class="s2"&gt;"^4.18.6"&lt;/span&gt; from the root projects
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running &lt;code&gt;npm dedupe&lt;/code&gt; will correct the &lt;code&gt;package-lock.json&lt;/code&gt; and remove the duplicate dependency:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm dedupe
npm list @ant-design/icons
example-fix-npm-dependencies@1.0.0 repo
├── @ant-design/icons@4.8.1
└─┬ antd@4.24.14
  └── @ant-design/icons@4.8.1 deduped
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;p&gt;Bundle analysis - duplicate packages - fixed using npm dedupe&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Finuloc82lmp6xp55i6zx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Finuloc82lmp6xp55i6zx.png" alt="Bundle analysis - duplicate packages - fixed using npm dedupe" width="800" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/relative-ci/example-fix-npm-duplicates/pull/4" rel="noopener noreferrer"&gt;View example GitHub pull request&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://app.relative-ci.com/projects/pAhM7X9PvW10mTVYY4s2/jobs/16-30vHJN2LYGTs7aubsMEf" rel="noopener noreferrer"&gt;View RelativeCI bundle analysis&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Upgrade/downgrade to a common version
&lt;/h3&gt;

&lt;p&gt;Another potential solution is to update and/or downgrade the dependency to a common version that the dependents can share.&lt;br&gt;
In the example above, we can update the application version to &lt;code&gt;v4.8.1&lt;/code&gt;, the same as the version resolved for antd. &lt;strong&gt;npm&lt;/strong&gt; will resolve both dependencies to v4.8.1.&lt;/p&gt;

&lt;p&gt;Updating a package version, especially a major version, can break existing functionality. Follow the change log of the dependency for changes, and make sure to test after the update.&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save&lt;/span&gt; @ant-design/icons@^4.8.1
example-fix-npm-dependencies@1.0.0 repo
├── @ant-design/icons@4.8.1
└─┬ antd@4.24.14
  └── @ant-design/icons@4.8.1 deduped
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/relative-ci/example-fix-npm-duplicates/pull/2" rel="noopener noreferrer"&gt;View example GitHub pull request&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://app.relative-ci.com/projects/pAhM7X9PvW10mTVYY4s2/jobs/12-caftkDBfWyJKm4q6tQyd" rel="noopener noreferrer"&gt;View RelativeCI bundle analysis&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Use npm overrides
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://docs.npmjs.com/cli/v8/configuring-npm/package-json?v=true#overrides" rel="noopener noreferrer"&gt;npm overrides configuration&lt;/a&gt; allows you to explicitly set package versions and override the npm resolution for any dependency, direct or transitive. In our example, we can override the resolved version of &lt;code&gt;@ant-design/icons&lt;/code&gt; to &lt;code&gt;4.7.0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Again, updating a package version, especially a major version, can break existing functionality. Remember to follow the change log of the dependency for changes, and ensure you test after updating.&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"app"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;/*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;*/&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@ant-design/icons"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^4.6.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"antd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^4.18.6"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;/*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;*/&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"overrides"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"antd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"@ant-design/icons"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"4.7.0"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm list @ant-design/icons

example-fix-npm-dependencies@1.0.0
├── @ant-design/icons@4.7.0
└─┬ antd@4.24.14
  └── @ant-design/icons@4.7.0 deduped
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/relative-ci/example-fix-npm-duplicates/pull/3" rel="noopener noreferrer"&gt;View example GitHub pull request&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://app.relative-ci.com/projects/pAhM7X9PvW10mTVYY4s2/jobs/17-BOq3doE2qSSdW0UzsKQk" rel="noopener noreferrer"&gt;View RelativeCI bundle analysis&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Use webpack configuration
&lt;/h3&gt;

&lt;p&gt;Webpack allows dependency imports to be overridden at bundle time using the &lt;code&gt;resolve.alias&lt;/code&gt; configuration option. &lt;/p&gt;

&lt;p&gt;Don't forget that updating a package version, especially a major version, can break existing functionality. Always follow the change log of the dependency for changes and test after the update.&lt;/p&gt;

&lt;p&gt;To point all the app imports of &lt;code&gt;@ant-design/icons&lt;/code&gt; to the same version, we can add an entry to &lt;code&gt;resolve.alias&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ... webpack config&lt;/span&gt;
  &lt;span class="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@ant-design/icons&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node_modules/@ant-design/icons&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/relative-ci/example-fix-npm-duplicates/pull/5" rel="noopener noreferrer"&gt;View example GitHub pull request&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://app.relative-ci.com/projects/pAhM7X9PvW10mTVYY4s2/jobs/18-WQzTEirA9xvau2bsKDzj" rel="noopener noreferrer"&gt;View RelativeCI bundle analysis&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;span id="fn-1"&gt;[1]&lt;/span&gt;: Data based on open-source projects analyzed by RelativeCI&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;2020&lt;/th&gt;
&lt;th&gt;2021&lt;/th&gt;
&lt;th&gt;2022&lt;/th&gt;
&lt;th&gt;2023&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Median package count&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;47&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;52&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;95&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;98&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Mean package count&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;46&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;76&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;130&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;138&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>webpack</category>
      <category>npm</category>
      <category>webperf</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
