activescott / serverless-aws-static-file-handler

Easily serve static files with the Serverless Framework on AWS Lambda.
MIT License
52 stars 14 forks source link

Depends on 5 megabytes of lodash just for _.get() #200

Closed tomchiverton closed 1 year ago

tomchiverton commented 1 year ago

Adding this plugin balloons the deploy size.

Take the built .serverless/*.zip and unpack it

Observe the node_modules/* folder sizes. lodash is the biggest consumer at 5 meg

$ npm list -prod -all
npm WARN config production Use `--omit=dev` instead.
xxxxx@0.1.0 /home/xxxxx/web-site
├─┬ promise-mysql@5.2.0
│ ├── @types/bluebird@3.5.38
│ ├─┬ @types/mysql@2.15.21
│ │ └── @types/node@18.11.11
│ ├── bluebird@3.7.2
│ └─┬ mysql@2.18.1
│   ├── bignumber.js@9.0.0
│   ├─┬ readable-stream@2.3.7
│   │ ├── core-util-is@1.0.3
│   │ ├── inherits@2.0.4
│   │ ├── isarray@1.0.0
│   │ ├── process-nextick-args@2.0.1
│   │ ├── safe-buffer@5.1.2 deduped
│   │ ├─┬ string_decoder@1.1.1
│   │ │ └── safe-buffer@5.1.2 deduped
│   │ └── util-deprecate@1.0.2
│   ├── safe-buffer@5.1.2
│   └── sqlstring@2.3.1
├─┬ serverless-aws-static-file-handler@4.0.1
│ ├── lodash@4.17.21
│ ├─┬ mime-types@2.1.35
│ │ └── mime-db@1.52.0
│ └── mustache@4.2.0
└── yesql@5.0.0

$ cd .serverless
... unzip *zip ...
$ cd */node_modules
$ du -skh *|sort -h| tail -n 2
724K    bluebird
5.0M    lodash

As far as I can see _.get() is the only thing used from all of lodash, it could be replaced with own impl.

serverless-aws-static-file-handler@4.0.1 node 18 Ubuntu 22.04 LTS

activescott commented 1 year ago

Love it! I'll help get this through!!

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 4.0.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: