/
options.ts
130 lines (127 loc) · 3.16 KB
/
options.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import type { BuildOptions, Plugin as EsbuildPlugin, Loader } from 'esbuild'
import type { InputOption } from 'rollup'
export type Format = 'cjs' | 'esm' | 'iife'
export type DtsConfig = {
entry?: InputOption
/** Resolve external types used in dts files from node_modules */
resolve?: boolean | (string | RegExp)[]
/** Emit declaration files only */
only?: boolean
/** Insert at the top of each output .d.ts file */
banner?: string
/** Insert at the bottom */
footer?: string
}
/**
* The options available in tsup.config.ts
* Not all of them are available from CLI flags
*/
export type Options = {
/** Optional config name to show in CLI output */
name?: string
entryPoints?: BuildOptions['entryPoints']
/**
* Output different formats to differen folder instead of using different extensions
*/
legacyOutput?: boolean
/**
* Compile target
*
* default to `node12`
*/
target?: string
minify?: boolean
minifyWhitespace?: boolean
minifyIdentifiers?: boolean
minifySyntax?: boolean
keepNames?: boolean
watch?: boolean | string | (string | boolean)[]
ignoreWatch?: string[] | string
onSuccess?: string
jsxFactory?: string
jsxFragment?: string
outDir?: string
format?: Format[]
globalName?: string
env?: {
[k: string]: string
}
define?: {
[k: string]: string
}
dts?: boolean | string | DtsConfig
sourcemap?: BuildOptions['sourcemap']
/** Always bundle modules matching given patterns */
noExternal?: (string | RegExp)[]
/** Don't bundle these modules */
external?: (string | RegExp)[]
/** Transform the result with `@babel/core` */
babel?: boolean
/**
* Replace `process.env.NODE_ENV` with `production` or `development`
* `production` when the bundled is minified, `development` otherwise
*/
replaceNodeEnv?: boolean
/**
* Code splitting
* Default to `true`
* You may want to disable code splitting sometimes: #255
*/
splitting?: boolean
/**
* Clean output directory before each build
*/
clean?: boolean | string[]
esbuildPlugins?: EsbuildPlugin[]
esbuildOptions?: (options: BuildOptions, context: { format: Format }) => void
/**
* Suppress non-error logs (excluding "onSuccess" process output)
*/
silent?: boolean
/**
* Skip node_modules bundling
*/
skipNodeModulesBundle?: boolean
/**
* @see https://esbuild.github.io/api/#pure
*/
pure?: string | string[]
/**
* Disable bunlding, default to true
*/
bundle?: boolean
/**
* This option allows you to automatically replace a global variable with an import from another file.
* @see https://esbuild.github.io/api/#inject
*/
inject?: string[]
/**
* Emit esbuild metafile
* @see https://esbuild.github.io/api/#metafile
*/
metafile?: boolean
footer?: BuildOptions['footer']
banner?: BuildOptions['banner']
/**
* Target platform
* @default `node`
*/
platform?: 'node' | 'browser'
/**
* Esbuild loader option
*/
loader?: Record<string, Loader>
/**
* Disable config file with `false`
*/
config?: boolean
/**
* Use a custom tsconfig
*/
tsconfig?: string
/**
* CJS and ESM shims
* @default `true`
*/
shims?: boolean
}