Skip to content

Commit 4a66070

Browse files
fix(bundle): adapted proposal from issue #338 to fix memory leak when skipRebuild is true (#540)
1 parent 607a3ae commit 4a66070

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/bundle.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import assert from 'assert';
22
import { Predicate } from 'effect';
33
import type { BuildOptions } from 'esbuild';
4+
import * as pkg from 'esbuild';
45
import fs from 'fs-extra';
56
import pMap from 'p-map';
67
import path from 'path';
@@ -104,11 +105,9 @@ export async function bundle(this: EsbuildServerlessPlugin): Promise<void> {
104105
outdir: path.join(buildDirPath, path.dirname(entry)),
105106
};
106107

107-
const pkg = await import('esbuild');
108-
109108
type ContextFn = (opts: typeof options) => Promise<BuildContext>;
110109
type WithContext = typeof pkg & { context?: ContextFn };
111-
const context = await (pkg as WithContext).context?.(options);
110+
const context = buildOptions.skipRebuild ? undefined : await (pkg as WithContext).context?.(options);
112111

113112
let result;
114113
if (!buildOptions.skipRebuild) {

0 commit comments

Comments
 (0)