# lambda-zip

> Zips a node module with its declared dependencies.

Latest version **0.3.2** (published 2020-02-29) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install lambda-zip
pnpm add lambda-zip
yarn add lambda-zip
bun add lambda-zip
```

Provides the command `lambda-zip`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2020-02-29 |
| First published | 2019-01-19 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 15.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Min Shi |
| Maintainers | akq |
| Keywords | pack, dependencies, lambda, zip |

## Links

- npm: https://www.npmjs.com/package/lambda-zip
- Repository: https://github.com/akq/lambda-zip
- Homepage: https://github.com/akq/lambda-zip#readme
- Issues: https://github.com/akq/lambda-zip/issues
- npm.io page: https://npm.io/package/lambda-zip

## Dependencies (3)

- [globby](https://npm.io/package/globby.md) ^6.1.0
- [archiver](https://npm.io/package/archiver.md) ^1.3.0
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.0

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 0.3.2 (latest) — 2020-02-29
- 0.3.1 — 2019-01-19

## README

It was mainly designed to help deploy node.js functions to AWS Lambda.

When deploying node.js codes to AWS lambda, all dependent modules needed to be included. 
But if you simply zip all content node_modules/ folder, the final media may be messed up with some dev dependencies.
So to exclude the dev dependencies, initially I found [node-pack-zip](https://github.com/Merlin-Taylor/node-pack-zip)
, but @jogoussard found this repo did not support transitive dependencies (see [issue#2](https://github.com/Merlin-Taylor/node-pack-zip/issues/2)).
and then he forked and created [node-repack-zip](https://github.com/jogoussard/node-repack-zip).

As the .packignore config file in original design only did files exclusion, but in my case, I only need to specify which files should be included.
So I modified [node-repack-zip](https://github.com/jogoussard/node-repack-zip) repo, and created a new one. You should explicitly specify the files you want to include or exclude in the config files.


## Installation

`npm install --save-dev lambda-zip`



## Example

_my-lambda_ is an npm package I want to run as an AWS Lambda Function.

Install _lambda-zip_ locally in _my-lambda_
```
npm install --save-dev lambda-zip
```

Install any runtime dependencies of _my-lambda_.
```
npm install
```
Add a config file in the root of _my-lambda_, let's say _.dev_
it's content will be like .gitignore, using ! to exclude files, for example

```
index.js
lib/**/*
proj/**/*
!lib/test.js
```

Modify _my-lambda/package.json_:
```JSON
"scripts": {
    "build-aws-lambda": "lambda-zip .dev lambda.zip -a -v"
    ...
}
```

Create the lambda.zip file containing _my-lambda_ and all its dependencies, ready to be uploaded to AWS Lambda
```
npm run build-aws-lambda
```

## Release notes
* 0.3.2 - refine the original codes  
  add excluding aws-sdk option  
  add verbose mode option and some running information

* 0.3.1 - remove .packignore file, and all files are not included by default.

* 0.2.5 - Added support for root module _phantomChildren dependencies.

* 0.2.4 - Initial published release

---
_Source: https://npm.io/package/lambda-zip · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
