Skip to content

Commit 12ab744

Browse files
committed
refactor: sort options keys
1 parent 8782f6b commit 12ab744

File tree

1 file changed

+130
-114
lines changed

1 file changed

+130
-114
lines changed

src/options/types.ts

Lines changed: 130 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,23 @@ export interface Options {
107107
* Defaults to `'src/index.ts'` if it exists.
108108
*/
109109
entry?: InputOption
110+
110111
external?: ExternalOption
111112
noExternal?:
112113
| Arrayable<string | RegExp>
113114
| ((
114115
id: string,
115116
importer: string | undefined,
116117
) => boolean | null | undefined | void)
118+
/**
119+
* Skip bundling `node_modules`.
120+
* @default false
121+
*/
122+
skipNodeModulesBundle?: boolean
123+
117124
alias?: Record<string, string>
118125
tsconfig?: string | boolean
126+
119127
/**
120128
* Specifies the target runtime platform for the build.
121129
*
@@ -128,6 +136,94 @@ export interface Options {
128136
* @see https://tsdown.dev/options/platform
129137
*/
130138
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+
131227
inputOptions?:
132228
| InputOptions
133229
| ((
@@ -152,35 +248,13 @@ export interface Options {
152248
* @default true
153249
*/
154250
clean?: boolean | string[]
155-
/** @default false */
251+
/**
252+
* @default false
253+
*/
156254
minify?: boolean | 'dce-only' | MinifyOptions
157255
footer?: ChunkAddon
158256
banner?: ChunkAddon
159257

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-
184258
/**
185259
* Determines whether unbundle mode is enabled.
186260
* When set to true, the output files will mirror the input file structure.
@@ -194,30 +268,26 @@ export interface Options {
194268
*/
195269
bundle?: boolean
196270

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-
208271
/**
209272
* Use a fixed extension for output files.
210273
* The extension will always be `.cjs` or `.mjs`.
211274
* Otherwise, it will depend on the package type.
212275
* @default false
213276
*/
214277
fixedExtension?: boolean
278+
215279
/**
216280
* Custom extensions for output files.
217281
* `fixedExtension` will be overridden by this option.
218282
*/
219283
outExtensions?: OutExtensionFactory
220284

285+
/**
286+
* If enabled, appends hash to chunk filenames.
287+
* @default true
288+
*/
289+
hash?: boolean
290+
221291
/**
222292
* @default true
223293
*/
@@ -231,19 +301,21 @@ export interface Options {
231301
context: { cjsDts: boolean },
232302
) => Awaitable<OutputOptions | void | null>)
233303

234-
/** @default true */
235-
treeshake?: boolean
236-
plugins?: InputOptions['plugins']
304+
//#region CLI Options
305+
237306
/**
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.
245310
*/
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
247319

248320
/**
249321
* @default false
@@ -270,30 +342,28 @@ export interface Options {
270342
* Config file path
271343
*/
272344
config?: boolean | string
273-
/** @default false */
274-
watch?: boolean | Arrayable<string>
275-
ignoreWatch?: Arrayable<string | RegExp>
276345

277346
/**
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
279349
*/
280-
onSuccess?:
281-
| string
282-
| ((config: ResolvedOptions, signal: AbortSignal) => void | Promise<void>)
350+
fromVite?: boolean | 'vitest'
283351

284352
/**
285-
* Skip bundling `node_modules`.
286353
* @default false
287354
*/
288-
skipNodeModulesBundle?: boolean
355+
watch?: boolean | Arrayable<string>
356+
ignoreWatch?: Arrayable<string | RegExp>
289357

290358
/**
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
293360
*/
294-
fromVite?: boolean | 'vitest'
361+
onSuccess?:
362+
| string
363+
| ((config: ResolvedOptions, signal: AbortSignal) => void | Promise<void>)
295364

296365
//#region Addons
366+
297367
/**
298368
* Emit TypeScript declaration files (.d.ts).
299369
*
@@ -340,18 +410,6 @@ export interface Options {
340410
*/
341411
exports?: boolean | ExportsOptions
342412

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-
355413
/**
356414
* @deprecated Alias for `copy`, will be removed in the future.
357415
*/
@@ -373,54 +431,12 @@ export interface Options {
373431
| Partial<TsdownHooks>
374432
| ((hooks: Hookable<TsdownHooks>) => Awaitable<void>)
375433

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-
419434
/**
420435
* **[experimental]** Enable workspace mode.
421436
* This allows you to build multiple packages in a monorepo.
422437
*/
423438
workspace?: Workspace | Arrayable<string> | true
439+
424440
/**
425441
* Filter workspace packages. This option is only available in workspace mode.
426442
*/

0 commit comments

Comments
 (0)