Skip to content

Commit 457e513

Browse files
authored
fix: Check for existing results to rebuild (#123)
* Check for existing results to rebuild * refactor: renamed oldResult to result
1 parent b5a9bdb commit 457e513

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export class EsbuildPlugin implements Plugin {
201201
}
202202
}
203203

204-
async bundle(incremental = false): Promise<BuildResult[]> {
204+
async bundle(incremental = true): Promise<BuildResult[]> {
205205
this.prepare();
206206
this.serverless.cli.log('Compiling with esbuild...');
207207

@@ -226,9 +226,16 @@ export class EsbuildPlugin implements Plugin {
226226
delete config['watch'];
227227
delete config['pugins'];
228228

229+
const bundlePath = entry.substr(0, entry.lastIndexOf('.')) + '.js';
230+
231+
if (this.buildResults) {
232+
const { result } = this.buildResults.find(({func: fn}) => fn.name === func.name);
233+
await result.rebuild();
234+
return { result, bundlePath, func };
235+
}
236+
229237
const result = await build(config);
230238

231-
const bundlePath = entry.substr(0, entry.lastIndexOf('.')) + '.js';
232239
return { result, bundlePath, func };
233240
})
234241
).then(results => {

0 commit comments

Comments
 (0)