Skip to content

jacobsood/webpack-lambda-layer-plugin

Repository files navigation

Webpack Lambda Layer Plugin

Efficiently Package Required Node Modules for Your Lambda Layer

npm version Dependency Status Blazing Fast
Main Programming Language Last Commit License Code Style: Prettier

Webpack Lambda Layer Plugin is a tool designed to simplify the process of packaging code libraries for your Lambda functions. The plugin works by bundling the necessary node dependencies as a separate package, which can then be utilized in your Lambda Layer, providing an efficient way to share code libraries with multiple Lambda Functions.

Simultaneously, these dependencies will get externalized from your Lambda Function bundles, leading to reduced bundle sizes and improved build and deployment times.

Installation

yarn

yarn add --dev webpack-lambda-layer-plugin

npm

npm i --save-dev webpack-lambda-layer-plugin

Usage

webpack.config.js

import { LambdaLayerExternalsPlugin } from "webpack-lambda-layer-plugin";

const config: WebpackConfiguration = {
  entry: "index.js",
  output: {
    filename: "[name]/handler.js",
    path: path.resolve("dist"),
  },
  
  plugins: [
    new LambdaLayerExternalsPlugin(),
  ],
}

export default config;

This will generate a zip archive dist/externals.zip containing the used node_modules dependencies, alongside your Lambda Function bundles.

About

Webpack plugin to export used node_modules as a separate package for the lambda layer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published