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

Unable to exclude aws-sdk from bundle

Open C5H8NNaO4 opened this issue 2 years ago • 5 comments

This is a (Bug Report / Feature Proposal)

Description

For bug reports:

  • The aws-sdk package gets bundled into the lambda.zip bundle
  • The aws-sdk should not be bundled
  • The config used is as follows:
webpack:
    webpackConfig: ./webpack.config.js
    includeModules:
        forceExclude:
            - aws-sdk
####
webpack:
    webpackConfig: ./webpack.config.js
    includeModules: true
    excludeFiles: node_modules/aws-sdk/**

The aws-sdk has also been added as an external in the webpack config.

However the aws-sdk is still being included in the bundle.

Running a script like rm node_modules/aws-sdk unfortunately throws an error. So I can't use that as a workaround.

Additional Data

  • Serverless-Webpack Version you're using: 5.8.0
  • Webpack version you're using: 5.74.0
  • Serverless Framework Version you're using: ??
  • Operating System: Windows

C5H8NNaO4 avatar Aug 20 '22 16:08 C5H8NNaO4

Would you mind try adding an exclude pattern in package?

serverless.yml

package:
  patterns:
    - '!node_modeuls/aws-sdk/**'

vicary avatar Aug 20 '22 16:08 vicary

Possible duplicate with #1218, see https://github.com/serverless-heaven/serverless-webpack/issues/1218#issuecomment-1214427420 for unconfirmed workaround.

vicary avatar Aug 20 '22 16:08 vicary

@vicary I tried adding the exclude pattern in package but that doesn't change anything. I also saw the duplicate, but none of the suggested workarounds or solutions do help.

C5H8NNaO4 avatar Aug 20 '22 18:08 C5H8NNaO4

@C5H8NNaO4 Thanks, that's unfortunate. There are many possible ways to have this happening, usually due to misconfiguration and oversights.

If a minimum reproducting repo is possible, please try to make one so we could pin point the problem.

vicary avatar Aug 20 '22 22:08 vicary

@C5H8NNaO4 try this https://github.com/serverless-heaven/serverless-webpack/issues/1218#issuecomment-1269723395

andrew-ignatiev avatar Oct 06 '22 09:10 andrew-ignatiev