From a4407c9062ddc9aeb8dd298b4c28f3730bccf5f5 Mon Sep 17 00:00:00 2001 From: mmeyers-xomly <101290120+mmeyers-xomly@users.noreply.github.com> Date: Mon, 4 Apr 2022 07:46:47 -0600 Subject: [PATCH] fix: Fix lambda layers support (#267) --- src/Serverless.d.ts | 7 +++++++ src/index.ts | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/src/Serverless.d.ts b/src/Serverless.d.ts index 7c3e9f2d..3b05529e 100644 --- a/src/Serverless.d.ts +++ b/src/Serverless.d.ts @@ -15,8 +15,10 @@ declare namespace Serverless { functions: { [key: string]: Serverless.Function } + layers: { [key: string]: Serverless.Layer } package: Serverless.Package getAllFunctions(): string[] + getAllLayers(): string[] custom?: { serverlessPluginTypescript?: { tsConfigFileLocation: string @@ -38,6 +40,11 @@ declare namespace Serverless { package: Serverless.Package } + interface Layer { + handler: string + package: Serverless.Package + } + interface Package { include: string[] exclude: string[] diff --git a/src/index.ts b/src/index.ts index adafe7a3..d4ebc0b8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -250,6 +250,15 @@ export class TypeScriptPlugin { path.join(this.originalServicePath, SERVERLESS_FOLDER) ) + const layerNames = service.getAllLayers() + layerNames.forEach(name => { + service.layers[name].package.artifact = path.join( + this.originalServicePath, + SERVERLESS_FOLDER, + path.basename(service.layers[name].package.artifact) + ) + }) + if (this.options.function) { const fn = service.functions[this.options.function] fn.package.artifact = path.join(