A CLI tool for compiling and packaging AWS Lambda functions created in TypeScript into ZIP files.
Simply run it using npx:
npx @abfry0620/lambda-package
# Or install globally if you prefer
npm install -g @abfry0620/lambda-packagenpx @abfry0620/lambda-package --helpExample output:
Usage: lambda-package [options]
Compile and Zip programs created in TypeScript for AWS Lambda.
Options:
-V, --version output the version number
-h, --help display help for commandnpx @abfry0620/lambda-package --versionWhen you run the tool, it performs the following steps:
- Clean up existing
distdirectory andpackagesdirectory - Compile TypeScript code (
npm run build) - Install production dependencies only
- Package compiled code and dependencies into a ZIP file
- Restore development dependencies
By default, it works with the following settings:
distDir: 'dist' - Directory where compiled files are storedpackageDir: 'packages' - Directory where the output ZIP file is storedpackageName: 'lambda-function.zip' - Name of the output ZIP file
To customize the configuration, create a lambda-package-config.json file in your project's root directory:
{
"distDir": "build",
"packageDir": "deploy",
"packageName": "my-lambda.zip"
}If the configuration file doesn't exist on the first run, it will be automatically created with default settings.
You can also add it to your package.json scripts:
"scripts": {
"package": "lambda-package"
}Then run:
npm run packageABfry