I'm using esbuild to package my lambdas functions. However, when generating the build of them to perform the deployment, I get an alert that the package is too big, as in the image below.
File to big
I found in the documentation a way to remove certain packages with the --external: flag. However, I have many lambdas, and for each lambda I would have to add this flag in my build script whenever there is a new devDependencie package. I would like to know if there is a more practical and easier way to solve this?
build script:
for function in $(ls functions/typescript); do
esbuild functions/typescript/$function/index.ts --platform=node --bundle --minify --external:@types/aws-lambda --external:@types/aws-sdk --external:@types/node-forge --external:@types/pem --external:aws-sdk --outfile=functions/__compiled__/$function/index.js
done
P.S: remembering that not all lambdas will need these devDependencies packages
Edit1:
package.json
{
"name": "clinicSettings",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"aws-lambda": "^1.0.7",
"lambda-utils": "private-repo",
"node-forge": "^1.3.1",
"pem": "^1.14.6",
"squel": "^5.13.0"
},
"devDependencies": {
"@types/aws-lambda": "^8.10.101",
"@types/aws-sdk": "^2.7.0",
"@types/node-forge": "^1.0.4",
"@types/pem": "^1.9.6",
"aws-sdk": "^2.1177.0"
}
}