Registry / aws / lambda-build

lambda-build

JSON →
library1.0.6jsnpmunverified

Bundle TypeScript/JavaScript Node.js Lambda handlers into a deployable zip using esbuild. Current version: 1.0.6. Provides CLI commands (`archive`, `upload`) and programmatic API (`build`, `buildAndUpload`). Supports custom entry files, excluding external modules (e.g., layers), and generating esbuild metafiles for bundle analysis. Differentiates from similar tools by focusing solely on Lambda deployment with zero-config defaults and AWS CLI integration. Ships with TypeScript declarations. Lightweight alternative to serverless-webpack or AWS SAM.

npm install lambda-build
INSTALL
IMPORT
SIG · LAMBDA-BUILD
L
lambda-build
awsjavascriptv1.0.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.

build
import { build } from 'lambda-build'
const build = require('lambda-build').build
Package exports named exports; default import does not exist. Works in both ESM and CJS, but ESM import is preferred for TypeScript.
buildAndUpload
import { buildAndUpload } from 'lambda-build'
const { buildAndUpload } = require('lambda-build')
Correct in CJS but ESM import is recommended when using TypeScript or ES modules.
default import (does not exist)
import { build } from 'lambda-build'
import lambdaBuild from 'lambda-build'
Package only exports named exports. Doing a default import will result in undefined.

Shows programmatic usage: bundle a TypeScript Lambda handler and create a zip archive with metafile.

import { build } from 'lambda-build'; async function quickstart() { const result = await build({ entry: 'src/handler.ts', external: ['aws-sdk'], metafile: true, }); console.log('Archive size:', result.archiveSize); // result.archive is a Buffer of the zip } quickstart().catch(console.error);
lambda-build --version
Debug
Known issues
gotchaThe `upload` command requires the AWS CLI to be installed and configured locally.
fix
Ensure AWS CLI is set up via `aws configure` before using `upload`.
affects: >=0.0.0
gotchaExternal modules declared via `-x` or `external` option must be available in the Lambda runtime environment (e.g., via layers or Lambda provided SDK).
fix
Verify that excluded dependencies are present as layers or included in the Lambda runtime.
affects: >=0.0.0
deprecatedNo deprecated features known at this version.
fix
None.
affects: >=0.0.0
breakingMajor version 1.x introduced esbuild as the bundler. If migrating from a previous major version that used a different bundler, configuration may differ.
fix
Update to use esbuild options; see documentation for changes.
affects: <1.0.0
Errors
Common errors & fixes
Error: esbuild is not installed. Please install it manually: npm i -D esbuild
lambda-build depends on esbuild but does not automatically install it.
fix
Install esbuild as a dev dependency: `npm i -D esbuild`
Error: Cannot find module 'aws-sdk'
AWS SDK is excluded by default but not provided in the runtime layer.
fix
Either add 'aws-sdk' to external array only if you have it in a layer, or bundle it by removing it from external.
Error: The 'entry' option is required.
You called `build` without specifying an entry file.
fix
Pass an `entry` option pointing to your handler file, e.g., `entry: 'src/handler.ts'`.
Error: ENOENT: no such file or directory, open 'src/index.ts'
The default entry file (index.js or index.ts) does not exist in the current directory.
fix
Use `-e` to specify a custom entry file, or create a default index file.
Upgrade
Version history
1.0.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
lambda-build — npm install lambda-build · libregistry