bunup 0.3.15 → 0.3.16

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 CHANGED
@@ -7,10 +7,10 @@ An extremely fast, zero-config bundler for TypeScript & JavaScript, powered by [
7
7
 
8
8
  | Bundler | Format | Build Time | Build Time (with dts) |
9
9
  | ------- | -------- | -------------- | --------------------- |
10
- | bunup | esm, cjs | **0.86ms ⚡️** | **7.54ms ⚡️** |
11
- | tsdown | esm, cjs | 3.57ms | 15.73ms |
12
- | unbuild | esm, cjs | 12.79ms | 252.01ms |
13
- | tsup | esm, cjs | 10.53ms | 665.55ms |
10
+ | bunup | esm, cjs | **0.86ms ⚡️** | **5.44ms ⚡️** |
11
+ | tsdown | esm, cjs | 3.85ms | 11.03ms |
12
+ | unbuild | esm, cjs | 12.90ms | 252.92ms |
13
+ | tsup | esm, cjs | 10.99ms | 671.39ms |
14
14
 
15
15
  _Lower build time is better. Benchmark run on the same code with identical output formats._
16
16
 
package/build/cli.mjs CHANGED
@@ -20,7 +20,7 @@ To fix this, use named entries in your configuration:
20
20
  }
21
21
  }
22
22
 
