Closed stanyq4 closed 10 months ago
PR to review: https://github.com/agutoli/serverless-layers/pull/131
package:
patterns:
- '!node_modules/express/**'
- 'node_modules/**'
Reference: https://www.serverless.com/framework/docs/providers/aws/guide/packaging
(It wasn't release yet, but probably will be on next version).
If you could merge this bad boy that would be pretty cool. Thanks
@agutoli Thanks for the fix. Can you please merge it?
As a workaround, install clean-modules
npm module and use customInstallationCommand
option to call npm ci --omit=dev --ignore-scripts && clean-modules -y
and set up a .cleanmodules
file with the patterns you want to exclude.
Bonus: If you want to include, you can use this undocumented option copyBeforeInstall
serverless-layers:
copyBeforeInstall:
- package-lock.json
- path/to/custom/files # This file will be part of the layers
please try: serverless-layers@2.7.0
Thanks @agutoli :)
In the serverless.yml, I am specifying the following node modules to be excluded as part of the layer:
AWS SDK is around 50MB and is included by default in all lambdas, so it makes no sense to package it as part of the layer.
However, when the layer is being created it still includes the @aws-sdk folder from node_modules
Created layer package /Users/stanyeshchenko/Dev/projects/api-demo/.serverless/api-demo-nodejs-default.zip (88.9 MB)
Attaching a screenshot with layer that I downloaded from S3, you can see that aws-sdk is not excluded