01-09-22
The AWS Amplify SDK is 1.2mb minified and I have to ask why?
Now let me just be fair first (excuse the exaggerated point above) and say, the package encompasses a large set of tools ranging from auth (cognito) to storage (S3) and more. It is tree-shakeable and gzipped it drops to 280.4kb.
But all that still is not okay when I am still shipping over 200kb of JS on first load just to use their Auth package because it’s the only SDK (out of there three versions?) that has semi-readable documentation for implementing Cognito.
I can’t just use the module ‘@aws-amplify/auth’ without ‘@aws-amplify/core’ to setup the Amplify config. Which might be okay if we stopped there, however I also need withSSRContext from the full-featured, all-inclusive ‘aws-amplify’ package. And unfortunately tree-shaking here isn’t enough to keep your bundle size lower than ~200kb. That’s because withSSRContext is an API that applys to all modules not just for your specifc use.
There is an open issue on the aws-amplify repo currently that has seen some activity and comments about being resolved in the next full-release of the package but I’m not exactly sure when that is. Or why there isn’t a better way to do this in the first place. Are we all really okay with that much JS for a wrapper to just send HTTP requests mostly?
To compare, Auth0’s nextjs-auth package is 6.4kb gzipped. Next-auth which is an actual authentication solution not just an wrapper to interact with a third-party system is only 77.9kb gzipped.
The size is just too much and really hard to justify in my opinion.