bunup 0.5.9 → 0.5.10

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.
package/dist/index.d.ts CHANGED
@@ -1,88 +1,66 @@
1
1
  import _Bun from "bun";
2
2
 
3
- //#region \0dts:/home/runner/work/bunup/bunup/packages/bunup/src/helpers/entry.d.ts
3
+ //#region packages/bunup/src/helpers/entry.d.ts
4
4
  type ProcessableEntry = {
5
- fullPath: string
6
- /**
7
- * The relative path to the output directory.
8
- *
9
- * This is the path that will be used to name the output file.
10
- *
11
- * Examples:
12
- * - "src/index.ts" → "index"
13
- * - "src/plugins/index.ts" → "plugins/index"
14
- * - etc.
15
- */
16
- outputBasePath: string
17
- };
18
-
19
- //#endregion
20
- //#region \0dts:/home/runner/work/bunup/bunup/packages/bunup/src/plugins/types.d.ts
21
- /**
22
- * Represents a Bun plugin that can be used with Bunup
23
- */
5
+ fullPath: string;
6
+ /**
7
+ * The relative path to the output directory.
8
+ *
9
+ * This is the path that will be used to name the output file.
10
+ *
11
+ * Examples:
12
+ * - "src/index.ts" → "index"
13
+ * - "src/plugins/index.ts" → "plugins/index"
14
+ * - etc.
15
+ */
16
+ outputBasePath: string;
17
+ }; //#endregion
18
+ //#region packages/bunup/src/plugins/types.d.ts
24
19
  type BunupBunPlugin = {
25
- /** Identifies this as a native Bun plugin */
26
- type: "bun"
27
- /** Optional name for the plugin */
28
- name?: string
29
- /** The actual Bun plugin implementation */
30
- plugin: BunPlugin
20
+ /** Identifies this as a native Bun plugin */
21
+ type: "bun";
22
+ /** Optional name for the plugin */
23
+ name?: string;
24
+ /** The actual Bun plugin implementation */
25
+ plugin: BunPlugin;
31
26
  };
32
- /**
33
- * Represents the output of a build operation
34
- */
35
27
  type BuildOutput = {
36
- /** Array of generated files with their paths and contents */
37
- files: Array<{
38
- /** Path to the generated file */
39
- fullPath: string
40
- /** Path to the generated file relative to the root directory */
41
- relativePathToRootDir: string
42
- }>
28
+ /** Array of generated files with their paths and contents */
29
+ files: Array<{
30
+ /** Path to the generated file */
31
+ fullPath: string;
32
+ /** Path to the generated file relative to the root directory */
33
+ relativePathToRootDir: string;
34
+ }>;
43
35
  };
44
- /**
45
- * Context provided to build hooks
46
- */
47
36
  type BuildContext = {
48
- /** The build options that were used */
49
- options: BuildOptions
50
- /** The output of the build */
51
- output: BuildOutput
37
+ /** The build options that were used */
38
+ options: BuildOptions;
39
+ /** The output of the build */
40
+ output: BuildOutput;
52
41
  };
53
- /**
54
- * Hooks that can be implemented by Bunup plugins
55
- */
56
42
  type BunupPluginHooks = {
57
- /**
58
- * Called when a build is successfully completed
59
- * @param ctx Build context containing options and output
60
- */
61
- onBuildDone?: (ctx: BuildContext) => MaybePromise<void>
62
- /**
63
- * Called before a build starts
64
- * @param options Build options that will be used
65
- */
66
- onBuildStart?: (options: BuildOptions) => MaybePromise<void>
43
+ /**
44
+ * Called when a build is successfully completed
45
+ * @param ctx Build context containing options and output
46
+ */
47
+ onBuildDone?: (ctx: BuildContext) => MaybePromise<void>;
48
+ /**
49
+ * Called before a build starts
50
+ * @param options Build options that will be used
51
+ */
52
+ onBuildStart?: (options: BuildOptions) => MaybePromise<void>;
67
53
  };
68
- /**
69
- * Represents a Bunup-specific plugin
70
- */
71
54
  type BunupPlugin = {
72
- /** Identifies this as a Bunup-specific plugin */
73
- type: "bunup"
74
- /** Optional name for the plugin */
75
- name?: string
76
- /** The hooks implemented by this plugin */
77
- hooks: BunupPluginHooks
55
+ /** Identifies this as a Bunup-specific plugin */
56
+ type: "bunup";
57
+ /** Optional name for the plugin */
58
+ name?: string;
59
+ /** The hooks implemented by this plugin */
60
+ hooks: BunupPluginHooks;
78
61
  };
