s3-resizer 4.0
Technically, the interface is still compatible with version 3.x (100x100_max/my-image.jpg
- the path is still the same), but this update brings major changes including using new import/export syntax, so the decision was to jump to a new version. It does not follow semver.
Here is what's new:
- Update the Sharp library: v0.23.3 => v0.32.0
- Update AWS SDK: aws-sdk v2.36.0 => @aws-sdk/client-s3 v3.304.0. The former api contained the whole sdk with 99% unused code whereas the new one contains functions specific to S3.
- Buffers were replaced by streams. The latest versions of both AWS SDK and Sharp support streams, so now it's almost impossible to go out-of-memory if an image is too large (though it is still highly recommended to keep memory big +512mb, you can do that in Configuration->Edit)
- CommonJS => ES Module. And hence
require/exports
=>import/export
. So if the lambda wakes up, it is expected to take less time in the first request. - Reduce zip size containing compiled node_modules: 30mb => 10mb.
- If
?path=
is not set or is invalid, return explaining message andstatusCode: 400
. Previously it wasInternal Server Error
withstatusCode: 500
.
🎉 Compiled and tested for NodeJS 18.x 🎉
# default
npm i --arch=x64 --platform=linux
# without aws libraries
npm i --arch=x64 --platform=linux --only=prod
Use the latter only if you know what you are doing! It does not contain awk libraries in node_modules, so the latest version of the sdk will be used. You can configure auto update of built-in sdk in lambda Runtime settings -> Edit runtime management configuration -> Update runtime version.