Example spits out a 10.7MB main.bundle.js #255
Comments
Agree that that is a concern. Does that end up including the whole aws sdk or only the cognito identity service provider client? |
I've spent an hour following different ways to configure webpack and AWS Cognito and I'm just about to give up and put it into SCRIPT tag like most others. I don't get it, it does work, just like this example, but produces huge bundle like you noticed. I use only Cognito Pool, so don't need fulls SDK. Importing |
I think the issue should likely be reported here: My 2¢:
for example, just import this for s3. Build using webpack -p and set the node environment to "production". Finally, use this tool to find out where all your megabytes are coming from: |
@sbussard Im using webpack2 and am aware of tree shaking. That's why I migrated. I'm using -p and separate production config which is ok and working for many other modules quite well. My only issue is cognito. I am new to this so it takes time to get arround but for sure it does not work well "out of the box" nor following official AWS docs, not even this example. Bundle is just huge and it's not a small issue. I don't know how to import only what I need from aws-sdk. I need only cognito, not connecting to S3 or anything. I thought the whole point of aws-cognito-sdk was that it is stripped down version of aws-sdk for projects like mine where you only use Cognito pool. Logical step was to webpack-visualizer is a great find, really usefull! |
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. Note also that we have a couple of pull requests that we are in the process of integrating to remove some of the dependencies that will reduce the bundle size. |
If you are not going to fix your Webpack sample, why don't you at the very least source the browser-builder.js built JS? |
An
npm run build
spits out a ~11M build file which is a tad worrying.https://github.com/aws/amazon-cognito-identity-js/tree/master/examples/babel-webpack
https://twitter.com/slightlylate/status/822632880547500033
The text was updated successfully, but these errors were encountered: