Registry / aws / aws-lambda-nodejs-esbuild

aws-lambda-nodejs-esbuild

JSON →
library1.1.6jsnpmunverified

AWS CDK Construct for bundling Node.js AWS Lambda functions using esbuild. Version 1.1.6 (latest) supports zero-config bundling with ESNext/TypeScript, automatic package manager detection, and external module support. Unlike @aws-cdk/aws-lambda-nodejs (which uses esbuild internally but with less configurability), this construct exposes full esbuild options and allows overriding the 'exclude' list. Currently in maintenance mode; designed for CDK v1 and lacks native CDK v2 support.

npm install aws-lambda-nodejs-esbuild
INSTALL
IMPORT
SIG · AWS-LAMBDA-NODEJS-
A
aws-lambda-nodejs-esbuild
awsjavascriptv1.1.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NodejsFunction
import { NodejsFunction } from 'aws-lambda-nodejs-esbuild'
const { NodejsFunction } = require('aws-lambda-nodejs-esbuild')
Package ships TypeScript types; ESM import is preferred but CJS require works in Node.js
NodejsFunctionProps
import { NodejsFunctionProps } from 'aws-lambda-nodejs-esbuild'
Type export for TypeScript users; use to type the props object
default
import AWS from 'aws-lambda-nodejs-esbuild'
import AWS from 'aws-lambda-nodejs-esbuild'
No default export; must use named import

Creates a CDK stack with a Lambda function bundled using esbuild, with minification and external aws-sdk.

import * as cdk from '@aws-cdk/core'; import { NodejsFunction } from 'aws-lambda-nodejs-esbuild'; import { Runtime } from '@aws-cdk/aws-lambda'; class MyStack extends cdk.Stack { constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { super(scope, id, props); new NodejsFunction(this, 'MyLambda', { entry: 'src/handler.ts', runtime: Runtime.NODEJS_14_X, esbuildOptions: { minify: true, target: 'ES2017', external: ['aws-sdk'], }, }); } } const app = new cdk.App(); new MyStack(app, 'MyStack');
Debug
Known issues
deprecatedPackage is designed for AWS CDK v1 and not updated for CDK v2
fix
For CDK v2, use @aws-cdk/aws-lambda-nodejs built-in bundling or migrate to a CDK v2 compatible construct
affects: >=1.0.0 <=1.1.6
gotchaesbuild must be installed separately in the project; not a dependency of this package
fix
Run 'npm install --save-dev esbuild' or 'yarn add --dev esbuild'
affects: >=1.0.0
gotchaThe default 'exclude' option only excludes 'aws-sdk'; other large dependencies must be manually externalized
fix
Add additional modules to esbuildOptions.external: e.g., external: ['aws-sdk', 'pg-native']
affects: >=1.0.0
breakingVersion 1.1.6 changed default runtime to match CDK Lambda defaults; may affect previously working builds
fix
Explicitly set runtime property on NodejsFunction to avoid reliance on default
affects: 1.1.6
Errors
Common errors & fixes
Error: Cannot find module 'esbuild'
esbuild is not installed in the project
fix
npm install --save-dev esbuild
Error: Cannot find module '@aws-cdk/aws-lambda'
CDK peer dependencies not installed
fix
npm install --save @aws-cdk/aws-lambda @aws-cdk/core
Property 'entry' is missing in type 'NodejsFunctionProps'
The 'entry' property is required for NodejsFunction but omitted
fix
Add 'entry' to the props: entry: 'src/index.ts'
Upgrade
Version history
1.1.6latest on npm
Audit
Dependencies
esbuildoptionalBundling Lambda code; must be installed separately in the project
@aws-cdk/aws-lambdarequiredCDK Lambda construct base class; peer dependency
@aws-cdk/corerequiredCDK core library for stack and construct definitions; peer dependency
Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
2
Resources