79
- /**
80
- * Union type representing all supported plugin types
81
- */
82
- type Plugin = BunupBunPlugin | BunupPlugin;
83
-
84
- //#endregion
85
- //#region \0dts:/home/runner/work/bunup/bunup/packages/bunup/src/options.d.ts
62
+ type Plugin = BunupBunPlugin | BunupPlugin; //#endregion
63
+ //#region packages/bunup/src/options.d.ts
86
64
  type Loader = NonNullable<BunBuildOptions["loader"]>[string];
87
65
  type Define = BunBuildOptions["define"];
88
66
  type Sourcemap = BunBuildOptions["sourcemap"];
@@ -92,408 +70,403 @@ type External = (string | RegExp)[];
92
70
  type Env = BunBuildOptions["env"] | Record<string, string>;
93
71
  type Entry = Arrayable<string> | Record<string, string>;
94
72
  type ShimOptions = {
95
- /**
96
- * Adds __dirname and __filename shims for ESM files when used
97
- */
98
- dirnameFilename?: boolean
99
- /**
100
- * Adds import.meta.url shims for CJS files when used
101
- */
102
- importMetaUrl?: boolean
73
+ /**
74
+ * Adds __dirname and __filename shims for ESM files when used
75
+ */
76
+ dirnameFilename?: boolean;
77
+ /**
78
+ * Adds import.meta.url shims for CJS files when used
79
+ */
80
+ importMetaUrl?: boolean;
103
81
  };
104
82
  type Shims = boolean | ShimOptions;
105
83
  type DtsResolve = boolean | (string | RegExp)[];
106
84
  type DtsOptions = {
107
- /**
108
- * Entry point files for TypeScript declaration file generation
109
- *
110
- * This can be:
111
- * - A string path to a file
112
- * - An array of file paths
113
- * - An object where keys are output names and values are input file paths
114
- *
115
- * The key names are used for the generated declaration files.
116
- * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
117
- *
118
- * If not specified, the main entry points will be used for declaration file generation.
119
- *
120
- * If it's a string or an array of strings, the file name (without extension)
121
- * will be used as the name for the output declaration file.
122
- *
123
- * @example
124
- * // Using a string path
125
- * entry: 'src/index.ts' // Generates index.d.ts
126
- *
127
- * // Using string paths in an array
128
- * entry: ['src/index.ts'] // Generates index.d.ts
129
- *
130
- * // Using named outputs as an object
131
- * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
132
- *
133
- * // Organizing output with subdirectories
134
- * entry: { "client/index": "src/client/index.ts", "server/index": "src/server/index.ts" } // Generates client/index.d.ts and server/index.d.ts
135
- */
136
- entry?: Entry
137
- /**
138
- * Resolve external types used in dts files from node_modules
139
- */
140
- resolve?: DtsResolve
85
+ /**
86
+ * Entry point files for TypeScript declaration file generation
87
+ *
88
+ * This can be:
89
+ * - A string path to a file
90
+ * - An array of file paths
91
+ * - An object where keys are output names and values are input file paths
92
+ *
93
+ * The key names are used for the generated declaration files.
94
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
95
+ *
96
+ * If not specified, the main entry points will be used for declaration file generation.
97
+ *
98
+ * If it's a string or an array of strings, the file name (without extension)
99
+ * will be used as the name for the output declaration file.
100
+ *
101
+ * @example
102
+ * // Using a string path
103
+ * entry: 'src/index.ts' // Generates index.d.ts
104
+ *
105
+ * // Using string paths in an array
106
+ * entry: ['src/index.ts'] // Generates index.d.ts
107
+ *
108
+ * // Using named outputs as an object
109
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
110
+ *
111
+ * // Organizing output with subdirectories
112
+ * entry: { "client/index": "src/client/index.ts", "server/index": "src/server/index.ts" } // Generates client/index.d.ts and server/index.d.ts
113
+ */
114
+ entry?: Entry;
115
+ /**
116
+ * Resolve external types used in dts files from node_modules
117
+ */
118
+ resolve?: DtsResolve;
141
119
  };
