From d5d2f77e776ce3cf6ebf7fee7ad1e9fc7ed6d119 Mon Sep 17 00:00:00 2001 From: Pong Date: Wed, 4 Aug 2021 23:44:49 +0800 Subject: [PATCH] feat: make build option more flexible (#364) * feat(): allow to disable esbuild bundle option * feat(): allow to add clean patterns * Update index.ts Co-authored-by: EGOIST <0x142857@gmail.com> --- src/index.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 5a0ca88..26095b1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -91,7 +91,7 @@ export type Options = { /** * Clean output directory before each build */ - clean?: boolean + clean?: boolean | string[]; esbuildPlugins?: EsbuildPlugin[] /** * Supress non-error logs (excluding "onSuccess" process output) @@ -105,6 +105,10 @@ export type Options = { * @see https://esbuild.github.io/api/#pure */ pure?: string | string[] + /** + * Disable bunlding, default to true + */ + bundle?: boolean } export type NormalizedOptions = MarkRequired< @@ -167,7 +171,7 @@ export async function runEsbuild( result = await esbuild({ entryPoints: options.entryPoints, format: splitting && format === 'cjs' ? 'esm' : format, - bundle: true, + bundle: typeof options.bundle === 'undefined' ? true : options.bundle, platform: 'node', globalName: options.globalName, jsxFactory: options.jsxFactory, @@ -407,7 +411,8 @@ export async function build(_options: Options) { const killPromise = killPreviousProcess() if (options.clean) { - await removeFiles(['**/*', '!**/*.d.ts'], options.outDir) + const extraPatterns = Array.isArray(options.clean) ? options.clean : [] + await removeFiles(['**/*', '!**/*.d.ts', ...extraPatterns], options.outDir) log('CLI', 'info', 'Cleaning output folder') }