UNPKG

@invisit/webpack-aws-lambda-auto-deploy-plugin

Version:

Uploads compiled assets to s3 after build

58 lines (57 loc) 2.25 kB
/// <reference types="node" /> import type { PackageJson } from "types-package-json"; import * as AWS from "aws-sdk"; import Webpack from "webpack"; import { AutoDeployStorage, AWSDeployEvent, AWSLambdaAutoDeployPluginConfig, EntryLambdaMapping, ErrorKind } from "./types"; import { EventEmitter } from "events"; export default class AWSLambdaAutoDeployPlugin<Storage extends AutoDeployStorage = any> { config: AWSLambdaAutoDeployPluginConfig<Storage>; readonly awsConfig: Partial<AWS.Config>; readonly entryMap: Record<string, EntryLambdaMapping>; protected readonly events: EventEmitter; readonly pkg: PackageJson; readonly name: string; private readonly clients; /** * Zip up the assets * * @param entry * @param entryOutputPath * @param entryFiles * @returns */ private archive; /** * Deploy the compilation to the configured * entry <-> lambda mappings * * @param {webpack.compilation.Compilation} compilation * @param {EntryLambdaMapping} entryMapping * @returns {Promise<void>} */ private deploy; /** * Process done compilation event * * @param {webpack.Stats | webpack.compilation.MultiStats} statsOrMultiStats * @returns {Promise<void>} */ private onDone; /** * Entries that have configured functions * * @returns {string[]} */ get entryNames(): string[]; get s3(): AWS.S3; get lambda(): AWS.Lambda; emit(event: "error", error: ErrorKind): void; emit(event: "deploy", data: AWSDeployEvent<Storage>): void; on(event: "error", listener: (event: ErrorKind) => any): AWSLambdaAutoDeployPlugin; on(event: "deploy", listener: (event: AWSDeployEvent<Storage>) => any): AWSLambdaAutoDeployPlugin; off(event: "error", listener: (event: ErrorKind) => any): AWSLambdaAutoDeployPlugin; off(event: "deploy", listener: (event: AWSDeployEvent<Storage>) => any): AWSLambdaAutoDeployPlugin; constructor(config: AWSLambdaAutoDeployPluginConfig<Storage>, awsConfig?: Partial<AWS.Config>, entryMap?: Record<string, EntryLambdaMapping>); apply(anyCompiler: Webpack.Compiler): void; handleErrors(error: any, compilation: any): Promise<void>; }