Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Considerable bundle size increase when upgrading from @aws-amplify/[email protected] to @aws-amplify/[email protected] #7313

Closed
huoxito opened this issue Dec 1, 2020 · 10 comments
Labels
Build Related to build issues feature-request Request a new feature

Comments

@huoxito
Copy link

huoxito commented Dec 1, 2020

Hi!

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.

@huoxito huoxito added the to-be-reproduced Used in order for Amplify to reproduce said issue label Dec 1, 2020
@amhinson amhinson added the Build Related to build issues label Dec 1, 2020
@sammartinez sammartinez added needs-discussion Used for internal discussions and removed to-be-reproduced Used in order for Amplify to reproduce said issue labels Dec 8, 2020
@quinnturner
Copy link

quinnturner commented Dec 22, 2020

More specifically, it's between 3.4.0 and 3.4.2, or aws-amplify 3.1.0 and 3.2.0.

On aws-amplify 3.1.0 (auth 3.4.0), my bundle size is 216kb. On aws-amplify 3.2.0 (auth 3.4.2), my bundle size is 301kb.

@PaulTime
Copy link

PaulTime commented Dec 24, 2020

still having problems with this issue
image

bundle size increased from 200kb gzip to 440kb gzip after I installed @aws-amplify/auth and called AmplifyAuth.configure() method

@PaulTime
Copy link

image

@picardplaisimond
Copy link

picardplaisimond commented Dec 25, 2020

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:

@aws-amplify/auth": "^3.4.16,
@aws-amplify/core": "^3.8.8,

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 using Auth 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.

@nnyath
Copy link
Contributor

nnyath commented Jan 8, 2021

I think I've identified part of the issue and have got the ball rolling with a detailed PR here #7521

Thanks everyone for your stats and input; they have helped in corroborating my initial findings :)

@jamessouth
Copy link

My bundle, from 7484.

You can significantly reduce your dev bundle by using @aws-amplify/auth, etc., rather than aws-amplify as instructed in the Amplify React docs.

@cwomack
Copy link
Member

cwomack commented Dec 22, 2022

@huoxito and anyone following this, our team is investigating improvements to the bundle size for Amplify. We will provide you with updates when we have the next steps identified. Thank you all for providing us with this feedback!

@tannerabread tannerabread added the feature-request Request a new feature label Mar 6, 2023
@cwomack cwomack removed the needs-discussion Used for internal discussions label Mar 6, 2023
@abdallahshaban557
Copy link
Contributor

Hello everybody, our team has been focusing on reducing the bundle size of the Amplify library, and starting v 5.2.5, we have been able to reduce the bundle size for the below use cases:

    * Amplify core + Auth category: 73kB → 54kB (-26%)
    * Amplify core + Analytics category: 56kB → 30kB (-46%)

This is only the first step in our bundle size reduction efforts. In our next major version of Amplify JavaScript, we are going to provide better mechanisms for tree-shaking that will substantially reduce the bundle size. Stay tuned - we will provide updates on this issue when we have expected timelines mapped out.

Please try out the newest version of Amplify, and let us know if you are seeing the improvements I've mentioned! Your feedback is essential to helping us improve our library!

@abdallahshaban557
Copy link
Contributor

Hello everyone, We have made some additional changes to reduce the bundle size which include reduction to the Storage category as part of [email protected]. Below are our updated reduction numbers for the gzip bundle size. Please let us know if you are seeing these reductions in your apps.

  • Amplify core + Auth category: 73kB → 54kB (-26%)
  • Amplify core + Analytics category: 56kB → 30kB (-46%)
  • Amplify core + Storage category: 71KB → 29kB (-59%).

@cwomack
Copy link
Member

cwomack commented Nov 16, 2023

With the release of the latest major version of Amplify (aws-amplify@>6), this issue should now be resolved! Please refer to our release announcement, migration guide, and documentation for more information.

@cwomack cwomack closed this as completed Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Related to build issues feature-request Request a new feature
Projects
None yet
Development

No branches or pull requests