I come from working with nodejs and serverless framework, where I can configure esbuild so that functions that require other functions are in a single bundle file. Now I am working python with serverless framework, however, when I import an external function, and deploy. In the function bundle the whole project is uploaded. Clearly this would increase costs and delay the startup of the functions.
I have been reading about mock plugins serverless-python-individually, serverless-package-python-functions but i have not been able to package the function and its dependencies individually.
Is there any way to package the dependencies of the lambda functions individually?
example:
In nodejs I have the following structure:
api/
├─ v1/
│ ├─ handler/
│ │ ├─ fileHandler.js
│ ├─ anotherlambda/
│ │ ├─ index.js
│ ├─ s3Storage/
│ │ ├─ index.js
serverless.yml
When I deploy, it looks like this:
api/
├─ v1/
│ ├─ handler/
│ │ ├─ fileHandler.js
Where in fileHandler.js the code of the s3Storage/index.js dependency is inserted.
In python I have the following structure:
api/
├─ v1/
│ ├─ handler/
│ │ ├─ fileHandler.py
│ ├─ anotherlambda/
│ │ ├─ hello.py
│ ├─ s3Storage/
│ │ ├─ index.py
I would like to know if there is a way to package it in the same way as with nodejs esbuild.