serverless-esbuild
serverless-esbuild copied to clipboard
Get `runtime` from the function level
Problem
Currently, you can only build for runtimes at the provider level.
provider:
name: aws
region: sa-east-1
runtime: nodejs18.x
functions:
hello-world:
handler: index.handler
If I want to build multiple functions with different runtimes, I have to create another serverless.yml
file, which is not convenient.
Proposed solution
I would like to build multiple functions with multiple runtimes. Getting the runtime from the function level.
provider:
name: aws
region: sa-east-1
functions:
hello-world-node18:
handler: index.handler
runtime: nodejs18.x
hello-world-node16:
handler: index.handler
runtime: nodejs16.x
Currently, this throws the following error:
Error:
AssertionError [ERR_ASSERTION]: not a supported runtime
at new AssertionError (node:internal/assert/assertion_error:451:5)
Alternatives considered
Maybe also use the provider as a fallback?
Additional context
- Latest version of
serverless
- Latest version of
serverless-esbuild
- LTS version of
node
.
This issue is also affecting build with a different runtime as node or no runtime set at provider level.
The plugin throws a hard assertion if the runtime-provider is empty, although the functions have a valid runtime set.
It should be easy to solve.
@duncanista this should be considered a bug because it breaks deployments. The title is just missleading.
Same for me; I want to use esbuild with just a single lambda. Most lambdas in my app are using a custom docker image (mostly Python).
I'm a few versions behind and was trying to upgrade. this use to work on v1.34.0. v1.35.0 seems to have broken this functionality.
Same problem here. esbuild is a dependency from another module. We don't use it directly since our provider runtime is python. V1.35.0 broke our build with assertIsSupportedRuntime(providerRuntime);