mirror of
https://github.com/egoist/tsup.git
synced 2025-12-08 20:35:58 +00:00
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>
This commit is contained in:
parent
405e165ef7
commit
d5d2f77e77
11
src/index.ts
11
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')
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user