Open joe-price-jt opened 4 months ago
Possibly a duplicate of https://github.com/serverless/serverless/issues/12840
Ok, I think I see what's going on here. I opened a PR with a fix:
@joe-price-jt Is there a reason you cannot define your dependencies in the service's package.json
? The best practice is for it to be defined as a dependency in every service.
Hey @Mmarzex, apologies for my very slow reply!
The repository isn't structured such that each service has its own package.json
with its own dependencies. The top-level package.json
manages all of the dependencies that are used across the services.
Encountering the same issue – yes, the goal is also to move away from a top-level package.json
but this is a wider refactor. @Mmarzex are you planning to enforce this and is @eahefnawy's change likely to make it to a release anytime soon? This is currently blocking our upgrade to V4.
Issue description
Bug
We're currently using Serverless Compose to deploy a number of Node services defined in a single repository in sequence. All services use a common build file:
In this case,
zod
is labelled as a dependency in our top-levelpackage.json
.As
zod
is being labelled as an external dependency in the build configuration; when I package this service via Serverless Compose (e.g.npx sls some-service package --stage=local
), I expectzod
to be included as part of thenode_modules
directory for each lambda function zip. However, this is not the case:This is behaving as expected in a different repository with the same build configuration where Serverless Compose is not being utilised:
When packaging via Serverless Compose with debug logs enabled, I can see that Serverless V4 is registering
zod
as an external dependency:Summary
When packaging services via Serverless Compose, Serverless V4 does not seem to include packages labelled as external in the build configuration as part of the
node_modules
directory for each lambda function zip. This is preventing us from migrating our repository using Serverless Compose to V4. Is there something that I've missed here?Context
Serverless Framework version: 4.4.16