Lerna to Lambda Bundler

0.3.1 · active · verified Tue Apr 21

lerna-to-lambda (l2l) is a specialized utility designed for developers working with Lerna monorepos who need to deploy individual packages as AWS Lambda functions. At version 0.3.1, this tool facilitates the creation of compact, standalone deployment archives by intelligently bundling a specific monorepo package with only its necessary dependencies. It resolves the common challenge of dealing with hoisted `node_modules` in Lerna projects by copying direct and recursive subdependencies into a single `node_modules` structure within the output directory. A key differentiator is its ability to correctly handle both external npm packages and internal, inter-dependent monorepo packages, ensuring a self-contained runtime environment for Lambda. By default, it excludes `aws-sdk`, assuming it's provided by the Lambda runtime. While a powerful bundling solution, it is not a package manager itself; users must ensure all dependencies are installed via `yarn` or `npm` prior to execution. Its release cadence is likely feature-driven given its current version number.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates adding `lerna-to-lambda` as a dev dependency and integrating its `l2l` command into a TypeScript project's build workflow to create Lambda deployment packages.

yarn add -W --dev lerna-to-lambda

// In package.json scripts for a Lerna package:
"scripts": {
  "clean": "rimraf build lambda",
  "compile": "tsc -p tsconfig.build.json",
  "package": "l2l -i build -o lambda",
  "build": "yarn run clean && yarn run compile && yarn run package"
}

view raw JSON →