bunup 0.3.87 → 0.3.89
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/README.md +1 -1
- package/build/cli.mjs +14 -14
- package/build/index.cjs +15 -0
- package/build/index.d.cts +273 -0
- package/build/index.d.mts +14 -220
- package/build/index.mjs +6 -6
- package/package.json +5 -5
- package/build/index.d.ts +0 -479
- package/build/index.js +0 -15
package/build/index.d.ts
DELETED
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
import _Bun from "bun";
|
|
2
|
-
|
|
3
|
-
//#region \0dts:/home/runner/work/bunup/bunup/src/options.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Entry point files for TypeScript declaration file generation
|
|
6
|
-
*
|
|
7
|
-
* This can be:
|
|
8
|
-
* - A string path to a file
|
|
9
|
-
* - An array of file paths
|
|
10
|
-
* - An object where keys are output names and values are input file paths
|
|
11
|
-
*
|
|
12
|
-
* The key names are used for the generated declaration files.
|
|
13
|
-
* For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
|
|
14
|
-
*
|
|
15
|
-
* If not specified, the main entry points will be used for declaration file generation.
|
|
16
|
-
*
|
|
17
|
-
* If it's a string or an array of strings, the file name (without extension)
|
|
18
|
-
* will be used as the name for the output declaration file.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* // Using a string path
|
|
22
|
-
* entry: 'src/index.ts' // Generates index.d.ts
|
|
23
|
-
*
|
|
24
|
-
* // Using string paths in an array
|
|
25
|
-
* entry: ['src/index.ts'] // Generates index.d.ts
|
|
26
|
-
*
|
|
27
|
-
* // Using named outputs as an object
|
|
28
|
-
* entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
|
|
29
|
-
*/
|
|
30
|
-
type Loader = NonNullable<BunBuildOptions["loader"]>[string];
|
|
31
|
-
/**
|
|
32
|
-
* Entry point files for TypeScript declaration file generation
|
|
33
|
-
*
|
|
34
|
-
* This can be:
|
|
35
|
-
* - A string path to a file
|
|
36
|
-
* - An array of file paths
|
|
37
|
-
* - An object where keys are output names and values are input file paths
|
|
38
|
-
*
|
|
39
|
-
* The key names are used for the generated declaration files.
|
|
40
|
-
* For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
|
|
41
|
-
*
|
|
42
|
-
* If not specified, the main entry points will be used for declaration file generation.
|
|
43
|
-
*
|
|
44
|
-
* If it's a string or an array of strings, the file name (without extension)
|
|
45
|
-
* will be used as the name for the output declaration file.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* // Using a string path
|
|
49
|
-
* entry: 'src/index.ts' // Generates index.d.ts
|
|
50
|
-
*
|
|
51
|
-
* // Using string paths in an array
|
|
52
|
-
* entry: ['src/index.ts'] // Generates index.d.ts
|
|
53
|
-
*
|
|
54
|
-
* // Using named outputs as an object
|
|
55
|
-
* entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
|
|
56
|
-
*/
|
|
57
|
-
type Define = BunBuildOptions["define"];
|
|
58
|
-
/**
|
|
59
|
-
* Entry point files for TypeScript declaration file generation
|
|
60
|
-
*
|
|
61
|
-
* This can be:
|
|
62
|
-
* - A string path to a file
|
|
63
|
-
* - An array of file paths
|
|
64
|
-
* - An object where keys are output names and values are input file paths
|
|
65
|
-
*
|
|
66
|
-
* The key names are used for the generated declaration files.
|
|
67
|
-
* For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
|
|
68
|
-
*
|
|
69
|
-
* If not specified, the main entry points will be used for declaration file generation.
|
|
70
|
-
*
|
|
71
|
-
* If it's a string or an array of strings, the file name (without extension)
|
|
72
|
-
* will be used as the name for the output declaration file.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* // Using a string path
|
|
76
|
-
* entry: 'src/index.ts' // Generates index.d.ts
|
|
77
|
-
*
|
|
78
|
-
* // Using string paths in an array
|
|
79
|
-
* entry: ['src/index.ts'] // Generates index.d.ts
|
|
80
|
-
*
|
|
81
|
-
* // Using named outputs as an object
|
|
82
|
-
* entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
|
|
83
|
-
*/
|
|
84
|
-
type Sourcemap = BunBuildOptions["sourcemap"];
|
|
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
|
-
type Format = Exclude<BunBuildOptions["format"], undefined>;
|
|
112
|
-
/**
|
|
113
|
-
* Entry point files for TypeScript declaration file generation
|
|
114
|
-
*
|
|
115
|
-
* This can be:
|
|
116
|
-
* - A string path to a file
|
|
117
|
-
* - An array of file paths
|
|
118
|
-
* - An object where keys are output names and values are input file paths
|
|
119
|
-
*
|
|
120
|
-
* The key names are used for the generated declaration files.
|
|
121
|
-
* For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
|
|
122
|
-
*
|
|
123
|
-
* If not specified, the main entry points will be used for declaration file generation.
|
|
124
|
-
*
|
|
125
|
-
* If it's a string or an array of strings, the file name (without extension)
|
|
126
|
-
* will be used as the name for the output declaration file.
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* // Using a string path
|
|
130
|
-
* entry: 'src/index.ts' // Generates index.d.ts
|
|
131
|
-
*
|
|
132
|
-
* // Using string paths in an array
|
|
133
|
-
* entry: ['src/index.ts'] // Generates index.d.ts
|
|
134
|
-
*
|
|
135
|
-
* // Using named outputs as an object
|
|
136
|
-
* entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
|
|
137
|
-
*/
|
|
138
|
-
type Target = BunBuildOptions["target"];
|
|
139
|
-
/**
|
|
140
|
-
* Entry point files for TypeScript declaration file generation
|
|
141
|
-
*
|
|
142
|
-
* This can be:
|
|
143
|
-
* - A string path to a file
|
|
144
|
-
* - An array of file paths
|
|
145
|
-
* - An object where keys are output names and values are input file paths
|
|
146
|
-
*
|
|
147
|
-
* The key names are used for the generated declaration files.
|
|
148
|
-
* For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
|
|
149
|
-
*
|
|
150
|
-
* If not specified, the main entry points will be used for declaration file generation.
|
|
151
|
-
*
|
|
152
|
-
* If it's a string or an array of strings, the file name (without extension)
|
|
153
|
-
* will be used as the name for the output declaration file.
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* // Using a string path
|
|
157
|
-
* entry: 'src/index.ts' // Generates index.d.ts
|
|
158
|
-
*
|
|
159
|
-
* // Using string paths in an array
|
|
160
|
-
* entry: ['src/index.ts'] // Generates index.d.ts
|
|
161
|
-
*
|
|
162
|
-
* // Using named outputs as an object
|
|
163
|
-
* entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
|
|
164
|
-
*/
|
|
165
|
-
type External = (string | RegExp)[];
|
|
166
|
-
/**
|
|
167
|
-
* Entry point files for TypeScript declaration file generation
|
|
168
|
-
*
|
|
169
|
-
* This can be:
|
|
170
|
-
* - A string path to a file
|
|
171
|
-
* - An array of file paths
|
|
172
|
-
* - An object where keys are output names and values are input file paths
|
|
173
|
-
*
|
|
174
|
-
* The key names are used for the generated declaration files.
|
|
175
|
-
* For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
|
|
176
|
-
*
|
|
177
|
-
* If not specified, the main entry points will be used for declaration file generation.
|
|
178
|
-
*
|
|
179
|
-
* If it's a string or an array of strings, the file name (without extension)
|
|
180
|
-
* will be used as the name for the output declaration file.
|
|
181
|
-
*
|
|
182
|
-
* @example
|
|
183
|
-
* // Using a string path
|
|
184
|
-
* entry: 'src/index.ts' // Generates index.d.ts
|
|
185
|
-
*
|
|
186
|
-
* // Using string paths in an array
|
|
187
|
-
* entry: ['src/index.ts'] // Generates index.d.ts
|
|
188
|
-
*
|
|
189
|
-
* // Using named outputs as an object
|
|
190
|
-
* entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
|
|
191
|
-
*/
|
|
192
|
-
type Entry = Arrayable<string> | Record<string, string>;
|
|
193
|
-
/**
|
|
194
|
-
* Entry point files for TypeScript declaration file generation
|
|
195
|
-
*
|
|
196
|
-
* This can be:
|
|
197
|
-
* - A string path to a file
|
|
198
|
-
* - An array of file paths
|
|
199
|
-
* - An object where keys are output names and values are input file paths
|
|
200
|
-
*
|
|
201
|
-
* The key names are used for the generated declaration files.
|
|
202
|
-
* For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
|
|
203
|
-
*
|
|
204
|
-
* If not specified, the main entry points will be used for declaration file generation.
|
|
205
|
-
*
|
|
206
|
-
* If it's a string or an array of strings, the file name (without extension)
|
|
207
|
-
* will be used as the name for the output declaration file.
|
|
208
|
-
*
|
|
209
|
-
* @example
|
|
210
|
-
* // Using a string path
|
|
211
|
-
* entry: 'src/index.ts' // Generates index.d.ts
|
|
212
|
-
*
|
|
213
|
-
* // Using string paths in an array
|
|
214
|
-
* entry: ['src/index.ts'] // Generates index.d.ts
|
|
215
|
-
*
|
|
216
|
-
* // Using named outputs as an object
|
|
217
|
-
* entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
|
|
218
|
-
*/
|
|
219
|
-
type DtsOptions = {
|
|
220
|
-
/**
|
|
221
|
-
* Entry point files for TypeScript declaration file generation
|
|
222
|
-
*
|
|
223
|
-
* This can be:
|
|
224
|
-
* - A string path to a file
|
|
225
|
-
* - An array of file paths
|
|
226
|
-
* - An object where keys are output names and values are input file paths
|
|
227
|
-
*
|
|
228
|
-
* The key names are used for the generated declaration files.
|
|
229
|
-
* For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
|
|
230
|
-
*
|
|
231
|
-
* If not specified, the main entry points will be used for declaration file generation.
|
|
232
|
-
*
|
|
233
|
-
* If it's a string or an array of strings, the file name (without extension)
|
|
234
|
-
* will be used as the name for the output declaration file.
|
|
235
|
-
*
|
|
236
|
-
* @example
|
|
237
|
-
* // Using a string path
|
|
238
|
-
* entry: 'src/index.ts' // Generates index.d.ts
|
|
239
|
-
*
|
|
240
|
-
* // Using string paths in an array
|
|
241
|
-
* entry: ['src/index.ts'] // Generates index.d.ts
|
|
242
|
-
*
|
|
243
|
-
* // Using named outputs as an object
|
|
244
|
-
* entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
|
|
245
|
-
*/
|
|
246
|
-
entry?: Entry
|
|
247
|
-
/**
|
|
248
|
-
* Resolve external types used in dts files from node_modules
|
|
249
|
-
*/
|
|
250
|
-
resolve?: boolean | (string | RegExp)[]
|
|
251
|
-
};
|
|
252
|
-
/**
|
|
253
|
-
* Name of the build configuration
|
|
254
|
-
* Used for logging and identification purposes
|
|
255
|
-
*/
|
|
256
|
-
interface BunupOptions {
|
|
257
|
-
/**
|
|
258
|
-
* Name of the build configuration
|
|
259
|
-
* Used for logging and identification purposes
|
|
260
|
-
*/
|
|
261
|
-
name?: string;
|
|
262
|
-
/**
|
|
263
|
-
* Entry point files for the build
|
|
264
|
-
*
|
|
265
|
-
* This can be:
|
|
266
|
-
* - A string path to a file
|
|
267
|
-
* - An array of file paths
|
|
268
|
-
* - An object where keys are output names and values are input file paths
|
|
269
|
-
*
|
|
270
|
-
* The key names are used for the generated output files.
|
|
271
|
-
* For example, `{custom: 'src/index.ts'}` will generate `custom.js`
|
|
272
|
-
*
|
|
273
|
-
* If it's a string or an array of strings, the file name (without extension)
|
|
274
|
-
* will be used as the name for the output file.
|
|
275
|
-
*
|
|
276
|
-
* @example
|
|
277
|
-
* // Using a string path
|
|
278
|
-
* entry: 'src/index.ts' // Generates index.js
|
|
279
|
-
*
|
|
280
|
-
* // Using string paths in an array
|
|
281
|
-
* entry: ['src/index.ts'] // Generates index.js
|
|
282
|
-
*
|
|
283
|
-
* // Using named outputs as an object
|
|
284
|
-
* entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.js and utils.js
|
|
285
|
-
*/
|
|
286
|
-
entry: Entry;
|
|
287
|
-
/**
|
|
288
|
-
* Output directory for the bundled files
|
|
289
|
-
* Defaults to 'dist' if not specified
|
|
290
|
-
*/
|
|
291
|
-
outDir: string;
|
|
292
|
-
/**
|
|
293
|
-
* Output formats for the bundle
|
|
294
|
-
* Can include 'esm', 'cjs', and/or 'iife'
|
|
295
|
-
* Defaults to ['cjs'] if not specified
|
|
296
|
-
*/
|
|
297
|
-
format: Format[];
|
|
298
|
-
/**
|
|
299
|
-
* Whether to enable all minification options
|
|
300
|
-
* When true, enables minifyWhitespace, minifyIdentifiers, and minifySyntax
|
|
301
|
-
*/
|
|
302
|
-
minify?: boolean;
|
|
303
|
-
/**
|
|
304
|
-
* Whether to enable code splitting
|
|
305
|
-
* Defaults to true for ESM format, false for CJS format
|
|
306
|
-
*/
|
|
307
|
-
splitting?: boolean;
|
|
308
|
-
/**
|
|
309
|
-
* Whether to minify whitespace in the output
|
|
310
|
-
* Removes unnecessary whitespace to reduce file size
|
|
311
|
-
*/
|
|
312
|
-
minifyWhitespace?: boolean;
|
|
313
|
-
/**
|
|
314
|
-
* Whether to minify identifiers in the output
|
|
315
|
-
* Renames variables and functions to shorter names
|
|
316
|
-
*/
|
|
317
|
-
minifyIdentifiers?: boolean;
|
|
318
|
-
/**
|
|
319
|
-
* Whether to minify syntax in the output
|
|
320
|
-
* Optimizes code structure for smaller file size
|
|
321
|
-
*/
|
|
322
|
-
minifySyntax?: boolean;
|
|
323
|
-
/**
|
|
324
|
-
* Whether to watch for file changes and rebuild automatically
|
|
325
|
-
*/
|
|
326
|
-
watch?: boolean;
|
|
327
|
-
/**
|
|
328
|
-
* Whether to generate TypeScript declaration files (.d.ts)
|
|
329
|
-
* When set to true, generates declaration files for all entry points
|
|
330
|
-
* Can also be configured with DtsOptions for more control
|
|
331
|
-
*/
|
|
332
|
-
dts?: boolean | DtsOptions;
|
|
333
|
-
/**
|
|
334
|
-
* Path to a preferred tsconfig.json file to use for declaration generation
|
|
335
|
-
*
|
|
336
|
-
* If not specified, the tsconfig.json in the project root will be used.
|
|
337
|
-
* This option allows you to use a different TypeScript configuration
|
|
338
|
-
* specifically for declaration file generation.
|
|
339
|
-
*
|
|
340
|
-
* @example
|
|
341
|
-
* preferredTsconfigPath: './tsconfig.build.json'
|
|
342
|
-
*/
|
|
343
|
-
preferredTsconfigPath?: string;
|
|
344
|
-
/**
|
|
345
|
-
* External packages that should not be bundled
|
|
346
|
-
* Useful for dependencies that should be kept as external imports
|
|
347
|
-
*/
|
|
348
|
-
external?: External;
|
|
349
|
-
/**
|
|
350
|
-
* Packages that should be bundled even if they are in external
|
|
351
|
-
* Useful for dependencies that should be included in the bundle
|
|
352
|
-
*/
|
|
353
|
-
noExternal?: External;
|
|
354
|
-
/**
|
|
355
|
-
* The target environment for the bundle
|
|
356
|
-
* Can be 'browser', 'bun', 'node', etc.
|
|
357
|
-
* Defaults to 'node' if not specified
|
|
358
|
-
*/
|
|
359
|
-
target?: Target;
|
|
360
|
-
/**
|
|
361
|
-
* Whether to clean the output directory before building
|
|
362
|
-
* When true, removes all files in the outDir before starting a new build
|
|
363
|
-
* Defaults to true if not specified
|
|
364
|
-
*/
|
|
365
|
-
clean?: boolean;
|
|
366
|
-
/**
|
|
367
|
-
* Specifies the type of sourcemap to generate
|
|
368
|
-
* Can be 'none', 'linked', 'external', or 'inline'
|
|
369
|
-
*
|
|
370
|
-
* @see https://bun.sh/docs/bundler#sourcemap
|
|
371
|
-
*
|
|
372
|
-
* @default 'none'
|
|
373
|
-
*
|
|
374
|
-
* @example
|
|
375
|
-
* sourcemap: 'linked'
|
|
376
|
-
*/
|
|
377
|
-
sourcemap?: Sourcemap;
|
|
378
|
-
/**
|
|
379
|
-
* Define global constants for the build
|
|
380
|
-
* These values will be replaced at build time
|
|
381
|
-
*
|
|
382
|
-
* @see https://bun.sh/docs/bundler#define
|
|
383
|
-
*
|
|
384
|
-
* @example
|
|
385
|
-
* define: {
|
|
386
|
-
* 'process.env.NODE_ENV': '"production"',
|
|
387
|
-
* 'PACKAGE_VERSION': '"1.0.0"'
|
|
388
|
-
* }
|
|
389
|
-
*/
|
|
390
|
-
define?: Define;
|
|
391
|
-
/**
|
|
392
|
-
* A callback function that runs after the build process completes
|
|
393
|
-
* This can be used for custom post-build operations like copying files,
|
|
394
|
-
* running additional tools, or logging build information
|
|
395
|
-
*
|
|
396
|
-
* If watch mode is enabled, this callback runs after each rebuild
|
|
397
|
-
*/
|
|
398
|
-
onBuildSuccess?: () => PromiseOr<void>;
|
|
399
|
-
/**
|
|
400
|
-
* 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.
|
|
401
|
-
*
|
|
402
|
-
* @see https://bun.sh/docs/bundler#banner
|
|
403
|
-
*
|
|
404
|
-
* @example
|
|
405
|
-
* banner: '"use client";'
|
|
406
|
-
*/
|
|
407
|
-
banner?: string;
|
|
408
|
-
/**
|
|
409
|
-
* 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.
|
|
410
|
-
*
|
|
411
|
-
* @see https://bun.sh/docs/bundler#footer
|
|
412
|
-
*
|
|
413
|
-
* @example
|
|
414
|
-
* footer: '// built with love in SF'
|
|
415
|
-
*/
|
|
416
|
-
footer?: string;
|
|
417
|
-
/**
|
|
418
|
-
* 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.
|
|
419
|
-
*
|
|
420
|
-
* @see https://bun.sh/docs/bundler#drop
|
|
421
|
-
*
|
|
422
|
-
* @example
|
|
423
|
-
* drop: ["console", "debugger", "anyIdentifier.or.propertyAccess"]
|
|
424
|
-
*/
|
|
425
|
-
drop?: string[];
|
|
426
|
-
/**
|
|
427
|
-
* 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.
|
|
428
|
-
*
|
|
429
|
-
* @see https://bun.sh/docs/bundler#loader
|
|
430
|
-
*
|
|
431
|
-
* @example
|
|
432
|
-
* loader: {
|
|
433
|
-
* ".png": "dataurl",
|
|
434
|
-
* ".txt": "file",
|
|
435
|
-
* }
|
|
436
|
-
*/
|
|
437
|
-
loader?: Record<string, Loader>;
|
|
438
|
-
/**
|
|
439
|
-
* Generate bytecode for the output. This can dramatically improve cold start times, but will make the final output larger and slightly increase memory usage.
|
|
440
|
-
*
|
|
441
|
-
* Bytecode is currently only supported for CommonJS (format: "cjs").
|
|
442
|
-
*
|
|
443
|
-
* Must be target: "bun"
|
|
444
|
-
*
|
|
445
|
-
* @see https://bun.sh/docs/bundler#bytecode
|
|
446
|
-
*
|
|
447
|
-
* @default false
|
|
448
|
-
*/
|
|
449
|
-
bytecode?: boolean;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
//#endregion
|
|
453
|
-
//#region \0dts:/home/runner/work/bunup/bunup/src/types.d.ts
|
|
454
|
-
type PromiseOr<T> = Promise<T> | T;
|
|
455
|
-
type WithOptional<
|
|
456
|
-
T,
|
|
457
|
-
K extends keyof T
|
|
458
|
-
> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
459
|
-
type Arrayable<T> = T | T[];
|
|
460
|
-
type Bun = typeof _Bun;
|
|
461
|
-
type BunBuildOptions = Parameters<Bun["build"]>[0];
|
|
462
|
-
type DefineConfigEntry = Omit<WithOptional<BunupOptions, "outDir" | "format">, "watch">;
|
|
463
|
-
type DefineWorkspaceEntry = {
|
|
464
|
-
name: string
|
|
465
|
-
root: string
|
|
466
|
-
config: DefineConfigEntry | DefineConfigEntry[]
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
//#endregion
|
|
470
|
-
//#region \0dts:/home/runner/work/bunup/bunup/src/define.d.ts
|
|
471
|
-
declare function defineConfig(options: Arrayable<DefineConfigEntry>): Arrayable<DefineConfigEntry>;
|
|
472
|
-
declare function defineWorkspace(options: DefineWorkspaceEntry[]): DefineWorkspaceEntry[];
|
|
473
|
-
|
|
474
|
-
//#endregion
|
|
475
|
-
//#region \0dts:/home/runner/work/bunup/bunup/src/build.d.ts
|
|
476
|
-
declare function build(options: BunupOptions, rootDir: string): Promise<void>;
|
|
477
|
-
|
|
478
|
-
//#endregion
|
|
479
|
-
export { DefineConfigEntry, DefineWorkspaceEntry, build, defineConfig, defineWorkspace };
|
package/build/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var St=require("node:module");var Mt=Object.create;var{getPrototypeOf:Bt,defineProperty:y,getOwnPropertyNames:j,getOwnPropertyDescriptor:Tt}=Object,q=Object.prototype.hasOwnProperty;var E=(t,e,n)=>{n=t!=null?Mt(Bt(t)):{};let r=e||!t||!t.__esModule?y(n,"default",{value:t,enumerable:!0}):n;for(let i of j(t))if(!q.call(r,i))y(r,i,{get:()=>t[i],enumerable:!0});return r},F=new WeakMap,Lt=(t)=>{var e=F.get(t),n;if(e)return e;if(e=y({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")j(t).map((r)=>!q.call(e,r)&&y(e,r,{get:()=>t[r],enumerable:!(n=Tt(t,r))||n.enumerable}));return F.set(t,e),e};var At=(t,e)=>{for(var n in e)y(t,n,{get:e[n],enumerable:!0,configurable:!0,set:(r)=>e[n]=()=>r})};var Kt={};At(Kt,{defineWorkspace:()=>X,defineConfig:()=>G,build:()=>Rt});module.exports=Lt(Kt);function G(t){return t}function X(t){return t}var ct=require("rolldown"),ut=require("rolldown-plugin-dts");class I extends Error{constructor(t){super(t);this.name="BunupError"}}class $ extends I{constructor(t){super(t);this.name="BunupBuildError"}}class p extends I{constructor(t){super(t);this.name="BunupDTSBuildError"}}var d=(t)=>{if(t instanceof Error)return t.message;return String(t)};var Ot=E(require("node:fs/promises")),Wt=E(require("node:path"));function H(t,e){return{outdir:`${e}/${t.outDir}`,minify:It(t),target:t.target,splitting:t.splitting,sourcemap:t.sourcemap,define:t.define,loader:t.loader,drop:t.drop,banner:t.banner,footer:t.footer}}function It(t){let{minify:e,minifyWhitespace:n,minifyIdentifiers:r,minifySyntax:i}=t,s=e===!0;return{whitespace:n??s,identifiers:r??s,syntax:i??s}}function O(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k(t=8){return Math.random().toString(36).substring(2,2+t)}function K(t,e){switch(t){case"esm":return".mjs";case"cjs":return D(e)?".cjs":".js";case"iife":return".global.js"}}function Y(t,e){switch(t){case"esm":return".d.mts";case"cjs":return D(e)?".d.cts":".d.ts";case"iife":return".d.ts"}}function D(t){return t==="module"}function Q(t){if(!t)return[];return Array.from(new Set([...Object.keys(t.dependencies||{}),...Object.keys(t.peerDependencies||{})]))}function Z(t,e){return t===void 0?e==="esm":t}function W(t){if(t===0)return"0 B";let e=["B","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(1024));if(n===0)return`${t} ${e[n]}`;return`${(t/1024**n).toFixed(2)} ${e[n]}`}function b(t,e=3){return t.split("/").slice(-e).join("/")}function z(t,e){return e==="cjs"?t:void 0}function J(t){return t.map((e)=>typeof e==="string"?new RegExp(`^${O(e)}($|\\/|\\\\)`):e)}function M(t,e){return J(t.external||[]).concat(Q(e).map((n)=>new RegExp(`^${O(n)}($|\\/|\\\\)`)))}function B(t){return J(t.noExternal||[])}var it=E(require("node:path")),ot=require("oxc-resolver");var x=E(require("node:path"));var P="\x00dts:",tt=(t,e,n)=>{return{name:"bunup:virtual-dts",async resolveId(r,i){if(_(r))return r;if(!i||!_(i))return null;let s=await T(r,e,n,C(i));if(!s)return null;let o=w(s);if(t.has(o))return L(o);return null},load(r){if(r.startsWith(P)){let i=C(r),s=t.get(i);if(s)return et.add(i),s}return null}}};function nt(t){return t.tsconfig?.compilerOptions}function w(t){return t.replace(/\.tsx?$/,".d.ts")}function N(t){let e=x.default.dirname(t.path||""),n=nt(t);return n?.baseUrl?x.default.resolve(e,n.baseUrl):e}function rt(t){let e=new Map,n=nt(t)?.paths;if(!n)return e;let r=N(t);for(let[i,s]of Object.entries(n))if(Array.isArray(s)&&s.length){let o=i.replace(/\*/g,"(.*)"),a=s[0].replace(/\*/g,"$1");e.set(`^${o}$`,x.default.join(r,a))}return e}function _t(t,e,n){for(let[r,i]of e){let s=new RegExp(r),o=t.match(s);if(o)return i.replace("$1",o[1]||"")}return n?x.default.join(n,t):null}async function Nt(t){let e=["",".ts",".tsx","/index.ts","/index.tsx"];for(let n of e){let r=`${t}${n}`;if(await Bun.file(r).exists()&&(r.endsWith(".ts")||r.endsWith(".tsx")))return r}return null}function T(t,e,n,r){let i=t.startsWith(".")?x.default.resolve(x.default.dirname(r||""),t):_t(t,e,n);if(!i)return Promise.resolve(null);return Nt(i)}function _(t){return t.startsWith(P)}function C(t){return t.replace(P,"")}function L(t){return`${P}${t}`}var st;function at(t){return{name:"bunup:types-resolve",buildStart(){st||=new ot.ResolverFactory({mainFields:["types"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".ts"],modules:["node_modules","node_modules/@types"]})},async resolveId(e,n){let r=n?C(n):void 0;if(/\0/.test(e))return;if(t){if(!t.some((a)=>{let c=!1;if(typeof a==="string")c=a===e||!!r?.includes(a);else c=a.test(e)||!!(r&&a.test(r));return c}))return}let i=r?it.default.dirname(r):process.cwd(),{path:s}=await st.async(i,e);if(!s)return;if(/[cm]?jsx?$/.test(s)){let o=s.replace(/\.([cm]?)jsx?$/,".d.$1ts");return await Bun.file(o).exists()?o:void 0}return s}}}async function lt(t,e,n,r,i,s){let o=w(t),a=L(o),c=M(n,r),l=B(n);try{let{output:f}=await ct.build({input:a,output:{dir:n.outDir,inlineDynamicImports:!0},write:!1,onwarn(u,m){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(u.code??""))return;m(u)},plugins:[tt(e,i,s),typeof n.dts==="object"&&"resolve"in n.dts&&at(typeof n.dts.resolve==="boolean"?void 0:n.dts.resolve),ut.dts({dtsInput:!0})],external:(u)=>c.some((m)=>m.test(u))&&!l.some((m)=>m.test(u))});if(!f[0]?.code)throw new p("Generated bundle is empty");return f[0].code}catch(f){throw new p(`DTS bundling failed: ${d(f)}`)}}class R{static instance;loggedOnceMessages=new Set;MAX_LABEL_LENGTH=3;MAX_MESSAGE_LENGTH=25;colors={cli:"147",info:"245",warn:"179",error:"174",progress:{ESM:"172",CJS:"108",IIFE:"146",DTS:"110"},default:"252",size:"65"};labels={cli:"CLI",info:"INFO",warn:"WARN",error:"ERROR"};constructor(){}static getInstance(){if(!R.instance)R.instance=new R;return R.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(t){if(!t?.once)return!0;if(this.loggedOnceMessages.has(t.once))return!1;return this.loggedOnceMessages.add(t.once),!0}formatMessage({colorCode:t,label:e,message:n,size:r,identifier:i,muted:s}){let o=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-e.length)),a=s?`\x1B[38;5;${this.colors.info}m${n}\x1B[0m`:n;if(r){let[l,...f]=a.split(" "),u=" ".repeat(Math.max(0,this.MAX_MESSAGE_LENGTH-l.length)),m=i?` \x1B[48;5;${t};38;5;0m ${i} \x1B[0m`:"";return`\x1B[38;5;${t}m${e}\x1B[0m ${o}${l}${u} \x1B[38;5;${this.colors.size}m${r}\x1B[0m ${f.join(" ")}${m}`}let c=i?` \x1B[48;5;${t};38;5;0m ${i} \x1B[0m`:"";return`\x1B[38;5;${t}m${e}\x1B[0m ${o}${a}${c}`}output(t,e={},n=console.log){if(!this.shouldLog(e))return;if(e.verticalSpace)console.log("");if(n(t),e.verticalSpace)console.log("")}cli(t,e={}){let n=this.formatMessage({colorCode:this.colors.cli,label:this.labels.cli,message:t,identifier:e.identifier,muted:e.muted});this.output(n,e)}info(t,e={}){let n=this.formatMessage({colorCode:this.colors.info,label:this.labels.info,message:t,identifier:e.identifier,muted:e.muted});this.output(n,e)}warn(t,e={}){let n=this.formatMessage({colorCode:this.colors.warn,label:this.labels.warn,message:t,identifier:e.identifier,muted:e.muted});this.output(n,e,console.warn)}error(t,e={}){let n=this.formatMessage({colorCode:this.colors.error,label:this.labels.error,message:t,identifier:e.identifier,muted:e.muted});this.output(n,e,console.error)}progress(t,e,n,r){let i=String(t),s=this.colors.default,o,a,c={};if(typeof n==="string")o=n,a=r;else if(n)o=n.size,a=n.identifier,c=n;for(let[f,u]of Object.entries(this.colors.progress))if(i.includes(f)){s=u;break}let l=this.formatMessage({colorCode:s,label:i,message:e,size:o,identifier:a,muted:c.muted});this.output(l,c)}}var g=R.getInstance();var Ut=/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]/gm,vt=/^\s*export\s+.*from\s+['"]([^'"]+)['"]/gm,Vt=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,Ft=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,jt=/import\s+\w+\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,qt=/\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/g,Gt=/\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/g;function Xt(t){let e=new Set,n=[Ut,vt,Vt,Ft,jt,qt,Gt];for(let r of n){let i=t.matchAll(r);for(let s of i)if(s[1])e.add(s[1])}return e}async function gt(t,e,n){let r=new Set([t]),i=[t];while(i.length){let s=i.pop();if(!s)continue;try{let o=await Bun.file(s).text(),a=Xt(o);for(let c of a){let l=await T(c,e,n,s);if(!l)continue;if(!r.has(l))r.add(l),i.push(l)}}catch(o){g.warn(`Error processing ${s}: ${d(o)}`)}}return r}var ft=require("oxc-transform");async function mt(t){let e=new Map;return await Promise.all([...t].map(async(n)=>{try{let r=w(n);if(!await Bun.file(n).exists())return;let s=await Bun.file(n).text(),{code:o}=ft.isolatedDeclaration(n,s);if(o)e.set(r,o)}catch(r){g.warn(`Failed to generate declaration for ${n}: ${d(r)}`)}})),e}var U=E(require("node:fs/promises")),A=E(require("node:path")),Ht=require("oxc-transform");async function pt(t,e){let n=A.default.resolve(t),r=A.default.resolve(n,e);if(!await U.default.exists(n))throw new p(`Root directory does not exist: ${n}`);if(!await Bun.file(r).exists())throw new p(`Entry file does not exist: ${r}`);if(!r.endsWith(".ts"))throw new p(`Entry file must be a TypeScript file (.ts): ${r}`);if(A.default.relative(n,r).startsWith(".."))throw new p(`Entry file must be within rootDir: ${r}`);return{absoluteRootDir:n,absoluteEntry:r}}async function dt(t,e,n,r,i){let{absoluteEntry:s}=await pt(t,e),o=rt(r),a=N(r),c=await gt(s,o,a),l=await mt(c);return lt(s,l,n,i,o,a)}function xt(t){return t.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function v(t){let e=[],n=new Set,r={};function i(s,o){if(n.has(s)){let a=k(),c=`${s}_${a}`;g.warn(`Output name conflict: "${s}" is used by multiple files.
|
|
2
|
-
Bunup uses filenames without extensions as output names by default.
|
|
3
|
-
|
|
4
|
-
${r[s]} -> ${s}.js
|
|
5
|
-
${o} -> ${c}.js (auto-renamed to avoid conflict)
|
|
6
|
-
|
|
7
|
-
To fix this, use named entries in your configuration:
|
|
8
|
-
{
|
|
9
|
-
entry: {
|
|
10
|
-
custom_name: "${r[s]}",
|
|
11
|
-
another_name: "${o}"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),e.push({name:c,path:o})}else e.push({name:s,path:o}),n.add(s),r[s]=o}if(Array.isArray(t))for(let s of t){let o=xt(s);i(o,s)}else if(typeof t==="object")for(let[s,o]of Object.entries(t))i(s,o);else{let s=xt(t);i(s,t)}return e}function ht(t,e){return`[dir]/${t}${e}`}var V=require("coffi");async function Et(t){let{config:e,filepath:n}=await V.loadConfig({name:"package",cwd:t,extensions:[".json"],maxDepth:1});return{packageJson:e,path:n}}async function bt(t,e){let{config:n,filepath:r}=await V.loadConfig({name:"tsconfig",cwd:t,extensions:[".json"],preferredPath:e,maxDepth:3});return{tsconfig:n,path:r}}function wt(t,e){return{name:"bunup:external-plugin",setup(n){n.onResolve({filter:/.*/},(r)=>{let i=r.path;if(t.some((o)=>o.test(i))&&!e.some((o)=>o.test(i)))return{path:i,external:!0};return null})}}}var et=new Set;async function Rt(t,e){if(!t.entry||t.entry.length===0||!t.outDir)throw new $("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let{packageJson:n,path:r}=await Et(e);if(n&&r)g.cli(`Using package.json: ${b(r,2)}`,{muted:!0,identifier:t.name,once:`${r}:${t.name}`});let i=n?.type,s=M(t,n),o=B(t),a=[wt(s,o)],c=v(t.entry),l=H(t,e),f=t.format.flatMap((u)=>c.map((m)=>{return kt(t,e,m,u,i,a,l)}));if(await Promise.all(f),t.dts){let u=await bt(e,t.preferredTsconfigPath);if(u.path)g.cli(`Using tsconfig: ${b(u.path,2)}`,{muted:!0,identifier:t.name,once:`${u.path}:${t.name}`});let m=t.format.filter((h)=>{if(h==="iife"&&!D(i)&&t.format.includes("cjs"))return!1;return!0}),yt=typeof t.dts==="object"&&t.dts.entry?v(t.dts.entry):c;try{await Promise.all(yt.map(async(h)=>{let $t=await dt(e,h.path,t,u,n);await Promise.all(m.map(async(Ct)=>{let Pt=Y(Ct,i),S=`${e}/${t.outDir}/${h.name}${Pt}`;await Bun.write(S,$t);let Dt=Bun.file(S).size||0;g.progress("DTS",b(S),W(Dt),t.name)}))}))}catch(h){throw new p(d(h))}}}async function kt(t,e,n,r,i,s,o){let a=K(r,i),c=await Bun.build({...o,entrypoints:[`${e}/${n.path}`],format:r,naming:{entry:ht(n.name,a)},splitting:Z(t.splitting,r),bytecode:z(t.bytecode,r),plugins:s,throw:!1});if(!c.success)for(let u of c.logs){if(u.level==="error")throw new $(u.message);if(u.level==="warning")g.warn(u.message);else if(u.level==="info")g.info(u.message)}let l=`${e}/${t.outDir}/${n.name}${a}`,f=Bun.file(l).size||0;g.progress(r.toUpperCase(),b(l),W(f),t.name)}
|