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) {