Considerable bundle size increase when upgrading from @aws-amplify/auth@3.2.4 to @aws-amplify/auth@3.4.13
See original GitHub issueHi!
We’re trying to upgrade to latest @aws-amplify/auth
and we noticed a considerable build size increase. Our vendor bundle went from 213,58KB to 304,46KB.
Looking into npm it seems the unpacked size went from 2.16 MB to 6.47 MB. Any chance there’s a way to decrease this bundle size? Maybe opt out some features not needed for some apps. Is there any on going project / task to try decrease that bundle size?
We haven’t found any bugs with 3.4.13, so far all good. But since this build increase affects our TTI I was hoping to understand better what happened or how we could make it better moving forward with amplify/js.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:14
- Comments:7 (1 by maintainers)
Top Results From Across the Web
5 Methods to Reduce JavaScript Bundle Size - Bits and Pieces
4. Compressing Bundles. If your application bundle size increases and affects performance, you can compress them to reduce the size. Gzip and ...
Read more >Slimming down your bundle size - LogRocket Blog
A critical part for improving frontend performance is to reduce the JavaScript bundle size that should be downloaded via the network.
Read more >How to decrease prod bundle size? - angular - Stack Overflow
With this import change our unpacked bundle size decreased from 1.0MB to 663kB (213.4kB -> 126kB packed). We had to update every import...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I’ve identified part of the issue and have got the ball rolling with a detailed PR here https://github.com/aws-amplify/amplify-js/pull/7521
Thanks everyone for your stats and input; they have helped in corroborating my initial findings 😃
This is a very important problem in my opinion. I have to support this. In my case, I only use:
import Amplify from '@aws-amplify/core'
import Auth from '@aws-amplify/auth'
It increases the size of the application by 244 kb ! It’s way too much to just handle authentication ! Chrome DevTools tells us that most of the javascript isn’t even executed. So it’s an optimization problem.
From what I’ve seen, if we use the
Auth
module, all the functions of this class are imported. There must be a way to optimize that. Maybe with more targeted dynamic imports in that class? I’m talking about a big refactoring.I found nothing else to fix it. If anyone has a better solution, that would be great. I’m also thinking about using
amazon-cognito-identity-js
on the client to cut over the amplify’s overload…Here are the versions I am currently using:
Edit:
It may not be important but … After some investigation, I found that after installing the last
@preview
version(3.0.18-preview.4
), the size was drastically reduced by over 50%. Since I am just usingAuth
basic functions (signUp, signIn, signOut, ect …) everything seems to work fine. This package is more than 6 months old. It proves that it is possible to have a smaller bundle size. However, I know it’s old, so not recommended in production.