# aws-cdk-webpack-lambda-function

> This library provides constructs for Node.js Lambda function bundled using webpack.

Latest version **1.0.0** (published 2022-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install aws-cdk-webpack-lambda-function
pnpm add aws-cdk-webpack-lambda-function
yarn add aws-cdk-webpack-lambda-function
bun add aws-cdk-webpack-lambda-function
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-09-03 |
| First published | 2020-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 14.15.0 |
| Dependencies | 1 |
| Unpacked size | 13.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Masahiro Onohara |
| Maintainers | masahirompp |
| Keywords | aws-cdk, lambda, webpack |

## Links

- npm: https://www.npmjs.com/package/aws-cdk-webpack-lambda-function
- Repository: https://github.com/masahirompp/aws-cdk-webpack-lambda-function
- Homepage: https://github.com/masahirompp/aws-cdk-webpack-lambda-function#readme
- Issues: https://github.com/masahirompp/aws-cdk-webpack-lambda-function/issues
- npm.io page: https://npm.io/package/aws-cdk-webpack-lambda-function

## Dependencies (1)

- [cross-spawn](https://npm.io/package/cross-spawn.md) ^7.0.3

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2022-09-03
- 0.6.0 — 2021-05-11
- 0.5.2 — 2021-02-13
- 0.5.1 — 2020-12-29
- 0.5.0 — 2020-11-06
- 0.4.0 — 2020-10-04
- 0.3.3 — 2020-09-22
- 0.3.2 — 2020-08-25
- 0.3.1 — 2020-05-17
- 0.3.0 — 2020-05-13
- 0.2.2 — 2020-05-13
- 0.2.1 — 2020-04-21
- 0.2.0 — 2020-04-20
- 0.1.3 — 2020-04-20
- 0.1.2 — 2020-04-20
- … 2 more at https://npm.io/package/aws-cdk-webpack-lambda-function/versions

## README

# aws-cdk-webpack-lambda-function

forked from [@aws-cdk/aws-lambda-nodejs](https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-lambda-nodejs)

This library provides constructs for Node.js Lambda function bundled using webpack.

## Quick Start

1. install using yarn:

   ```sh
   npm i -D aws-cdk-webpack-lambda-function aws-cdk-lib webpack@5 webpack-cli
   ```

   | cdk | aws-cdk-webpack-lambda-function |
   | --- | ------------------------------- |
   | v1  | 0.6.0                           |
   | v2  | 1.0.0                           |

1. add webpack.config.js:

   ```js
   module.exports = {
     mode: "production", // production or development
     target: "node",
     externals: [/^aws-sdk(\/.+)?$/], // important!!!
     devtool: "source-map", // if needed
     optimization: { minimize: false }, // if needed
     // for TypeScript
     module: {
       rules: [
         {
           test: /\.ts$/,
           use: {
             loader: "ts-loader",
             options: {
               configFile: "your/path/to/tsconfig.json", // if needed
               // colors: true,
               // logInfoToStdOut: true,
               // logLevel: 'INFO',
               transpileOnly: true,
             },
           },
           exclude: /node_modules/,
         },
       ],
     },
     resolve: {
       extensions: [".js", ".ts"],
     },
   };
   ```

1. (Optional) add tsconfig.json for lambda

   ```json
   {
     "extends": "../ ... /tsconfig.json",
     "compilerOptions": {
       "importHelpers": false,
       "target": "ES2018",
       "noEmit": false
     }
   }
   ```

1. your cdk source code:

   ```typescript
   import { WebpackFunction } from "aws-cdk-webpack-lambda-function";

   new WebpackFunction(this, "YourFunction", {
     entry: "your/path/to/function.ts",
     config: "your/path/to/webpack.config.js",
   });
   ```

## Options

### entry: string (required)

Path to the entry file (JavaScript or TypeScript).

### config: string (required)

Path to webpack config file.

### handler: string

The name of the exported handler in the entry file.

default: "handler"

### runtime: lambda.Runtime

The runtime environment. Only runtimes of the Node.js family are supported.

default: NODEJS_14

### buildDir: string

The build directory.

default: `.build` in the entry file directory

### ensureUniqueBuildPath: boolean

Control whether the build output is placed in a unique directory (sha256 hash) or not. This can be disabled to simplify development and debugging.

default: true

### ...other options

All other properties of lambda.Function are supported, see also the [AWS Lambda construct library](https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-lambda).

## Run tests

```sh
yarn build
yarn test
```

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