AWS CDK Construct to build Node.js AWS lambdas using esbuild.
- Zero-config: Works out of the box without the need to install any other packages
- Supports ESNext and TypeScript syntax with transforming limitations (See Note)
Note: The default JavaScript syntax target is set to ES2017
, so the final bundle will be supported by all AWS Lambda Node.js runtimes. If you still using an old lambda runtime and have to respect it you can play with esbuild target
option, see JavaScript syntax support for more details about syntax transform limitations.
yarn add --dev aws-lambda-nodejs-esbuild
# or
npm install -D aws-lambda-nodejs-esbuild
By default, no configuration required, but you can change esbuild behavior:
TODO
Check esbuild documentation for the full list of available options. Note that some options like entryPoints
or outdir
cannot be overwritten.
The package specified in the exclude
option is passed to esbuild as external
, but it is not included in the function bundle either. The default value for this option is ['aws-sdk']
.
The normal AWS CDK deploy procedure will automatically compile with esbuild
:
- Create the AWS CDK project with
cdk init app --language=typescript
- Install aws-lambda-nodejs-esbuild plugin as above
- Deploy with
cdk deploy