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.mts
CHANGED
|
@@ -1,221 +1,13 @@
|
|
|
1
1
|
import _Bun from "bun";
|
|
2
2
|
|
|
3
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
4
|
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
5
|
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
6
|
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
7
|
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
8
|
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
9
|
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
10
|
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
11
|
type DtsOptions = {
|
|
220
12
|
/**
|
|
221
13
|
* Entry point files for TypeScript declaration file generation
|
|
@@ -249,11 +41,7 @@ type DtsOptions = {
|
|
|
249
41
|
*/
|
|
250
42
|
resolve?: boolean | (string | RegExp)[]
|
|
251
43
|
};
|
|
252
|
-
|
|
253
|
-
* Name of the build configuration
|
|
254
|
-
* Used for logging and identification purposes
|
|
255
|
-
*/
|
|
256
|
-
interface BunupOptions {
|
|
44
|
+
interface BuildOptions {
|
|
257
45
|
/**
|
|
258
46
|
* Name of the build configuration
|
|
259
47
|
* Used for logging and identification purposes
|
|
@@ -447,6 +235,12 @@ interface BunupOptions {
|
|
|
447
235
|
* @default false
|
|
448
236
|
*/
|
|
449
237
|
bytecode?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Disable logging during the build process. When set to true, no logs will be printed to the console.
|
|
240
|
+
*
|
|
241
|
+
* @default false
|
|
242
|
+
*/
|
|
243
|
+
silent?: boolean;
|
|
450
244
|
}
|
|
451
245
|
|
|
452
246
|
//#endregion
|
|
@@ -459,21 +253,21 @@ type WithOptional<
|
|
|
459
253
|
type Arrayable<T> = T | T[];
|
|
460
254
|
type Bun = typeof _Bun;
|
|
461
255
|
type BunBuildOptions = Parameters<Bun["build"]>[0];
|
|
462
|
-
type
|
|
463
|
-
type
|
|
256
|
+
type DefineConfigItem = Omit<WithOptional<BuildOptions, "outDir" | "format">, "watch">;
|
|
257
|
+
type DefineWorkspaceItem = {
|
|
464
258
|
name: string
|
|
465
259
|
root: string
|
|
466
|
-
config:
|
|
260
|
+
config: DefineConfigItem | DefineConfigItem[]
|
|
467
261
|
};
|
|
468
262
|
|
|
469
263
|
//#endregion
|
|
470
264
|
//#region \0dts:/home/runner/work/bunup/bunup/src/define.d.ts
|
|
471
|
-
declare function defineConfig(options: Arrayable<
|
|
472
|
-
declare function defineWorkspace(options:
|
|
265
|
+
declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
|
|
266
|
+
declare function defineWorkspace(options: DefineWorkspaceItem[]): DefineWorkspaceItem[];
|
|
473
267
|
|
|
474
268
|
//#endregion
|
|
475
269
|
//#region \0dts:/home/runner/work/bunup/bunup/src/build.d.ts
|
|
476
|
-
declare function build(options:
|
|
270
|
+
declare function build(options: BuildOptions, rootDir: string): Promise<void>;
|
|
477
271
|
|
|
478
272
|
//#endregion
|
|
479
|
-
export {
|
|
273
|
+
export { BuildOptions, DefineConfigItem, DefineWorkspaceItem, build, defineConfig, defineWorkspace };
|
package/build/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
function
|
|
1
|
+
function bt(t){return t}function Et(t){return t}import{build as Pt}from"rolldown";import{dts as Dt}from"rolldown-plugin-dts";class I extends Error{constructor(t){super(t);this.name="BunupError"}}class h 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)};import W from"node:fs/promises";import wt from"node:path";function L(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function U(t=8){let e="";while(e.length<t)e+=Math.random().toString(36).substring(2);return e.substring(0,t)}function v(t,e){switch(t){case"esm":return".mjs";case"cjs":return C(e)?".cjs":".js";case"iife":return".global.js"}}function F(t,e){switch(t){case"esm":return".d.mts";case"cjs":return C(e)?".d.cts":".d.ts";case"iife":return".d.ts"}}function C(t){return t==="module"}function V(t){if(!t)return[];return Array.from(new Set([...Object.keys(t.dependencies||{}),...Object.keys(t.peerDependencies||{})]))}function j(t,e){return t===void 0?e==="esm":t}function S(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("/")}async function G(t,e){let n=wt.join(t,e);try{await W.rm(n,{recursive:!0,force:!0})}catch(r){throw new h(`Failed to clean output directory: ${r}`)}await W.mkdir(n,{recursive:!0})}function q(t,e){return e==="cjs"?t:void 0}function X(t){return t.map((e)=>typeof e==="string"?new RegExp(`^${L(e)}($|\\/|\\\\)`):e)}function P(t,e){return X(t.external||[]).concat(V(e).map((n)=>new RegExp(`^${L(n)}($|\\/|\\\\)`)))}function D(t){return X(t.noExternal||[])}import $t from"node:path";import{ResolverFactory as Ct}from"oxc-resolver";import w from"node:path";var $="\x00dts:",H=(t,e,n)=>{return{name:"bunup:virtual-dts",async resolveId(r,i){if(A(r))return r;if(!i||!A(i))return null;let o=await M(r,e,n,y(i));if(!o)return null;let s=E(o);if(t.has(s))return T(s);return null},load(r){if(r.startsWith($)){let i=y(r),o=t.get(i);if(o)return k.add(i),o}return null}}};function K(t){return t.tsconfig?.compilerOptions}function E(t){return t.replace(/\.tsx?$/,".d.ts")}function O(t){let e=w.dirname(t.path||""),n=K(t);return n?.baseUrl?w.resolve(e,n.baseUrl):e}function Y(t){let e=new Map,n=K(t)?.paths;if(!n)return e;let r=O(t);for(let[i,o]of Object.entries(n))if(Array.isArray(o)&&o.length){let s=i.replace(/\*/g,"(.*)"),a=o[0].replace(/\*/g,"$1");e.set(`^${s}$`,w.join(r,a))}return e}function Rt(t,e,n){for(let[r,i]of e){let o=new RegExp(r),s=t.match(o);if(s)return i.replace("$1",s[1]||"")}return n?w.join(n,t):null}async function yt(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 M(t,e,n,r){let i=t.startsWith(".")?w.resolve(w.dirname(r||""),t):Rt(t,e,n);if(!i)return Promise.resolve(null);return yt(i)}function A(t){return t.startsWith($)}function y(t){return t.replace($,"")}function T(t){return`${$}${t}`}var Q;function Z(t){return{name:"bunup:types-resolve",buildStart(){Q||=new Ct({mainFields:["types"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".ts"],modules:["node_modules","node_modules/@types"]})},async resolveId(e,n){let r=n?y(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?$t.dirname(r):process.cwd(),{path:o}=await Q.async(i,e);if(!o)return;if(/[cm]?jsx?$/.test(o)){let s=o.replace(/\.([cm]?)jsx?$/,".d.$1ts");return await Bun.file(s).exists()?s:void 0}return o}}}async function z(t,e,n,r,i,o){let s=E(t),a=T(s),c=P(n,r),u=D(n);try{let{output:g}=await Pt({input:a,output:{dir:n.outDir,inlineDynamicImports:!0},write:!1,onwarn(l,m){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(l.code??""))return;m(l)},plugins:[H(e,i,o),typeof n.dts==="object"&&"resolve"in n.dts&&Z(typeof n.dts.resolve==="boolean"?void 0:n.dts.resolve),Dt({dtsInput:!0})],external:(l)=>c.some((m)=>m.test(l))&&!u.some((m)=>m.test(l))});if(!g[0]?.code)throw new p("Generated bundle is empty");return g[0].code}catch(g){throw new p(`DTS bundling failed: ${d(g)}`)}}var J=!1;function tt(t){J=t??!1}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:o}){let s=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-e.length)),a=o?`\x1B[38;5;${this.colors.info}m${n}\x1B[0m`:n;if(r){let[u,...g]=a.split(" "),l=" ".repeat(Math.max(0,this.MAX_MESSAGE_LENGTH-u.length)),m=i?` \x1B[48;5;${t};38;5;0m ${i} \x1B[0m`:"";return`\x1B[38;5;${t}m${e}\x1B[0m ${s}${u}${l} \x1B[38;5;${this.colors.size}m${r}\x1B[0m ${g.join(" ")}${m}`}let c=i?` \x1B[48;5;${t};38;5;0m ${i} \x1B[0m`:"";return`\x1B[38;5;${t}m${e}\x1B[0m ${s}${a}${c}`}output(t,e={},n=console.log){if(J)return;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),o=this.colors.default,s,a,c={};if(typeof n==="string")s=n,a=r;else if(n)s=n.size,a=n.identifier,c=n;for(let[g,l]of Object.entries(this.colors.progress))if(i.includes(g)){o=l;break}let u=this.formatMessage({colorCode:o,label:i,message:e,size:s,identifier:a,muted:c.muted});this.output(u,c)}}var f=R.getInstance();var Mt=/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]/gm,Tt=/^\s*export\s+.*from\s+['"]([^'"]+)['"]/gm,Bt=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,It=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,Lt=/import\s+\w+\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,St=/\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/g,At=/\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/g;function Ot(t){let e=new Set,n=[Mt,Tt,Bt,It,Lt,St,At];for(let r of n){let i=t.matchAll(r);for(let o of i)if(o[1])e.add(o[1])}return e}async function et(t,e,n){let r=new Set([t]),i=[t];while(i.length){let o=i.pop();if(!o)continue;try{let s=await Bun.file(o).text(),a=Ot(s);for(let c of a){let u=await M(c,e,n,o);if(!u)continue;if(!r.has(u))r.add(u),i.push(u)}}catch(s){f.warn(`Error processing ${o}: ${d(s)}`)}}return r}import{isolatedDeclaration as _t}from"oxc-transform";async function nt(t){let e=new Map;return await Promise.all([...t].map(async(n)=>{try{let r=E(n);if(!await Bun.file(n).exists())return;let o=await Bun.file(n).text(),{code:s}=_t(n,o);if(s)e.set(r,s)}catch(r){f.warn(`Failed to generate declaration for ${n}: ${d(r)}`)}})),e}import rt from"node:fs/promises";import _ from"node:path";import{isolatedDeclaration as Ce}from"oxc-transform";async function st(t,e){let n=_.resolve(t),r=_.resolve(n,e);if(!await rt.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(_.relative(n,r).startsWith(".."))throw new p(`Entry file must be within rootDir: ${r}`);return{absoluteRootDir:n,absoluteEntry:r}}async function it(t,e,n,r,i){let{absoluteEntry:o}=await st(t,e),s=Y(r),a=O(r),c=await et(o,s,a),u=await nt(c);return z(o,u,n,i,s,a)}function ot(t){return t.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function N(t,{warnOnConflict:e=!0}={}){let n=[],r=new Set,i={};function o(s,a){if(r.has(s)){let c=U(),u=`${s}_${c}`;if(e)f.warn(`Output name conflict: "${s}" is used by multiple files.
|
|
2
2
|
Bunup uses filenames without extensions as output names by default.
|
|
3
3
|
|
|
4
|
-
${
|
|
5
|
-
${
|
|
4
|
+
${i[s]} -> ${s}.js
|
|
5
|
+
${a} -> ${u}.js (auto-renamed to avoid conflict)
|
|
6
6
|
|
|
7
7
|
To fix this, use named entries in your configuration:
|
|
8
8
|
{
|
|
9
9
|
entry: {
|
|
10
|
-
custom_name: "${
|
|
11
|
-
another_name: "${
|
|
10
|
+
custom_name: "${i[s]}",
|
|
11
|
+
another_name: "${a}"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0})
|
|
15
|
+
See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0});n.push({name:u,path:a})}else n.push({name:s,path:a}),r.add(s),i[s]=a}if(Array.isArray(t))for(let s of t){let a=ot(s);o(a,s)}else if(typeof t==="object")for(let[s,a]of Object.entries(t))o(s,a);else{let s=ot(t);o(s,t)}return n}function at(t,e){return`[dir]/${t}${e}`}import{loadConfig as ct}from"coffi";async function lt(t){let{config:e,filepath:n}=await ct({name:"package",cwd:t,extensions:[".json"],maxDepth:1});return{packageJson:e,path:n}}async function ut(t,e){let{config:n,filepath:r}=await ct({name:"tsconfig",cwd:t,extensions:[".json"],preferredPath:e,maxDepth:3});return{tsconfig:n,path:r}}function ft(t,e){return{outdir:`${e}/${t.outDir}`,minify:Nt(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 Nt(t){let{minify:e,minifyWhitespace:n,minifyIdentifiers:r,minifySyntax:i}=t,o=e===!0;return{whitespace:n??o,identifiers:r??o,syntax:i??o}}function gt(t,e){return{name:"bunup:external-plugin",setup(n){n.onResolve({filter:/.*/},(r)=>{let i=r.path;if(t.some((s)=>s.test(i))&&!e.some((s)=>s.test(i)))return{path:i,external:!0};return null})}}}var k=new Set;async function Wt(t,e){if(!t.entry||t.entry.length===0||!t.outDir)throw new h("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(t.clean)G(e,t.outDir);tt(t.silent);let{packageJson:n,path:r}=await lt(e);if(n&&r)f.cli(`Using package.json: ${b(r,2)}`,{muted:!0,identifier:t.name,once:`${r}:${t.name}`});let i=n?.type,o=P(t,n),s=D(t),a=[gt(o,s)],c=N(t.entry),u=ft(t,e),g=t.format.flatMap((l)=>c.map((m)=>{return Ut(t,e,m,l,i,a,u)}));if(await Promise.all(g),t.dts){let l=await ut(e,t.preferredTsconfigPath);if(l.path)f.cli(`Using tsconfig: ${b(l.path,2)}`,{muted:!0,identifier:t.name,once:`${l.path}:${t.name}`});let m=t.format.filter((x)=>{if(x==="iife"&&!C(i)&&t.format.includes("cjs"))return!1;return!0}),mt=typeof t.dts==="object"&&t.dts.entry?N(t.dts.entry):c;try{await Promise.all(mt.map(async(x)=>{let pt=await it(e,x.path,t,l,n);await Promise.all(m.map(async(dt)=>{let xt=F(dt,i),B=`${e}/${t.outDir}/${x.name}${xt}`;await Bun.write(B,pt);let ht=Bun.file(B).size||0;f.progress("DTS",b(B),S(ht),t.name)}))}))}catch(x){throw new p(d(x))}}}async function Ut(t,e,n,r,i,o,s){let a=v(r,i),c=await Bun.build({...s,entrypoints:[`${e}/${n.path}`],format:r,naming:{entry:at(n.name,a)},splitting:j(t.splitting,r),bytecode:q(t.bytecode,r),plugins:o,throw:!1});if(!c.success)for(let l of c.logs){if(l.level==="error")throw new h(l.message);if(l.level==="warning")f.warn(l.message);else if(l.level==="info")f.info(l.message)}let u=`${e}/${t.outDir}/${n.name}${a}`,g=Bun.file(u).size||0;f.progress(r.toUpperCase(),b(u),S(g),t.name)}export{Et as defineWorkspace,bt as defineConfig,Wt as build};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunup",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.89",
|
|
4
4
|
"description": "An extremely fast, zero-config bundler for TypeScript & JavaScript, powered by Bun.",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -17,11 +17,10 @@
|
|
|
17
17
|
"@commitlint/config-conventional": "^19.5.0",
|
|
18
18
|
"@types/bun": "^1.2.5",
|
|
19
19
|
"bumpp": "^10.1.0",
|
|
20
|
-
"bunup": "^0.3.
|
|
20
|
+
"bunup": "^0.3.88",
|
|
21
21
|
"husky": "^9.1.7",
|
|
22
22
|
"typescript": "^5.8.3",
|
|
23
|
-
"
|
|
24
|
-
"create-bunup": "0.3.87"
|
|
23
|
+
"create-bunup": "0.3.89"
|
|
25
24
|
},
|
|
26
25
|
"peerDependencies": {
|
|
27
26
|
"typescript": ">=4.5.0"
|
|
@@ -58,6 +57,7 @@
|
|
|
58
57
|
"rolldown": "1.0.0-beta.7",
|
|
59
58
|
"rolldown-plugin-dts": "^0.4.0"
|
|
60
59
|
},
|
|
60
|
+
"type": "module",
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "bunup",
|
|
63
63
|
"dev": "bunup --watch",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"create-bunup": "create-bunup",
|
|
66
66
|
"dev:docs": "pnpm -C docs dev",
|
|
67
67
|
"test-build": "pnpm -C tests build",
|
|
68
|
-
"test": "
|
|
68
|
+
"test": "bun test",
|
|
69
69
|
"lint": "biome check .",
|
|
70
70
|
"lint:fix": "biome check --write .",
|
|
71
71
|
"format": "biome format .",
|