@rzl-zone/build-tools 0.0.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.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/dist/.references/index.d.cts +18 -0
  3. package/dist/.references/index.d.ts +18 -0
  4. package/dist/bundler/rolldown.cjs +32 -0
  5. package/dist/bundler/rolldown.cjs.map +1 -0
  6. package/dist/bundler/rolldown.d.cts +162 -0
  7. package/dist/bundler/rolldown.d.ts +162 -0
  8. package/dist/bundler/rolldown.js +25 -0
  9. package/dist/bundler/rolldown.js.map +1 -0
  10. package/dist/bundler/tsdown.cjs +132 -0
  11. package/dist/bundler/tsdown.cjs.map +1 -0
  12. package/dist/bundler/tsdown.d.cts +1165 -0
  13. package/dist/bundler/tsdown.d.ts +1165 -0
  14. package/dist/bundler/tsdown.js +124 -0
  15. package/dist/bundler/tsdown.js.map +1 -0
  16. package/dist/bundler/utils.cjs +24 -0
  17. package/dist/bundler/utils.cjs.map +1 -0
  18. package/dist/bundler/utils.d.cts +40 -0
  19. package/dist/bundler/utils.d.ts +40 -0
  20. package/dist/bundler/utils.js +21 -0
  21. package/dist/bundler/utils.js.map +1 -0
  22. package/dist/client-XhkdKJ4d.js +160 -0
  23. package/dist/client-XhkdKJ4d.js.map +1 -0
  24. package/dist/client-u8yLSxEI.cjs +221 -0
  25. package/dist/client-u8yLSxEI.cjs.map +1 -0
  26. package/dist/commander-kit/index.cjs +569 -0
  27. package/dist/commander-kit/index.cjs.map +1 -0
  28. package/dist/commander-kit/index.d.cts +1383 -0
  29. package/dist/commander-kit/index.d.ts +1383 -0
  30. package/dist/commander-kit/index.js +550 -0
  31. package/dist/commander-kit/index.js.map +1 -0
  32. package/dist/extra-CVuXMpEw.d.ts +994 -0
  33. package/dist/extra-CxDwtQEy.d.cts +994 -0
  34. package/dist/fast-globe-options-6r2aj6UC.d.ts +126 -0
  35. package/dist/fast-globe-options-BFt__e__.d.cts +126 -0
  36. package/dist/helper-BdjaR8Yv.js +215 -0
  37. package/dist/helper-BdjaR8Yv.js.map +1 -0
  38. package/dist/helper-DorgNsB9.cjs +377 -0
  39. package/dist/helper-DorgNsB9.cjs.map +1 -0
  40. package/dist/identity-BJ0QX7AJ.js +88 -0
  41. package/dist/identity-BJ0QX7AJ.js.map +1 -0
  42. package/dist/identity-CxR9DRMh.cjs +100 -0
  43. package/dist/identity-CxR9DRMh.cjs.map +1 -0
  44. package/dist/index-B-NeF7PU.d.cts +670 -0
  45. package/dist/index-CzxZta4Z.d.ts +356 -0
  46. package/dist/index-Idak1iwg.d.cts +356 -0
  47. package/dist/index-PXsb85LI.d.ts +670 -0
  48. package/dist/index.cjs +1689 -0
  49. package/dist/index.cjs.map +1 -0
  50. package/dist/index.d.cts +2193 -0
  51. package/dist/index.d.ts +2193 -0
  52. package/dist/index.js +1641 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/package-banner-6RzEf-mV.cjs +54 -0
  55. package/dist/package-banner-6RzEf-mV.cjs.map +1 -0
  56. package/dist/package-banner-BzheZbxy.js +41 -0
  57. package/dist/package-banner-BzheZbxy.js.map +1 -0
  58. package/dist/server-B2hBoGDR.cjs +181 -0
  59. package/dist/server-B2hBoGDR.cjs.map +1 -0
  60. package/dist/server-CWrDd29Y.js +142 -0
  61. package/dist/server-CWrDd29Y.js.map +1 -0
  62. package/dist/utils/client.cjs +23 -0
  63. package/dist/utils/client.d.cts +887 -0
  64. package/dist/utils/client.d.ts +887 -0
  65. package/dist/utils/client.js +12 -0
  66. package/dist/utils/server.cjs +17 -0
  67. package/dist/utils/server.d.cts +124 -0
  68. package/dist/utils/server.d.ts +124 -0
  69. package/dist/utils/server.js +12 -0
  70. package/package.json +151 -0
