serverless-layers icon indicating copy to clipboard operation
serverless-layers copied to clipboard

Force excluding / including packages

Open ptimson opened this issue 5 years ago • 4 comments
trafficstars

How should I go about excluding aws-sdk from the layer?

ptimson avatar Sep 13 '20 21:09 ptimson

Hello, @ptimson . You can remove aws-sdk from dependencies and place it in devDependencies.

agutoli avatar Sep 14 '20 01:09 agutoli

Thanks for the response @agutoli. Seem's like a good work around.

I do like the serverless-webpack approach to this issue: https://github.com/serverless-heaven/serverless-webpack#forced-exclusion

I don't think inclusion makes sense with this lib as everything is included anyway! (Unless you are force including a dev dependency). But I feel like the force exclusion may be useful both for this case and maybe others where a dependency has dependencies that your code doesn't use. Then again maybe this is more what https://github.com/beforeyoubid/serverless-webpack-layers aims to achieve.

I could work on a PR for it.

ptimson avatar Sep 14 '20 07:09 ptimson

Yes, that's is a good feature to implement.

agutoli avatar Sep 15 '20 05:09 agutoli

I ran into this as well, with a complex issue not worth explaining here. Another option is to customize your serverless-layers installation command:

serverless-layers:
    packageManager: yarn
    customInstallationCommand: yarn install --production && rm -rd ./node_modules/your-package-name

The remove command is executed in the temporary folder, so it will not affect your development environment or your CI/CD pipelines.

adambartholomew avatar Sep 25 '20 16:09 adambartholomew

Thanks for the response @agutoli. Seem's like a good work around.

I do like the serverless-webpack approach to this issue: https://github.com/serverless-heaven/serverless-webpack#forced-exclusion

I don't think inclusion makes sense with this lib as everything is included anyway! (Unless you are force including a dev dependency). But I feel like the force exclusion may be useful both for this case and maybe others where a dependency has dependencies that your code doesn't use. Then again maybe this is more what https://github.com/beforeyoubid/serverless-webpack-layers aims to achieve.

I could work on a PR for it.

Is this still being worked on?

jaywala avatar Sep 08 '23 06:09 jaywala

please try: [email protected]

agutoli avatar Oct 18 '23 09:10 agutoli