question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: bundle size larger than expected with ionic 6 + webpack

See original GitHub issue

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

This is a follow-up to https://github.com/ionic-team/ionic-framework/issues/24280, which was closed as fixed. Unfortunately, I am still having the same issue-- in Ionic 5, with a React app, the first big chunk of my app was about 500 Kb, but with Ionic 6, it’s 1.4 MB.

ionic_react_6_bundle_still_too_big

I also tried using the tool’s "show bundle content (inaccurate) option:

more_bundle_info

What surprised me about the above result is that it shows that ion-slides, ion-accordion-group, ion-breadcrumb, and other components that I do not use in my app are being pulled in, so this is likely the source of the bloat.

Expected Behavior

I expected Ionic 5 and 6 to be roughly the same size.

Steps to Reproduce

Update a moderately sized app from v5 to v6. I am using CRA5 with Webpack 5.

Tested with webpack-bundle-analyzer

react-scripts build --stats; webpack-bundle-analyzer build/bundle-stats.json

Code Reproduction URL

No response

Ionic Info

Ionic:

Ionic CLI : 6.18.1 (/home/anon/.npm-global/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/react 6.0.13

Capacitor:

Capacitor CLI : 3.4.3 @capacitor/android : 3.4.3 @capacitor/core : 3.4.3 @capacitor/ios : 3.4.3

Utility:

cordova-res : 0.15.4 native-run : 1.5.0

System:

NodeJS : v16.14.1 (/usr/bin/node) npm : 8.5.0 OS : Linux 5.10

Additional Information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ptmkennycommented, Apr 4, 2022

@liamdebeasi Ok thanks. I had some more time to look at this and I see that the actual bundles are correct, and the webpack-bundle-analyzer output is inaccurate.

I’ll close this now as the issue is completely solved in the latest release. Many thanks for such a thorough solution!

0reactions
ionitron-bot[bot]commented, May 4, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Anything I can do about a 6mb built JS? - Ionic Forum
My main.js is a plump 6.0mb (before gzip compression), ... Thanks for the advice about moment.js, it's quite a bit larger than I...
Read more >
Webpack output bundle larger than expected - Stack Overflow
The jQuery JS file has the size of 29.5kb from jsdelivr. My entry, that only includes jQuery, and nothing else, has the size...
Read more >
5 Methods to Reduce JavaScript Bundle Size - Bits and Pieces
1. Code Splitting with Webpack ... Code splitting allows you to separate your code into bundles and load them on-demand. There are multiple...
Read more >
All About Angular Engine Ivy in 5 mins
The bundle size is also reduced with its help. It was first available in the Angular version 8 with Angular Ivy opt-in. Pipeine...
Read more >
Writing ES6 Ionic code with webpack - codebits
Then, when it comes to bundling, webpack allows you to bundle not only js files, but also bundle your scss, hbs\jade and image...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found