Skip to content

Difficulty optimizing dependencies for AWS Lambda #297

Open
@spaceemotion

Description

@spaceemotion

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

Hi there,

I am currently trying to make my lambda as lean as I can to reduce our cold start times. I noticed that this package pulls in quite a bit, and also uses a couple outdated dependencies.

All my findings are based on the metafile esbuild produces, to check which code actually gets pulled at the end.

  1. mime-db seems to be about 130kb in size, just to check which mime-types are compressible. My API only ever deals with JSON data, and also sits in front of an API Gateway, so I was wondering if there is a way to make this optional? (or at least lazy-loaded)
  2. The build currently has multiple different versions of string_decoder and readable-stream. I tried to see if there is an easy way to upgrade them all, but even newer versions of through2 only depend on readable-stream@3, whereas version 4 is already out. I am using the pino logger with fastify, which pulls in the up-to-date versions of these packages.
  3. Similar case with duplexify:
    dependencies:
    @fastify/compress 7.0.3
    ├─┬ peek-stream 1.1.3
    │ └── duplexify 3.7.1
    └─┬ pumpify 2.0.1
      └── duplexify 4.1.3
    

I only ever need to compress responses, never decompress the input. Are there simpler/leaner/easier ways to do this?

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions