bunup 0.5.9 → 0.5.11

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