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/cli.js +2 -2
- package/dist/index.d.ts +427 -454
- package/dist/index.js +1 -1
- package/dist/plugins.d.ts +432 -458
- package/dist/plugins.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,88 +1,66 @@
|
|
|
1
1
|
import _Bun from "bun";
|
|
2
2
|
|
|
3
|
-
//#region
|
|
3
|
+
//#region packages/bunup/src/helpers/entry.d.ts
|
|
4
4
|
type ProcessableEntry = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
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
|
-
|
|
486
|
-
|
|
487
|
-
|
|
458
|
+
name: string;
|
|
459
|
+
root: string;
|
|
460
|
+
config: DefineConfigItem | DefineConfigItem[];
|
|
488
461
|
};
|
|
489
462
|
|
|
490
463
|
//#endregion
|
|
491
|
-
//#region
|
|
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
|
|
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
|