AnomalyInnovations / serverless-bundle

Optimized packages for ES6 and TypeScript Node.js Lambda functions without any configuration.
https://serverless-stack.com/chapters/package-lambdas-with-serverless-bundle.html
MIT License
532 stars 153 forks source link

Not all libs from externals end up packaged in my lambda function #367

Closed gligorkot closed 7 months ago

gligorkot commented 7 months ago

I declare 3 packages in my externals list, but only 2 of them get included in the zip package of my lambda function.

The packages in question are:

I believe the issue is that chartjs-node-canvas has canvas as a dependency, but chart.js as a peer dependency. When I run serverless package I get a warning

WARNING: Could not check for peer dependencies of chartjs-node-canvas. Set nodeModulesRelativeDir if node_modules is in different directory.

I believe if nodeModulesRelativeDir is exposed as an additional webpack config we can modify via serverless-bundle, I'd be able to configure it to correctly pull through the peer dependency chart.js as well.

gligorkot commented 7 months ago

I believe this was caused because my services are part of a monorepo. I've now exposed this setting via serverless-bundle config and it's working! I'll send a PR soon.