142
120
  interface BuildOptions {
143
- /**
144
- * Name of the build configuration
145
- * Used for logging and identification purposes
146
- */
147
- name?: string;
148
- /**
149
- * Entry point files for the build
150
- *
151
- * This can be:
152
- * - A string path to a file
153
- * - An array of file paths
154
- * - An object where keys are output names and values are input file paths
155
- *
156
- * The key names are used for the generated output files.
157
- * For example, `{custom: 'src/index.ts'}` will generate `custom.js`
158
- *
159
- * If it's a string or an array of strings, the file name (without extension)
160
- * will be used as the name for the output file.
161
- *
162
- * @example
163
- * // Using a string path
164
- * entry: 'src/index.ts' // Generates index.js
165
- *
166
- * // Using string paths in an array
167
- * entry: ['src/index.ts'] // Generates index.js
168
- *
169
- * // Using named outputs as an object
170
- * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.js and utils.js
171
- */
172
- entry: Entry;
173
- /**
174
- * Output directory for the bundled files
175
- * Defaults to 'dist' if not specified
176
- */
177
- outDir: string;
178
- /**
179
- * Output formats for the bundle
180
- * Can include 'esm', 'cjs', and/or 'iife'
181
- * Defaults to ['cjs'] if not specified
182
- */
183
- format: Format[];
184
- /**
185
- * Whether to enable all minification options
186
- * When true, enables minifyWhitespace, minifyIdentifiers, and minifySyntax
187
- */
188
- minify?: boolean;
189
- /**
190
- * Whether to enable code splitting
191
- * Defaults to true for ESM format, false for CJS format
192
- */
193
- splitting?: boolean;
194
- /**
195
- * Whether to minify whitespace in the output
196
- * Removes unnecessary whitespace to reduce file size
197
- */
198
- minifyWhitespace?: boolean;
199
- /**
200
- * Whether to minify identifiers in the output
201
- * Renames variables and functions to shorter names
202
- */
203
- minifyIdentifiers?: boolean;
204
- /**
205
- * Whether to minify syntax in the output
206
- * Optimizes code structure for smaller file size
207
- */
208
- minifySyntax?: boolean;
209
- /**
210
- * Whether to watch for file changes and rebuild automatically
211
- */
212
- watch?: boolean;
213
- /**
214
- * Whether to generate TypeScript declaration files (.d.ts)
215
- * When set to true, generates declaration files for all entry points
216
- * Can also be configured with DtsOptions for more control
217
- */
218
- dts?: boolean | DtsOptions;
219
- /**
220
- * Generate only TypeScript declaration files (.d.ts) without any JavaScript output
221
- * When set to true, bunup will skip the JavaScript bundling process entirely
222
- * and only generate declaration files for the specified entry points
223
- *
224
- * This is useful when you want to use bunup's fast declaration file generation
225
- * but handle the JavaScript bundling separately or not at all.
226
- *
227
- * Note: When this option is true, the `dts` option is implicitly set to true
228
- * and other bundling-related options are ignored.
229
- *
230
- * @example
231
- * dtsOnly: true
232
- */
233
- dtsOnly?: boolean;
234
- /**
235
- * Path to a preferred tsconfig.json file to use for declaration generation
236
- *
237
- * If not specified, the tsconfig.json in the project root will be used.
238
- * This option allows you to use a different TypeScript configuration
239
- * specifically for declaration file generation.
240
- *
241
- * @example
242
- * preferredTsconfigPath: './tsconfig.build.json'
243
- */
244
- preferredTsconfigPath?: string;
245
- /**
246
- * External packages that should not be bundled
247
- * Useful for dependencies that should be kept as external imports
248
- */
249
- external?: External;
250
- /**
251
- * Packages that should be bundled even if they are in external
252
- * Useful for dependencies that should be included in the bundle
253
- */
254
- noExternal?: External;
255
- /**
256
- * The target environment for the bundle
257
- * Can be 'browser', 'bun', 'node', etc.
258
- * Defaults to 'node' if not specified
259
- */
260
- target?: Target;
261
- /**
262
- * Whether to clean the output directory before building
263
- * When true, removes all files in the outDir before starting a new build
264
- * Defaults to true if not specified
265
- */
266
- clean?: boolean;
267
- /**
268
- * Specifies the type of sourcemap to generate
269
- * Can be 'none', 'linked', 'external', or 'inline'
270
- * Can also be a boolean - when true, it will use 'inline'
271
- *
272
- * @see https://bun.sh/docs/bundler#sourcemap
273
- *
274
- * @default 'none'
275
- *
276
- * @example
277
- * sourcemap: 'linked'
278
- * // or
279
- * sourcemap: true // equivalent to 'inline'
280
- */
281
- sourcemap?: Sourcemap;
282
- /**
283
- * Define global constants for the build
284
- * These values will be replaced at build time
285
- *
286
- * @see https://bun.sh/docs/bundler#define
287
- *
288
- * @example
289
- * define: {
290
- * 'process.env.NODE_ENV': '"production"',
291
- * 'PACKAGE_VERSION': '"1.0.0"'
292
- * }
293
- */
294
- define?: Define;
295
- /**
296
- * A callback function that runs after the build process completes
297
- * This can be used for custom post-build operations like copying files,
298
- * running additional tools, or logging build information
299
- *
300
- * If watch mode is enabled, this callback runs after each rebuild
301
- *
302
- * @param options The build options that were used
303
- */
304
- onSuccess?: (options: Partial<BuildOptions>) => MaybePromise<void>;
305
- /**
306
- * A banner to be added to the final bundle, this can be a directive like "use client" for react or a comment block such as a license for the code.
307
- *
308
- * @see https://bun.sh/docs/bundler#banner
309
- *
310
- * @example
311
- * banner: '"use client";'
312
- */
313
- banner?: string;
314
- /**
315
- * A footer to be added to the final bundle, this can be something like a comment block for a license or just a fun easter egg.
316
- *
317
- * @see https://bun.sh/docs/bundler#footer
318
- *
319
- * @example
320
- * footer: '// built with love in SF'
321
- */
322
- footer?: string;
323
- /**
324
- * Remove function calls from a bundle. For example, `drop: ["console"]` will remove all calls to `console.log`. Arguments to calls will also be removed, regardless of if those arguments may have side effects. Dropping `debugger` will remove all `debugger` statements.
325
- *
326
- * @see https://bun.sh/docs/bundler#drop
327
- *
328
- * @example
329
- * drop: ["console", "debugger", "anyIdentifier.or.propertyAccess"]
330
- */
331
- drop?: string[];
332
- /**
333
- * A map of file extensions to [built-in loader names](https://bun.sh/docs/bundler/loaders#built-in-loaders). This can be used to quickly customize how certain files are loaded.
334
- *
335
- * @see https://bun.sh/docs/bundler#loader
336
- *
337
- * @example
338
- * loader: {
339
- * ".png": "dataurl",
340
- * ".txt": "file",
341
- * }
342
- */
343
- loader?: Record<string, Loader>;
344
- /**
345
- * Generate bytecode for the output. This can dramatically improve cold start times, but will make the final output larger and slightly increase memory usage.
346
- *
347
- * Bytecode is currently only supported for CommonJS (format: "cjs").
348
- *
349
- * Must be target: "bun"
350
- *
351
- * @see https://bun.sh/docs/bundler#bytecode
352
- *
353
- * @default false
354
- */
355
- bytecode?: boolean;
356
- /**
357
- * Disable logging during the build process. When set to true, no logs will be printed to the console.
358
- *
359
- * @default false
360
- */
361
- silent?: boolean;
362
- /**
363
- * You can specify a prefix to be added to specific import paths in your bundled code
364
- *
365
- * Used for assets, external modules, and chunk files when splitting is enabled
366
- *
367
- * @see https://bunup.dev/docs#public-path for more information
368
- *
369
- * @example
370
- * publicPath: 'https://cdn.example.com/'
371
- */
372
- publicPath?: string;
373
- /**
374
- * Inject Node.js compatibility shims for ESM/CJS interoperability
375
- *
376
- * When set to true, automatically injects all shims when needed
377
- * When set to an object, only injects the specified shims
378
- *
379
- * Available shims:
380
- * - dirnameFilename: Adds __dirname and __filename for ESM files when used
381
- * - importMetaUrl: Adds import.meta.url for CJS files when used
382
- *
383
- * @example
384
- * // Enable all shims
385
- * shims: true
386
- *
387
- * // Enable only specific shims
388
- * shims: { dirnameFilename: true, importMetaUrl: true }
389
- */
390
- shims?: Shims;
391
- /**
392
- * Controls how environment variables are handled during bundling.
393
- *
394
- * Can be one of:
395
- * - `"inline"`: Replaces all `process.env.FOO` references in your code with the actual values
396
- * of those environment variables at the time the build runs.
397
- * - `"disable"`: Disables environment variable injection entirely, leaving `process.env.*` as-is.
398
- * - A string ending in `*`: Only inlines environment variables matching the given prefix.
399
- * For example, `"MY_PUBLIC_*"` will inline variables like `MY_PUBLIC_API_URL`.
400
- * - An object of key-value pairs: Replaces both `process.env.KEY` and `import.meta.env.KEY`
401
- * with the provided values, regardless of the runtime environment.
402
- *
403
- * Note: Values are injected at build time. Secrets or private keys should be excluded
404
- * from inlining when targeting browser environments.
405
- *
406
- * @see https://bun.sh/docs/bundler#env to learn more about inline, disable, prefix, and object modes
407
- *
408
- * @example
409
- * // Inline all environment variables available at build time
410
- * env: "inline"
411
- *
412
- * // Disable all environment variable injection
413
- * env: "disable"
414
- *
415
- * // Only inline environment variables with a specific prefix
416
- * env: "PUBLIC_*"
417
- *
418
- * // Provide specific environment variables manually
419
- * env: { API_URL: "https://api.example.com", DEBUG: "false" }
420
- */
421
- env?: Env;
422
- /**
423
- * Plugins to extend the build process functionality
424
- *
425
- * The Plugin type uses a discriminated union pattern with the 'type' field
426
- * to support different plugin systems. Currently, only "bun" plugins are supported,
427
- * but in the future, this will be extended to include "bunup" plugins as well.
428
- *
429
- * Each plugin type has its own specific plugin implementation:
430
- * - "bun": Uses Bun's native plugin system (BunPlugin)
431
- * - "bunup": Will use bunup's own plugin system (coming in future versions)
432
- *
433
- * This architecture allows for extensibility as more plugin systems are added.
434
- *
435
- * @example
436
- * plugins: [
437
- * {
438
- * type: "bun",
439
- * plugin: myBunPlugin()
440
- * },
441
- * // In the future:
442
- * // {
443
- * // type: "bunup",
444
- * // plugin: myBunupPlugin()
445
- * // }
446
- * ]
447
- */
448
- plugins?: Plugin[];
449
- /**
450
- * Customize the output file extension for each format.
451
- *
452
- * @param options Contains format, packageType, options, and entry information
453
- * @returns Object with js and dts extensions (including the leading dot)
454
- *
455
- * @example
456
- * outputExtension: ({ format, entry }) => ({
457
- * js: entry.outputBasePath === 'worker' ? '.worker.js' : `.${format}.js`,
458
- * dts: `.${format}.d.ts`
459
- * })
460
- */
461
- outputExtension?: (options: {
462
- format: Format
463
- packageType: string | undefined
464
- options: BuildOptions
465
- entry: ProcessableEntry
466
- }) => {
467
- js: string
468
- dts: string
469
- };
470
- }
471
-
472
- //#endregion
473
- //#region \0dts:/home/runner/work/bunup/bunup/packages/bunup/src/types.d.ts
121
+ /**
122
+ * Name of the build configuration
123
+ * Used for logging and identification purposes
124
+ */
125
+ name?: string;
126
+ /**
127
+ * Entry point files for the build
128
+ *
129
+ * This can be:
130
+ * - A string path to a file
131
+ * - An array of file paths
132
+ * - An object where keys are output names and values are input file paths
133
+ *
134
+ * The key names are used for the generated output files.
135
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.js`
136
+ *
137
+ * If it's a string or an array of strings, the file name (without extension)
138
+ * will be used as the name for the output file.
139
+ *
140
+ * @example
141
+ * // Using a string path
142
+ * entry: 'src/index.ts' // Generates index.js
143
+ *
144
+ * // Using string paths in an array
145
+ * entry: ['src/index.ts'] // Generates index.js
146
+ *
147
+ * // Using named outputs as an object
148
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.js and utils.js
149
+ */
150
+ entry: Entry;
151
+ /**
152
+ * Output directory for the bundled files
153
+ * Defaults to 'dist' if not specified
154
+ */
155
+ outDir: string;
156
+ /**
157
+ * Output formats for the bundle
158
+ * Can include 'esm', 'cjs', and/or 'iife'
159
+ * Defaults to ['cjs'] if not specified
160
+ */
161
+ format: Format[];
162
+ /**
163
+ * Whether to enable all minification options
164
+ * When true, enables minifyWhitespace, minifyIdentifiers, and minifySyntax
165
+ */
166
+ minify?: boolean;
167
+ /**
168
+ * Whether to enable code splitting
169
+ * Defaults to true for ESM format, false for CJS format
170
+ */
171
+ splitting?: boolean;
172
+ /**
173
+ * Whether to minify whitespace in the output
174
+ * Removes unnecessary whitespace to reduce file size
175
+ */
176
+ minifyWhitespace?: boolean;
177
+ /**
178
+ * Whether to minify identifiers in the output
179
+ * Renames variables and functions to shorter names
180
+ */
181
+ minifyIdentifiers?: boolean;
182
+ /**
183
+ * Whether to minify syntax in the output
184
+ * Optimizes code structure for smaller file size
185
+ */
186
+ minifySyntax?: boolean;
187
+ /**
188
+ * Whether to watch for file changes and rebuild automatically
189
+ */
190
+ watch?: boolean;
191
+ /**
192
+ * Whether to generate TypeScript declaration files (.d.ts)
193
+ * When set to true, generates declaration files for all entry points
194
+ * Can also be configured with DtsOptions for more control
195
+ */
196
+ dts?: boolean | DtsOptions;
197
+ /**
198
+ * Generate only TypeScript declaration files (.d.ts) without any JavaScript output
199
+ * When set to true, bunup will skip the JavaScript bundling process entirely
200
+ * and only generate declaration files for the specified entry points
201
+ *
202
+ * This is useful when you want to use bunup's fast declaration file generation
203
+ * but handle the JavaScript bundling separately or not at all.
204
+ *
205
+ * Note: When this option is true, the `dts` option is implicitly set to true
206
+ * and other bundling-related options are ignored.
207
+ *
208
+ * @example
209
+ * dtsOnly: true
210
+ */
211
+ dtsOnly?: boolean;
212
+ /**
213
+ * Path to a preferred tsconfig.json file to use for declaration generation
214
+ *
215
+ * If not specified, the tsconfig.json in the project root will be used.
216
+ * This option allows you to use a different TypeScript configuration
217
+ * specifically for declaration file generation.
218
+ *
219
+ * @example
220
+ * preferredTsconfigPath: './tsconfig.build.json'
221
+ */
222
+ preferredTsconfigPath?: string;
223
+ /**
224
+ * External packages that should not be bundled
225
+ * Useful for dependencies that should be kept as external imports
226
+ */
227
+ external?: External;
228
+ /**
229
+ * Packages that should be bundled even if they are in external
230
+ * Useful for dependencies that should be included in the bundle
231
+ */
232
+ noExternal?: External;
233
+ /**
234
+ * The target environment for the bundle
235
+ * Can be 'browser', 'bun', 'node', etc.
236
+ * Defaults to 'node' if not specified
237
+ */
238
+ target?: Target;
239
+ /**
240
+ * Whether to clean the output directory before building
241
+ * When true, removes all files in the outDir before starting a new build
242
+ * Defaults to true if not specified
243
+ */
244
+ clean?: boolean;
245
+ /**
246
+ * Specifies the type of sourcemap to generate
247
+ * Can be 'none', 'linked', 'external', or 'inline'
248
+ * Can also be a boolean - when true, it will use 'inline'
249
+ *
250
+ * @see https://bun.sh/docs/bundler#sourcemap
251
+ *
252
+ * @default 'none'
253
+ *
254
+ * @example
255
+ * sourcemap: 'linked'
256
+ * // or
257
+ * sourcemap: true // equivalent to 'inline'
258
+ */
259
+ sourcemap?: Sourcemap;
260
+ /**
261
+ * Define global constants for the build
262
+ * These values will be replaced at build time
263
+ *
264
+ * @see https://bun.sh/docs/bundler#define
265
+ *
266
+ * @example
267
+ * define: {
268
+ * 'process.env.NODE_ENV': '"production"',
269
+ * 'PACKAGE_VERSION': '"1.0.0"'
270
+ * }
271
+ */
272
+ define?: Define;
273
+ /**
274
+ * A callback function that runs after the build process completes
275
+ * This can be used for custom post-build operations like copying files,
276
+ * running additional tools, or logging build information
277
+ *
278
+ * If watch mode is enabled, this callback runs after each rebuild
279
+ *
280
+ * @param options The build options that were used
281
+ */
282
+ onSuccess?: (options: Partial<BuildOptions>) => MaybePromise<void>;
283
+ /**
284
+ * A banner to be added to the final bundle, this can be a directive like "use client" for react or a comment block such as a license for the code.
285
+ *
286
+ * @see https://bun.sh/docs/bundler#banner
287
+ *
288
+ * @example
289
+ * banner: '"use client";'
290
+ */
291
+ banner?: string;
292
+ /**
293
+ * A footer to be added to the final bundle, this can be something like a comment block for a license or just a fun easter egg.
294
+ *
295
+ * @see https://bun.sh/docs/bundler#footer
296
+ *
297
+ * @example
298
+ * footer: '// built with love in SF'
299
+ */
300
+ footer?: string;
301
+ /**
302
+ * Remove function calls from a bundle. For example, `drop: ["console"]` will remove all calls to `console.log`. Arguments to calls will also be removed, regardless of if those arguments may have side effects. Dropping `debugger` will remove all `debugger` statements.
303
+ *
304
+ * @see https://bun.sh/docs/bundler#drop
305
+ *
306
+ * @example
307
+ * drop: ["console", "debugger", "anyIdentifier.or.propertyAccess"]
308
+ */
309
+ drop?: string[];
310
+ /**
311
+ * A map of file extensions to [built-in loader names](https://bun.sh/docs/bundler/loaders#built-in-loaders). This can be used to quickly customize how certain files are loaded.
312
+ *
313
+ * @see https://bun.sh/docs/bundler#loader
314
+ *
315
+ * @example
316
+ * loader: {
317
+ * ".png": "dataurl",
318
+ * ".txt": "file",
319
+ * }
320
+ */
321
+ loader?: Record<string, Loader>;
322
+ /**
323
+ * Generate bytecode for the output. This can dramatically improve cold start times, but will make the final output larger and slightly increase memory usage.
324
+ *
325
+ * Bytecode is currently only supported for CommonJS (format: "cjs").
326
+ *
327
+ * Must be target: "bun"
328
+ *
329
+ * @see https://bun.sh/docs/bundler#bytecode
330
+ *
331
+ * @default false
332
+ */
333
+ bytecode?: boolean;
334
+ /**
335
+ * Disable logging during the build process. When set to true, no logs will be printed to the console.
336
+ *
337
+ * @default false
338
+ */
339
+ silent?: boolean;
340
+ /**
341
+ * You can specify a prefix to be added to specific import paths in your bundled code
342
+ *
343
+ * Used for assets, external modules, and chunk files when splitting is enabled
344
+ *
345
+ * @see https://bunup.dev/docs#public-path for more information
346
+ *
347
+ * @example
348
+ * publicPath: 'https://cdn.example.com/'
349
+ */
350
+ publicPath?: string;
351
+ /**
352
+ * Inject Node.js compatibility shims for ESM/CJS interoperability
353
+ *
354
+ * When set to true, automatically injects all shims when needed
355
+ * When set to an object, only injects the specified shims
356
+ *
357
+ * Available shims:
358
+ * - dirnameFilename: Adds __dirname and __filename for ESM files when used
359
+ * - importMetaUrl: Adds import.meta.url for CJS files when used
360
+ *
361
+ * @example
362
+ * // Enable all shims
363
+ * shims: true
364
+ *
365
+ * // Enable only specific shims
366
+ * shims: { dirnameFilename: true, importMetaUrl: true }
367
+ */
368
+ shims?: Shims;
369
+ /**
370
+ * Controls how environment variables are handled during bundling.
371
+ *
372
+ * Can be one of:
373
+ * - `"inline"`: Replaces all `process.env.FOO` references in your code with the actual values
374
+ * of those environment variables at the time the build runs.
375
+ * - `"disable"`: Disables environment variable injection entirely, leaving `process.env.*` as-is.
376
+ * - A string ending in `*`: Only inlines environment variables matching the given prefix.
377
+ * For example, `"MY_PUBLIC_*"` will inline variables like `MY_PUBLIC_API_URL`.
378
+ * - An object of key-value pairs: Replaces both `process.env.KEY` and `import.meta.env.KEY`
379
+ * with the provided values, regardless of the runtime environment.
380
+ *
381
+ * Note: Values are injected at build time. Secrets or private keys should be excluded
382
+ * from inlining when targeting browser environments.
383
+ *
384
+ * @see https://bun.sh/docs/bundler#env to learn more about inline, disable, prefix, and object modes
385
+ *
386
+ * @example
387
+ * // Inline all environment variables available at build time
388
+ * env: "inline"
389
+ *
390
+ * // Disable all environment variable injection
391
+ * env: "disable"
392
+ *
393
+ * // Only inline environment variables with a specific prefix
394
+ * env: "PUBLIC_*"
395
+ *
396
+ * // Provide specific environment variables manually
397
+ * env: { API_URL: "https://api.example.com", DEBUG: "false" }
398
+ */
399
+ env?: Env;
400
+ /**
401
+ * Plugins to extend the build process functionality
402
+ *
403
+ * The Plugin type uses a discriminated union pattern with the 'type' field
404
+ * to support different plugin systems. Currently, only "bun" plugins are supported,
405
+ * but in the future, this will be extended to include "bunup" plugins as well.
406
+ *
407
+ * Each plugin type has its own specific plugin implementation:
408
+ * - "bun": Uses Bun's native plugin system (BunPlugin)
409
+ * - "bunup": Will use bunup's own plugin system (coming in future versions)
410
+ *
411
+ * This architecture allows for extensibility as more plugin systems are added.
412
+ *
413
+ * @example
414
+ * plugins: [
415
+ * {
416
+ * type: "bun",
417
+ * plugin: myBunPlugin()
418
+ * },
419
+ * // In the future:
420
+ * // {
421
+ * // type: "bunup",
422
+ * // plugin: myBunupPlugin()
423
+ * // }
424
+ * ]
425
+ */
426
+ plugins?: Plugin[];
427
+ /**
428
+ * Customize the output file extension for each format.
429
+ *
430
+ * @param options Contains format, packageType, options, and entry information
431
+ * @returns Object with js and dts extensions (including the leading dot)
432
+ *
433
+ * @example
434
+ * outputExtension: ({ format, entry }) => ({
435
+ * js: entry.outputBasePath === 'worker' ? '.worker.js' : `.${format}.js`,
436
+ * dts: `.${format}.d.ts`
437
+ * })
438
+ */
439
+ outputExtension?: (options: {
440
+ format: Format;
441
+ packageType: string | undefined;
442
+ options: BuildOptions;
443
+ entry: ProcessableEntry;
444
+ }) => {
445
+ js: string;
446
+ dts: string;
447
+ };
448
+ } //#endregion
449
+ //#region packages/bunup/src/types.d.ts
474
450
  type MaybePromise<T> = Promise<T> | T;
