Code splitting with serverless build doesn't really work
Issue description
Hi!
I'm trying to update my sls repo to v4 and move from serverless-esbuild to serverless native build
I have pretty simple setup with 2 lambdas with different dependencies in one repo.
serverless v3
My serverless.yml for v3 looks like that:
custom:
target: node20
external:
- sharp
exclude:
- '@aws-sdk/client-dynamodb'
- '@aws-sdk/client-lambda'
- '@aws-sdk/client-s3'
- '@aws-sdk/lib-dynamodb'
- encoding
and I have this output:
As you can see sharp-statistics zip archive is way bigger, because it includes sharp package dependency
serverless v4
In v4 I have almost the same serverless.yml configuration related to build:
build:
esbuild:
target: node20
external:
- sharp
exclude:
- '@aws-sdk/client-dynamodb'
- '@aws-sdk/client-lambda'
- '@aws-sdk/client-s3'
- '@aws-sdk/lib-dynamodb'
- encoding
But sls package output is very different:
For some reason telegram-telegram-bot includes a sharp dependency in its build, even though the codebase is exactly the same as the v3 branch, and this lambda doesn't use the sharp package at all.
It would be great if you could help me find the reason for different behavior of sls package and fix it
You can find my repo here: https://github.com/EugeneDraitsev/telegram-bot-app
It has 2 branches: master with v3 and serverless-v4 with v4
Context
No response
Source: serverless/serverless