@@ -107,15 +107,23 @@ export interface Options {
107
107
* Defaults to `'src/index.ts'` if it exists.
108
108
*/
109
109
entry ?: InputOption
110
+
110
111
external ?: ExternalOption
111
112
noExternal ?:
112
113
| Arrayable < string | RegExp >
113
114
| ( (
114
115
id : string ,
115
116
importer : string | undefined ,
116
117
) => boolean | null | undefined | void )
118
+ /**
119
+ * Skip bundling `node_modules`.
120
+ * @default false
121
+ */
122
+ skipNodeModulesBundle ?: boolean
123
+
117
124
alias ?: Record < string , string >
118
125
tsconfig ?: string | boolean
126
+
119
127
/**
120
128
* Specifies the target runtime platform for the build.
121
129
*
@@ -128,6 +136,94 @@ export interface Options {
128
136
* @see https://tsdown.dev/options/platform
129
137
*/
130
138
platform ?: 'node' | 'neutral' | 'browser'
139
+
140
+ /**
141
+ * Specifies the compilation target environment(s).
142
+ *
143
+ * Determines the JavaScript version or runtime(s) for which the code should be compiled.
144
+ * If not set, defaults to the value of `engines.node` in your project's `package.json`.
145
+ *
146
+ * Accepts a single target (e.g., `'es2020'`, `'node18'`) or an array of targets.
147
+ *
148
+ * @see {@link https://tsdown.dev/options/target#supported-targets } for a list of valid targets and more details.
149
+ *
150
+ * @example
151
+ * ```jsonc
152
+ * // Target a single environment
153
+ * { "target": "node18" }
154
+ * ```
155
+ *
156
+ * @example
157
+ * ```jsonc
158
+ * // Target multiple environments
159
+ * { "target": ["node18", "es2020"] }
160
+ * ```
161
+ */
162
+ target ?: string | string [ ] | false
163
+
164
+ /**
165
+ * Compile-time env variables.
166
+ * @example
167
+ * ```json
168
+ * {
169
+ * "DEBUG": true,
170
+ * "NODE_ENV": "production"
171
+ * }
172
+ * ```
173
+ */
174
+ env ?: Record < string , any >
175
+ define ?: Record < string , string >
176
+
177
+ /** @default false */
178
+ shims ?: boolean
179
+
180
+ /**
181
+ * @default true
182
+ */
183
+ treeshake ?: boolean
184
+ loader ?: ModuleTypes
185
+
186
+ /**
187
+ * If enabled, strips the `node:` protocol prefix from import source.
188
+ *
189
+ * @default false
190
+ * @deprecated Use `nodeProtocol: 'strip'` instead.
191
+ *
192
+ * @example
193
+ * // With removeNodeProtocol enabled:
194
+ * import('node:fs'); // becomes import('fs')
195
+ */
196
+ removeNodeProtocol ?: boolean
197
+
198
+ /**
199
+ * - If true, add `node:` prefix to built-in modules.
200
+ * - If 'strip', strips the `node:` protocol prefix from import source.
201
+ * - If false, does not modify the import source.
202
+ *
203
+ * @default false
204
+ *
205
+ * @example
206
+ * // With nodeProtocol enabled:
207
+ * import('fs'); // becomes import('node:fs')
208
+ * // With nodeProtocol set to 'strip':
209
+ * import('node:fs'); // becomes import('fs')
210
+ * // With nodeProtocol set to false:
211
+ * import('node:fs'); // remains import('node:fs')
212
+ *
213
+ */
214
+ nodeProtocol ?: 'strip' | boolean
215
+
216
+ plugins ?: InputOptions [ 'plugins' ]
217
+ /**
218
+ * Sets how input files are processed.
219
+ * For example, use 'js' to treat files as JavaScript or 'base64' for images.
220
+ * Lets you import or require files like images or fonts.
221
+ * @example
222
+ * ```json
223
+ * { '.jpg': 'asset', '.png': 'base64' }
224
+ * ```
225
+ */
226
+
131
227
inputOptions ?:
132
228
| InputOptions
133
229
| ( (
@@ -152,35 +248,13 @@ export interface Options {
152
248
* @default true
153
249
*/
154
250
clean ?: boolean | string [ ]
155
- /** @default false */
251
+ /**
252
+ * @default false
253
+ */
156
254
minify ?: boolean | 'dce-only' | MinifyOptions
157
255
footer ?: ChunkAddon
158
256
banner ?: ChunkAddon
159
257
160
- /**
161
- * Specifies the compilation target environment(s).
162
- *
163
- * Determines the JavaScript version or runtime(s) for which the code should be compiled.
164
- * If not set, defaults to the value of `engines.node` in your project's `package.json`.
165
- *
166
- * Accepts a single target (e.g., `'es2020'`, `'node18'`) or an array of targets.
167
- *
168
- * @see {@link https://tsdown.dev/options/target#supported-targets } for a list of valid targets and more details.
169
- *
170
- * @example
171
- * ```jsonc
172
- * // Target a single environment
173
- * { "target": "node18" }
174
- * ```
175
- *
176
- * @example
177
- * ```jsonc
178
- * // Target multiple environments
179
- * { "target": ["node18", "es2020"] }
180
- * ```
181
- */
182
- target ?: string | string [ ] | false
183
-
184
258
/**
185
259
* Determines whether unbundle mode is enabled.
186
260
* When set to true, the output files will mirror the input file structure.
@@ -194,30 +268,26 @@ export interface Options {
194
268
*/
195
269
bundle ?: boolean
196
270
197
- define ?: Record < string , string >
198
- /** @default false */
199
- shims ?: boolean
200
-
201
- /**
202
- * The name to show in CLI output. This is useful for monorepos or workspaces.
203
- * When using workspace mode, this option defaults to the package name from package.json.
204
- * In non-workspace mode, this option must be set explicitly for the name to show in the CLI output.
205
- */
206
- name ?: string
207
-
208
271
/**
209
272
* Use a fixed extension for output files.
210
273
* The extension will always be `.cjs` or `.mjs`.
211
274
* Otherwise, it will depend on the package type.
212
275
* @default false
213
276
*/
214
277
fixedExtension ?: boolean
278
+
215
279
/**
216
280
* Custom extensions for output files.
217
281
* `fixedExtension` will be overridden by this option.
218
282
*/
219
283
outExtensions ?: OutExtensionFactory
220
284
285
+ /**
286
+ * If enabled, appends hash to chunk filenames.
287
+ * @default true
288
+ */
289
+ hash ?: boolean
290
+
221
291
/**
222
292
* @default true
223
293
*/
@@ -231,19 +301,21 @@ export interface Options {
231
301
context : { cjsDts : boolean } ,
232
302
) => Awaitable < OutputOptions | void | null > )
233
303
234
- /** @default true */
235
- treeshake ?: boolean
236
- plugins ?: InputOptions [ 'plugins' ]
304
+ //#region CLI Options
305
+
237
306
/**
238
- * Sets how input files are processed.
239
- * For example, use 'js' to treat files as JavaScript or 'base64' for images.
240
- * Lets you import or require files like images or fonts.
241
- * @example
242
- * ```json
243
- * { '.jpg': 'asset', '.png': 'base64' }
244
- * ```
307
+ * The working directory of the config file.
308
+ * - Defaults to `process.cwd()` for root config.
309
+ * - Defaults to the package directory for workspace config.
245
310
*/
246
- loader ?: ModuleTypes
311
+ cwd ?: string
312
+
313
+ /**
314
+ * The name to show in CLI output. This is useful for monorepos or workspaces.
315
+ * When using workspace mode, this option defaults to the package name from package.json.
316
+ * In non-workspace mode, this option must be set explicitly for the name to show in the CLI output.
317
+ */
318
+ name ?: string
247
319
248
320
/**
249
321
* @default false
@@ -270,30 +342,28 @@ export interface Options {
270
342
* Config file path
271
343
*/
272
344
config ?: boolean | string
273
- /** @default false */
274
- watch ?: boolean | Arrayable < string >
275
- ignoreWatch ?: Arrayable < string | RegExp >
276
345
277
346
/**
278
- * You can specify command to be executed after a successful build, specially useful for Watch mode
347
+ * Reuse config from Vite or Vitest (experimental)
348
+ * @default false
279
349
*/
280
- onSuccess ?:
281
- | string
282
- | ( ( config : ResolvedOptions , signal : AbortSignal ) => void | Promise < void > )
350
+ fromVite ?: boolean | 'vitest'
283
351
284
352
/**
285
- * Skip bundling `node_modules`.
286
353
* @default false
287
354
*/
288
- skipNodeModulesBundle ?: boolean
355
+ watch ?: boolean | Arrayable < string >
356
+ ignoreWatch ?: Arrayable < string | RegExp >
289
357
290
358
/**
291
- * Reuse config from Vite or Vitest (experimental)
292
- * @default false
359
+ * You can specify command to be executed after a successful build, specially useful for Watch mode
293
360
*/
294
- fromVite ?: boolean | 'vitest'
361
+ onSuccess ?:
362
+ | string
363
+ | ( ( config : ResolvedOptions , signal : AbortSignal ) => void | Promise < void > )
295
364
296
365
//#region Addons
366
+
297
367
/**
298
368
* Emit TypeScript declaration files (.d.ts).
299
369
*
@@ -340,18 +410,6 @@ export interface Options {
340
410
*/
341
411
exports ?: boolean | ExportsOptions
342
412
343
- /**
344
- * Compile-time env variables.
345
- * @example
346
- * ```json
347
- * {
348
- * "DEBUG": true,
349
- * "NODE_ENV": "production"
350
- * }
351
- * ```
352
- */
353
- env ?: Record < string , any >
354
-
355
413
/**
356
414
* @deprecated Alias for `copy`, will be removed in the future.
357
415
*/
@@ -373,54 +431,12 @@ export interface Options {
373
431
| Partial < TsdownHooks >
374
432
| ( ( hooks : Hookable < TsdownHooks > ) => Awaitable < void > )
375
433
376
- /**
377
- * If enabled, strips the `node:` protocol prefix from import source.
378
- *
379
- * @default false
380
- * @deprecated Use `nodeProtocol: 'strip'` instead.
381
- *
382
- * @example
383
- * // With removeNodeProtocol enabled:
384
- * import('node:fs'); // becomes import('fs')
385
- */
386
- removeNodeProtocol ?: boolean
387
-
388
- /**
389
- * - If true, add `node:` prefix to built-in modules.
390
- * - If 'strip', strips the `node:` protocol prefix from import source.
391
- * - If false, does not modify the import source.
392
- *
393
- * @default false
394
- *
395
- * @example
396
- * // With nodeProtocol enabled:
397
- * import('fs'); // becomes import('node:fs')
398
- * // With nodeProtocol set to 'strip':
399
- * import('node:fs'); // becomes import('fs')
400
- * // With nodeProtocol set to false:
401
- * import('node:fs'); // remains import('node:fs')
402
- *
403
- */
404
- nodeProtocol ?: 'strip' | boolean
405
-
406
- /**
407
- * If enabled, appends hash to chunk filenames.
408
- * @default true
409
- */
410
- hash ?: boolean
411
-
412
- /**
413
- * The working directory of the config file.
414
- * - Defaults to `process.cwd()` for root config.
415
- * - Defaults to the package directory for workspace config.
416
- */
417
- cwd ?: string
418
-
419
434
/**
420
435
* **[experimental]** Enable workspace mode.
421
436
* This allows you to build multiple packages in a monorepo.
422
437
*/
423
438
workspace ?: Workspace | Arrayable < string > | true
439
+
424
440
/**
425
441
* Filter workspace packages. This option is only available in workspace mode.
426
442
*/
0 commit comments