@@ -0,0 +1,1165 @@
1
+ /*!
2
+ * ========================================================================
3
+ * @rzl-zone/build-tools
4
+ * ------------------------------------------------------------------------
5
+ * Version: `0.0.5`
6
+ * Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`
7
+ * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`
8
+ * ========================================================================
9
+ */
10
+
11
+ import { l as StrictAwaitable, n as Arrayable, o as OverrideTypes, s as Prettify } from "../extra-CVuXMpEw.js";
12
+ import * as _tsDown from "tsdown";
13
+ import { DepsConfig as DepsConfig$1, InlineConfig as InlineConfig$1, UserConfig as UserConfig$1 } from "tsdown";
14
+
15
+ type InlineConfig = InlineConfig$1;
16
+ /** ----------------------------------------------------------------
17
+ * * ***Override the default user config.***
18
+ * ----------------------------------------------------------------
19
+ *
20
+ * Represents the user-facing configuration that can override
21
+ * the library's internal defaults.
22
+ *
23
+ * All fields are optional and will be merged with the base defaults.
24
+ *
25
+ * ----------------------------------------------------------------
26
+ * ⚠️ ***Peer dependency required.***
27
+ *
28
+ * {@link https://github.com/rolldown/tsdown | `tsdown`} is declared as a
29
+ * **peer dependency** of this package.
30
+ *
31
+ * You **MUST install it explicitly** in your project for this type
32
+ * to be resolved correctly.
33
+ *
34
+ * ❌ **If `tsdown` is not installed**, TypeScript will fail to resolve
35
+ * the underlying types (e.g.
36
+ * `Cannot find module "tsdown" or its corresponding type declarations`),
37
+ * and the related types may degrade to `any`.
38
+ *
39
+ * @see {@link https://tsdown.dev/guide/getting-started#installation | **`tsdown installation guide`**}.
40
+ *
41
+ * ----------------------------------------------------------------
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * import { type UserConfig } from "@rzl-zone/build-tools/bundler/tsdown";
46
+ *
47
+ * const config: UserConfig = {
48
+ * dts: false,
49
+ * minify: "esbuild",
50
+ * format: ["esm"]
51
+ * };
52
+ * ```
53
+ */
54
+ type UserConfig = Omit<UserConfig$1, "dts" | "clean" | "minify" | "sourcemap" | "format" | "fixedExtension" | "banner" | "deps"> & UserConfigDefault;
55
+ /** ----------------------------------------------------------------
56
+ * * ***Base user config without overridden defaults.***
57
+ * ----------------------------------------------------------------
58
+ *
59
+ * A strict version of {@link UserConfig | **`UserConfig`**} with internal default-controlled
60
+ * options omitted.
61
+ *
62
+ * - ***These fields are intentionally managed by the default config layer:***
63
+ * - `dts`.
64
+ * - `minify`.
65
+ * - `clean`.
66
+ * - `inlineOnly`.
67
+ * - `sourcemap`.
68
+ * - `format`.
69
+ * - `fixedExtension`.
70
+ * - `banner`.
71
+ *
72
+ * ----------------------------------------------------------------
73
+ * ⚠️ ***Peer dependency required.***
74
+ *
75
+ * {@link https://github.com/rolldown/tsdown | `tsdown`} is declared as a
76
+ * **peer dependency** of this package.
77
+ *
78
+ * You **MUST install it explicitly** in your project for this type
79
+ * to be resolved correctly.
80
+ *
81
+ * ❌ **If `tsdown` is not installed**, TypeScript will fail to resolve
82
+ * the underlying types (e.g.
83
+ * `Cannot find module "tsdown" or its corresponding type declarations`),
84
+ * and the related types may degrade to `any`.
85
+ *
86
+ * @see {@link https://tsdown.dev/guide/getting-started#installation | **`tsdown installation guide`**.}
87
+ */
88
+ type InternalUserConfigBase = Omit<UserConfig, "dts" | "minify" | "clean" | "deps" | "sourcemap" | "format" | "fixedExtension" | "banner">;
89
+ /** Deps option from `UserConfig.deps` */
90
+ type DepsConfig = Omit<DepsConfig$1, "onlyAllowBundle" | "onlyBundle"> & {
91
+ /** Whitelist of dependencies allowed to be bundled from `node_modules`.
92
+ * Throws an error if any unlisted dependency is bundled.
93
+ *
94
+ * - `undefined`: Show warnings for bundled dependencies.
95
+ * - `false` **(default)**: Suppress all warnings about bundled dependencies.
96
+ *
97
+ * Note: Be sure to include all required sub-dependencies as well.
98
+ *
99
+ * - **⚠️ Warning:**
100
+ * - Only effective in tsdown v0.21.1 or bellow.
101
+ * - Versions v0.21.1+ use {@link DepsConfig.onlyBundle | `onlyBundle`} instead, because these options is deprecated.
102
+ *
103
+ * @see {@link https://github.com/rolldown/tsdown/releases/tag/v0.21.2}
104
+ */
105
+ onlyAllowBundle?: Arrayable<string | RegExp> | false;
106
+ /** Whitelist of dependencies allowed to be bundled from `node_modules`.
107
+ * Throws an error if any unlisted dependency is bundled.
108
+ *
109
+ * - `undefined`: Show warnings for bundled dependencies.
110
+ * - `false` **(default)**: Suppress all warnings about bundled dependencies.
111
+ *
112
+ * Note: Be sure to include all required sub-dependencies as well.
113
+ *
114
+ * - **⚠️ Warning:**
115
+ * - Only effective in tsdown v0.21.2 or later.
116
+ * - Versions below v0.21.2 use {@link DepsConfig.onlyAllowBundle | `onlyAllowBundle`}, because will ignore these options.
117
+ *
118
+ * @see {@link https://github.com/rolldown/tsdown/releases/tag/v0.21.2}
119
+ */
120
+ onlyBundle?: Arrayable<string | RegExp> | false;
121
+ };
122
+ type UserConfigDefault = {
123
+ /** Enables generation of TypeScript declaration files (`.d.ts`).
124
+ *
125
+ * By default, this option is true, also auto-detected based on your project's `package.json`:
126
+ * - If the `types` field is present, or if the main `exports` contains a `types` entry, declaration file generation is enabled by default.
127
+ * - Otherwise, declaration file generation is disabled by default.
128
+ *
129
+ * @default true
130
+ */
131
+ dts?: UserConfig$1["dts"];
132
+ /** Clean directories before build.
133
+ *
134
+ * Default to output directory.
135
+ * @default ["dist/*"]
136
+ */
137
+ clean?: UserConfig$1["clean"];
138
+ /** Minification strategy.
139
+ *
140
+ * @default false
141
+ */
142
+ minify?: UserConfig$1["minify"];
143
+ /** Bundle only the dependencies listed here; throw an error if any others are missing.
144
+ *
145
+ * - `undefined`: Show warnings for bundled dependencies.
146
+ * - `false` **(default)**: Suppress all warnings about `inlineOnly` option.
147
+ *
148
+ * Note: Be sure to include all required sub-dependencies as well.
149
+ *
150
+ * ----------------------------------------------------------------
151
+ * ⚠️ Version Compatibility
152
+ *
153
+ * - Only effective in **tsdown below v0.21.0**.
154
+ * - Versions **v0.21.0** **`>=`** **v0.21.01**:
155
+ * - Use {@link DepsConfig.onlyAllowBundle | **`deps.onlyAllowBundle`**}.
156
+ * - ***Example:***
157
+ * ```json
158
+ * {
159
+ * deps: {
160
+ * onlyAllowBundle: true
161
+ * }
162
+ * }
163
+ * ```
164
+ * - Versions **v0.21.2** or higher use
165
+ * - Use {@link DepsConfig.onlyBundle | **`deps.onlyBundle`**}
166
+ * as the transitional option.
167
+ * - ***Example:***
168
+ * ```json
169
+ * {
170
+ * deps: {
171
+ * onlyBundle: true
172
+ * }
173
+ * }
174
+ * ```
175
+ *
176
+ * ----------------------------------------------------------------
177
+ * @see {@link https://github.com/rolldown/tsdown/releases/tag/v0.21.0}
178
+ * @see {@link https://github.com/rolldown/tsdown/releases/tag/v0.21.2}
179
+ */
180
+ inlineOnly?: UserConfig$1["inlineOnly"];
181
+ /** Whether to generate source map files.
182
+ *
183
+ * Note that this option will always be `true` if you have
184
+ * [`declarationMap`](https://www.typescriptlang.org/tsconfig/#declarationMap)
185
+ * option enabled in your `tsconfig.json`.
186
+ *
187
+ * @default true
188
+ */
189
+ sourcemap?: UserConfig$1["sourcemap"];
190
+ /** Output formats to generate.
191
+ *
192
+ * - Available formats are:
193
+ * - `esm`: ESM.
194
+ * - `cjs`: CommonJS.
195
+ * - `iife`: IIFE.
196
+ * - `umd`: UMD.
197
+ * @default ["cjs", "esm"]
198
+ */
199
+ format?: UserConfig$1["format"];
200
+ /** Use a fixed extension for output files.
201
+ * - If `true`, the extension will always be `.cjs` or `.mjs`.
202
+ * - Otherwise, it will depend on the package type.
203
+ *
204
+ * @default false
205
+ */
206
+ fixedExtension?: UserConfig$1["fixedExtension"];
207
+ /** Custom banner string injected into output files.
208
+ *
209
+ * Defaults to the value generated by **`generatePackageBanner`**.
210
+ *
211
+ * Set to `false` if you want to disable automatic banner injection.
212
+ */
213
+ banner?: UserConfig$1["banner"] | false;
214
+ /** Dependency handling options.
215
+ *
216
+ * - **⚠️ Warning:**
217
+ * - Only effective in tsdown **v0.21.0** or later.
218
+ * - Versions below **v0.21.0** will ignore these options.
219
+ */
220
+ deps?: DepsConfig;
221
+ };
222
+ type UserConfigInternal = InternalUserConfigBase & UserConfigDefault;
223
+ type UserConfigOptionsResult = Prettify<OverrideTypes<UserConfigInternal, {
224
+ banner?: UserConfig["banner"];
225
+ }>>;
226
+ /** ----------------------------------------------------------------
227
+ * * ***Default config input variants.***
228
+ * ----------------------------------------------------------------
229
+ *
230
+ * - ***Supported forms:***
231
+ * - Single config object.
232
+ * - Array of config objects.
233
+ * - Async config resolver function.
234
+ * - Promise resolving to any of the above.
235
+ *
236
+ * ----------------------------------------------------------------
237
+ * ⚠️ ***Peer dependency required.***
238
+ *
239
+ * {@link https://github.com/rolldown/tsdown | `tsdown`} is declared as a
240
+ * **peer dependency** of this package.
241
+ *
242
+ * You **MUST install it explicitly** in your project for this type
243
+ * to be resolved correctly.
244
+ *
245
+ * ❌ **If `tsdown` is not installed**, TypeScript will fail to resolve
246
+ * the underlying types (e.g.
247
+ * `Cannot find module "tsdown" or its corresponding type declarations`),
248
+ * and the related types may degrade to `any`.
249
+ *
250
+ * @see {@link https://tsdown.dev/guide/getting-started#installation | **`tsdown installation guide`**}.
251
+ *
252
+ * ----------------------------------------------------------------
253
+ *
254
+ * @example
255
+ * ```ts
256
+ * resolveDefaultConfig({
257
+ * dts: false,
258
+ * format: ["esm"]
259
+ * });
260
+ *
261
+ *
262
+ * resolveDefaultConfig([
263
+ * { format: ["cjs"] },
264
+ * { format: ["esm"] }
265
+ * ]);
266
+ *
267
+ * resolveDefaultConfig(async () => ({
268
+ * sourcemap: false
269
+ * }));
270
+ *
271
+ * resolveDefaultConfig((_, ctx) => [
272
+ * { format: ["esm"] },
273
+ * ctx.ci ? { minify: true } : { sourcemap: true }
274
+ * ]);
275
+ * ```
276
+ */
277
+ type ConfigOptions = StrictAwaitable<UserConfigFn | Arrayable<UserConfig>>;
278
+ /** ----------------------------------------------------------------
279
+ * * ***User config override function.***
280
+ * ----------------------------------------------------------------
281
+ *
282
+ * Allows dynamic configuration based on build context.
283
+ *
284
+ * ----------------------------------------------------------------
285
+ * ⚠️ ***Peer dependency required.***
286
+ *
287
+ * {@link https://github.com/rolldown/tsdown | `tsdown`} is declared as a
288
+ * **peer dependency** of this package.
289
+ *
290
+ * You **MUST install it explicitly** in your project for this type
291
+ * to be resolved correctly.
292
+ *
293
+ * ❌ **If `tsdown` is not installed**, TypeScript will fail to resolve
294
+ * the underlying types (e.g.
295
+ * `Cannot find module "tsdown" or its corresponding type declarations`),
296
+ * and the related types may degrade to `any`.
297
+ *
298
+ * @see {@link https://tsdown.dev/guide/getting-started#installation | **`tsdown installation guide`**}.
299
+ *
300
+ * ----------------------------------------------------------------
301
+ * @example
302
+ * ```ts
303
+ * import { type UserConfigFn } from "@rzl-zone/build-tools/bundler/tsdown";
304
+ *
305
+ * const overrideConfig: UserConfigFn = (inline, ctx) => {
306
+ * if (ctx.ci) {
307
+ * return {
308
+ * sourcemap: false,
309
+ * minify: true
310
+ * };
311
+ * }
312
+ *
313
+ * return {
314
+ * sourcemap: true
315
+ * };
316
+ * };
317
+ * ```
318
+ */
319
+ type UserConfigFn = (inlineConfig: InlineConfig, context: {
320
+ ci: boolean;
321
+ }) => StrictAwaitable<Arrayable<UserConfig>>;
322
+ /** ----------------------------------------------------------------
323
+ * * ***Config export variants.***
324
+ * ----------------------------------------------------------------
325
+ *
326
+ * Represents all supported **exported configuration forms**
327
+ * that a user can provide to the config resolver.
328
+ *
329
+ * This type mirrors the typical patterns used in modern
330
+ * build tools and bundlers where configuration can be:
331
+ *
332
+ * - A **static config object**
333
+ * - An **array of config objects**
334
+ * - A **config resolver function**
335
+ * - A **Promise resolving to either of the above**
336
+ *
337
+ * ----------------------------------------------------------------
338
+ * ⚠️ ***Peer dependency required.***
339
+ *
340
+ * {@link https://github.com/rolldown/tsdown | `tsdown`} is declared as a
341
+ * **peer dependency** of this package.
342
+ *
343
+ * You **MUST install it explicitly** in your project for this type
344
+ * to be resolved correctly.
345
+ *
346
+ * ❌ **If `tsdown` is not installed**, TypeScript will fail to resolve
347
+ * the underlying types (e.g.
348
+ * `Cannot find module "tsdown" or its corresponding type declarations`),
349
+ * and the related types may degrade to `any`.
350
+ *
351
+ * @see {@link https://tsdown.dev/guide/getting-started#installation | **`tsdown installation guide`**}.
352
+ *
353
+ * ----------------------------------------------------------------
354
+ *
355
+ * @example
356
+ * ```ts
357
+ * // Static config
358
+ * const config: UserConfigExport = {
359
+ * format: ["esm"]
360
+ * };
361
+ *
362
+ * // Multiple configs
363
+ * const config: UserConfigExport = [
364
+ * { format: ["esm"] },
365
+ * { format: ["cjs"] }
366
+ * ];
367
+ *
368
+ * // Dynamic config
369
+ * const config: UserConfigExport = (_, ctx) => ({
370
+ * sourcemap: !ctx.ci
371
+ * });
372
+ *
373
+ * // Async config
374
+ * const config: UserConfigExport = Promise.resolve({
375
+ * minify: true
376
+ * });
377
+ * ```
378
+ */
379
+ type UserConfigExport = UserConfigFn | Arrayable<UserConfig> | Promise<UserConfigFn | Arrayable<UserConfig>>;
380
+ /** ----------------------------------------------------------------
381
+ * * ***Base default configuration.***
382
+ * ----------------------------------------------------------------
383
+ *
384
+ * Used as the foundation for all resolved configurations.
385
+ *
386
+ */
387
+ declare const BASE_DEFAULT_CONFIG: {
388
+ readonly dts: true;
389
+ readonly minify: false;
390
+ readonly clean: readonly ["dist/*"];
391
+ readonly sourcemap: true;
392
+ readonly format: readonly ["cjs", "esm"];
393
+ readonly banner: undefined;
394
+ readonly fixedExtension: false;
395
+ };
396
+ /** ----------------------------------------------------------------
397
+ * * ***Resolve default configuration.***
398
+ * ----------------------------------------------------------------
399
+ *
400
+ * Normalizes all supported config input shapes into a resolved config.
401
+ *
402
+ * This function is designed to act as a **config composition layer**
403
+ * on top of bundler configuration tools such as
404
+ * {@link https://github.com/rolldown/tsdown | **`tsdown`**}.
405
+ *
406
+ * - *Behavior:*
407
+ * - Merges user configuration with `INTERNAL_DEFAULT_CONFIG`.
408
+ * - Automatically injects a banner generated by `generatePackageBanner`.
409
+ * - Set `options.banner` to `false` to disable automatic banner injection.
410
+ *
411
+ * - *Supported input forms:*
412
+ * - Plain config object.
413
+ * - Array of config objects.
414
+ * - Resolver function returning a config or config array.
415
+ * - Promise resolving to any of the above.
416
+ *
417
+ * ----------------------------------------------------------------
418
+ * ⚠️ ***Peer dependency required.***
419
+ *
420
+ * {@link https://github.com/rolldown/tsdown | **`tsdown`**} is declared as a
421
+ * **peer dependency** of this package.
422
+ *
423
+ * You **MUST install it explicitly** in your project for this export
424
+ * to resolve correctly.
425
+ *
426
+ * ❌ **If {@link https://github.com/rolldown/tsdown | **`tsdown`**} is not installed**, importing this module will
427
+ * result in a **runtime module resolution error** (e.g. `Cannot find module "tsdown"`).
428
+ *
429
+ * @see {@link https://tsdown.dev/guide/getting-started#installation | **`tsdown installation guide`**.}
430
+ *
431
+ * ----------------------------------------------------------------
432
+ * ⚠️ ***Node.js only.***
433
+ *
434
+ * **DO NOT import this module in browser or client-side code.**
435
+ *
436
+ * - {@link https://github.com/rolldown/tsdown | **`tsdown`**} relies on Node.js–specific features such as:
437
+ * - filesystem access.
438
+ * - process environment variables.
439
+ * - native module resolution.
440
+ * ----------------------------------------------------------------
441
+ *
442
+ * @param options
443
+ * User-provided configuration or resolver.
444
+ *
445
+ * - **May be:**
446
+ * - A config object.
447
+ * - An array of config objects.
448
+ * - A resolver function returning a config or config array.
449
+ * - A Promise resolving to any of the above.
450
+ *
451
+ * ----------------------------------------------------------------
452
+ *
453
+ * @returns
454
+ * A resolved configuration object or an array of configs,
455
+ * depending on the original input shape.
456
+ *
457
+ * ----------------------------------------------------------------
458
+ *
459
+ * @example
460
+ * **Basic usage**
461
+ *
462
+ * ```ts
463
+ * import { resolveDefaultConfig } from "@rzl-zone/build-tools/bundler/tsdown";
464
+ *
465
+ * const config = await resolveDefaultConfig({
466
+ * entry: "src/index.ts",
467
+ * dts: false
468
+ * });
469
+ *
470
+ * // ➔ returns an array of configs
471
+ * // ➔ each item is merged with BASE_DEFAULT_CONFIG
472
+ * ```
473
+ * @see {@link BASE_DEFAULT_CONFIG | **`BASE_DEFAULT_CONFIG`**}.
474
+ *
475
+ * ----------------------------------------------------------------
476
+ *
477
+ * @example
478
+ * **Direct usage in `tsdown.config.ts`**
479
+ *
480
+ * `resolveDefaultConfig` can be exported directly as the config.
481
+ *
482
+ * ```ts
483
+ * import { resolveDefaultConfig } from "@rzl-zone/build-tools/bundler/tsdown";
484
+ *
485
+ * export default resolveDefaultConfig({
486
+ * entry: ["src/index.ts"]
487
+ * });
488
+ * ```
489
+ *
490
+ * This works because `tsdown` accepts **awaitable config values**
491
+ * (objects, arrays, promises, or resolver functions).
492
+ *
493
+ * ----------------------------------------------------------------
494
+ *
495
+ * @example
496
+ * ❌ **Invalid (nested resolver — will throw in tsdown)**
497
+ *
498
+ * ```ts
499
+ * export default defineConfig(async () =>
500
+ * resolveDefaultConfig(async (_, ctx) => ({
501
+ * entry: ["src/index.ts"],
502
+ * sourcemap: !ctx.ci
503
+ * }))
504
+ * );
505
+ * ```
506
+ *
507
+ * ✅ **Valid**
508
+ *
509
+ * ```ts
510
+ * export default defineConfig(
511
+ * resolveDefaultConfig(async (_, ctx) => ({
512
+ * entry: ["src/index.ts"],
513
+ * sourcemap: !ctx.ci
514
+ * }))
515
+ * );
516
+ * ```
517
+ *
518
+ * Resolver functions must be passed **directly** to `defineConfig`.
519
+ *
520
+ * ----------------------------------------------------------------
521
+ *
522
+ * @example
523
+ * **Promise-based configuration**
524
+ *
525
+ * ```ts
526
+ * import { resolveDefaultConfig } from "@rzl-zone/build-tools/bundler/tsdown";
527
+ *
528
+ * const config = await resolveDefaultConfig(
529
+ * Promise.resolve({
530
+ * entry: ["src/index.ts"],
531
+ * sourcemap: false
532
+ * })
533
+ * );
534
+ * ```
535
+ *
536
+ * ----------------------------------------------------------------
537
+ *
538
+ * @example
539
+ * **Conditional configuration (CI-aware)**
540
+ *
541
+ * ```ts
542
+ * import { resolveDefaultConfig } from "@rzl-zone/build-tools/bundler/tsdown";
543
+ *
544
+ * const config = await resolveDefaultConfig((_, ctx) => {
545
+ * return ctx.ci
546
+ * ? { entry: ["src/index.ts"], sourcemap: false, minify: true }
547
+ * : { entry: ["src/index.ts"], sourcemap: true };
548
+ * });
549
+ * ```
550
+ *
551
+ * ----------------------------------------------------------------
552
+ *
553
+ * @example
554
+ * **Conditional resolver returning multiple configs**
555
+ *
556
+ * ```ts
557
+ * import { resolveDefaultConfig } from "@rzl-zone/build-tools/bundler/tsdown";
558
+ *
559
+ * const configs = await resolveDefaultConfig((_, ctx) => [
560
+ * { format: ["esm"] },
561
+ * ctx.ci
562
+ * ? { minify: true }
563
+ * : { sourcemap: true }
564
+ * ]);
565
+ *
566
+ * // ➜ returns an array of configs
567
+ * // ➜ each item is merged with BASE_DEFAULT_CONFIG
568
+ * ```
569
+ *
570
+ * @see {@link BASE_DEFAULT_CONFIG | **`BASE_DEFAULT_CONFIG`**}.
571
+ *
572
+ * ----------------------------------------------------------------
573
+ *
574
+ * @example
575
+ * **Multiple entry configurations**
576
+ *
577
+ * ```ts
578
+ * import { resolveDefaultConfig } from "@rzl-zone/build-tools/bundler/tsdown";
579
+ *
580
+ * const configs = await resolveDefaultConfig([
581
+ * {
582
+ * entry: ["src/index.ts"]
583
+ * },
584
+ * {
585
+ * entry: ["src/cli/*"],
586
+ * outDir: "dist/cli",
587
+ * format: ["cjs"],
588
+ * dts: false
589
+ * }
590
+ * ]);
591
+ * ```
592
+ *
593
+ * ----------------------------------------------------------------
594
+ *
595
+ * @example
596
+ * **Usage with `defineConfig` from `tsdown`**
597
+ *
598
+ * ```ts
599
+ * import { defineConfig } from "tsdown";
600
+ * import { resolveDefaultConfig } from "@rzl-zone/build-tools/bundler/tsdown";
601
+ *
602
+ * export default defineConfig(
603
+ * resolveDefaultConfig([
604
+ * { entry: ["src/index.ts"] },
605
+ * {
606
+ * entry: ["src/cli/*"],
607
+ * outDir: "dist/cli",
608
+ * format: ["cjs"],
609
+ * dts: false
610
+ * }
611
+ * ])
612
+ * );
613
+ * ```
614
+ *
615
+ * ----------------------------------------------------------------
616
+ *
617
+ * @example
618
+ * **Usage with the bundled `tsdown` facade**
619
+ *
620
+ * ```ts
621
+ * import {
622
+ * tsdown,
623
+ * resolveDefaultConfig
624
+ * } from "@rzl-zone/build-tools/bundler/tsdown";
625
+ *
626
+ * export default tsdown.defineConfig(
627
+ * resolveDefaultConfig({
628
+ * entry: ["src/index.ts"]
629
+ * })
630
+ * );
631
+ * ```
632
+ *
633
+ * ----------------------------------------------------------------
634
+ *
635
+ * @environment `node`
636
+ *
637
+ * @remarks
638
+ *
639
+ * - This function intentionally **preserves the input shape**
640
+ * (single object or array) to allow flexible composition.
641
+ *
642
+ * - The resolver performs a **shallow merge only**, nested objects are not deeply merged.
643
+ */
644
+ declare function resolveDefaultConfig(options: UserConfigFn): Promise<UserConfigFn>;
645
+ declare function resolveDefaultConfig(options: UserConfig[]): Promise<UserConfig>;
646
+ declare function resolveDefaultConfig(options: UserConfig): Promise<UserConfig[]>;
647
+ declare function resolveDefaultConfig(options: UserConfigExport): Promise<UserConfigExport>;
648
+ /** ----------------------------------------------------------------
649
+ * * ***Create default config.***
650
+ * ----------------------------------------------------------------
651
+ *
652
+ * Shorthand helper for merging user overrides with the internal
653
+ * base default configuration.
654
+ *
655
+ * This helper mirrors the typical **`resolveDefaultConfig()`**
656
+ * pattern commonly used in bundler `defineConfig()` factories.
657
+ *
658
+ * Unlike {@link resolveDefaultConfig | `resolveDefaultConfig`}, this helper is intended for
659
+ * **static configuration objects only**.
660
+ *
661
+ * ----------------------------------------------------------------
662
+ *
663
+ * @description
664
+ * - Designed for **simple configuration factories**.
665
+ * - Accepts a single config object and merges it with
666
+ * `INTERNAL_DEFAULT_CONFIG`.
667
+ * - Does **not support resolver functions** or contextual
668
+ * configuration.
669
+ *
670
+ * If you need dynamic configuration based on environment or CI
671
+ * context, use {@link resolveDefaultConfig | `resolveDefaultConfig`} instead.
672
+ *
673
+ * ----------------------------------------------------------------
674
+ * ⚠️ ***Peer dependency required.***
675
+ *
676
+ * {@link https://github.com/rolldown/tsdown | **`tsdown`**} is declared as a
677
+ * **peer dependency** of this package.
678
+ *
679
+ * You **MUST install it explicitly** in your project for this export
680
+ * to resolve correctly.
681
+ *
682
+ * ❌ **If {@link https://github.com/rolldown/tsdown | **`tsdown`**} is not installed**, importing this module will
683
+ * result in a **runtime module resolution error** (e.g. `Cannot find module "tsdown"`).
684
+ *
685
+ * @see {@link https://tsdown.dev/guide/getting-started#installation | **`tsdown installation guide`**.}
686
+ *
687
+ * ----------------------------------------------------------------
688
+ * ⚠️ ***Node.js only.***
689
+ *
690
+ * **DO NOT import this module in browser or client-side code.**
691
+ *
692
+ * - {@link https://github.com/rolldown/tsdown | **`tsdown`**} relies on Node.js–specific features such as:
693
+ * - filesystem access.
694
+ * - process environment variables.
695
+ * - native module resolution.
696
+ * ----------------------------------------------------------------
697
+ *
698
+ * @param options
699
+ * User config overrides.
700
+ *
701
+ * ----------------------------------------------------------------
702
+ *
703
+ * @returns
704
+ * A configuration object merged with `INTERNAL_DEFAULT_CONFIG`.
705
+ *
706
+ * ----------------------------------------------------------------
707
+ *
708
+ * @example
709
+ * **Basic usage**
710
+ *
711
+ * ```ts
712
+ * import { createDefaultConfig } from "@rzl-zone/build-tools/bundler/tsdown";
713
+ *
714
+ * const config = await createDefaultConfig({
715
+ * entry: ["src/index.ts"],
716
+ * format: ["esm"]
717
+ * });
718
+ * ```
719
+ *
720
+ * ----------------------------------------------------------------
721
+ *
722
+ * @example
723
+ * **Usage with `defineConfig` (direct import)**
724
+ *
725
+ * ```ts
726
+ * import { defineConfig } from "tsdown";
727
+ * import { createDefaultConfig } from "@rzl-zone/build-tools/bundler/tsdown";
728
+ *
729
+ * export default defineConfig([
730
+ * await createDefaultConfig({
731
+ * entry: ["src/browser.ts"],
732
+ * format: "umd",
733
+ * sourcemap: false
734
+ * }),
735
+ * await createDefaultConfig({
736
+ * entry: ["src/index.ts"]
737
+ * })
738
+ * ]);
739
+ * ```
740
+ *
741
+ * ----------------------------------------------------------------
742
+ *
743
+ * @example
744
+ * **Usage with bundled `tsdown` facade**
745
+ *
746
+ * ```ts
747
+ * import { tsdown, createDefaultConfig } from "@rzl-zone/build-tools/bundler/tsdown";
748
+ *
749
+ * export default tsdown.defineConfig([
750
+ * await createDefaultConfig({
751
+ * entry: ["src/browser.ts"],
752
+ * format: "umd",
753
+ * sourcemap: false
754
+ * }),
755
+ * await createDefaultConfig({
756
+ * entry: ["src/index.ts"]
757
+ * })
758
+ * ]);
759
+ * ```
760
+ *
761
+ * ----------------------------------------------------------------
762
+ *
763
+ * @example
764
+ * **Mixed usage with `resolveDefaultConfig`**
765
+ *
766
+ * ```ts
767
+ * import { defineConfig } from "tsdown";
768
+ * import {
769
+ * createDefaultConfig,
770
+ * resolveDefaultConfig
771
+ * } from "@rzl-zone/build-tools/bundler/tsdown";
772
+ *
773
+ *
774
+ * // When wrapped with `resolveDefaultConfig`, configuration entries
775
+ * // may be provided either synchronously or asynchronously,
776
+ * // as the resolver accepts Awaitable values.
777
+ * export default defineConfig(
778
+ * resolveDefaultConfig([
779
+ * await createDefaultConfig({
780
+ * entry: ["src/browser.ts"],
781
+ * format: "umd",
782
+ * sourcemap: false
783
+ * }),
784
+ * createDefaultConfig({
785
+ * entry: ["src/index.ts"]
786
+ * })
787
+ * ])
788
+ * );
789
+ * ```
790
+ *
791
+ * ----------------------------------------------------------------
792
+ *
793
+ * @see {@link resolveDefaultConfig | `resolveDefaultConfig`}
794
+ * @environment `node`
795
+ */
796
+ declare const createDefaultConfig: (options: UserConfig) => Promise<UserConfigOptionsResult>;
797
+ type TsDown = typeof _tsDown;
798
+ /** ----------------------------------------------------------------
799
+ * * ***Package `tsdown` bundler API (Node.js only).***
800
+ * ----------------------------------------------------------------
801
+ * Thin namespace re-export of the {@link https://github.com/rolldown/tsdown | **`tsdown`**} package.
802
+ *
803
+ * - This export is provided as a **convenience facade** only.
804
+ * - The actual implementation is resolved from the consumer's
805
+ * dependency graph.
806
+ * - *Typical use cases:*
807
+ * - `defineConfig()` usage.
808
+ * - Programmatic bundler configuration.
809
+ * - Build pipelines and tooling.
810
+ *
811
+ * ----------------------------------------------------------------
812
+ * ⚠️ ***Peer dependency required.***
813
+ *
814
+ * {@link https://github.com/rolldown/tsdown | **`tsdown`**} is declared as a
815
+ * **peer dependency** of this package.
816
+ *
817
+ * You **MUST install it explicitly** in your project for this export
818
+ * to resolve correctly.
819
+ *
820
+ * ❌ **If {@link https://github.com/rolldown/tsdown | **`tsdown`**} is not installed**, importing this module will
821
+ * result in a **runtime module resolution error** (e.g. `Cannot find module "tsdown"`).
822
+ *
823
+ * @see {@link https://tsdown.dev/guide/getting-started#installation | **`tsdown installation guide`**.}
824
+ *
825
+ * ----------------------------------------------------------------
826
+ * ⚠️ ***Node.js only.***
827
+ *
828
+ * **DO NOT import this module in browser or client-side code.**
829
+ *
830
+ * - {@link https://github.com/rolldown/tsdown | **`tsdown`**} relies on Node.js–specific features such as:
831
+ * - filesystem access.
832
+ * - process environment variables.
833
+ * - native module resolution.
834
+ * ----------------------------------------------------------------
835
+ *
836
+ * @see {@link https://tsdown.dev | **`https://tsdown.dev`**.}
837
+ * @environment `node`.
838
+ *
839
+ */
840
+ declare const tsdown: TsDown;
841
+ /** ----------------------------------------------------------------
842
+ * * ***Filter process warnings at runtime.***
843
+ * ----------------------------------------------------------------
844
+ *
845
+ * Monkey-patches `process.stderr.write` to suppress specific noisy
846
+ * warnings emitted by tooling such as `tsdown`, `rolldown`,
847
+ * or other build-time utilities that bypass the official logger API.
848
+ *
849
+ * These warnings are written directly to stderr, making them
850
+ * impossible to silence using standard logger hooks.
851
+ *
852
+ * ----------------------------------------------------------------
853
+ *
854
+ * @description
855
+ *
856
+ * - Intercepts all `process.stderr.write` calls.
857
+ * - Extracts string content from the output chunk.
858
+ * - Suppresses messages that match configured patterns.
859
+ * - Forwards all other messages to the original stderr writer.
860
+ *
861
+ * This utility acts as a **last-resort filtering mechanism**
862
+ * when upstream tooling does not expose proper logging hooks.
863
+ *
864
+ * ----------------------------------------------------------------
865
+ *
866
+ * @remarks
867
+ *
868
+ * This utility is **not tied to any specific config helper**.
869
+ *
870
+ * - Can be used with:
871
+ * - `resolveDefaultConfig`
872
+ * - `createDefaultConfig`
873
+ * - native `tsdown` config (`defineConfig`)
874
+ * - direct `build()` API
875
+ * - or any custom build script
876
+ *
877
+ * It works by patching the global `process.stderr.write`,
878
+ * so it applies to **any tool emitting warnings to stderr**.
879
+ *
880
+ * ----------------------------------------------------------------
881
+ *
882
+ * @param patterns
883
+ * Additional patterns used to match and suppress warnings.
884
+ *
885
+ * - Each pattern is matched using `String.prototype.includes`.
886
+ * - Invalid values (non-string, empty, or whitespace-only) are **ignored at runtime**.
887
+ * - Patterns are automatically **trimmed and sanitized**.
888
+ *
889
+ * ----------------------------------------------------------------
890
+ *
891
+ * @param options
892
+ * Optional configuration for filter behavior.
893
+ *
894
+ * ----------------------------------------------------------------
895
+ *
896
+ * @returns
897
+ * `void`
898
+ *
899
+ * ----------------------------------------------------------------
900
+ *
901
+ * @example
902
+ * **Basic usage (default behavior)**
903
+ *
904
+ * ```ts
905
+ * applyWarningFilter();
906
+ * ```
907
+ *
908
+ * Filters:
909
+ * - `[MISSING_EXPORT] Warning`
910
+ * - `[PLUGIN_TIMINGS] Warning`
911
+ *
912
+ * ----------------------------------------------------------------
913
+ *
914
+ * @example
915
+ * **Extend default filter**
916
+ *
917
+ * ```ts
918
+ * applyWarningFilter([
919
+ * "[ANOTHER_WARNING]"
920
+ * ]);
921
+ * ```
922
+ *
923
+ * Filters:
924
+ * - `[MISSING_EXPORT] Warning`
925
+ * - `[PLUGIN_TIMINGS] Warning`
926
+ * - `[ANOTHER_WARNING]`
927
+ *
928
+ * ----------------------------------------------------------------
929
+ *
930
+ * @example
931
+ * **Override default filters**
932
+ *
933
+ * ```ts
934
+ * applyWarningFilter(
935
+ * ["[ANOTHER_WARNING]"],
936
+ * {
937
+ * includeMissingExportWarning: false,
938
+ * includePluginTimingsWarning: false
939
+ * }
940
+ * );
941
+ * ```
942
+ *
943
+ * Filters:
944
+ * - `[ANOTHER_WARNING]`
945
+ *
946
+ * ----------------------------------------------------------------
947
+ *
948
+ * @example
949
+ * **Partial match (recommended)**
950
+ *
951
+ * ```ts
952
+ * applyWarningFilter([
953
+ * "MISSING_EXPORT",
954
+ * "PLUGIN_TIMINGS"
955
+ * ]);
956
+ * ```
957
+ *
958
+ * ----------------------------------------------------------------
959
+ *
960
+ * @example
961
+ * **Usage (top-level, recommended)**
962
+ *
963
+ * Apply the filter once at the top of your config file:
964
+ *
965
+ * ```ts
966
+ * applyWarningFilter();
967
+ *
968
+ * export default resolveDefaultConfig({
969
+ * entry: ["src/index.ts"]
970
+ * });
971
+ * ```
972
+ *
973
+ * ----------------------------------------------------------------
974
+ *
975
+ * @example
976
+ * **Usage inside config resolver**
977
+ *
978
+ * You can also call the filter inside a resolver function.
979
+ * This is useful when applying dynamic configuration:
980
+ *
981
+ * ```ts
982
+ * export default resolveDefaultConfig(() => {
983
+ * applyWarningFilter(
984
+ * ["[ANOTHER_WARNING]"]
985
+ * );
986
+ *
987
+ * return [
988
+ * {
989
+ * entry: {
990
+ * index: "src/index.ts"
991
+ * }
992
+ * }
993
+ * ];
994
+ * });
995
+ * ```
996
+ *
997
+ * ----------------------------------------------------------------
998
+ *
999
+ * @example
1000
+ * **Usage with native tsdown config**
1001
+ *
1002
+ * ```ts
1003
+ * import { defineConfig } from "tsdown";
1004
+ *
1005
+ * applyWarningFilter(["MISSING_EXPORT"]);
1006
+ *
1007
+ * export default defineConfig({
1008
+ * entry: ["src/index.ts"]
1009
+ * });
1010
+ * ```
1011
+ *
1012
+ * ----------------------------------------------------------------
1013
+ *
1014
+ * @example
1015
+ * **Programmatic usage (build script)**
1016
+ *
1017
+ * ```ts
1018
+ * import { build } from "tsdown";
1019
+ *
1020
+ * applyWarningFilter();
1021
+ *
1022
+ * await build({
1023
+ * entry: ["src/index.ts"]
1024
+ * });
1025
+ * ```
1026
+ *
1027
+ * ----------------------------------------------------------------
1028
+ *
1029
+ * ⚠️ ***Important Notes***
1030
+ *
1031
+ * - This modifies global process behavior (**side-effect**).
1032
+ * - Must be executed **before** build tools emit logs.
1033
+ * - Not recommended for long-running applications.
1034
+ *
1035
+ * ----------------------------------------------------------------
1036
+ *
1037
+ * ⚠️ ***Node.js only***
1038
+ *
1039
+ * **DO NOT use this in browser or client-side environments.**
1040
+ *
1041
+ * ----------------------------------------------------------------
1042
+ *
1043
+ * @category Build Utilities
1044
+ * @environment `node`
1045
+ *
1046
+ * ----------------------------------------------------------------
1047
+ *
1048
+ * @remarks
1049
+ *
1050
+ * This utility is **not tied to any specific configuration helper**.
1051
+ *
1052
+ * - It can be used with:
1053
+ * - `resolveDefaultConfig`
1054
+ * - `createDefaultConfig`
1055
+ * - native `tsdown` config (`defineConfig`)
1056
+ * - direct `build()` API
1057
+ * - or any custom Node.js build script
1058
+ *
1059
+ * ----------------------------------------------------------------
1060
+ *
1061
+ * Internally, this function patches the global `process.stderr.write`,
1062
+ * meaning it will affect **all warnings emitted to stderr** during
1063
+ * the current process lifecycle.
1064
+ *
1065
+ * - As a result:
1066
+ * - The filter applies globally across all tools.
1067
+ * - It is not limited to `tsdown` or any specific bundler.
1068
+ * - It may also suppress warnings from unrelated libraries if
1069
+ * they match the provided patterns.
1070
+ *
1071
+ * ----------------------------------------------------------------
1072
+ *
1073
+ * For predictable behavior, it is recommended to call this function:
1074
+ * - once
1075
+ * - as early as possible (before any build or logging starts)
1076
+ *
1077
+ * ----------------------------------------------------------------
1078
+ */
1079
+ declare function applyWarningFilter(patterns?: readonly string[], options?: {
1080
+ /** ----------------------------------------------------------------
1081
+ * * ***Include `[MISSING_EXPORT]` warning filter.***
1082
+ * ----------------------------------------------------------------
1083
+ *
1084
+ * Controls whether the built-in filter for:
1085
+ *
1086
+ * ```txt
1087
+ * [MISSING_EXPORT] Warning
1088
+ * ```
1089
+ *
1090
+ * is applied.
1091
+ *
1092
+ * ----------------------------------------------------------------
1093
+ *
1094
+ * @remarks
1095
+ *
1096
+ * - When `true` **(default)**, this pattern is included and merged
1097
+ * with user-provided `patterns`.
1098
+ * - When `false`, it is excluded unless explicitly provided.
1099
+ *
1100
+ * ----------------------------------------------------------------
1101
+ *
1102
+ * This warning is typically emitted by underlying tooling
1103
+ * (e.g. dts bundling or rolldown internals) and may not be
1104
+ * configurable through official `tsdown` options.
1105
+ *
1106
+ * In such cases, filtering the output is the only practical way
1107
+ * to suppress this warning.
1108
+ *
1109
+ * ----------------------------------------------------------------
1110
+ *
1111
+ * This utility only suppresses warnings at the output level.
1112
+ * It does not disable the underlying checks or warning generation.
1113
+ *
1114
+ * ----------------------------------------------------------------
1115
+ *
1116
+ * @default true
1117
+ */
1118
+ includeMissingExportWarning?: boolean;
1119
+ /** ----------------------------------------------------------------
1120
+ * * ***Include `[PLUGIN_TIMINGS]` warning filter.***
1121
+ * ----------------------------------------------------------------
1122
+ *
1123
+ * Controls whether the built-in filter for:
1124
+ *
1125
+ * ```txt
1126
+ * [PLUGIN_TIMINGS] Warning
1127
+ * ```
1128
+ *
1129
+ * is applied.
1130
+ *
1131
+ * ----------------------------------------------------------------
1132
+ *
1133
+ * @remarks
1134
+ *
1135
+ * - When `true` **(default)**, this pattern is included and merged
1136
+ * with user-provided `patterns`.
1137
+ * - When `false`, it is excluded unless explicitly provided.
1138
+ *
1139
+ * ----------------------------------------------------------------
1140
+ *
1141
+ * This warning can also be disabled via the official `tsdown`
1142
+ * configuration:
1143
+ *
1144
+ * ```ts
1145
+ * checks: {
1146
+ * pluginTimings: false
1147
+ * }
1148
+ * ```
1149
+ *
1150
+ * In such cases, using the built-in configuration is preferred
1151
+ * over filtering the output.
1152
+ *
1153
+ * ----------------------------------------------------------------
1154
+ *
1155
+ * This utility only suppresses warnings at the output level.
1156
+ * It does not disable the underlying checks or warning generation.
1157
+ *
1158
+ * ----------------------------------------------------------------
1159
+ *
1160
+ * @default true
1161
+ */
1162
+ includePluginTimingsWarning?: boolean;
1163
+ }): void;
1164
+ export { BASE_DEFAULT_CONFIG, ConfigOptions, DepsConfig, InlineConfig, UserConfig, UserConfigExport, UserConfigFn, applyWarningFilter, createDefaultConfig, resolveDefaultConfig, tsdown };
1165
+ //# sourceMappingURL=tsdown.d.ts.map