From f2ae68a32b4da0673a40a9a07d2c7e671899d488 Mon Sep 17 00:00:00 2001 From: Victor Korzunin <5180700+floydspace@users.noreply.github.com> Date: Wed, 20 Sep 2023 22:29:59 +0200 Subject: [PATCH] fix: incorrect position of optional chaining operator closes #493 --- src/bundle.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bundle.ts b/src/bundle.ts index db65cd1..e8824cf 100644 --- a/src/bundle.ts +++ b/src/bundle.ts @@ -100,8 +100,12 @@ export async function bundle(this: EsbuildServerlessPlugin): Promise { outdir: path.join(buildDirPath, path.dirname(entry)), }; - const pkg: any = await import('esbuild'); - const context: BuildContext = await pkg?.context(options); + const pkg = await import('esbuild'); + + type ContextFn = (opts: typeof options) => Promise; + type WithContext = typeof pkg & { context?: ContextFn }; + const context = await (pkg as WithContext).context?.(options); + let result = await context?.rebuild(); if (!result) {