npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lambda-build

v1.0.6

Published

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

Downloads

2,686

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