@scloud/lambda-bundle
v1.2.0
Published
esbuild bundler for Lambda deployment packages and CloudFront Functions.
Maintainers
Readme
@scloud/lambda-bundle
esbuild bundlers for Lambda deployment packages and CloudFront Functions.
Lambda
Produces dist/lambda.js for handler lambda.handler.
"scripts": {
"compile": "tsc --noEmit",
"package": "lambda-bundle && cd dist && zip -r function.zip ."
}For extra externals (e.g. native dependencies supplied via a Lambda layer):
import { bundleLambda } from '@scloud/lambda-bundle';
bundleLambda({ external: ['sharp'] });CloudFront Functions
Bundles every src/*Function.ts to dist/<name>.js using ES5 IIFE output for the CloudFront Functions runtime.
Each source file should assign the handler globally (esbuild IIFE output):
function handler(event: Event) { /* ... */ }
(globalThis as any).handler = handler;"scripts": {
"compile": "tsc --noEmit",
"package": "cf-bundle"
}Or specify functions explicitly:
import { bundleCloudFrontFunctions } from '@scloud/lambda-bundle';
bundleCloudFrontFunctions({
functions: [
{ entryPoint: 'src/websiteFunction.ts', outfile: 'dist/websiteFunction.js' },
],
});cf-bundle warns when any output exceeds the 10 KB CloudFront Functions size limit.
Release notes
- 1.2.0: Add
cf-bundleCLI andbundleCloudFrontFunctionsfor CloudFront Functions. - 1.1.0: Merge custom
externalpackages with defaults (aws-sdk) instead of replacing them. - 1.0.1: Initial release.
