Skip to content

Commit

Permalink
feat(bundle): add skipRebuild option
Browse files Browse the repository at this point in the history
  • Loading branch information
BorjaMacedo committed Mar 5, 2024
1 parent f3b929d commit 2536414
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,16 @@ export async function bundle(this: EsbuildServerlessPlugin): Promise<void> {
type ContextFn = (opts: typeof options) => Promise<BuildContext>;
type WithContext = typeof pkg & { context?: ContextFn };
const context = await (pkg as WithContext).context?.(options);
const result = await pkg.build(options);

let result;
if (!buildOptions.skipRebuild) {
result = await context?.rebuild();
if (!result) {
result = await pkg.build(options);
}
} else {
result = await pkg.build(options);
}

if (config.metafile) {
fs.writeFileSync(
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface Configuration extends EsbuildOptions {
outputFileExtension: '.js' | '.cjs' | '.mjs';
nodeExternals?: NodeExternalsOptions;
skipBuild?: boolean;
skipRebuild?: boolean;
skipBuildExcludeFns: string[];
stripEntryResolveExtensions?: boolean;
disposeContext?: boolean;
Expand Down

0 comments on commit 2536414

Please sign in to comment.