floydspace / serverless-esbuild

💨 A Serverless framework plugin to bundle JavaScript and TypeScript with extremely fast esbuild
MIT License
445 stars 137 forks source link

Support Lambda custom runtimes #529

Open theburningmonk opened 7 months ago

theburningmonk commented 7 months ago

Is your feature request related to a problem? Please describe. When using Lambda custom runtimes, I'd like to use the plugin to bundle my js but the custom runtimes (provided | provided.al2 | provided.al2023) are not supported.

Describe the solution you'd like In the helper.ts module, add the Lambda custom runtimes to the list of supported runtimes.

Describe alternatives you've considered Right now, the workaround I have is to:

  1. leave the runtime on one of the supported Node runtimes
  2. add another plugin (a local one to the project) that will update the Runtime in the generated CloudFormation template AFTER serverless-esbuild has bundle and generated the artefact

This is obviously not ideal and is a barrier for to people to run out alternative runtimes like Bun and LLRT.

Additional context Looking at the helper.ts module, it needs to match the node version from provider.runtime. We will need another way to tell serverless-esbuild which node version to use if provider.runtime is one of the custom runtimes.

floydspace commented 7 months ago

Hey @theburningmonk , good to see you here. I bet you want to run LLRT, that makes sense. I had thoughts about this, should it also provide a bootstrap file for you? we could also implement some custom runtimes like: llrt0.1.9-beta and bun1.0.29 as an idea.

you forked the repo, Do you want to come up with some implementation?

theburningmonk commented 7 months ago

Yup, trying to make using LLRT easier with the Serverless Framework!

I don't think it's necessary to provide the bootstrap file in the bundle, it's easy enough to bundle that as a layer, and I like being able to decouple the version of serverless-esbuild from the version of the LLRT bootstrap file.

I forked the repo last night to see what I need to do to make it support the custom runtimes, but I haven't looked closely enough to figure out the knock-on impacts of what node version the runtime is mapped to. So some feedback from you would be great.

If I add an option for AwsCustomRuntimes here: https://github.com/floydspace/serverless-esbuild/blob/master/src/helper.ts#L251 and map them to node20, would that break someone's build if they are running node18? I didn't think it should, but I wasn't sure.