serverless-esbuild
serverless-esbuild copied to clipboard
Overriding the keyword used to get the handler in the lambda function defintion
Is your feature request related to a problem? Please describe.
We are trying to setup Datadog in our serverless project. We are also using serverless-esbuild. An issue we are encountering is in src/helper.ts
on line 68: https://github.com/floydspace/serverless-esbuild/blob/b0ec8087808abbb7acf5746f6fe039326e064bc8/src/helper.ts#L68
The keyword handler is used to get the entrypoint to give to esbuild. However with Datadog, this handler is overidden by /opt/nodejs/node_modules/datadog-lambda-js/handler.handler
and the real handler is located in the environment:
DD_LAMBDA_HANDLER: 'handler.main'
This is throwing us the following error:
Error: Compilation failed for function alias XX. Please ensure you have an index file with ext .ts or .js, or have a path listed as main key in package.json
at /Users/XX/XX/XX/node_modules/serverless-esbuild/src/helper.ts:98:13
Describe the solution you'd like We would like serverless-esbuild to work with Datadog, we can see the following idea:
Allow an other keyword to be used: (could be hardcoded or defined in the custom part of the serverless file?)
{
handler: '/opt/nodejs/node_modules/datadog-lambda-js/handler.handler',
esbuildEntrypoint: `${pathResolver(__dirname)}/handler.main`,
}
const { handler, esbuildEntrypoint } = func;
const entryPoint = esbuildEntrypoint || handler;
Describe alternatives you've considered Maybe there is already a way to achieve what we are trying to do here? Did we miss it?
Additional context If indeed there is no way to achieve what we are doing, we would be pleased to work on a pull request if you think this could be useful for others
@floydspace What do you think?
sorry for late response (and I don't have any viable excuse for that), it lgtm and I merged it.
:tada: This issue has been resolved in version 1.54.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: