Skip to content

Feature request: minimize size of the production lambda-layer or published npm package #517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
michaelbrewer opened this issue Jan 26, 2022 · 5 comments
Labels
completed This item is complete and has been merged/shipped dependencies Changes that touch dependencies, e.g. Dependabot, etc.

Comments

@michaelbrewer
Copy link
Contributor

michaelbrewer commented Jan 26, 2022

Description of the feature request

Try to keep the production deployed node_modules, without loss of functionality

Related issue: #419 (comment)

Problem statement

Keeping the published npm package as lean as possible will benefit all users in terms of cold start.

Summary of the feature

  • strip unneeded files (tests, .d.ts)
    • this is not needed for runtime
  • strip unneeded dependencies or non-aws managed/secured (eg: @types/aws-lambda and lodash.clonedeep ?)
    • This is a security risk
    • It bloats the library when not needed (eg: for createChild we can also use setOptions( from the original or v8 built in deserialize / serialize)
    • some upstream bugs needs to be fixed (Incorrect types for lambda authorizer event DefinitelyTyped/DefinitelyTyped#51120)
    • It is often easier to add a dependency than remove
    • it is harder for people to vendor powertools features
    • or not even referenced within the project types/aws-lambda.
  • minify if not already

Code examples

NA

Benefits for you and the wider AWS community

Faster execution, deployments (especially if there are published lambda layers).

Describe alternatives you've considered

Using modclean, minify-all and node-prune and documentation on recommendations to reduce cold starts

Additional context

Related issues, RFCs

@michaelbrewer michaelbrewer added the triage This item has not been triaged by a maintainer, please wait label Jan 26, 2022
@michaelbrewer michaelbrewer changed the title all: try to minimize the product lambda-layer or published npm package all: try to minimize the production lambda-layer or published npm package Jan 26, 2022
@michaelbrewer michaelbrewer changed the title all: try to minimize the production lambda-layer or published npm package all: minimize size of the production lambda-layer or published npm package Jan 26, 2022
@saragerion
Copy link
Contributor

saragerion commented Jan 26, 2022

Thanks for creating this issue.
Good news are that this unit of work is already on our radar and we are looking at several ways in which we can iteratively reduce the size while also keep it under control in the future. Possible iterations on this effort include some of the tips you mention, and also tree shaking and safety nets in our CI/CD pipelines.

Our team will definitely work on this as part as the production-ready milestone.

@michaelbrewer
Copy link
Contributor Author

i am sure it makes sense once their is stability in the apis, integration and unit testing :). I am sure the community would really appreciate this level of effort. :)

Another useful thing to consider is building some benchmarking to track for regressions.

@saragerion
Copy link
Contributor

Another useful thing to consider is building some benchmarking to track for regressions.

100%. Related comment: #398 (comment)

@saragerion saragerion added this to the production-ready-release milestone Jan 27, 2022
@dreamorosi dreamorosi added the dependencies Changes that touch dependencies, e.g. Dependabot, etc. label Feb 28, 2022
@dreamorosi dreamorosi changed the title all: minimize size of the production lambda-layer or published npm package Feature (all): minimize size of the production lambda-layer or published npm package May 12, 2022
@saragerion saragerion removed this from the production-ready-release milestone May 24, 2022
@dreamorosi
Copy link
Contributor

We have just release Lambda Layers and have implemented automation to measure the impact of each PR.

I will be closing this issue for the time being as the size of the utilities is still within more than reasonable bounds.

Will revisit the topic once we implement benchmarks.

@dreamorosi dreamorosi removed the triage This item has not been triaged by a maintainer, please wait label Oct 19, 2022
@github-actions
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dreamorosi dreamorosi changed the title Feature (all): minimize size of the production lambda-layer or published npm package Feature request: minimize size of the production lambda-layer or published npm package Nov 14, 2022
@dreamorosi dreamorosi added the completed This item is complete and has been merged/shipped label Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped dependencies Changes that touch dependencies, e.g. Dependabot, etc.
Projects
None yet
Development

No branches or pull requests

3 participants