JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 819
  • Score
    100M100P100Q109990F
  • License MIT

lambda-build uses esbuild to take in your nodejs lambda handler and return a zip file ready to be used by your lambda function

Package Exports

  • lambda-build
  • lambda-build/dist/lib.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lambda-build) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

lambda-build ⚡️

Lambda Build

  • Bundle, archive and upload your lambda functions using esbuild

How it works

  • 🎯 Point it to a js/ts file containing your lambda handler(s)
  • 📦 Get a zip file containing tour bundle
  • 🚀 Upload it to aws

Install

npm i --save-dev lambda-build
  • see options:
npx lambda-build --help

CLI Usage

  • if your handler is called index.js|ts, you can generate a local archive.zip by running:
npx lambda-build
  • use upload to create a bundle and upload it to aws
  • use archive to create a bundle and save it as a local archive.zip file

lambda-build archive

npx lambda-build archive bundles your code and creates a local archive.zip file that you can then upload to aws yourself.

  • using -e, set a custom entry file:
npx lambda-build archive -e src/index.ts
  • using -x, exclude some libraries from bundling (for example, if you already load them in a layer):
npx lambda-build archive -e src/index.ts -x lodash dayjs
npx lambda-build archive -e src/index.ts -m

lambda-build upload

npx lambda-build upload bundles your code and then uploads it directly to your AWS lambda functions (requires the aws cli to be locally configured).

  • specify the lambda functions that you would like to deploy to:
npx lambda-build upload my-lambda1 my-lambda2 -e src/index.ts
  • you can specify the region using the -r flag (otherwise it defaults to us-east-1):
npx lambda-build upload my-lambda1 my-lambda2 -e src/index.ts -r us-east-2

Library Usage

build()

import { build } from 'lambda-build';

const res = await build({
  entry: 'src/index.js',
  external: ['lodash', 'dayjs'],
  metafile: true,
});
  • returns a res object:
    • res.archive - Buffer - contents of the zip archive
    • res.archiveSize - string - the size of the archive
    • res.meta - string - contents of the meta file

buildAndUpload()

import { buildAndUpload } from 'lambda-build';

const res = await buildAndUpload({
  entry: 'src/index.js',
  external: ['lodash', 'dayjs'],
  metafile: true,
  lambdas: ['my-lambda1', 'my-lambda2'],
  region: 'us-east-2',
});
  • returns a res object:
    • res.archive - Buffer - contents of the zip archive
    • res.archiveSize - string - the size of the archive
    • res.meta - string - contents of the meta file
    • updatedArns - string[] - an array with the ARNs of the lambda functions that were successfully deployed

Screencast

Lambda Build

More Lambda Screencasts

Follow me for updates