serverless-esbuild icon indicating copy to clipboard operation
serverless-esbuild copied to clipboard

Get `runtime` from the function level

Open duncanista opened this issue 1 year ago • 4 comments

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.

duncanista avatar Jun 14 '23 18:06 duncanista

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.

mklenbw avatar Aug 08 '23 10:08 mklenbw

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).

brettdh avatar Sep 29 '23 18:09 brettdh

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.

davidworkman9 avatar Oct 23 '23 14:10 davidworkman9

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);

andreas-wolf avatar Feb 20 '24 13:02 andreas-wolf