floydspace / serverless-esbuild

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

Feature request : being able to customize handler resolution #88

Open wimpheling opened 3 years ago

wimpheling commented 3 years ago

I've been trying to use your plugin but my setup involves Instana (a log analyzer vendor). The @instana/serverless module works this way :

When using serverless-esbuild this breaks handler resolution. I've been able to make it work by forking the module and replacing this line : https://github.com/floydspace/serverless-esbuild/blob/65b7431aca4bfe5b8f85bd1aecf8d6c1b9fc050b/src/helper.ts#L36-L37

with

  return Object.values(functions)
        .map(fn => (fn.environment && fn.environment.LAMBDA_HANDLER) || fn.handler)

Of course, this is very specific, so I wonder if you could add a way of providing this in the configuration or overriding the extractFileNames function, as you already provide a special behavior for the google provider.

If you're ok or have an idea about how it should be implemented, I may be able to submit a PR.

Thanks

floydspace commented 3 years ago

Hi @wimpheling, thank you for the request, we will consider this if we get more requests. For now, I recommend using patch-package, it's a nice package to keep your patches to node_modules shared. so you do not have to make a fork or whatever.

olup commented 3 years ago

@wimpheling did @floydspace's recommendation worked for you ? Can we close this ?

spamalot22 commented 4 months ago

Support for the Instana lambda layer would be a great enhancement for us. Serverless-Webpack allows this now by letting you set a different entrypoint for each lambda function.