475
- type WithOptional<
476
- T,
477
- K extends keyof T
478
- > = Omit<T, K> & Partial<Pick<T, K>>;
451
+ type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
479
452
  type Arrayable<T> = T | T[];
480
453
  type Bun = typeof _Bun;
481
454
  type BunBuildOptions = Parameters<Bun["build"]>[0];
482
455
  type BunPlugin = Exclude<BunBuildOptions["plugins"], undefined>[number];
483
456
  type DefineConfigItem = Omit<WithOptional<BuildOptions, "outDir" | "format">, "watch">;
484
457
  type DefineWorkspaceItem = {
485
- name: string
486
- root: string
487
- config: DefineConfigItem | DefineConfigItem[]
458
+ name: string;
459
+ root: string;
460
+ config: DefineConfigItem | DefineConfigItem[];
488
461
  };
489
462
 
490
463
  //#endregion
491
- //#region \0dts:/home/runner/work/bunup/bunup/packages/bunup/src/define.d.ts
464
+ //#region packages/bunup/src/define.d.ts
492
465
  declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
493
466
  declare function defineWorkspace(options: DefineWorkspaceItem[]): DefineWorkspaceItem[];
494
467
 
495
468
  //#endregion
496
- //#region \0dts:/home/runner/work/bunup/bunup/packages/bunup/src/build.d.ts
469
+ //#region packages/bunup/src/build.d.ts
497
470
  declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
498
471
 
499
472
  //#endregion