nfour / serverless-build-plugin

A Node.js focused build plugin for serverless.
MIT License
41 stars 9 forks source link

Excluding aws-sdk with webpack is not intuitive #37

Open sevenseat opened 7 years ago

sevenseat commented 7 years ago

I'm not sure this is a bug, but I found excluding the aws-sdk in a file build method using webpack unintuitive. Not only does it need to be excluded within the webpack.config.js using: externals: ['aws-sdk']

But it also needs to excluded in the serverless.build.yml using

modules:
  exclude:
     - aws-sdk
  deepExclude: # Excluded from deep nested node_modules
    - aws-sdk

It seems odd to have to exclude it in both places.

nfour commented 7 years ago

The reason for this is that webpack is its own thing, and it's expected that to use it you understand the way webpack works. Externals are basically saying to webpack "dont try to bundle this". The module excludes from this plugin can then take effect.

It may be that it should be documented as a use-case, though.