tsdown 0.22.3 → 0.22.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1427 @@
1
+ import { a as Awaitable, i as Arrayable, n as Logger, o as MarkPartial, s as Overwrite, t as LogLevel } from "./logger-Dewu9aCG.mjs";
2
+ import { BuildOptions, ChecksOptions, ExternalOption, InputOptions, InternalModuleFormat, MinifyOptions, ModuleFormat, ModuleTypes, OutputAsset, OutputChunk, OutputOptions, Plugin, RolldownPlugin, TreeshakingOptions } from "rolldown";
3
+ import { Hookable } from "hookable";
4
+ import { Buffer } from "node:buffer";
5
+ import { StartOptions } from "@vitejs/devtools/cli-commands";
6
+ import { ExeExtensionOptions } from "@tsdown/exe";
7
+ import { CheckPackageOptions } from "@arethetypeswrong/core";
8
+ import { Options } from "publint";
9
+ import { CssOptions } from "@tsdown/css";
10
+ import { Options as Options$1 } from "rolldown-plugin-dts";
11
+ import { Options as UnusedOptions } from "unplugin-unused";
12
+ //#region src/features/copy.d.ts
13
+ interface CopyEntry {
14
+ /**
15
+ * Source path or glob pattern.
16
+ */
17
+ from: string | string[];
18
+ /**
19
+ * Destination path.
20
+ * If not specified, defaults to the output directory ("outDir").
21
+ */
22
+ to?: string;
23
+ /**
24
+ * Whether to flatten the copied files (not preserving directory structure).
25
+ *
26
+ * @default true
27
+ */
28
+ flatten?: boolean;
29
+ /**
30
+ * Output copied items to console.
31
+ * @default false
32
+ */
33
+ verbose?: boolean;
34
+ /**
35
+ * Change destination file or folder name.
36
+ */
37
+ rename?: string | ((name: string, extension: string, fullPath: string) => string);
38
+ }
39
+ type CopyOptions = Arrayable<string | CopyEntry>;
40
+ type CopyOptionsFn = (options: ResolvedConfig) => Awaitable<CopyOptions>;
41
+ //#endregion
42
+ //#region src/utils/chunks.d.ts
43
+ type RolldownChunk = (OutputChunk | OutputAsset) & {
44
+ outDir: string;
45
+ };
46
+ type ChunksByFormat = Partial<Record<NormalizedFormat, RolldownChunk[]>>;
47
+ interface TsdownBundle extends AsyncDisposable {
48
+ chunks: RolldownChunk[];
49
+ config: ResolvedConfig;
50
+ inlinedDeps: Map<string, Set<string>>;
51
+ }
52
+ //#endregion
53
+ //#region src/features/deps.d.ts
54
+ type NoExternalFn = (id: string, importer: string | undefined) => boolean | null | undefined | void;
55
+ interface DepsConfig {
56
+ /**
57
+ * Mark dependencies as external (not bundled).
58
+ * Accepts strings, regular expressions, or Rolldown's
59
+ * {@linkcode ExternalOption}.
60
+ */
61
+ neverBundle?: ExternalOption;
62
+ /**
63
+ * Force dependencies to be bundled, even if they are in `dependencies`, `peerDependencies`, or `optionalDependencies`.
64
+ */
65
+ alwaysBundle?: Arrayable<string | RegExp> | NoExternalFn;
66
+ /**
67
+ * Whitelist of dependencies allowed to be bundled from `node_modules`.
68
+ * Throws an error if any unlisted dependency is bundled.
69
+ *
70
+ * - `undefined` (default): Show warnings for bundled dependencies.
71
+ * - `false`: Suppress all warnings about bundled dependencies.
72
+ *
73
+ * Note: Be sure to include all required sub-dependencies as well.
74
+ */
75
+ onlyBundle?: Arrayable<string | RegExp> | false;
76
+ /**
77
+ * @deprecated Use {@linkcode onlyBundle} instead.
78
+ */
79
+ onlyAllowBundle?: Arrayable<string | RegExp> | false;
80
+ /**
81
+ * Skip bundling all `node_modules` dependencies.
82
+ *
83
+ * **Note:** This option cannot be used together with {@linkcode alwaysBundle}.
84
+ *
85
+ * @default false
86
+ */
87
+ skipNodeModulesBundle?: boolean;
88
+ /**
89
+ * Override dependency bundling options for declaration file generation.
90
+ */
91
+ dts?: Pick<DepsConfig, "alwaysBundle" | "neverBundle">;
92
+ }
93
+ interface ResolvedDepsConfig {
94
+ neverBundle?: ExternalOption;
95
+ alwaysBundle?: NoExternalFn;
96
+ onlyBundle?: Array<string | RegExp> | false;
97
+ skipNodeModulesBundle: boolean;
98
+ /**
99
+ * Override dependency bundling options for declaration file generation.
100
+ */
101
+ dts: Pick<ResolvedDepsConfig, "alwaysBundle" | "neverBundle">;
102
+ }
103
+ declare function DepsPlugin({ pkg, deps: { alwaysBundle: jsAlwaysBundle, onlyBundle, skipNodeModulesBundle, dts }, logger, nameLabel }: ResolvedConfig, tsdownBundle: TsdownBundle): Plugin;
104
+ //#endregion
105
+ //#region src/features/devtools.d.ts
106
+ interface DevtoolsOptions extends NonNullable<InputOptions["devtools"]> {
107
+ /**
108
+ * **[experimental]** Enable devtools integration. `@vitejs/devtools` must be installed as a dependency.
109
+ *
110
+ * Defaults to true, if `@vitejs/devtools` is installed.
111
+ */
112
+ ui?: boolean | Partial<StartOptions>;
113
+ /**
114
+ * Clean devtools stale sessions.
115
+ *
116
+ * @default true
117
+ */
118
+ clean?: boolean;
119
+ }
120
+ //#endregion
121
+ //#region src/features/exe.d.ts
122
+ interface ExeOptions extends ExeExtensionOptions {
123
+ seaConfig?: Omit<SeaConfig, "main" | "output" | "mainFormat">;
124
+ /**
125
+ * Output file name without any suffix or extension.
126
+ * For example, do not include `.exe`, platform suffixes, or architecture suffixes.
127
+ */
128
+ fileName?: string | ((chunk: RolldownChunk) => string);
129
+ /**
130
+ * Output directory for executables.
131
+ * @default 'build'
132
+ */
133
+ outDir?: string;
134
+ }
135
+ /**
136
+ * See also [Node.js SEA Documentation](https://nodejs.org/api/single-executable-applications.html#generating-single-executable-applications-with---build-sea)
137
+ *
138
+ * Note some default values are different from Node.js defaults to optimize for typical use cases (e.g. disabling experimental warning, enabling code cache). These can be overridden.
139
+ */
140
+ interface SeaConfig {
141
+ main?: string;
142
+ /**
143
+ * Optional, if not specified, uses the current Node.js binary
144
+ */
145
+ executable?: string;
146
+ output?: string;
147
+ /**
148
+ * @default tsdownConfig.format === 'es' ? 'module' : 'commonjs'
149
+ */
150
+ mainFormat?: "commonjs" | "module";
151
+ /**
152
+ * @default true
153
+ */
154
+ disableExperimentalSEAWarning?: boolean;
155
+ /**
156
+ * @default false
157
+ */
158
+ useSnapshot?: boolean;
159
+ /**
160
+ * @default false
161
+ */
162
+ useCodeCache?: boolean;
163
+ execArgv?: string[];
164
+ /**
165
+ * @default 'env'
166
+ */
167
+ execArgvExtension?: "none" | "env" | "cli";
168
+ assets?: Record<string, string>;
169
+ }
170
+ //#endregion
171
+ //#region src/features/hooks.d.ts
172
+ interface BuildContext {
173
+ options: ResolvedConfig;
174
+ hooks: Hookable<TsdownHooks>;
175
+ }
176
+ interface RolldownContext {
177
+ buildOptions: BuildOptions;
178
+ }
179
+ /**
180
+ * Hooks for tsdown.
181
+ */
182
+ interface TsdownHooks {
183
+ /**
184
+ * Invoked before each tsdown build starts.
185
+ * Use this hook to perform setup or preparation tasks.
186
+ */
187
+ "build:prepare": (ctx: BuildContext) => void | Promise<void>;
188
+ /**
189
+ * Invoked before each Rolldown build.
190
+ * For dual-format builds, this hook is called for each format.
191
+ * Useful for configuring or modifying the build context before bundling.
192
+ */
193
+ "build:before": (ctx: BuildContext & RolldownContext) => void | Promise<void>;
194
+ /**
195
+ * Invoked after each tsdown build completes.
196
+ * Use this hook for cleanup or post-processing tasks.
197
+ */
198
+ "build:done": (ctx: BuildContext & {
199
+ chunks: RolldownChunk[];
200
+ }) => void | Promise<void>;
201
+ }
202
+ //#endregion
203
+ //#region node_modules/.pnpm/pkg-types@2.3.1/node_modules/pkg-types/dist/index.d.mts
204
+ //#endregion
205
+ //#region src/packagejson/types.d.ts
206
+ interface PackageJson {
207
+ /**
208
+ * The name is what your thing is called.
209
+ * Some rules:
210
+ * - The name must be less than or equal to 214 characters. This includes the scope for scoped packages.
211
+ * - The name can’t start with a dot or an underscore.
212
+ * - New packages must not have uppercase letters in the name.
213
+ * - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can’t contain any non-URL-safe characters.
214
+ */
215
+ name?: string;
216
+ /**
217
+ * Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
218
+ */
219
+ version?: string;
220
+ /**
221
+ * Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`.
222
+ */
223
+ description?: string;
224
+ /**
225
+ * Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`.
226
+ */
227
+ keywords?: string[];
228
+ /**
229
+ * The url to the project homepage.
230
+ */
231
+ homepage?: string;
232
+ /**
233
+ * The url to your project’s issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.
234
+ */
235
+ bugs?: string | {
236
+ url?: string;
237
+ email?: string;
238
+ };
239
+ /**
240
+ * You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you’re placing on it.
241
+ */
242
+ license?: string;
243
+ /**
244
+ * Specify the place where your code lives. This is helpful for people who want to contribute. If the git repo is on GitHub, then the `npm docs` command will be able to find you.
245
+ * For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install:
246
+ */
247
+ repository?: string | {
248
+ type: string;
249
+ url: string;
250
+ /**
251
+ * If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
252
+ */
253
+ directory?: string;
254
+ };
255
+ /**
256
+ * The `scripts` field is a dictionary containing script commands that are run at various times in the lifecycle of your package.
257
+ */
258
+ scripts?: PackageJsonScripts;
259
+ /**
260
+ * If you set `"private": true` in your package.json, then npm will refuse to publish it.
261
+ */
262
+ private?: boolean;
263
+ /**
264
+ * The “author” is one person.
265
+ */
266
+ author?: PackageJsonPerson;
267
+ /**
268
+ * “contributors” is an array of people.
269
+ */
270
+ contributors?: PackageJsonPerson[];
271
+ /**
272
+ * An object containing a URL that provides up-to-date information
273
+ * about ways to help fund development of your package,
274
+ * a string URL, or an array of objects and string URLs
275
+ */
276
+ funding?: PackageJsonFunding | PackageJsonFunding[];
277
+ /**
278
+ * The optional `files` field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**\/*`, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to `["*"]`, which means it will include all files.
279
+ */
280
+ files?: string[];
281
+ /**
282
+ * The main field is a module ID that is the primary entry point to your program. That is, if your package is named `foo`, and a user installs it, and then does `require("foo")`, then your main module’s exports object will be returned.
283
+ * This should be a module ID relative to the root of your package folder.
284
+ * For most modules, it makes the most sense to have a main script and often not much else.
285
+ */
286
+ main?: string;
287
+ /**
288
+ * If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren’t available in Node.js modules. (e.g. window)
289
+ */
290
+ browser?: string | Record<string, string | false>;
291
+ /**
292
+ * The `unpkg` field is used to specify the URL to a UMD module for your package. This is used by default in the unpkg.com CDN service.
293
+ */
294
+ unpkg?: string;
295
+ /**
296
+ * A map of command name to local file name. On install, npm will symlink that file into `prefix/bin` for global installs, or `./node_modules/.bin/` for local installs.
297
+ */
298
+ bin?: string | Record<string, string>;
299
+ /**
300
+ * Specify either a single file or an array of filenames to put in place for the `man` program to find.
301
+ */
302
+ man?: string | string[];
303
+ /**
304
+ * Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
305
+ */
306
+ dependencies?: Record<string, string>;
307
+ /**
308
+ * If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use.
309
+ * In this case, it’s best to map these additional items in a `devDependencies` object.
310
+ */
311
+ devDependencies?: Record<string, string>;
312
+ /**
313
+ * If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the `optionalDependencies` object. This is a map of package name to version or url, just like the `dependencies` object. The difference is that build failures do not cause installation to fail.
314
+ */
315
+ optionalDependencies?: Record<string, string>;
316
+ /**
317
+ * In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a `require` of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.
318
+ */
319
+ peerDependencies?: Record<string, string>;
320
+ /**
321
+ * TypeScript typings, typically ending by `.d.ts`.
322
+ */
323
+ types?: string;
324
+ /**
325
+ * This field is synonymous with `types`.
326
+ */
327
+ typings?: string;
328
+ /**
329
+ * Non-Standard Node.js alternate entry-point to main.
330
+ * An initial implementation for supporting CJS packages (from main), and use module for ESM modules.
331
+ */
332
+ module?: string;
333
+ /**
334
+ * Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require"
335
+ *
336
+ * Docs:
337
+ * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_package_json_type_field
338
+ *
339
+ * @default 'commonjs'
340
+ * @since Node.js v14
341
+ */
342
+ type?: "module" | "commonjs";
343
+ /**
344
+ * Alternate and extensible alternative to "main" entry point.
345
+ *
346
+ * When using `{type: "module"}`, any ESM module file MUST end with `.mjs` extension.
347
+ *
348
+ * Docs:
349
+ * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_exports_sugar
350
+ *
351
+ * @since Node.js v12.7
352
+ */
353
+ exports?: PackageJsonExports;
354
+ /**
355
+ * Docs:
356
+ * - https://nodejs.org/api/packages.html#imports
357
+ */
358
+ imports?: Record<string, string | Record<string, string>>;
359
+ /**
360
+ * The field is used to define a set of sub-packages (or workspaces) within a monorepo.
361
+ *
362
+ * This field is an array of glob patterns or an object with specific configurations for managing
363
+ * multiple packages in a single repository.
364
+ */
365
+ workspaces?: string[] | {
366
+ /**
367
+ * Workspace package paths. Glob patterns are supported.
368
+ */
369
+ packages?: string[];
370
+ /**
371
+ * Packages to block from hoisting to the workspace root.
372
+ * Uses glob patterns to match module paths in the dependency tree.
373
+ *
374
+ * Docs:
375
+ * - https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
376
+ */
377
+ nohoist?: string[];
378
+ };
379
+ /**
380
+ * The field is used to specify different TypeScript declaration files for
381
+ * different versions of TypeScript, allowing for version-specific type definitions.
382
+ */
383
+ typesVersions?: Record<string, Record<string, string[]>>;
384
+ /**
385
+ * You can specify which operating systems your module will run on:
386
+ * ```json
387
+ * {
388
+ * "os": ["darwin", "linux"]
389
+ * }
390
+ * ```
391
+ * You can also block instead of allowing operating systems, just prepend the blocked os with a '!':
392
+ * ```json
393
+ * {
394
+ * "os": ["!win32"]
395
+ * }
396
+ * ```
397
+ * The host operating system is determined by `process.platform`
398
+ * It is allowed to both block and allow an item, although there isn't any good reason to do this.
399
+ */
400
+ os?: string[];
401
+ /**
402
+ * If your code only runs on certain cpu architectures, you can specify which ones.
403
+ * ```json
404
+ * {
405
+ * "cpu": ["x64", "ia32"]
406
+ * }
407
+ * ```
408
+ * Like the `os` option, you can also block architectures:
409
+ * ```json
410
+ * {
411
+ * "cpu": ["!arm", "!mips"]
412
+ * }
413
+ * ```
414
+ * The host architecture is determined by `process.arch`
415
+ */
416
+ cpu?: string[];
417
+ /**
418
+ * This is a set of config values that will be used at publish-time.
419
+ */
420
+ publishConfig?: {
421
+ /**
422
+ * The registry that will be used if the package is published.
423
+ */
424
+ registry?: string;
425
+ /**
426
+ * The tag that will be used if the package is published.
427
+ */
428
+ tag?: string;
429
+ /**
430
+ * The access level that will be used if the package is published.
431
+ */
432
+ access?: "public" | "restricted";
433
+ /**
434
+ * **pnpm-only**
435
+ *
436
+ * By default, for portability reasons, no files except those listed in
437
+ * the bin field will be marked as executable in the resulting package
438
+ * archive. The executableFiles field lets you declare additional fields
439
+ * that must have the executable flag (+x) set even if
440
+ * they aren't directly accessible through the bin field.
441
+ */
442
+ executableFiles?: string[];
443
+ /**
444
+ * **pnpm-only**
445
+ *
446
+ * You also can use the field `publishConfig.directory` to customize
447
+ * the published subdirectory relative to the current `package.json`.
448
+ *
449
+ * It is expected to have a modified version of the current package in
450
+ * the specified directory (usually using third party build tools).
451
+ */
452
+ directory?: string;
453
+ /**
454
+ * **pnpm-only**
455
+ *
456
+ * When set to `true`, the project will be symlinked from the
457
+ * `publishConfig.directory` location during local development.
458
+ * @default true
459
+ */
460
+ linkDirectory?: boolean;
461
+ } & Pick<PackageJson, "bin" | "main" | "exports" | "types" | "typings" | "module" | "browser" | "unpkg" | "typesVersions" | "os" | "cpu">;
462
+ /**
463
+ * See: https://nodejs.org/api/packages.html#packagemanager
464
+ * This field defines which package manager is expected to be used when working on the current project.
465
+ * Should be of the format: `<name>@<version>[#hash]`
466
+ */
467
+ packageManager?: string;
468
+ [key: string]: any;
469
+ }
470
+ /**
471
+ * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#pre--post-scripts
472
+ */
473
+ type PackageJsonScriptWithPreAndPost<S extends string> = S | `${"pre" | "post"}${S}`;
474
+ /**
475
+ * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#life-cycle-operation-order
476
+ */
477
+ type PackageJsonNpmLifeCycleScripts = "dependencies" | "prepublishOnly" | PackageJsonScriptWithPreAndPost<"install" | "pack" | "prepare" | "publish" | "restart" | "start" | "stop" | "test" | "version">;
478
+ /**
479
+ * See: https://pnpm.io/scripts#lifecycle-scripts
480
+ */
481
+ type PackageJsonPnpmLifeCycleScripts = "pnpm:devPreinstall";
482
+ type PackageJsonCommonScripts = "build" | "coverage" | "deploy" | "dev" | "format" | "lint" | "preview" | "release" | "typecheck" | "watch";
483
+ type PackageJsonScriptName = PackageJsonCommonScripts | PackageJsonNpmLifeCycleScripts | PackageJsonPnpmLifeCycleScripts | (string & {});
484
+ type PackageJsonScripts = { [P in PackageJsonScriptName]?: string; };
485
+ /**
486
+ * A “person” is an object with a “name” field and optionally “url” and “email”. Or you can shorten that all into a single string, and npm will parse it for you.
487
+ */
488
+ type PackageJsonPerson = string | {
489
+ name: string;
490
+ email?: string;
491
+ url?: string;
492
+ };
493
+ type PackageJsonFunding = string | {
494
+ url: string;
495
+ type?: string;
496
+ };
497
+ type PackageJsonExportKey = "." | "import" | "require" | "types" | "node" | "browser" | "default" | (string & {});
498
+ type PackageJsonExportsObject = { [P in PackageJsonExportKey]?: string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>; };
499
+ type PackageJsonExports = string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>;
500
+ //#endregion
501
+ //#region src/utils/package.d.ts
502
+ interface PackageJsonWithPath extends PackageJson {
503
+ packageJsonPath: string;
504
+ }
505
+ type PackageType = "module" | "commonjs" | undefined;
506
+ //#endregion
507
+ //#region src/features/output.d.ts
508
+ interface OutExtensionContext {
509
+ options: InputOptions;
510
+ format: NormalizedFormat;
511
+ /**
512
+ * `"type"` field in project's `package.json`.
513
+ */
514
+ pkgType?: PackageType;
515
+ }
516
+ interface OutExtensionObject {
517
+ js?: string;
518
+ dts?: string;
519
+ }
520
+ type OutExtensionFactory = (context: OutExtensionContext) => OutExtensionObject | undefined;
521
+ interface ChunkAddonObject {
522
+ js?: string;
523
+ css?: string;
524
+ dts?: string;
525
+ }
526
+ type ChunkAddonFunction = (ctx: {
527
+ format: Format;
528
+ fileName: string;
529
+ }) => ChunkAddonObject | string | undefined;
530
+ type ChunkAddon = ChunkAddonObject | ChunkAddonFunction | string;
531
+ //#endregion
532
+ //#region src/features/pkg/attw.d.ts
533
+ interface AttwOptions extends CheckPackageOptions {
534
+ module?: typeof import("@arethetypeswrong/core");
535
+ /**
536
+ * Profiles select a set of resolution modes to require/ignore. All are evaluated but failures outside
537
+ * of those required are ignored.
538
+ *
539
+ * The available profiles are:
540
+ * - `strict`: requires all resolutions
541
+ * - `node16`: ignores node10 resolution failures
542
+ * - `esm-only`: ignores CJS resolution failures
543
+ *
544
+ * @default 'strict'
545
+ */
546
+ profile?: "strict" | "node16" | "esm-only";
547
+ /**
548
+ * The level of the check.
549
+ *
550
+ * The available levels are:
551
+ * - `error`: fails the build
552
+ * - `warn`: warns the build
553
+ *
554
+ * @default 'warn'
555
+ */
556
+ level?: "error" | "warn";
557
+ /**
558
+ * List of problem types to ignore by rule name.
559
+ *
560
+ * The available values are:
561
+ * - `no-resolution`
562
+ * - `untyped-resolution`
563
+ * - `false-cjs`
564
+ * - `false-esm`
565
+ * - `cjs-resolves-to-esm`
566
+ * - `fallback-condition`
567
+ * - `cjs-only-exports-default`
568
+ * - `named-exports`
569
+ * - `false-export-default`
570
+ * - `missing-export-equals`
571
+ * - `unexpected-module-syntax`
572
+ * - `internal-resolution-error`
573
+ *
574
+ * @example
575
+ * ```ts
576
+ * ignoreRules: ['no-resolution', 'false-cjs']
577
+ * ```
578
+ *
579
+ * @default []
580
+ *
581
+ * @uniqueItems
582
+ */
583
+ ignoreRules?: ("no-resolution" | "untyped-resolution" | "false-cjs" | "false-esm" | "cjs-resolves-to-esm" | "fallback-condition" | "cjs-only-exports-default" | "named-exports" | "false-export-default" | "missing-export-equals" | "unexpected-module-syntax" | "internal-resolution-error" | (string & {}))[];
584
+ }
585
+ //#endregion
586
+ //#region src/features/pkg/exports.d.ts
587
+ interface ExportsOptions {
588
+ /**
589
+ * Generate exports that link to source code during development.
590
+ * - `string`: add as a custom condition.
591
+ * - `true`: all conditions point to source files, and add `dist` exports to `publishConfig`.
592
+ */
593
+ devExports?: boolean | string;
594
+ /**
595
+ * Generate `exports` for `package.json` file.
596
+ *
597
+ * @example
598
+ * ```json
599
+ * {
600
+ * "exports": {
601
+ * ".": {
602
+ * "types": "./dist/index.d.mts",
603
+ * "import": "./dist/index.mjs"
604
+ * },
605
+ * "./package.json": "./package.json"
606
+ * }
607
+ * }
608
+ * ```
609
+ *
610
+ * @default true
611
+ */
612
+ packageJson?: boolean;
613
+ /**
614
+ * Generate `exports` for all files.
615
+ *
616
+ * @example
617
+ * ```json
618
+ * {
619
+ * "exports": {
620
+ * "./*": "./*"
621
+ * }
622
+ * }
623
+ * ```
624
+ *
625
+ * @default false
626
+ */
627
+ all?: boolean;
628
+ /**
629
+ * Specifies file patterns (as glob patterns or regular expressions) to exclude from package exports.
630
+ * Use this to prevent certain files from being included in the exported package, such as test files, binaries, or internal utilities.
631
+ *
632
+ * **Note:** Do not include file extensions, and paths should be relative to the dist directory.
633
+ *
634
+ * @example
635
+ * ```ts
636
+ * exclude: ['cli', '**\/*.test', /internal/]
637
+ * ```
638
+ */
639
+ exclude?: (RegExp | string)[];
640
+ /**
641
+ * Generate legacy fields (`main` and `module`) for older Node.js and bundlers
642
+ * that do not support package `exports` field.
643
+ *
644
+ * Defaults to false, if only ESM builds are included, true otherwise.
645
+ *
646
+ * @see {@link https://github.com/publint/publint/issues/24}
647
+ */
648
+ legacy?: boolean;
649
+ /**
650
+ * Specifies custom exports to add to the package exports in addition to the ones generated by tsdown.
651
+ * Use this to add additional exports in the exported package, such as workers or assets.
652
+ *
653
+ * @example
654
+ * ```ts
655
+ * customExports(exports) {
656
+ * exports['./worker.js'] = './dist/worker.js';
657
+ * return exports;
658
+ * }
659
+ * ```
660
+ *
661
+ * @example
662
+ * ```jsonc
663
+ * {
664
+ * "customExports": {
665
+ * "./worker.js": {
666
+ * "types": "./dist/worker.d.ts",
667
+ * "default": "./dist/worker.js"
668
+ * }
669
+ * }
670
+ * }
671
+ * ```
672
+ */
673
+ customExports?: Record<string, any> | ((exports: Record<string, any>, context: {
674
+ pkg: PackageJson;
675
+ chunks: ChunksByFormat;
676
+ isPublish: boolean;
677
+ }) => Awaitable<Record<string, any>>);
678
+ /**
679
+ * Generate `inlinedDependencies` field in `package.json`.
680
+ * Lists dependencies that are physically inlined into the bundle with their exact versions.
681
+ *
682
+ * @default true
683
+ * @see {@link https://github.com/e18e/ecosystem-issues/issues/237}
684
+ */
685
+ inlinedDependencies?: boolean;
686
+ /**
687
+ * Add file extensions to subpath export keys.
688
+ *
689
+ * When enabled, all subpath exports (except the root `"."`) will include
690
+ * a `.js` extension in the key (e.g., `"./utils.js"` instead of `"./utils"`).
691
+ *
692
+ * This follows the Node.js recommendation for subpath exports:
693
+ * @see {@link https://nodejs.org/api/packages.html#extensions-in-subpaths}
694
+ *
695
+ * @default false
696
+ */
697
+ extensions?: boolean;
698
+ /**
699
+ * Generate the `bin` field in `package.json` for CLI executables.
700
+ *
701
+ * Behavior depends on the value:
702
+ *
703
+ * - *Unset* (default): Soft auto-detect. Scans entry chunks for shebangs
704
+ * (e.g. `#!/usr/bin/env node`). If exactly one is found, it is used as
705
+ * the bin entry. If multiple are found, a warning is shown and no `bin`
706
+ * field is written. If none are found, nothing happens silently.
707
+ * - `true`: Strict auto-detect. Same as the default, but throws if
708
+ * multiple shebang entries are found, and warns if none are found.
709
+ * Use this when your package is known to ship a CLI and you want to
710
+ * fail fast on misconfiguration.
711
+ * - `false`: Disable bin generation entirely, even if shebangs are
712
+ * present.
713
+ * - `string`: Use the given source file path (relative to `cwd`) as the
714
+ * CLI entry. The command name is derived from the package name without
715
+ * its scope. Warns if the source file does not contain a shebang.
716
+ * - `Record<string, string>`: Explicitly map command names to source file
717
+ * paths (relative to `cwd`). Warns for each source file that does not
718
+ * contain a shebang.
719
+ *
720
+ * When {@link ExportsOptions.devExports} is enabled, the `bin` field in
721
+ * `package.json` points to source files during local development, while
722
+ * `publishConfig.bin` points to built output paths for publishing.
723
+ *
724
+ * @example
725
+ * <caption>Auto-detect a CLI entry from a shebang</caption>
726
+ *
727
+ * ```ts
728
+ * {
729
+ * bin: true
730
+ * }
731
+ * ```
732
+ *
733
+ * @example
734
+ * <caption>Single CLI command with an explicit source entry</caption>
735
+ *
736
+ * ```ts
737
+ * {
738
+ * bin: './src/cli.ts'
739
+ * }
740
+ * ```
741
+ *
742
+ * @example
743
+ * <caption>Multiple named CLI commands</caption>
744
+ *
745
+ * ```ts
746
+ * {
747
+ * bin: {
748
+ * tool: './src/cli.ts',
749
+ * serve: './src/cli-extra.ts',
750
+ * },
751
+ * }
752
+ * ```
753
+ *
754
+ * @see {@link https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin | npm documentation for the `bin` field}
755
+ */
756
+ bin?: boolean | string | Record<string, string>;
757
+ }
758
+ //#endregion
759
+ //#region src/features/pkg/publint.d.ts
760
+ interface PublintOptions extends Omit<Options, "pack" | "pkgDir"> {
761
+ module?: [typeof import("publint"), typeof import("publint/utils")];
762
+ }
763
+ //#endregion
764
+ //#region src/features/plugin.d.ts
765
+ /**
766
+ * A tsdown-aware plugin. Extends Rolldown's {@linkcode Plugin} with
767
+ * tsdown-specific lifecycle hooks.
768
+ *
769
+ * Plugins that only use Rolldown's own lifecycle continue to work unchanged;
770
+ * tsdown detects these optional methods via runtime duck-typing.
771
+ */
772
+ interface TsdownPlugin<A = any> extends Plugin<A> {
773
+ /**
774
+ * Modify tsdown's user config before it is resolved. Analogous to Vite's
775
+ * [`config`](https://vite.dev/guide/api-plugin.html#config) hook.
776
+ *
777
+ * The hook may mutate {@linkcode config} in place, or return a partial
778
+ * {@linkcode UserConfig} that will be deep-merged into the current config.
779
+ * Array fields are replaced (not concatenated) during merging — to append
780
+ * plugins, mutate {@linkcode UserConfig.plugins | config.plugins} in place.
781
+ *
782
+ * The second argument is the original {@linkcode InlineConfig} passed to
783
+ * {@linkcode build | build()} (typically the CLI flags), useful for
784
+ * distinguishing values that came from the command line vs. the config file.
785
+ *
786
+ * Plugins injected via {@linkcode UserConfig.fromVite | fromVite} do not
787
+ * receive this hook, because they are loaded after the
788
+ * {@linkcode tsdownConfig} phase. Likewise, new plugins added by another
789
+ * plugin's {@linkcode tsdownConfig} do not themselves receive this hook
790
+ * (plugins are snapshotted before dispatch).
791
+ */
792
+ tsdownConfig?: (config: UserConfig, inlineConfig: InlineConfig) => Awaitable<UserConfig | void | null>;
793
+ /**
794
+ * Called after tsdown has fully resolved the user config. Analogous to
795
+ * Vite's [`configResolved`](https://vite.dev/guide/api-plugin.html#configresolved)
796
+ * hook.
797
+ *
798
+ * This hook fires once per produced {@linkcode ResolvedConfig} — i.e. once
799
+ * per output format when {@linkcode UserConfig.format | format} is an array.
800
+ * Typical usage is to stash the resolved config for later use in
801
+ * Rolldown hooks. Mutations made to {@linkcode resolvedConfig} here are
802
+ * not supported.
803
+ */
804
+ tsdownConfigResolved?: (resolvedConfig: ResolvedConfig) => Awaitable<void>;
805
+ }
806
+ /**
807
+ * A tsdown plugin slot — accepts tsdown plugins, any Rolldown plugin form,
808
+ * `null`/`undefined`/`false`, {@linkcode Promise | promises}, and
809
+ * nested arrays. Mirrors Rolldown's {@linkcode RolldownPluginOption} but with
810
+ * {@linkcode TsdownPlugin} as the atom so that tsdown-specific hooks are
811
+ * type-checked.
812
+ */
813
+ type TsdownPluginOption<A = any> = Awaitable<TsdownPlugin<A> | RolldownPlugin<A> | {
814
+ name: string;
815
+ } | undefined | null | void | false | TsdownPluginOption<A>[]>;
816
+ //#endregion
817
+ //#region src/features/report.d.ts
818
+ interface ReportOptions {
819
+ /**
820
+ * Enable/disable gzip-compressed size reporting.
821
+ * Compressing large output files can be slow, so disabling this may increase build performance for large projects.
822
+ *
823
+ * @default true
824
+ */
825
+ gzip?: boolean;
826
+ /**
827
+ * Enable/disable brotli-compressed size reporting.
828
+ * Compressing large output files can be slow, so disabling this may increase build performance for large projects.
829
+ *
830
+ * @default false
831
+ */
832
+ brotli?: boolean;
833
+ /**
834
+ * Skip reporting compressed size for files larger than this size.
835
+ * @default 1_000_000 // 1 MB
836
+ */
837
+ maxCompressSize?: number;
838
+ }
839
+ declare function ReportPlugin(config: ResolvedConfig, cjsDts?: boolean, isDualFormat?: boolean): Plugin;
840
+ //#endregion
841
+ //#region src/config/types.d.ts
842
+ interface DtsOptions extends Options$1 {
843
+ /**
844
+ * When building dual ESM+CJS formats, generate a `.d.cts` re-export stub
845
+ * instead of running a full second TypeScript compilation pass.
846
+ *
847
+ * The stub re-exports everything from the corresponding `.d.mts` file,
848
+ * ensuring CJS and ESM consumers share the same type declarations. This
849
+ * eliminates the TypeScript "dual module hazard" where separate `.d.cts`
850
+ * and `.d.mts` declarations cause `TS2352` ("neither type sufficiently
851
+ * overlaps") errors when casting between types derived from the same class.
852
+ *
853
+ * Only applies when building both `esm` and `cjs` formats simultaneously.
854
+ *
855
+ * @remarks
856
+ * The generated `.d.cts` stub uses a relative path to re-export from the
857
+ * corresponding `.d.mts` file, so both formats must be emitted to the
858
+ * **same** `outDir`. Splitting CJS and ESM outputs into separate
859
+ * format-specific directories (e.g. `dist/cjs` and `dist/esm`) is not
860
+ * supported with this option, because the re-export path would be invalid.
861
+ *
862
+ * @default false
863
+ */
864
+ cjsReexport?: boolean;
865
+ }
866
+ type Sourcemap = boolean | "inline" | "hidden";
867
+ type Format = ModuleFormat;
868
+ type NormalizedFormat = InternalModuleFormat;
869
+ /**
870
+ * Extended input option that supports glob negation patterns.
871
+ *
872
+ * When using object form, values can be:
873
+ * - A single glob pattern string
874
+ * - An array of glob patterns, including negation patterns (prefixed with `!`)
875
+ *
876
+ * @example
877
+ * ```ts
878
+ * entry: {
879
+ * // Single pattern
880
+ * "utils/*": "./src/utils/*.ts",
881
+ * // Array with negation pattern to exclude files
882
+ * "hooks/*": ["./src/hooks/*.ts", "!./src/hooks/index.ts"],
883
+ * }
884
+ * ```
885
+ */
886
+ type TsdownInputOption = Arrayable<string | Record<string, Arrayable<string>>>;
887
+ interface Workspace {
888
+ /**
889
+ * Workspace directories. Glob patterns are supported.
890
+ * - `auto`: Automatically detect `package.json` files in the workspace.
891
+ * @default 'auto'
892
+ */
893
+ include?: "auto" | (string & {}) | string[];
894
+ /**
895
+ * Exclude directories from workspace.
896
+ * Defaults to all `node_modules`, `dist`, `test`, `tests`, `temp`, and `tmp` directories.
897
+ *
898
+ * @default ['**\/node_modules/**', '**\/dist/**', '**\/test?(s)/**', '**\/t?(e)mp/**']
899
+ */
900
+ exclude?: Arrayable<string>;
901
+ /**
902
+ * Path to the workspace configuration file.
903
+ */
904
+ config?: boolean | string;
905
+ }
906
+ type CIOption = "ci-only" | "local-only";
907
+ type WithEnabled<T> = boolean | undefined | CIOption | (T & {
908
+ /**
909
+ * @default true
910
+ */
911
+ enabled?: boolean | CIOption;
912
+ });
913
+ /**
914
+ * Options for tsdown.
915
+ */
916
+ interface UserConfig {
917
+ /**
918
+ * Defaults to `'src/index.ts'` if it exists.
919
+ *
920
+ * Supports glob patterns with negation to exclude files:
921
+ * @example
922
+ * ```ts
923
+ * entry: {
924
+ * "hooks/*": ["./src/hooks/*.ts", "!./src/hooks/index.ts"],
925
+ * }
926
+ * ```
927
+ *
928
+ * @default { index: 'src/index.ts'}
929
+ */
930
+ entry?: TsdownInputOption;
931
+ /**
932
+ * Dependency handling options.
933
+ */
934
+ deps?: DepsConfig;
935
+ /**
936
+ * @deprecated Use {@linkcode DepsConfig.neverBundle | deps.neverBundle} instead.
937
+ */
938
+ external?: ExternalOption;
939
+ /**
940
+ * @deprecated Use {@linkcode DepsConfig.alwaysBundle | deps.alwaysBundle} instead.
941
+ */
942
+ noExternal?: Arrayable<string | RegExp> | NoExternalFn;
943
+ /**
944
+ * @deprecated Use {@linkcode DepsConfig.onlyBundle | deps.onlyBundle} instead.
945
+ */
946
+ inlineOnly?: Arrayable<string | RegExp> | false;
947
+ /**
948
+ * @deprecated Use {@linkcode DepsConfig.skipNodeModulesBundle | deps.skipNodeModulesBundle} instead.
949
+ * @default false
950
+ */
951
+ skipNodeModulesBundle?: boolean;
952
+ alias?: Record<string, string>;
953
+ /**
954
+ * @default true
955
+ */
956
+ tsconfig?: string | boolean;
957
+ /**
958
+ * Specifies the target runtime platform for the build.
959
+ *
960
+ * - `node`: Node.js and compatible runtimes (e.g., Deno, Bun).
961
+ * For CJS format, this is always set to `node` and cannot be changed.
962
+ * - `neutral`: A platform-agnostic target with no specific runtime assumptions.
963
+ * - `browser`: Web browsers.
964
+ *
965
+ * @default 'node'
966
+ * @see https://tsdown.dev/options/platform
967
+ */
968
+ platform?: "node" | "neutral" | "browser";
969
+ /**
970
+ * Specifies the compilation target environment(s).
971
+ *
972
+ * Determines the JavaScript version or runtime(s) for which the code should be compiled.
973
+ * If not set, defaults to the value of `engines.node` in your project's `package.json`.
974
+ * If no `engines.node` field exists, no syntax transformations are applied.
975
+ *
976
+ * Accepts a single target (e.g., `'es2020'`, `'node18'`, `'baseline-widely-available'`), an array of targets, or `false` to disable all transformations.
977
+ *
978
+ * @see {@link https://tsdown.dev/options/target#supported-targets} for a list of valid targets and more details.
979
+ *
980
+ * @example
981
+ * ```jsonc
982
+ * // Target a single environment
983
+ * { "target": "node18" }
984
+ * ```
985
+ *
986
+ * @example
987
+ * ```jsonc
988
+ * // Target multiple environments
989
+ * { "target": ["node18", "es2020"] }
990
+ * ```
991
+ *
992
+ * @example
993
+ * ```jsonc
994
+ * // Disable all syntax transformations
995
+ * { "target": false }
996
+ * ```
997
+ */
998
+ target?: string | string[] | false;
999
+ /**
1000
+ * Compile-time env variables, which can be accessed via `import.meta.env` or `process.env`.
1001
+ * @example
1002
+ * ```json
1003
+ * {
1004
+ * "DEBUG": true,
1005
+ * "NODE_ENV": "production"
1006
+ * }
1007
+ * ```
1008
+ *
1009
+ * @default {}
1010
+ */
1011
+ env?: Record<string, any>;
1012
+ /**
1013
+ * Path to env file providing compile-time env variables.
1014
+ * @example
1015
+ * `.env`, `.env.production`, etc.
1016
+ */
1017
+ envFile?: string;
1018
+ /**
1019
+ * When loading env variables from `envFile`, only include variables with these prefixes.
1020
+ * @default 'TSDOWN_'
1021
+ */
1022
+ envPrefix?: string | string[];
1023
+ define?: Record<string, string>;
1024
+ /**
1025
+ * @default false
1026
+ */
1027
+ shims?: boolean;
1028
+ /**
1029
+ * Configure tree shaking options.
1030
+ * @see {@link https://rolldown.rs/options/treeshake} for more details.
1031
+ * @default true
1032
+ */
1033
+ treeshake?: boolean | TreeshakingOptions;
1034
+ /**
1035
+ * Sets how input files are processed.
1036
+ * For example, use 'js' to treat files as JavaScript or 'base64' for images.
1037
+ * Lets you import or require files like images or fonts.
1038
+ * @example
1039
+ * ```json
1040
+ * { ".jpg": "asset", ".png": "base64" }
1041
+ * ```
1042
+ */
1043
+ loader?: ModuleTypes;
1044
+ /**
1045
+ * Remove the `node:` prefix from built-in Node.js module imports.
1046
+ * When enabled, rewrites import sources like `node:fs` to `fs`.
1047
+ *
1048
+ * @default false
1049
+ * @deprecated Use {@linkcode nodeProtocol | nodeProtocol: 'strip'} instead.
1050
+ *
1051
+ * @example
1052
+ * <caption>`removeNodeProtocol: true` — remove the `node:` prefix</caption>
1053
+ *
1054
+ * ```ts
1055
+ * // Input
1056
+ * import 'node:fs'
1057
+ *
1058
+ * // Output
1059
+ * import 'fs'
1060
+ * ```
1061
+ */
1062
+ removeNodeProtocol?: boolean;
1063
+ /**
1064
+ * Control whether built-in Node.js module imports use the `node:` protocol.
1065
+ *
1066
+ * - `true`: Add the `node:` prefix to built-in module imports.
1067
+ * - `'strip'`: Remove the `node:` prefix from built-in module imports.
1068
+ * - `false`: Do not transform built-in module imports.
1069
+ *
1070
+ * @default false
1071
+ *
1072
+ * @example
1073
+ * <caption>`nodeProtocol: true` — add the `node:` prefix</caption>
1074
+ *
1075
+ * ```ts
1076
+ * // Input
1077
+ * import 'fs'
1078
+ *
1079
+ * // Output
1080
+ * import 'node:fs'
1081
+ * ```
1082
+ *
1083
+ * @example
1084
+ * <caption>`nodeProtocol: 'strip'` — remove the `node:` prefix</caption>
1085
+ *
1086
+ * ```ts
1087
+ * // Input
1088
+ * import 'node:fs'
1089
+ *
1090
+ * // Output
1091
+ * import 'fs'
1092
+ * ```
1093
+ *
1094
+ * @example
1095
+ * <caption>`nodeProtocol: false` — do not transform imports</caption>
1096
+ *
1097
+ * ```ts
1098
+ * // Input
1099
+ * import 'node:fs'
1100
+ *
1101
+ * // Output
1102
+ * import 'node:fs'
1103
+ * ```
1104
+ */
1105
+ nodeProtocol?: "strip" | boolean;
1106
+ /**
1107
+ * Controls which warnings are emitted during the build process. Each option can be set to `true` (emit warning) or `false` (suppress warning).
1108
+ */
1109
+ checks?: ChecksOptions & {
1110
+ /**
1111
+ * If the config includes the `cjs` format and
1112
+ * one of its target >= node 20.19.0 / 22.12.0,
1113
+ * warn the user about the deprecation of CommonJS.
1114
+ *
1115
+ * @default true
1116
+ */
1117
+ legacyCjs?: boolean;
1118
+ };
1119
+ plugins?: TsdownPluginOption;
1120
+ /**
1121
+ * Use with caution; ensure you understand the implications.
1122
+ */
1123
+ inputOptions?: InputOptions | ((options: InputOptions, format: NormalizedFormat, context: {
1124
+ cjsDts: boolean;
1125
+ }) => Awaitable<InputOptions | void | null>);
1126
+ /**
1127
+ * Output format(s). Available formats are
1128
+ * - `esm`: ESM
1129
+ * - `cjs`: CommonJS
1130
+ * - `iife`: IIFE
1131
+ * - `umd`: UMD
1132
+ *
1133
+ * @default 'esm'
1134
+ */
1135
+ format?: Format | Format[] | Partial<Record<Format, Partial<ResolvedConfig>>>;
1136
+ globalName?: string;
1137
+ /**
1138
+ * @default 'dist'
1139
+ */
1140
+ outDir?: string;
1141
+ /**
1142
+ * Whether to write the files to disk.
1143
+ * This option is incompatible with watch mode.
1144
+ * @default true
1145
+ */
1146
+ write?: boolean;
1147
+ /**
1148
+ * Whether to generate source map files.
1149
+ *
1150
+ * Note that this option will always be `true` if you have
1151
+ * {@link https://www.typescriptlang.org/tsconfig/#declarationMap | `declarationMap`}
1152
+ * option enabled in your `tsconfig.json`.
1153
+ *
1154
+ * @default false
1155
+ */
1156
+ sourcemap?: Sourcemap;
1157
+ /**
1158
+ * Clean directories before build.
1159
+ *
1160
+ * Default to output directory.
1161
+ * @default true
1162
+ */
1163
+ clean?: boolean | string[];
1164
+ /**
1165
+ * @default false
1166
+ */
1167
+ minify?: boolean | "dce-only" | MinifyOptions;
1168
+ footer?: ChunkAddon;
1169
+ banner?: ChunkAddon;
1170
+ /**
1171
+ * Determines whether `unbundle` is enabled.
1172
+ * When set to `true`, the output files will mirror the input file structure.
1173
+ * @default false
1174
+ */
1175
+ unbundle?: boolean;
1176
+ /**
1177
+ * Specifies the root directory of input files, similar to TypeScript's `rootDir`.
1178
+ * This determines the output directory structure.
1179
+ *
1180
+ * By default, the root is computed as the common base directory of all entry files.
1181
+ *
1182
+ * @see https://www.typescriptlang.org/tsconfig/#rootDir
1183
+ */
1184
+ root?: string;
1185
+ /**
1186
+ * @deprecated Use {@linkcode unbundle} instead.
1187
+ * @default true
1188
+ */
1189
+ bundle?: boolean;
1190
+ /**
1191
+ * Use a fixed extension for output files.
1192
+ * The extension will always be `.cjs` or `.mjs`.
1193
+ * Otherwise, it will depend on the package type.
1194
+ *
1195
+ * Defaults to `true` if {@linkcode platform} is set to `node`,
1196
+ * `false` otherwise.
1197
+ *
1198
+ * @default platform === 'node'
1199
+ */
1200
+ fixedExtension?: boolean;
1201
+ /**
1202
+ * Custom extensions for output files.
1203
+ * {@linkcode fixedExtension} will be overridden by this option.
1204
+ */
1205
+ outExtensions?: OutExtensionFactory;
1206
+ /**
1207
+ * @deprecated Use {@linkcode outExtensions} instead.
1208
+ */
1209
+ outExtension?: OutExtensionFactory;
1210
+ /**
1211
+ * If enabled, appends hash to chunk filenames.
1212
+ * @default true
1213
+ */
1214
+ hash?: boolean;
1215
+ /**
1216
+ * @default true
1217
+ */
1218
+ cjsDefault?: boolean;
1219
+ /**
1220
+ * Use with caution; ensure you understand the implications.
1221
+ */
1222
+ outputOptions?: OutputOptions | ((options: OutputOptions, format: NormalizedFormat, context: {
1223
+ cjsDts: boolean;
1224
+ }) => Awaitable<OutputOptions | void | null>);
1225
+ /**
1226
+ * The working directory of the config file.
1227
+ * - Defaults to {@linkcode process.cwd | process.cwd()} for root config.
1228
+ * - Defaults to the package directory for {@linkcode workspace} config.
1229
+ *
1230
+ * @default process.cwd()
1231
+ */
1232
+ cwd?: string;
1233
+ /**
1234
+ * The name to show in CLI output. This is useful for monorepos or workspaces.
1235
+ * When using workspace mode, this option defaults to the package name from package.json.
1236
+ * In non-workspace mode, this option must be set explicitly for the name to show in the CLI output.
1237
+ */
1238
+ name?: string;
1239
+ /**
1240
+ * Log level.
1241
+ * @default 'info'
1242
+ */
1243
+ logLevel?: LogLevel;
1244
+ /**
1245
+ * If true, fails the build on warnings.
1246
+ * @default false
1247
+ */
1248
+ failOnWarn?: boolean | CIOption;
1249
+ /**
1250
+ * Custom logger.
1251
+ */
1252
+ customLogger?: Logger;
1253
+ /**
1254
+ * Reuse config from Vite or Vitest (experimental)
1255
+ * @default false
1256
+ */
1257
+ fromVite?: boolean | "vitest";
1258
+ /**
1259
+ * @default false
1260
+ */
1261
+ watch?: boolean | Arrayable<string>;
1262
+ /**
1263
+ * Files or patterns to not watch while in watch mode.
1264
+ */
1265
+ ignoreWatch?: Arrayable<string | RegExp>;
1266
+ /**
1267
+ * **[experimental]** Enable devtools.
1268
+ *
1269
+ * DevTools is still under development, and this is for early testers only.
1270
+ *
1271
+ * This may slow down the build process significantly.
1272
+ *
1273
+ * @default false
1274
+ */
1275
+ devtools?: WithEnabled<DevtoolsOptions>;
1276
+ /**
1277
+ * You can specify command to be executed after a successful build, specially useful for Watch mode
1278
+ */
1279
+ onSuccess?: string | ((config: ResolvedConfig, signal: AbortSignal) => void | Promise<void>);
1280
+ /**
1281
+ * Enables generation of TypeScript declaration files (`.d.ts`).
1282
+ *
1283
+ * By default, this option is auto-detected based on your project's `package.json`:
1284
+ * - If {@linkcode exe} is enabled, declaration file generation is disabled by default.
1285
+ * - If the `types` field is present, or if the main `exports` contains a `types` entry, declaration file generation is enabled by default.
1286
+ * - Otherwise, declaration file generation is disabled by default.
1287
+ */
1288
+ dts?: WithEnabled<DtsOptions>;
1289
+ /**
1290
+ * Enable unused dependencies check with `unplugin-unused`
1291
+ * Requires `unplugin-unused` to be installed.
1292
+ * @default false
1293
+ */
1294
+ unused?: WithEnabled<UnusedOptions>;
1295
+ /**
1296
+ * Run `publint` after bundling.
1297
+ * Requires `publint` to be installed.
1298
+ * @default false
1299
+ */
1300
+ publint?: WithEnabled<PublintOptions>;
1301
+ /**
1302
+ * Run `arethetypeswrong` after bundling.
1303
+ * Requires `@arethetypeswrong/core` to be installed.
1304
+ *
1305
+ * @default false
1306
+ * @see https://github.com/arethetypeswrong/arethetypeswrong.github.io
1307
+ */
1308
+ attw?: WithEnabled<AttwOptions>;
1309
+ /**
1310
+ * Enable size reporting after bundling.
1311
+ * @default true
1312
+ */
1313
+ report?: WithEnabled<ReportOptions>;
1314
+ /**
1315
+ * `import.meta.glob` support.
1316
+ * @see https://vite.dev/guide/features.html#glob-import
1317
+ * @default true
1318
+ */
1319
+ globImport?: boolean;
1320
+ /**
1321
+ * Generate package exports for `package.json`.
1322
+ *
1323
+ * This will set the `exports` field in `package.json` to point to the
1324
+ * generated files.
1325
+ *
1326
+ * @default false
1327
+ */
1328
+ exports?: WithEnabled<ExportsOptions>;
1329
+ /**
1330
+ * **[experimental]** CSS options.
1331
+ * Requires `@tsdown/css` to be installed.
1332
+ */
1333
+ css?: CssOptions;
1334
+ /**
1335
+ * @deprecated Use {@linkcode CssOptions.inject | css.inject} instead.
1336
+ */
1337
+ injectStyle?: boolean;
1338
+ /**
1339
+ * @alias copy
1340
+ * @deprecated Alias for {@linkcode copy}, will be removed in the future.
1341
+ */
1342
+ publicDir?: CopyOptions | CopyOptionsFn;
1343
+ /**
1344
+ * Copy files to another directory.
1345
+ * @example
1346
+ * ```ts
1347
+ * [
1348
+ * 'src/assets',
1349
+ * 'src/env.d.ts',
1350
+ * 'src/styles/**\/*.css',
1351
+ * { from: 'src/assets', to: 'dist/assets' },
1352
+ * { from: 'src/styles/**\/*.css', to: 'dist', flatten: true },
1353
+ * ]
1354
+ * ```
1355
+ */
1356
+ copy?: CopyOptions | CopyOptionsFn;
1357
+ hooks?: Partial<TsdownHooks> | ((hooks: Hookable<TsdownHooks>) => Awaitable<void>);
1358
+ /**
1359
+ * **[experimental]** Bundle as executable using Node.js SEA (Single Executable Applications).
1360
+ *
1361
+ * This will bundle the output into a single executable file using Node.js SEA.
1362
+ * Note that this is only supported on Node.js 25.7.0 and later, and is not supported in Bun or Deno.
1363
+ *
1364
+ * @default false
1365
+ */
1366
+ exe?: WithEnabled<ExeOptions>;
1367
+ /**
1368
+ * **[experimental]** Enable workspace mode.
1369
+ * This allows you to build multiple packages in a monorepo.
1370
+ */
1371
+ workspace?: Workspace | Arrayable<string> | true;
1372
+ }
1373
+ interface InlineConfig extends UserConfig {
1374
+ /**
1375
+ * Config file path
1376
+ */
1377
+ config?: boolean | string;
1378
+ /**
1379
+ * Config loader to use. It can only be set via CLI or API.
1380
+ * @default 'auto'
1381
+ */
1382
+ configLoader?: "auto" | "native" | "tsx" | "unrun";
1383
+ /**
1384
+ * Filter configs by cwd or name.
1385
+ */
1386
+ filter?: RegExp | Arrayable<string>;
1387
+ }
1388
+ type UserConfigFn = (inlineConfig: InlineConfig, context: {
1389
+ ci: boolean;
1390
+ rootConfig?: UserConfig;
1391
+ }) => Awaitable<Arrayable<UserConfig>>;
1392
+ type UserConfigExport = Awaitable<Arrayable<UserConfig> | UserConfigFn>;
1393
+ type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "fromVite" | "publicDir" | "bundle" | "injectStyle" | "removeNodeProtocol" | "outExtension" | "external" | "noExternal" | "inlineOnly" | "skipNodeModulesBundle" | "logLevel" | "failOnWarn" | "customLogger" | "envFile" | "envPrefix">, "globalName" | "inputOptions" | "outputOptions" | "minify" | "define" | "alias" | "onSuccess" | "outExtensions" | "hooks" | "copy" | "loader" | "name" | "banner" | "footer" | "checks" | "css">, {
1394
+ /**
1395
+ * Resolved entry map (after glob expansion)
1396
+ */
1397
+ entry: Record<string, string>;
1398
+ /**
1399
+ * Original entry config before glob resolution (for watch mode re-globbing)
1400
+ */
1401
+ rawEntry?: TsdownInputOption;
1402
+ nameLabel: string | undefined;
1403
+ format: NormalizedFormat;
1404
+ target?: string[];
1405
+ clean: string[];
1406
+ pkg?: PackageJsonWithPath;
1407
+ nodeProtocol: "strip" | boolean;
1408
+ logger: Logger;
1409
+ ignoreWatch: Array<string | RegExp>;
1410
+ deps: ResolvedDepsConfig;
1411
+ /**
1412
+ * Resolved root directory of input files
1413
+ */
1414
+ root: string;
1415
+ configDeps: Set<string>;
1416
+ dts: false | DtsOptions;
1417
+ report: false | ReportOptions;
1418
+ tsconfig: false | string;
1419
+ exports: false | ExportsOptions;
1420
+ devtools: false | DevtoolsOptions;
1421
+ publint: false | PublintOptions;
1422
+ attw: false | AttwOptions;
1423
+ unused: false | UnusedOptions;
1424
+ exe: false | ExeOptions;
1425
+ }>;
1426
+ //#endregion
1427
+ export { PackageType as A, ResolvedDepsConfig as B, ChunkAddon as C, OutExtensionFactory as D, OutExtensionContext as E, SeaConfig as F, CopyOptionsFn as G, TsdownBundle as H, DevtoolsOptions as I, DepsConfig as L, RolldownContext as M, TsdownHooks as N, OutExtensionObject as O, ExeOptions as P, DepsPlugin as R, AttwOptions as S, ChunkAddonObject as T, CopyEntry as U, RolldownChunk as V, CopyOptions as W, ReportPlugin as _, NormalizedFormat as a, PublintOptions as b, TreeshakingOptions as c, UserConfig as d, UserConfigExport as f, ReportOptions as g, Workspace as h, InlineConfig as i, BuildContext as j, PackageJsonWithPath as k, TsdownInputOption as l, WithEnabled as m, DtsOptions as n, ResolvedConfig as o, UserConfigFn as p, Format as r, Sourcemap as s, CIOption as t, UnusedOptions as u, TsdownPlugin as v, ChunkAddonFunction as w, ExportsOptions as x, TsdownPluginOption as y, NoExternalFn as z };