Reduce the size of the node-modules zip sent by the serverless framework
aws-sdk
is in the neighborhood of 24MB and you don't need it since it's already available to lambda functions. One option is to move it to dev-dependencies and then put your dev-dependencies in package.json
of a parent directory.
There are also some tools that can help:
serverless-plugin-include-dependencies plugin - thought I'm not sure how well it works if the exclude function is broken: https://github.com/dougmoscrop/serverless-plugin-include-dependencies
Webpack can also be used with serverless-webpack plugin to control dependencies. Webpack's dead code elimination can make a pretty substantial difference.
Not ideal, but you can also run npm prune --production
before deployments. (You'll need to run npm install
again after.
You can use the serverless ability to exclude some packages you don't need (for example, you're guaranteed to here the manual.
Unfortunately, seems that since version 1.16 there's a problem that those excludes are ignored (version 1.15.1 created much smaller zips, and since 1.16 the zip include anything in your node_modules). I opened an issue, but it is still unanswered.