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.

Considerable bundle size increase when upgrading from @aws-amplify/auth@3.2.4 to @aws-amplify/auth@3.4.13

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:14
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
nnyathcommented, Jan 8, 2021

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 😃

4reactions
picardplaisimondcommented, Dec 26, 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.

Read more comments on GitHub >

github_iconTop 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 >

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