My Node lambda is a fairly small function in terms of what it does/lines of code. yet somehow is sitting at 18mb in size. I think this might be due to me installing firebase and it being quite a big package.
I was wondering if there was a way to reduce it?
I did have const firebase = require('firebase') but now I changed it to:
const firebase = require('firebase/app')
but when I zip the lambda up I can still see lines this like:
adding: node_modules/firebase/messaging/dist/ (stored 0%)
adding: node_modules/firebase/messaging/dist/index.cjs.js.map (deflated 20%)
adding: node_modules/firebase/messaging/dist/index.cjs.js (deflated 3%)
which looks like it's still adding the messaging package for some reason?
is there a way to reduce this lambda as I think 18mb is pretty big
You may use lambda layers to solve this problem. We had to use facebook node.js sdk in our lambda and it was huge(~7MB zipped version), we used lambda layers to reduce deployment package.
Layers let you keep your deployment package small, which makes development easier. You can avoid errors that can occur when you install and package dependencies with your function code. For Node.js, Python, and Ruby functions, you can develop your function code in the Lambda console as long as you keep your deployment package under 3 MB.
Please check this link for more information
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With