23
- See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),t.push({name:c,path:o})}else t.push({name:i,path:o}),e.add(i),r[i]=o}if(Array.isArray(n))for(let i of n){let o=A(i);s(o,i)}else if(typeof n==="object")Object.entries(n).forEach(([i,o])=>{s(i,o)});else{let i=A(n);s(i,n)}return t}function pn(n,t){return`[dir]/${n}${t}`}import{loadTsConfig as zn}from"load-tsconfig";function dn(n){try{return zn(".",n)}catch(t){return l.warn(`Failed to load tsconfig: ${m(t)}`),{path:n,data:{},files:[]}}}import J from"node:path";async function hn(n){let t=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let e of t){let r=J.join(n,`bunup.config${e}`);try{if(!await Bun.file(r).exists())continue;let i=await Kn(r,e);if(!i)continue;return{configs:Xn(i,n),configFilePath:r}}catch(s){throw new x(`Failed to load config from ${r}: ${m(s)}`)}}return{configs:[],configFilePath:""}}async function Kn(n,t){if(t===".json"||t===".jsonc")return Qn(n);return Zn(n)}async function Qn(n){try{let t=await Bun.file(n).text(),e=JSON.parse(t);return e.bunup||e}catch(t){throw new Error(`Invalid JSON in config file. ${m(t)}`)}}async function Zn(n){try{let t=await import(`file://${n}`),e=t.default||t;if(!e)return l.warn(`No export found in ${n}. Make sure you're exporting your configuration.`),{};return e}catch(t){throw new Error(`Failed to import config file. ${m(t)}`)}}function Xn(n,t){let e=[];if(Fn(n))Vn(n,t,e);else if(Array.isArray(n))nt(n,t,e);else if(n&&typeof n==="object")e.push({options:n,rootDir:t});else throw new Error("Invalid configuration format. Expected an object, array, or workspace configuration.");return e}function Fn(n){return Array.isArray(n)&&n.length>0&&n.every((t)=>typeof t==="object"&&t!==null&&("name"in t)&&("root"in t)&&("config"in t))}function Vn(n,t,e){for(let r of n){let s=J.resolve(t,r.root);if(Array.isArray(r.config))for(let i of r.config)e.push({options:{name:r.name,...i},rootDir:s});else e.push({options:{name:r.name,...r.config},rootDir:s})}}function nt(n,t,e){for(let r of n){if(!r||typeof r!=="object")throw new Error("Invalid configuration item. Expected an object.");e.push({options:r,rootDir:t})}}async function xn(n){let t=J.join(n,"package.json");try{if(!await Bun.file(t).exists())return{packageJson:null,path:t};let r=await Bun.file(t).text();return{packageJson:JSON.parse(r),path:t}}catch(e){return l.warn(`Failed to load package.json at ${t}: ${m(e)}`),{packageJson:null,path:t}}}function wn(n,t){return{name:"bunup:external-plugin",setup(e){e.onResolve({filter:/.*/},(r)=>{let s=r.path;if(n.some((o)=>o.test(s))&&!t.some((o)=>o.test(s)))return{path:s,external:!0};return null})}}}var B=new Set;async function L(n,t){if(!n.entry||n.entry.length===0||!n.outDir)throw new x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let{packageJson:e,path:r}=await xn(t);if(e)l.cli(`Using package.json: ${w(r,2)}`,{muted:!0});let s=e?.type,i=M(n,e),o=k(n),a=[wn(i,o)],c=S(n.entry),u=K(n,t),g=n.format.flatMap((f)=>c.map((R)=>{return tt(n,t,R,f,s,a,u)}));if(await Promise.all(g),n.dts){let f=dn(n.preferredTsconfigPath);if(f.path)l.cli(`Using tsconfig: ${w(f.path,2)}`,{muted:!0});let R=n.format.filter((b)=>{if(b==="iife"&&!N(s)&&n.format.includes("cjs"))return!1;return!0}),En=typeof n.dts==="object"&&n.dts.entry?S(n.dts.entry):c;try{await Promise.all(En.map(async(b)=>{let vn=await gn(t,b.path,n,f,e);await Promise.all(R.map(async(Rn)=>{let jn=X(Rn,s),W=`${t}/${n.outDir}/${b.name}${jn}`;await Bun.write(W,vn);let An=Bun.file(W).size||0;l.progress("DTS",w(W),q(An),n.name)}))}))}catch(b){throw new d(m(b))}}}async function tt(n,t,e,r,s,i,o){let a=Z(r,s),c=await Bun.build({...o,entrypoints:[`${t}/${e.path}`],format:r,naming:{entry:pn(e.name,a)},splitting:V(n.splitting,r),plugins:i,throw:!1});if(!c.success)c.logs.forEach((f)=>{if(f.level==="error")throw new x(f.message);else if(f.level==="warning")l.warn(f.message);else if(f.level==="info")l.info(f.message)});let u=`${t}/${n.outDir}/${e.name}${a}`,g=Bun.file(u).size||0;l.progress(r.toUpperCase(),w(u),q(g),n.name)}var H="0.3.15";var yn="https://bun.sh/docs/installation",bn="https://bunup.arshadyaseen.com/#cli-options";function y(n){return(t,e)=>{e[n]=t===!0?!0:t==="true"}}function v(n){return(t,e)=>{if(typeof t==="string")e[n]=t;else throw new h(`Option --${n} requires a string value`)}}function $n(n){return(t,e)=>{if(typeof t==="string")e[n]=t.split(",");else throw new h(`Option --${n} requires a string value`)}}function rt(){console.log(`
23
+ See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),t.push({name:c,path:o})}else t.push({name:i,path:o}),e.add(i),r[i]=o}if(Array.isArray(n))for(let i of n){let o=A(i);s(o,i)}else if(typeof n==="object")Object.entries(n).forEach(([i,o])=>{s(i,o)});else{let i=A(n);s(i,n)}return t}function pn(n,t){return`[dir]/${n}${t}`}import{loadTsConfig as zn}from"load-tsconfig";function dn(n){try{return zn(".",n)}catch(t){return l.warn(`Failed to load tsconfig: ${m(t)}`),{path:n,data:{},files:[]}}}import J from"node:path";async function hn(n){let t=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let e of t){let r=J.join(n,`bunup.config${e}`);try{if(!await Bun.file(r).exists())continue;let i=await Kn(r,e);if(!i)continue;return{configs:Xn(i,n),configFilePath:r}}catch(s){throw new x(`Failed to load config from ${r}: ${m(s)}`)}}return{configs:[],configFilePath:""}}async function Kn(n,t){if(t===".json"||t===".jsonc")return Qn(n);return Zn(n)}async function Qn(n){try{let t=await Bun.file(n).text(),e=JSON.parse(t);return e.bunup||e}catch(t){throw new Error(`Invalid JSON in config file. ${m(t)}`)}}async function Zn(n){try{let t=await import(`file://${n}`),e=t.default||t;if(!e)return l.warn(`No export found in ${n}. Make sure you're exporting your configuration.`),{};return e}catch(t){throw new Error(`Failed to import config file. ${m(t)}`)}}function Xn(n,t){let e=[];if(Fn(n))Vn(n,t,e);else if(Array.isArray(n))nt(n,t,e);else if(n&&typeof n==="object")e.push({options:n,rootDir:t});else throw new Error("Invalid configuration format. Expected an object, array, or workspace configuration.");return e}function Fn(n){return Array.isArray(n)&&n.length>0&&n.every((t)=>typeof t==="object"&&t!==null&&("name"in t)&&("root"in t)&&("config"in t))}function Vn(n,t,e){for(let r of n){let s=J.resolve(t,r.root);if(Array.isArray(r.config))for(let i of r.config)e.push({options:{name:r.name,...i},rootDir:s});else e.push({options:{name:r.name,...r.config},rootDir:s})}}function nt(n,t,e){for(let r of n){if(!r||typeof r!=="object")throw new Error("Invalid configuration item. Expected an object.");e.push({options:r,rootDir:t})}}async function xn(n){let t=J.join(n,"package.json");try{if(!await Bun.file(t).exists())return{packageJson:null,path:t};let r=await Bun.file(t).text();return{packageJson:JSON.parse(r),path:t}}catch(e){return l.warn(`Failed to load package.json at ${t}: ${m(e)}`),{packageJson:null,path:t}}}function wn(n,t){return{name:"bunup:external-plugin",setup(e){e.onResolve({filter:/.*/},(r)=>{let s=r.path;if(n.some((o)=>o.test(s))&&!t.some((o)=>o.test(s)))return{path:s,external:!0};return null})}}}var B=new Set;async function L(n,t){if(!n.entry||n.entry.length===0||!n.outDir)throw new x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let{packageJson:e,path:r}=await xn(t);if(e)l.cli(`Using package.json: ${w(r,2)}`,{muted:!0});let s=e?.type,i=M(n,e),o=k(n),a=[wn(i,o)],c=S(n.entry),u=K(n,t),g=n.format.flatMap((f)=>c.map((R)=>{return tt(n,t,R,f,s,a,u)}));if(await Promise.all(g),n.dts){let f=dn(n.preferredTsconfigPath);if(f.path)l.cli(`Using tsconfig: ${w(f.path,2)}`,{muted:!0});let R=n.format.filter((b)=>{if(b==="iife"&&!N(s)&&n.format.includes("cjs"))return!1;return!0}),En=typeof n.dts==="object"&&n.dts.entry?S(n.dts.entry):c;try{await Promise.all(En.map(async(b)=>{let vn=await gn(t,b.path,n,f,e);await Promise.all(R.map(async(Rn)=>{let jn=X(Rn,s),W=`${t}/${n.outDir}/${b.name}${jn}`;await Bun.write(W,vn);let An=Bun.file(W).size||0;l.progress("DTS",w(W),q(An),n.name)}))}))}catch(b){throw new d(m(b))}}}async function tt(n,t,e,r,s,i,o){let a=Z(r,s),c=await Bun.build({...o,entrypoints:[`${t}/${e.path}`],format:r,naming:{entry:pn(e.name,a)},splitting:V(n.splitting,r),plugins:i,throw:!1});if(!c.success)c.logs.forEach((f)=>{if(f.level==="error")throw new x(f.message);else if(f.level==="warning")l.warn(f.message);else if(f.level==="info")l.info(f.message)});let u=`${t}/${n.outDir}/${e.name}${a}`,g=Bun.file(u).size||0;l.progress(r.toUpperCase(),w(u),q(g),n.name)}var H="0.3.16";var yn="https://bun.sh/docs/installation",bn="https://bunup.arshadyaseen.com/#cli-options";function y(n){return(t,e)=>{e[n]=t===!0?!0:t==="true"}}function v(n){return(t,e)=>{if(typeof t==="string")e[n]=t;else throw new h(`Option --${n} requires a string value`)}}function $n(n){return(t,e)=>{if(typeof t==="string")e[n]=t.split(",");else throw new h(`Option --${n} requires a string value`)}}function rt(){console.log(`
24
24
  Bunup - An extremely fast, zero-config bundler for JavaScript and TypeScript, powered by Bun.
25
25
  `),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${bn}\x1B[0m
26
26
  `),process.exit(0)}function st(){console.log(H),process.exit(0)}var it={name:{flags:["n","name"],handler:v("name")},format:{flags:["f","format"],handler:(n,t)=>{if(typeof n==="string")t.format=n.split(",");else throw new h("Option --format requires a string value")}},outDir:{flags:["o","out-dir"],handler:v("outDir")},minify:{flags:["m","minify"],handler:y("minify")},watch:{flags:["w","watch"],handler:y("watch")},dts:{flags:["d","dts"],handler:y("dts")},banner:{flags:["b","banner"],handler:v("banner")},footer:{flags:["f","footer"],handler:v("footer")},external:{flags:["e","external"],handler:$n("external")},sourcemap:{flags:["sm","sourcemap"],handler:v("sourcemap")},target:{flags:["t","target"],handler:v("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:y("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:y("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:y("minifySyntax")},clean:{flags:["c","clean"],handler:y("clean")},splitting:{flags:["s","splitting"],handler:y("splitting")},noExternal:{flags:["ne","no-external"],handler:$n("noExternal")}},ot={help:{flags:["h","help"],handler:()=>rt()},version:{flags:["v","version"],handler:()=>st()}},U={};for(let n of Object.values(it))if(n)for(let t of n.flags)U[t]=n.handler;for(let n of Object.values(ot))for(let t of n.flags)U[t]=n.handler;function On(n){let t={},e={},r=0;while(r<n.length){let s=n[r];if(s.startsWith("--")){let i,o;if(s.includes("=")){let[a,c]=s.slice(2).split("=",2);i=a,o=c}else{i=s.slice(2);let a=n[r+1];if(o=a&&!a.startsWith("-")?a:!0,typeof o==="string")r++}if(i==="entry")if(typeof o==="string"){let a=A(o);if(e[a])l.warn(`Duplicate entry name '${a}' derived from '${o}'. Overwriting previous entry.`);e[a]=o}else throw new h("Option --entry requires a string value");else if(i.startsWith("entry.")){let a=i.slice(6);if(typeof o==="string"){if(e[a])l.warn(`Duplicate entry name '${a}' provided via --entry.${a}. Overwriting previous entry.`);e[a]=o}else throw new h(`Option --entry.${a} requires a string value`)}else{let a=U[i];if(a)a(o,t);else throw new h(`Unknown option: --${i}`)}}else if(s.startsWith("-")){let i=s.slice(1),o=n[r+1],a=o&&!o.startsWith("-")?o:!0;if(typeof a==="string")r++;let c=U[i];if(c)c(a,t);else throw new h(`Unknown option: -${i}`)}else{let i=A(s);if(e[i])l.warn(`Duplicate entry name '${i}' derived from positional argument '${s}'. Overwriting previous entry.`);e[i]=s}r++}if(Object.keys(e).length>0)t.entry=e;return t}(()=>{if(typeof Bun==="undefined")throw new h(`Bunup requires Bun to run.
package/build/index.d.mts CHANGED
@@ -1,12 +1,220 @@
1
- import * as bun from 'bun';
2
1
 
2
+ //#region \0virtual:/home/runner/work/bunup/bunup/src/options.d.ts
3
+ /**
4
+ * Entry point files for TypeScript declaration file generation
5
+ *
6
+ * This can be:
7
+ * - A string path to a file
8
+ * - An array of file paths
9
+ * - An object where keys are output names and values are input file paths
10
+ *
11
+ * The key names are used for the generated declaration files.
12
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
13
+ *
14
+ * If not specified, the main entry points will be used for declaration file generation.
15
+ *
16
+ * If it's a string or an array of strings, the file name (without extension)
17
+ * will be used as the name for the output declaration file.
18
+ *
19
+ * @example
20
+ * // Using a string path
21
+ * entry: 'src/index.ts' // Generates index.d.ts
22
+ *
23
+ * // Using string paths in an array
24
+ * entry: ['src/index.ts'] // Generates index.d.ts
25
+ *
26
+ * // Using named outputs as an object
27
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
28
+ */
3
29
  type Loader = NonNullable<BunBuildOptions["loader"]>[string];
30
+ /**
31
+ * Entry point files for TypeScript declaration file generation
32
+ *
33
+ * This can be:
34
+ * - A string path to a file
35
+ * - An array of file paths
36
+ * - An object where keys are output names and values are input file paths
37
+ *
38
+ * The key names are used for the generated declaration files.
39
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
40
+ *
41
+ * If not specified, the main entry points will be used for declaration file generation.
42
+ *
43
+ * If it's a string or an array of strings, the file name (without extension)
44
+ * will be used as the name for the output declaration file.
45
+ *
46
+ * @example
47
+ * // Using a string path
48
+ * entry: 'src/index.ts' // Generates index.d.ts
49
+ *
50
+ * // Using string paths in an array
51
+ * entry: ['src/index.ts'] // Generates index.d.ts
52
+ *
53
+ * // Using named outputs as an object
54
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
55
+ */
4
56
  type Define = BunBuildOptions["define"];
57
+ /**
58
+ * Entry point files for TypeScript declaration file generation
59
+ *
60
+ * This can be:
61
+ * - A string path to a file
62
+ * - An array of file paths
63
+ * - An object where keys are output names and values are input file paths
64
+ *
65
+ * The key names are used for the generated declaration files.
66
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
67
+ *
68
+ * If not specified, the main entry points will be used for declaration file generation.
69
+ *
70
+ * If it's a string or an array of strings, the file name (without extension)
71
+ * will be used as the name for the output declaration file.
72
+ *
73
+ * @example
74
+ * // Using a string path
75
+ * entry: 'src/index.ts' // Generates index.d.ts
76
+ *
77
+ * // Using string paths in an array
78
+ * entry: ['src/index.ts'] // Generates index.d.ts
79
+ *
80
+ * // Using named outputs as an object
81
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
82
+ */
5
83
  type Sourcemap = BunBuildOptions["sourcemap"];
84
+ /**
85
+ * Entry point files for TypeScript declaration file generation
86
+ *
87
+ * This can be:
88
+ * - A string path to a file
89
+ * - An array of file paths
90
+ * - An object where keys are output names and values are input file paths
91
+ *
92
+ * The key names are used for the generated declaration files.
93
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
94
+ *
95
+ * If not specified, the main entry points will be used for declaration file generation.
96
+ *
97
+ * If it's a string or an array of strings, the file name (without extension)
98
+ * will be used as the name for the output declaration file.
99
+ *
100
+ * @example
101
+ * // Using a string path
102
+ * entry: 'src/index.ts' // Generates index.d.ts
103
+ *
104
+ * // Using string paths in an array
105
+ * entry: ['src/index.ts'] // Generates index.d.ts
106
+ *
107
+ * // Using named outputs as an object
108
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
109
+ */
6
110
  type Format = Exclude<BunBuildOptions["format"], undefined>;
111
+ /**
112
+ * Entry point files for TypeScript declaration file generation
113
+ *
114
+ * This can be:
115
+ * - A string path to a file
116
+ * - An array of file paths
117
+ * - An object where keys are output names and values are input file paths
118
+ *
119
+ * The key names are used for the generated declaration files.
120
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
121
+ *
122
+ * If not specified, the main entry points will be used for declaration file generation.
123
+ *
124
+ * If it's a string or an array of strings, the file name (without extension)
125
+ * will be used as the name for the output declaration file.
126
+ *
127
+ * @example
128
+ * // Using a string path
129
+ * entry: 'src/index.ts' // Generates index.d.ts
130
+ *
131
+ * // Using string paths in an array
132
+ * entry: ['src/index.ts'] // Generates index.d.ts
133
+ *
134
+ * // Using named outputs as an object
135
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
136
+ */
7
137
  type Target = BunBuildOptions["target"];
138
+ /**
139
+ * Entry point files for TypeScript declaration file generation
140
+ *
141
+ * This can be:
142
+ * - A string path to a file
143
+ * - An array of file paths
144
+ * - An object where keys are output names and values are input file paths
145
+ *
146
+ * The key names are used for the generated declaration files.
147
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
148
+ *
149
+ * If not specified, the main entry points will be used for declaration file generation.
150
+ *
151
+ * If it's a string or an array of strings, the file name (without extension)
152
+ * will be used as the name for the output declaration file.
153
+ *
154
+ * @example
155
+ * // Using a string path
156
+ * entry: 'src/index.ts' // Generates index.d.ts
157
+ *
158
+ * // Using string paths in an array
159
+ * entry: ['src/index.ts'] // Generates index.d.ts
160
+ *
161
+ * // Using named outputs as an object
162
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
163
+ */
8
164
  type External = (string | RegExp)[];
165
+ /**
166
+ * Entry point files for TypeScript declaration file generation
167
+ *
168
+ * This can be:
169
+ * - A string path to a file
170
+ * - An array of file paths
171
+ * - An object where keys are output names and values are input file paths
172
+ *
173
+ * The key names are used for the generated declaration files.
174
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
175
+ *
176
+ * If not specified, the main entry points will be used for declaration file generation.
177
+ *
178
+ * If it's a string or an array of strings, the file name (without extension)
179
+ * will be used as the name for the output declaration file.
180
+ *
181
+ * @example
182
+ * // Using a string path
183
+ * entry: 'src/index.ts' // Generates index.d.ts
184
+ *
185
+ * // Using string paths in an array
186
+ * entry: ['src/index.ts'] // Generates index.d.ts
187
+ *
188
+ * // Using named outputs as an object
189
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
190
+ */
9
191
  type Entry = Arrayable<string> | Record<string, string>;
192
+ /**
193
+ * Entry point files for TypeScript declaration file generation
194
+ *
195
+ * This can be:
196
+ * - A string path to a file
197
+ * - An array of file paths
198
+ * - An object where keys are output names and values are input file paths
199
+ *
200
+ * The key names are used for the generated declaration files.
201
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
202
+ *
203
+ * If not specified, the main entry points will be used for declaration file generation.
204
+ *
205
+ * If it's a string or an array of strings, the file name (without extension)
206
+ * will be used as the name for the output declaration file.
207
+ *
208
+ * @example
209
+ * // Using a string path
210
+ * entry: 'src/index.ts' // Generates index.d.ts
211
+ *
212
+ * // Using string paths in an array
213
+ * entry: ['src/index.ts'] // Generates index.d.ts
214
+ *
215
+ * // Using named outputs as an object
216
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
217
+ */
10
218
  type DtsOptions = {
11
219
  /**
12
220
  * Entry point files for TypeScript declaration file generation
@@ -40,6 +248,10 @@ type DtsOptions = {
40
248
  */
41
249
  resolve?: boolean | (string | RegExp)[]
42
250
  };
251
+ /**
252
+ * Name of the build configuration
253
+ * Used for logging and identification purposes
254
+ */
43
255
  interface BunupOptions {
44
256
  /**
45
257
  * Name of the build configuration
@@ -224,13 +436,15 @@ interface BunupOptions {
224
436
  loader?: Record<string, Loader>;
225
437
  }
226
438
 
439
+ //#endregion
440
+ //#region \0virtual:/home/runner/work/bunup/bunup/src/types.d.ts
227
441
  type PromiseOr<T> = Promise<T> | T;
228
442
  type WithOptional<
229
443
  T,
230
444
  K extends keyof T
231
445
  > = Omit<T, K> & Partial<Pick<T, K>>;
232
446
  type Arrayable<T> = T | T[];
233
- type Bun = typeof bun;
447
+ type Bun = typeof import("bun");
234
448
  type BunBuildOptions = Parameters<Bun["build"]>[0];
235
449
  type DefineConfigEntry = Omit<WithOptional<BunupOptions, "outDir" | "format">, "watch">;
236
450
  type DefineWorkspaceEntry = {
@@ -239,10 +453,14 @@ type DefineWorkspaceEntry = {
239
453
  config: DefineConfigEntry | DefineConfigEntry[]
240
454
  };
241
455
 
456
+ //#endregion
457
+ //#region \0virtual:/home/runner/work/bunup/bunup/src/define.d.ts
242
458
  declare function defineConfig(options: DefineConfigEntry | DefineConfigEntry[]): DefineConfigEntry | DefineConfigEntry[];
243
459
  declare function defineWorkspace(options: DefineWorkspaceEntry[]): DefineWorkspaceEntry[];
244
460
 
461
+ //#endregion
462
+ //#region \0virtual:/home/runner/work/bunup/bunup/src/build.d.ts
245
463
  declare function build(options: BunupOptions, rootDir: string): Promise<void>;
246
464
 
247
- export { build, defineConfig, defineWorkspace };
248
- export type { DefineConfigEntry, DefineWorkspaceEntry };
465
+ //#endregion
466
+ export { DefineConfigEntry, DefineWorkspaceEntry, build, defineConfig, defineWorkspace };
package/build/index.d.ts CHANGED
@@ -1,12 +1,220 @@
1
- import * as bun from 'bun';
2
1
 
2
+ //#region \0virtual:/home/runner/work/bunup/bunup/src/options.d.ts
3
+ /**
4
+ * Entry point files for TypeScript declaration file generation
5
+ *
6
+ * This can be:
7
+ * - A string path to a file
8
+ * - An array of file paths
9
+ * - An object where keys are output names and values are input file paths
10
+ *
11
+ * The key names are used for the generated declaration files.
12
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
13
+ *
14
+ * If not specified, the main entry points will be used for declaration file generation.
15
+ *
16
+ * If it's a string or an array of strings, the file name (without extension)
17
+ * will be used as the name for the output declaration file.
18
+ *
19
+ * @example
20
+ * // Using a string path
21
+ * entry: 'src/index.ts' // Generates index.d.ts
22
+ *
23
+ * // Using string paths in an array
24
+ * entry: ['src/index.ts'] // Generates index.d.ts
25
+ *
26
+ * // Using named outputs as an object
27
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
28
+ */
3
29
  type Loader = NonNullable<BunBuildOptions["loader"]>[string];
30
+ /**
31
+ * Entry point files for TypeScript declaration file generation
32
+ *
33
+ * This can be:
34
+ * - A string path to a file
35
+ * - An array of file paths
36
+ * - An object where keys are output names and values are input file paths
37
+ *
38
+ * The key names are used for the generated declaration files.
39
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
40
+ *
41
+ * If not specified, the main entry points will be used for declaration file generation.
42
+ *
43
+ * If it's a string or an array of strings, the file name (without extension)
44
+ * will be used as the name for the output declaration file.
45
+ *
46
+ * @example
47
+ * // Using a string path
48
+ * entry: 'src/index.ts' // Generates index.d.ts
49
+ *
50
+ * // Using string paths in an array
51
+ * entry: ['src/index.ts'] // Generates index.d.ts
52
+ *
53
+ * // Using named outputs as an object
54
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
55
+ */
4
56
  type Define = BunBuildOptions["define"];
57
+ /**
58
+ * Entry point files for TypeScript declaration file generation
59
+ *
60
+ * This can be:
61
+ * - A string path to a file
62
+ * - An array of file paths
63
+ * - An object where keys are output names and values are input file paths
64
+ *
65
+ * The key names are used for the generated declaration files.
66
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
67
+ *
68
+ * If not specified, the main entry points will be used for declaration file generation.
69
+ *
70
+ * If it's a string or an array of strings, the file name (without extension)
71
+ * will be used as the name for the output declaration file.
72
+ *
73
+ * @example
74
+ * // Using a string path
75
+ * entry: 'src/index.ts' // Generates index.d.ts
76
+ *
77
+ * // Using string paths in an array
78
+ * entry: ['src/index.ts'] // Generates index.d.ts
79
+ *
80
+ * // Using named outputs as an object
81
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
82
+ */
5
83
  type Sourcemap = BunBuildOptions["sourcemap"];
84
+ /**
85
+ * Entry point files for TypeScript declaration file generation
86
+ *
87
+ * This can be:
88
+ * - A string path to a file
89
+ * - An array of file paths
90
+ * - An object where keys are output names and values are input file paths
91
+ *
92
+ * The key names are used for the generated declaration files.
93
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
94
+ *
95
+ * If not specified, the main entry points will be used for declaration file generation.
96
+ *
97
+ * If it's a string or an array of strings, the file name (without extension)
98
+ * will be used as the name for the output declaration file.
99
+ *
100
+ * @example
101
+ * // Using a string path
102
+ * entry: 'src/index.ts' // Generates index.d.ts
103
+ *
104
+ * // Using string paths in an array
105
+ * entry: ['src/index.ts'] // Generates index.d.ts
106
+ *
107
+ * // Using named outputs as an object
108
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
109
+ */
6
110
  type Format = Exclude<BunBuildOptions["format"], undefined>;
111
+ /**
112
+ * Entry point files for TypeScript declaration file generation
113
+ *
114
+ * This can be:
115
+ * - A string path to a file
116
+ * - An array of file paths
117
+ * - An object where keys are output names and values are input file paths
118
+ *
119
+ * The key names are used for the generated declaration files.
120
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
121
+ *
122
+ * If not specified, the main entry points will be used for declaration file generation.
123
+ *
124
+ * If it's a string or an array of strings, the file name (without extension)
125
+ * will be used as the name for the output declaration file.
126
+ *
127
+ * @example
128
+ * // Using a string path
129
+ * entry: 'src/index.ts' // Generates index.d.ts
130
+ *
131
+ * // Using string paths in an array
132
+ * entry: ['src/index.ts'] // Generates index.d.ts
133
+ *
134
+ * // Using named outputs as an object
135
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
136
+ */
7
137
  type Target = BunBuildOptions["target"];
138
+ /**
139
+ * Entry point files for TypeScript declaration file generation
140
+ *
141
+ * This can be:
142
+ * - A string path to a file
143
+ * - An array of file paths
144
+ * - An object where keys are output names and values are input file paths
145
+ *
146
+ * The key names are used for the generated declaration files.
147
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
148
+ *
149
+ * If not specified, the main entry points will be used for declaration file generation.
150
+ *
151
+ * If it's a string or an array of strings, the file name (without extension)
152
+ * will be used as the name for the output declaration file.
153
+ *
154
+ * @example
155
+ * // Using a string path
156
+ * entry: 'src/index.ts' // Generates index.d.ts
157
+ *
158
+ * // Using string paths in an array
159
+ * entry: ['src/index.ts'] // Generates index.d.ts
160
+ *
161
+ * // Using named outputs as an object
162
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
163
+ */
8
164
  type External = (string | RegExp)[];
165
+ /**
166
+ * Entry point files for TypeScript declaration file generation
167
+ *
168
+ * This can be:
169
+ * - A string path to a file
170
+ * - An array of file paths
171
+ * - An object where keys are output names and values are input file paths
172
+ *
173
+ * The key names are used for the generated declaration files.
174
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
175
+ *
176
+ * If not specified, the main entry points will be used for declaration file generation.
177
+ *
178
+ * If it's a string or an array of strings, the file name (without extension)
179
+ * will be used as the name for the output declaration file.
180
+ *
181
+ * @example
182
+ * // Using a string path
183
+ * entry: 'src/index.ts' // Generates index.d.ts
184
+ *
185
+ * // Using string paths in an array
186
+ * entry: ['src/index.ts'] // Generates index.d.ts
187
+ *
188
+ * // Using named outputs as an object
189
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
190
+ */
9
191
  type Entry = Arrayable<string> | Record<string, string>;
192
+ /**
193
+ * Entry point files for TypeScript declaration file generation
194
+ *
195
+ * This can be:
196
+ * - A string path to a file
197
+ * - An array of file paths
198
+ * - An object where keys are output names and values are input file paths
199
+ *
200
+ * The key names are used for the generated declaration files.
201
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
202
+ *
203
+ * If not specified, the main entry points will be used for declaration file generation.
204
+ *
205
+ * If it's a string or an array of strings, the file name (without extension)
206
+ * will be used as the name for the output declaration file.
207
+ *
208
+ * @example
209
+ * // Using a string path
210
+ * entry: 'src/index.ts' // Generates index.d.ts
211
+ *
212
+ * // Using string paths in an array
213
+ * entry: ['src/index.ts'] // Generates index.d.ts
214
+ *
215
+ * // Using named outputs as an object
216
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
217
+ */
10
218
  type DtsOptions = {
11
219
  /**
12
220
  * Entry point files for TypeScript declaration file generation
@@ -40,6 +248,10 @@ type DtsOptions = {
40
248
  */
41
249
  resolve?: boolean | (string | RegExp)[]
42
250
  };
251
+ /**
252
+ * Name of the build configuration
253
+ * Used for logging and identification purposes
254
+ */
43
255
  interface BunupOptions {
44
256
  /**
45
257
  * Name of the build configuration
@@ -224,13 +436,15 @@ interface BunupOptions {
224
436
  loader?: Record<string, Loader>;
225
437
  }
226
438
 
439
+ //#endregion
440
+ //#region \0virtual:/home/runner/work/bunup/bunup/src/types.d.ts
227
441
  type PromiseOr<T> = Promise<T> | T;
228
442
  type WithOptional<
229
443
  T,
230
444
  K extends keyof T
231
445
  > = Omit<T, K> & Partial<Pick<T, K>>;
232
446
  type Arrayable<T> = T | T[];
233
- type Bun = typeof bun;
447
+ type Bun = typeof import("bun");
234
448
  type BunBuildOptions = Parameters<Bun["build"]>[0];
235
449
  type DefineConfigEntry = Omit<WithOptional<BunupOptions, "outDir" | "format">, "watch">;
236
450
  type DefineWorkspaceEntry = {
@@ -239,10 +453,14 @@ type DefineWorkspaceEntry = {
239
453
  config: DefineConfigEntry | DefineConfigEntry[]
240
454
  };
241
455
 
456
+ //#endregion
457
+ //#region \0virtual:/home/runner/work/bunup/bunup/src/define.d.ts
242
458
  declare function defineConfig(options: DefineConfigEntry | DefineConfigEntry[]): DefineConfigEntry | DefineConfigEntry[];
243
459
  declare function defineWorkspace(options: DefineWorkspaceEntry[]): DefineWorkspaceEntry[];
244
460
 
461
+ //#endregion
462
+ //#region \0virtual:/home/runner/work/bunup/bunup/src/build.d.ts
245
463
  declare function build(options: BunupOptions, rootDir: string): Promise<void>;
246
464
 
247
- export { build, defineConfig, defineWorkspace };
248
- export type { DefineConfigEntry, DefineWorkspaceEntry };
465
+ //#endregion
466
+ export { DefineConfigEntry, DefineWorkspaceEntry, build, defineConfig, defineWorkspace };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunup",
3
- "version": "0.3.15",
3
+ "version": "0.3.16",
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",
@@ -18,7 +18,7 @@
18
18
  "@types/bun": "^1.2.5",
19
19
  "@typescript-eslint/eslint-plugin": "^7.3.1",
20
20
  "bumpp": "^10.1.0",
21
- "bunup": "^0.3.7",
21
+ "bunup": "^0.3.15",
22
22
  "eslint": "^8.57.1",
23
23
  "husky": "^9.1.7",
24
24
  "prettier": "^3.5.3",