diff --git a/src/bundle.ts b/src/bundle.ts index 12548c4..5796703 100644 --- a/src/bundle.ts +++ b/src/bundle.ts @@ -1,5 +1,6 @@ import assert from 'assert'; import type { BuildOptions } from 'esbuild'; +import * as pkg from 'esbuild'; import fs from 'fs-extra'; import pMap from 'p-map'; import path from 'path'; @@ -103,11 +104,9 @@ export async function bundle(this: EsbuildServerlessPlugin): Promise { outdir: path.join(buildDirPath, path.dirname(entry)), }; - 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); + const context = buildOptions.skipRebuild ? undefined : await (pkg as WithContext).context?.(options); let result; if (!buildOptions.skipRebuild) {