Skip to content

Commit

Permalink
lambda-js: Add note about esbuild module exports
Browse files Browse the repository at this point in the history
This change adds a short blurb about requirements for users who are using esbuild.

As discussed in aws-observability/aws-otel-lambda#99 there is a quirk of esbuild that causes exported functions using the `export` keyword to be marked immutable in the transpiled JS. As a result, you must use `module.exports` instead, which is passed along by the esbuild transpilation process unscathed.
  • Loading branch information
indrora committed Jul 20, 2023
1 parent 0563167 commit bd372c7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/docs/getting-started/lambda/lambda-js.mdx
Expand Up @@ -19,6 +19,8 @@ The AWS managed Lambda layer for ADOT JavaScript provides a plug and play user e

The Lambda layer supports Node.JS v14+ Lambda runtimes. For more information about supported JavaScript and Node.JS versions, see the [OpenTelemetry JavaScript documentation](https://github.com/open-telemetry/opentelemetry-js).

For *TypeScript users*, if you are using `esbuild` (either directly or through tools such as the AWS CDK), you *must* export your handler function through `module.exports` rather than with the `export` keyword! The AWS mananaged layer for ADOT JavaScript needs to hot-patch your handler at runtime, but can't because `esbuild` makes your handler immutable when using the `export` keyword.

### Add the ARN of the Lambda Layer

In this section, we consume the Lambda layer for use with Node.JS Lambda Functions. This includes a reduced version of the [AWS Distro for OpenTelemetry Collector (ADOT Collector)](https://github.com/aws-observability/aws-otel-collector), which runs as a Lambda extension.
Expand Down

0 comments on commit bd372c7

Please sign in to comment.