smaller-modules
Shrink node_modules for deployment
Introduction
Are you having problems getting node_modules
down to a reasonable size?
An error occurred (RequestEntityTooLargeException) when calling the UpdateFunctionCode operation: Request must be smaller than 69905067 bytes for the UpdateFunctionCode operation
Do you hit size limits, even when creating separate layers to contain dependencies?
An error occurred (InvalidParameterValueException) when calling the UpdateFunctionCode operation: Unzipped size must be smaller than 262144000 bytes
Here's a utility that might help.
Quickstart
node_modules
for Lambda
Zip up smaller-modules --zip --file dist/handler.js
Copy dependencies of compiled output to a new directory
smaller-modules --copy --directory dist --output-subdirectory smaller_modules
.js
file
List dependencies of a smaller-modules --list --file dist/index.js --output-path dependencies.txt
or print it to the command line
smaller-modules --list --file dist/index.js
Usage
node_modules
for Lambda (in long-hand)
Zip up smaller-modules --zip --file dist/index.js --output-subdirectory nodejs --output-path node_modules.zip
Use with packages in a mono-repository
# Run from packages/<package-name>
smaller-modules --list --file dist/index.js --base "../.."