-
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
Allow force excluding deep dependencies #306
Comments
+1! |
Hi, Has any progress been made on this? I am hitting the same problem. This is my project structure:
common is a module which contains common code that will be reused in other services. This common module depends on the aws-sdk module. Obviously, the api module depends on common. When I package the lambda functions in the api module, dev dependencies in common (i.e. aws-sdk) are packaged too.
I tried adding aws-sdk as a peerDependency in common with no luck. I don't know what else to try. It is not affecting functionality, just making the zip files big. Not great. Thanks. |
For anyone else hitting this issue (especially with No excludes or includes needed in the custom:
webpack:
packager: 'yarn' In the webpack config: module.exports = {
entry: slsw.lib.entries,
mode: 'production',
externals: [{'aws-sdk': 'commonjs aws-sdk'}]
... |
I was able to get rid of custom:
webpack:
includeModules: true
packagerOptions:
scripts:
- rm -rf node_modules/aws-sdk |
When I work with serverless and Lambda, I just add aws-sdk as a dev dependency, and that works fine. I can test locally, and when I deploy, it doesn't package up AWS. |
I'm still investigating this and will report back if I find anything helpful in my workflow. |
Hey do we have any progress on that? I am also using a package which uses inside aws-sdk so at the end it bumps up the size of the deployment by lot of MB. The solution that @hsz wrote seems that does not change the zip output that will be uploaded to AWS. Trying to add
In a function that is uploading to S3, import of the function below:
As far as I know the lambda should automatically include the aws-sdk so now I'm lost. |
Rather than doing the above, the following worked for me until I included the custom:
webpack:
includeModules:
forceExclude:
- aws-sdk However after including |
Better delete all aws-sdk folders recursively to avoid skipping nested aws-sdk folders: packagerOptions:
scripts:
- find . -type d -name 'aws-sdk' -exec rm -rf {} + |
This is a Feature Proposal
Description
Currently the
forceExclude
option in the plugin only excludes 1st level dependencies.The question often arises if it could also exclude dependencies deeply, e.g.. if you force exclude
the
aws-sdk
then it would exclude it even if a 3rd dependency references it.Referencing issues are: #292 and #305
The whole feature is quite tricky, see the discussions in the referenced issues.
The first approach that should be investigated is mentioned in #305 (comment) (multi-pass approach) as it might integrate nicely into the isolation concept of the node_modules folder and lets npm do the work.
The text was updated successfully, but these errors were encountered: