-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
indirect aws-sdk dependency is always included in artifacts resulting in 10MB+ artifacts #292
Comments
Also, I tried this with These are my deps:
Note that |
Even setting this in webpack.config.js did not help:
|
I just confirmed that this is due to indirect dependencies on
to:
The package size will go from 10MB to 1MB. Of course, indirect dependencies on It seems that other build tools have "solved" this with a |
Hi @tommedema , In general, this declaration is the correct one to exclude dependencies (from your tries above):
Workaround - Solution IBut you can do a workaround, to transform the aws-sdk into a first level dependency.
Then the modules will be bundled and aws-sdk is now a first level dependency. The exclude declaration now will lead to a proper exclusion. Deep exclusionI had a look at the You can verify that just by doing a
So this cannot be solved in a correct way easily, if ever. Only NPM could solve that by having a switch/option to exclude packages - regardless where they appear. Solution IIThe most correct way is, that modules that require the aws-sdk define them as peerDependencies. So the |
Much appreciated, thanks again @HyperBrain. I understand the situation and why it's hard to resolve. I will for now use Not sure if this is very maintainable though, because it means that all these whitelisted packages will be bundled inside the webpack bundle and processed etc. I guess this could cause issues in the future, e.g. if they use binaries. |
I found a workaround described here: #306 (comment) for anyone struggling with this that can't change the library that requires aws-sdk |
Just adding a comment for those who may come to this late like me and was also stuck with It took me quite a few different attempts (due to my ignorance) and I didn't get it working until I read the source code of this plugin and found the correct syntax that works for me is: custom:
webpack:
includeModules:
forceExclude:
- aws-sdk Just thought it was worth a post in case anyone else got stuck (I had |
Ran into this recently and no the config in serverless.yml did not work. I had to update the webpack config by adding aws-sdk in the externals. |
This is a Bug Report
Description
For bug reports:
What went wrong?
aws-sdk is a built-in dependency on Lambda, therefore it should not be added to the bundle of functions that import
aws-sdk
, yet this does happen. Even when excludingaws-sdk
using theforceExclude
option. This results in each function being at least 10MB (the package itself is 25MB).What did you expect should have happened?
For
aws-sdk
to not be in the artifact zip filesnode_modules
folder.What was the config you used?
I tried several variations. This is my webpack.config.js:
And these are the variations of my serverless.yml that I tried; all failed to exclude aws-sdk:
I also tried:
I also tried:
And finally:
Additional Data
The text was updated successfully, but these errors were encountered: