Wednesday 23 October 2019

modular-aws-sdk-pure-node: the aws-sdk without any clutter

I have developed a lot of node.js services running on AWS (EC2) and using the aws-sdk. What always had bothered me is the size of the aws-sdk! Annpm install --save aws-sdk gives you 43 megabytes of full blown aws-sdk. I peeked inside the installed folder, and behold, there is a lot of stuff I, as a node.js developer, don't need: dist, dist-tools, files for supporting the sdk running in the browser.So, I wrote a small script (https://github.com/Junkern/modular-aws-sdk/blob/master/scripts/createPureNodeJsAWSSDK.sh) which gets rid of not needed files and folders and I published the resulting package. Installing the modular-aws-sdk-pure-node package (https://www.npmjs.com/package/modular-aws-sdk-pure-node) now results in a size of 30 Megabytes.This is, however, still a lot, especially when you are using only one service (e.g. DynamoDB) of the SDK.So, I analyzed the aws-sdk and found a way to create the whole SDK for only one service! When you use only the DynamoDB, you can save ~40 megabytes by installing the modular-aws-sdk-dynamodb package, instead of the aws-sdk. (Take a look at https://github.com/Junkern/modular-aws-sdk to find out more)I am a huge fan of keeping applications small, so I hope I can help you lowering the size of your applications, reducing costs and saving time while installing dependencies ;)Feel free to criticize, ask questions, come up with improvements :)I also see some cons of my approach:How can someone make sure that I did not alter the original aws-sdk in any way? => Maybe hash folder contents to prove that I did not alter anything?Does everything still work? => Tests are on my agenda. And I am using e.g. modular-aws-sdk-dynamodb in production, so far everything works fine :P

Submitted October 23, 2019 at 12:29PM by EverythingIsGoingUp

No comments:

Post a Comment