Registry / aws / aws-lambda-bundler

aws-lambda-bundler

JSON →
library0.4.2jsnpmunverified

aws-lambda-bundler is a JavaScript utility designed to create zip archives for AWS Lambda function deployments. Its primary feature is the explicit exclusion of the `aws-sdk` from the bundled package, aiming to reduce the overall deployment size, as the SDK is often the largest component. The package is currently at version 1.0.12. Released over six years ago, it appears to be no longer actively maintained, with minimal updates or recent community activity. While it offers a simple command-line and programmatic interface for basic bundling, modern AWS Lambda deployment practices typically favor more advanced bundlers like `esbuild` (often integrated into AWS CDK's `NodejsFunction` or Serverless Framework) or `webpack` for their superior performance, tree-shaking capabilities, and better support for contemporary JavaScript features like TypeScript and ESM. These newer alternatives provide more granular control over dependencies and often result in smaller, more optimized bundles and improved cold start times.

npm install aws-lambda-bundler
INSTALL
IMPORT
SIG · AWS-LAMBDA-BUNDLER
A
aws-lambda-bundler
awsjavascriptv0.4.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

bundle
import { bundle } from 'aws-lambda-bundler';
const bundle = require('aws-lambda-bundler').bundle;
While the README shows CommonJS `require`, modern Node.js and TypeScript usage often prefers ES Modules. However, given the package's age, its primary API is likely CJS-first, and ESM import might not be natively supported or correctly transpiled by older versions of the tool itself. Explicit named import is correct for both CJS and ESM, assuming modern tooling can handle CJS to ESM interop.
default export
import bundler from 'aws-lambda-bundler';
import { default as bundler } from 'aws-lambda-bundler';
The README excerpt suggests a named export `{ bundle }`. If there's a default export (e.g., the `bundle` function itself), it would be imported as `import bundler from 'aws-lambda-bundler';`. However, based on the provided snippet, `bundle` is a named export.

Demonstrates programmatic bundling of a simple AWS Lambda project, including its dependencies, into a zip file, then cleans up.

const { bundle } = require('aws-lambda-bundler'); const fs = require('fs'); const path = require('path'); async function createDummyLambdaProject() { const projectDir = path.join(__dirname, 'my-lambda-project'); const handlerDir = path.join(projectDir, 'src'); const handlerFile = path.join(handlerDir, 'handler.js'); const packageJsonFile = path.join(projectDir, 'package.json'); if (!fs.existsSync(handlerDir)) { fs.mkdirSync(handlerDir, { recursive: true }); } fs.writeFileSync(handlerFile, ` exports.handler = async (event) => { console.log('Received event:', event); const response = { statusCode: 200, body: JSON.stringify('Hello from Lambda!'), }; return response; }; `); fs.writeFileSync(packageJsonFile, ` { "name": "my-lambda-project", "version": "1.0.0", "description": "A dummy lambda for bundling demo", "main": "src/handler.js", "dependencies": { "lodash": "^4.17.21" } } `); console.log('Dummy lambda project created at:', projectDir); return projectDir; } async function runBundler() { const projectPath = await createDummyLambdaProject(); try { console.log(`\nBundling project at ${projectPath}...`); // The bundle function takes the source directory and optionally an output path. // It returns a promise that resolves with the path to the created zip file. const zipFilePath = await bundle(projectPath); console.log(`Successfully bundled to: ${zipFilePath}`); console.log('You can now inspect the contents of the zip file.'); } catch (error) { console.error('Bundling failed:', error); process.exit(1); } finally { // Clean up dummy project after bundling fs.rmSync(projectPath, { recursive: true, force: true }); console.log(`Cleaned up ${projectPath}`); } } runBundler();
aws-lambda-bundler --version
Debug
Known issues
breakingThe package `aws-lambda-bundler` has not been updated in over six years and is considered abandoned. It may contain unpatched security vulnerabilities, lack support for modern Node.js runtimes (e.g., Node.js 18+), and not support contemporary JavaScript features or module systems (ESM). Using it in new projects is highly discouraged.
fix
Migrate to actively maintained alternatives like `@aws-cdk/aws-lambda-nodejs` (which uses `esbuild`), `serverless-esbuild`, `serverless-webpack`, or directly use `esbuild` for bundling. These tools provide better performance, security, and feature support.
affects: >=1.0.0
gotchaThis bundler's primary optimization is to exclude the `aws-sdk` to reduce bundle size. While this was a common practice, newer AWS Lambda runtimes (Node.js 18+) include AWS SDK v3, and for optimal cold start performance and full control, it is often recommended to bundle the specific AWS SDK v3 modules your function uses with your deployment package, rather than relying on the runtime's provided SDK.
fix
Consider using a modern bundler that allows explicit inclusion and tree-shaking of AWS SDK v3 modules (e.g., `esbuild` with `bundleAwsSDK: true` in CDK's `NodejsFunction` configuration) to fine-tune cold start performance and ensure consistent SDK versions.
affects: >=1.0.0
gotchaThis package might not correctly handle advanced bundling scenarios such as TypeScript transpilation, ES Modules (ESM) resolution, or robust tree-shaking for complex dependency graphs. Its 'simple' approach of just zipping and excluding `aws-sdk` may lead to larger-than-necessary bundles or runtime errors with modern codebases.
fix
Evaluate modern bundlers (`esbuild`, `webpack`) that offer comprehensive support for TypeScript, ESM, and advanced optimizations like dead code elimination to significantly reduce package size and improve Lambda cold start times.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'aws-lambda-bundler'
The package is not installed in your project's `node_modules`.
fix
Run `npm install aws-lambda-bundler` or `yarn add aws-lambda-bundler` in your project directory.
ReferenceError: require is not defined in ES module scope
Attempting to use `require()` syntax within an ES Module (ESM) file, or the bundler itself does not correctly handle ESM input/output.
fix
Ensure your Lambda function code is written in CommonJS if using older tooling, or migrate to a modern bundler (like `esbuild`) that fully supports ESM input and output for Node.js Lambda functions.
Error: EACCES: permission denied, open '/path/to/output.zip'
The user running the bundling command or script does not have write permissions to the specified output directory.
fix
Ensure you have appropriate write permissions for the target output directory, or specify an output path where the user has permissions (e.g., a subdirectory within your project or a temporary directory).
Upgrade
Version history
0.4.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
aws-lambda-bundler — npm install aws-lambda-bundler · libregistry