Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

final bundle size is quite large #47

Open
jonknapp opened this issue Feb 26, 2017 · 10 comments
Open

final bundle size is quite large #47

jonknapp opened this issue Feb 26, 2017 · 10 comments

Comments

@jonknapp
Copy link

Feel free to close this out if things are working as intended, but in a fresh app created with create-react-app requiring this library adds almost 2 MBs of code to the final bundle size. To contrast, adding the amazon-cognito-identity-js library adds only 0.08 MBs.

I would imagine the scope of what each library does is drastically different, but I'm wondering if there is something else that can be done to cut back on the final bundle size. Possibly moving some of the more barebones methods to their own module that we can include directly.

@jonknapp
Copy link
Author

This additional increase to the bundle may be a side effect of running it through webpack / babel as well. I'm a little light on exactly why it's happening, just thought it worthwhile to bring it up since I didn't see it mentioned anywhere else.

@itrestian
Copy link
Contributor

You probably end up including the whole AWS SDK.

Basically this is the way you build only the necessary clients for the AWS SDK:

http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/building-sdk-for-browsers.html

node dist-tools/browser-builder.js

and specify the services you want to include.

@jonknapp
Copy link
Author

If this library includes the full AWS lib (or it was implicitly done via webpack) that may be it. My only other AWS require in the app was aws-sdk/global which added about 0.6 MBs.

@jonknapp
Copy link
Author

I think you are correct about the entire AWS lib being included. I have some code that avoids webpack and includes the minified version of this lib in another script tag and that was causing errors until I brought in the aws-sdk/clients/cognitosync library. When I was requiring this library through webpack before, it did not give the errors about the CognitoSync client.

I'm not sure where webpack / babel-loader is trying to pull in the full AWS library from this dist file's source though.

@jonknapp
Copy link
Author

Ah, looks like a new NPM version was not published after the change to remove the bulk of AWS sdk from the minified version of this lib: 47f6b8a

It would probably work for me as expected after a new release is cut that includes this fix.

@orzechowskid
Copy link

any chance we could get a new version of this package published to NPM? I'd love to get the bundle size fix that's been discussed here, and even though putting a GitHub commit hash in my package.json is supported and works it still feels a little dirty to have it there.

@DavidWells
Copy link

@orzechowskid whats the dependency look like in your package.json?

I'd like to shrink my bundle as well =)

@orzechowskid
Copy link

@DavidWells b57038c is the latest commit to amazon-cognito-js as of today:

"dependencies": {
-  "amazon-cognito-js": "^1.1.0"
+  "amazon-cognito-js": "aws/amazon-cognito-js#b57038ca817981a60bd8b26c2ddaff27c81b908a"
}

@alexjfno1
Copy link

alexjfno1 commented Aug 29, 2018

Just been looking at my bundle size and it seems #38 hasn't been released to NPM. Can someone release the latest code to NPM?

@christemple
Copy link

@itrestian can we please get a new version of this packaged published with the changes?

I'd prefer not to pull from a github commit in my package.json

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants