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 CHANGED
@@ -24,7 +24,7 @@ To run the benchmarks yourself, clone this repo and run `pnpm benchmark` and che
24
24
 
25
25
  - 🔥 **Bytecode Generation**: Faster startups by compiling to Bun bytecode—perfect for CLIs.
26
26
 
27
- - 📦 **Workspace Support**: Build multiple packages with `defineWorkspace()` in one command.
27
+ - 📦 **Workspace Support**: Build multiple packages with [defineWorkspace()](https://bunup.arshadyaseen.com/#workspaces) in one config file and command.
28
28
 
29
29
  - 🎯 **Bun Targeting**: Optimize for Bun runtime with `--target bun` for native features.
30
30
 
package/build/cli.mjs CHANGED
@@ -1,27 +1,27 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{build as Xe}from"rolldown";import{dts as Ye}from"rolldown-plugin-dts";class $ extends Error{constructor(e){super(e);this.name="BunupError"}}class y extends ${constructor(e){super(e);this.name="BunupBuildError"}}class g extends ${constructor(e){super(e);this.name="BunupDTSBuildError"}}class d extends ${constructor(e){super(e);this.name="BunupCLIError"}}class D extends ${constructor(e){super(e);this.name="BunupWatchError"}}var h=(e)=>{if(e instanceof Error)return e.message;return String(e)},We=[{pattern:/Could not resolve: "bun"/i,errorType:"BUILD ERROR",link:"https://bunup.arshadyaseen.com/#could-not-resolve-bun-error"}],V=(e,t)=>{let n=h(e),r=t?`[${t}] `:"",i="ERROR";if(e instanceof y)i="BUILD ERROR";else if(e instanceof g)i="DTS ERROR";else if(e instanceof d)i="CLI ERROR";else if(e instanceof D)i="WATCH ERROR";else if(e instanceof $)i="BUNUP ERROR";console.error(`\x1B[31m${i}\x1B[0m ${r}${n}`);let s=We.find((o)=>o.pattern.test(n)&&(o.errorType===i||!o.errorType));if(s)console.error(`
4
- \x1B[90mA solution for this error is available at: \x1B[36m${s.link}\x1B[0m
5
- `);else console.error("\x1B[90mIf you think this is a bug, please open an issue at: \x1B[36mhttps://github.com/arshadyaseen/bunup/issues/new\x1B[0m")},J=(e,t)=>{V(e,t),process.exit(1)};import te from"node:fs/promises";import He from"node:path";var v={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function ee(e,t){return{outdir:`${t}/${e.outDir}`,minify:je(e),target:e.target,splitting:e.splitting,sourcemap:e.sourcemap,define:e.define,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer}}function je(e){let{minify:t,minifyWhitespace:n,minifyIdentifiers:r,minifySyntax:i}=e,s=t===!0;return{whitespace:n??s,identifiers:r??s,syntax:i??s}}function G(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ne(e=8){return Math.random().toString(36).substring(2,2+e)}function re(e,t,n){return Array.isArray(e)?e.map((r)=>({...r,[t]:n})):{...e,[t]:n}}function X(e){return Array.isArray(e)?e:[e]}function se(e,t){switch(e){case"esm":return".mjs";case"cjs":return M(t)?".cjs":".js";case"iife":return".global.js"}}function ie(e,t){switch(e){case"esm":return".d.mts";case"cjs":return M(t)?".d.cts":".d.ts";case"iife":return".d.ts"}}function M(e){return e==="module"}function I(e){return e>=1000?`${(e/1000).toFixed(2)}s`:`${Math.round(e)}ms`}function oe(e){if(!e)return[];return Array.from(new Set([...Object.keys(e.dependencies||{}),...Object.keys(e.peerDependencies||{})]))}function ae(e,t){return e===void 0?t==="esm":e}function Y(e){if(e===0)return"0 B";let t=["B","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(1024));if(n===0)return`${e} ${t[n]}`;return`${(e/1024**n).toFixed(2)} ${t[n]}`}function x(e,t=3){return e.split("/").slice(-t).join("/")}async function le(e,t){let n=He.join(e,t);try{await te.rm(n,{recursive:!0,force:!0})}catch(r){throw new y(`Failed to clean output directory: ${r}`)}await te.mkdir(n,{recursive:!0})}function ce(e){return e||v.outDir}function ue(e){return e===void 0?v.clean:e}function fe(e,t){return t==="cjs"?e:void 0}function pe(e){return e.map((t)=>typeof t==="string"?new RegExp(`^${G(t)}($|\\/|\\\\)`):t)}function U(e,t){return pe(e.external||[]).concat(oe(t).map((n)=>new RegExp(`^${G(n)}($|\\/|\\\\)`)))}function _(e){return pe(e.noExternal||[])}import Ve from"node:path";import{ResolverFactory as Ge}from"oxc-resolver";import O from"node:path";var T="\x00dts:",me=(e,t,n)=>{return{name:"bunup:virtual-dts",async resolveId(r,i){if(K(r))return r;if(!i||!K(i))return null;let s=await N(r,t,n,P(i));if(!s)return null;let o=R(s);if(e.has(o))return k(o);return null},load(r){if(r.startsWith(T)){let i=P(r),s=e.get(i);if(s)return C.add(i),s}return null}}};function ge(e){return e.tsconfig?.compilerOptions}function R(e){return e.replace(/\.tsx?$/,".d.ts")}function Q(e){let t=O.dirname(e.path||""),n=ge(e);return n?.baseUrl?O.resolve(t,n.baseUrl):t}function de(e){let t=new Map,n=ge(e)?.paths;if(!n)return t;let r=Q(e);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");t.set(`^${o}$`,O.join(r,a))}return t}function Fe(e,t,n){for(let[r,i]of t){let s=new RegExp(r),o=e.match(s);if(o)return i.replace("$1",o[1]||"")}return n?O.join(n,e):null}async function qe(e){let t=["",".ts",".tsx","/index.ts","/index.tsx"];for(let n of t){let r=`${e}${n}`;if(await Bun.file(r).exists()&&(r.endsWith(".ts")||r.endsWith(".tsx")))return r}return null}function N(e,t,n,r){let i=e.startsWith(".")?O.resolve(O.dirname(r||""),e):Fe(e,t,n);if(!i)return Promise.resolve(null);return qe(i)}function K(e){return e.startsWith(T)}function P(e){return e.replace(T,"")}function k(e){return`${T}${e}`}var he;function xe(e){return{name:"bunup:types-resolve",buildStart(){he||=new Ge({mainFields:["types"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".ts"],modules:["node_modules","node_modules/@types"]})},async resolveId(t,n){let r=n?P(n):void 0;if(/\0/.test(t))return;if(e){if(!e.some((a)=>{let l=!1;if(typeof a==="string")l=a===t||!!r?.includes(a);else l=a.test(t)||!!(r&&a.test(r));return l}))return}let i=r?Ve.dirname(r):process.cwd(),{path:s}=await he.async(i,t);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 be(e,t,n,r,i,s){let o=R(e),a=k(o),l=U(n,r),u=_(n);try{let{output:p}=await Xe({input:a,output:{dir:n.outDir,inlineDynamicImports:!0},write:!1,onwarn(f,m){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(f.code??""))return;m(f)},plugins:[me(t,i,s),typeof n.dts==="object"&&"resolve"in n.dts&&xe(typeof n.dts.resolve==="boolean"?void 0:n.dts.resolve),Ye({dtsInput:!0})],external:(f)=>l.some((m)=>m.test(f))&&!u.some((m)=>m.test(f))});if(!p[0]?.code)throw new g("Generated bundle is empty");return p[0].code}catch(p){throw new g(`DTS bundling failed: ${h(p)}`)}}class B{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(!B.instance)B.instance=new B;return B.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(e){if(!e?.once)return!0;if(this.loggedOnceMessages.has(e.once))return!1;return this.loggedOnceMessages.add(e.once),!0}formatMessage({colorCode:e,label:t,message:n,size:r,identifier:i,muted:s}){let o=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-t.length)),a=s?`\x1B[38;5;${this.colors.info}m${n}\x1B[0m`:n;if(r){let[u,...p]=a.split(" "),f=" ".repeat(Math.max(0,this.MAX_MESSAGE_LENGTH-u.length)),m=i?` \x1B[48;5;${e};38;5;0m ${i} \x1B[0m`:"";return`\x1B[38;5;${e}m${t}\x1B[0m ${o}${u}${f} \x1B[38;5;${this.colors.size}m${r}\x1B[0m ${p.join(" ")}${m}`}let l=i?` \x1B[48;5;${e};38;5;0m ${i} \x1B[0m`:"";return`\x1B[38;5;${e}m${t}\x1B[0m ${o}${a}${l}`}output(e,t={},n=console.log){if(!this.shouldLog(t))return;if(t.verticalSpace)console.log("");if(n(e),t.verticalSpace)console.log("")}cli(e,t={}){let n=this.formatMessage({colorCode:this.colors.cli,label:this.labels.cli,message:e,identifier:t.identifier,muted:t.muted});this.output(n,t)}info(e,t={}){let n=this.formatMessage({colorCode:this.colors.info,label:this.labels.info,message:e,identifier:t.identifier,muted:t.muted});this.output(n,t)}warn(e,t={}){let n=this.formatMessage({colorCode:this.colors.warn,label:this.labels.warn,message:e,identifier:t.identifier,muted:t.muted});this.output(n,t,console.warn)}error(e,t={}){let n=this.formatMessage({colorCode:this.colors.error,label:this.labels.error,message:e,identifier:t.identifier,muted:t.muted});this.output(n,t,console.error)}progress(e,t,n,r){let i=String(e),s=this.colors.default,o,a,l={};if(typeof n==="string")o=n,a=r;else if(n)o=n.size,a=n.identifier,l=n;for(let[p,f]of Object.entries(this.colors.progress))if(i.includes(p)){s=f;break}let u=this.formatMessage({colorCode:s,label:i,message:t,size:o,identifier:a,muted:l.muted});this.output(u,l)}}var c=B.getInstance();var Ke=/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]/gm,Qe=/^\s*export\s+.*from\s+['"]([^'"]+)['"]/gm,Ze=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,ze=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,Je=/import\s+\w+\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,et=/\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/g,tt=/\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/g;function nt(e){let t=new Set,n=[Ke,Qe,Ze,ze,Je,et,tt];for(let r of n){let i=e.matchAll(r);for(let s of i)if(s[1])t.add(s[1])}return t}async function ye(e,t,n){let r=new Set([e]),i=[e];while(i.length){let s=i.pop();if(!s)continue;try{let o=await Bun.file(s).text(),a=nt(o);for(let l of a){let u=await N(l,t,n,s);if(!u)continue;if(!r.has(u))r.add(u),i.push(u)}}catch(o){c.warn(`Error processing ${s}: ${h(o)}`)}}return r}import{isolatedDeclaration as rt}from"oxc-transform";async function we(e){let t=new Map;return await Promise.all([...e].map(async(n)=>{try{let r=R(n);if(!await Bun.file(n).exists())return;let s=await Bun.file(n).text(),{code:o}=rt(n,s);if(o)t.set(r,o)}catch(r){c.warn(`Failed to generate declaration for ${n}: ${h(r)}`)}})),t}import Ee from"node:fs/promises";import Z from"node:path";import{isolatedDeclaration as st}from"oxc-transform";async function $e(e,t){let n=Z.resolve(e),r=Z.resolve(n,t);if(!await Ee.exists(n))throw new g(`Root directory does not exist: ${n}`);if(!await Bun.file(r).exists())throw new g(`Entry file does not exist: ${r}`);if(!r.endsWith(".ts"))throw new g(`Entry file must be a TypeScript file (.ts): ${r}`);if(Z.relative(n,r).startsWith(".."))throw new g(`Entry file must be within rootDir: ${r}`);return{absoluteRootDir:n,absoluteEntry:r}}async function Re(e){let t=!1;if(await Promise.all([...e].map(async(n)=>{try{let r=n.replace(/\.d\.ts$/,".ts"),i=await Bun.file(r).text(),{errors:s}=st(r,i);for(let o of s){if(!t)console.log(`
6
- `);let a=o.labels[0],l=a?it(i,a.start):"",p=`${x(r)}${l}: ${ot(o.message)}`;c.warn(p),t=!0}}catch{}})),t)c.info(`
3
+ import{build as Ge}from"rolldown";import{dts as Xe}from"rolldown-plugin-dts";class $ extends Error{constructor(e){super(e);this.name="BunupError"}}class y extends ${constructor(e){super(e);this.name="BunupBuildError"}}class d extends ${constructor(e){super(e);this.name="BunupDTSBuildError"}}class g extends ${constructor(e){super(e);this.name="BunupCLIError"}}class A extends ${constructor(e){super(e);this.name="BunupWatchError"}}var h=(e)=>{if(e instanceof Error)return e.message;return String(e)},We=[{pattern:/Could not resolve: "bun"/i,errorType:"BUILD ERROR",link:"https://bunup.arshadyaseen.com/#could-not-resolve-bun-error"}],V=(e,t)=>{let n=h(e),r=t?`[${t}] `:"",i="ERROR";if(e instanceof y)i="BUILD ERROR";else if(e instanceof d)i="DTS ERROR";else if(e instanceof g)i="CLI ERROR";else if(e instanceof A)i="WATCH ERROR";else if(e instanceof $)i="BUNUP ERROR";console.error(`\x1B[31m${i}\x1B[0m ${r}${n}`);let o=We.find((s)=>s.pattern.test(n)&&(s.errorType===i||!s.errorType));if(o)console.error(`
4
+ \x1B[90mA solution for this error is available at: \x1B[36m${o.link}\x1B[0m
5
+ `);else console.error("\x1B[90mIf you think this is a bug, please open an issue at: \x1B[36mhttps://github.com/arshadyaseen/bunup/issues/new\x1B[0m")},z=(e,t)=>{V(e,t),process.exit(1)};import J from"node:fs/promises";import je from"node:path";function G(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ee(e=8){let t="";while(t.length<e)t+=Math.random().toString(36).substring(2);return t.substring(0,e)}function te(e,t,n){return Array.isArray(e)?e.map((r)=>({...r,[t]:n})):{...e,[t]:n}}function ne(e){return Array.isArray(e)?e:[e]}function re(e,t){switch(e){case"esm":return".mjs";case"cjs":return M(t)?".cjs":".js";case"iife":return".global.js"}}function se(e,t){switch(e){case"esm":return".d.mts";case"cjs":return M(t)?".d.cts":".d.ts";case"iife":return".d.ts"}}function M(e){return e==="module"}function I(e){return e>=1000?`${(e/1000).toFixed(2)}s`:`${Math.round(e)}ms`}function ie(e){if(!e)return[];return Array.from(new Set([...Object.keys(e.dependencies||{}),...Object.keys(e.peerDependencies||{})]))}function oe(e,t){return e===void 0?t==="esm":e}function X(e){if(e===0)return"0 B";let t=["B","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(1024));if(n===0)return`${e} ${t[n]}`;return`${(e/1024**n).toFixed(2)} ${t[n]}`}function b(e,t=3){return e.split("/").slice(-t).join("/")}async function ae(e,t){let n=je.join(e,t);try{await J.rm(n,{recursive:!0,force:!0})}catch(r){throw new y(`Failed to clean output directory: ${r}`)}await J.mkdir(n,{recursive:!0})}function le(e,t){return t==="cjs"?e:void 0}function ce(e){return e.map((t)=>typeof t==="string"?new RegExp(`^${G(t)}($|\\/|\\\\)`):t)}function D(e,t){return ce(e.external||[]).concat(ie(t).map((n)=>new RegExp(`^${G(n)}($|\\/|\\\\)`)))}function U(e){return ce(e.noExternal||[])}import qe from"node:path";import{ResolverFactory as Ve}from"oxc-resolver";import O from"node:path";var T="\x00dts:",ue=(e,t,n)=>{return{name:"bunup:virtual-dts",async resolveId(r,i){if(Y(r))return r;if(!i||!Y(i))return null;let o=await _(r,t,n,v(i));if(!o)return null;let s=C(o);if(e.has(s))return N(s);return null},load(r){if(r.startsWith(T)){let i=v(r),o=e.get(i);if(o)return R.add(i),o}return null}}};function fe(e){return e.tsconfig?.compilerOptions}function C(e){return e.replace(/\.tsx?$/,".d.ts")}function K(e){let t=O.dirname(e.path||""),n=fe(e);return n?.baseUrl?O.resolve(t,n.baseUrl):t}function pe(e){let t=new Map,n=fe(e)?.paths;if(!n)return t;let r=K(e);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");t.set(`^${s}$`,O.join(r,a))}return t}function Fe(e,t,n){for(let[r,i]of t){let o=new RegExp(r),s=e.match(o);if(s)return i.replace("$1",s[1]||"")}return n?O.join(n,e):null}async function He(e){let t=["",".ts",".tsx","/index.ts","/index.tsx"];for(let n of t){let r=`${e}${n}`;if(await Bun.file(r).exists()&&(r.endsWith(".ts")||r.endsWith(".tsx")))return r}return null}function _(e,t,n,r){let i=e.startsWith(".")?O.resolve(O.dirname(r||""),e):Fe(e,t,n);if(!i)return Promise.resolve(null);return He(i)}function Y(e){return e.startsWith(T)}function v(e){return e.replace(T,"")}function N(e){return`${T}${e}`}var me;function de(e){return{name:"bunup:types-resolve",buildStart(){me||=new Ve({mainFields:["types"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".ts"],modules:["node_modules","node_modules/@types"]})},async resolveId(t,n){let r=n?v(n):void 0;if(/\0/.test(t))return;if(e){if(!e.some((a)=>{let l=!1;if(typeof a==="string")l=a===t||!!r?.includes(a);else l=a.test(t)||!!(r&&a.test(r));return l}))return}let i=r?qe.dirname(r):process.cwd(),{path:o}=await me.async(i,t);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 ge(e,t,n,r,i,o){let s=C(e),a=N(s),l=D(n,r),u=U(n);try{let{output:p}=await Ge({input:a,output:{dir:n.outDir,inlineDynamicImports:!0},write:!1,onwarn(f,m){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(f.code??""))return;m(f)},plugins:[ue(t,i,o),typeof n.dts==="object"&&"resolve"in n.dts&&de(typeof n.dts.resolve==="boolean"?void 0:n.dts.resolve),Xe({dtsInput:!0})],external:(f)=>l.some((m)=>m.test(f))&&!u.some((m)=>m.test(f))});if(!p[0]?.code)throw new d("Generated bundle is empty");return p[0].code}catch(p){throw new d(`DTS bundling failed: ${h(p)}`)}}var he=!1;function k(e){he=e??!1}class B{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(!B.instance)B.instance=new B;return B.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(e){if(!e?.once)return!0;if(this.loggedOnceMessages.has(e.once))return!1;return this.loggedOnceMessages.add(e.once),!0}formatMessage({colorCode:e,label:t,message:n,size:r,identifier:i,muted:o}){let s=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-t.length)),a=o?`\x1B[38;5;${this.colors.info}m${n}\x1B[0m`:n;if(r){let[u,...p]=a.split(" "),f=" ".repeat(Math.max(0,this.MAX_MESSAGE_LENGTH-u.length)),m=i?` \x1B[48;5;${e};38;5;0m ${i} \x1B[0m`:"";return`\x1B[38;5;${e}m${t}\x1B[0m ${s}${u}${f} \x1B[38;5;${this.colors.size}m${r}\x1B[0m ${p.join(" ")}${m}`}let l=i?` \x1B[48;5;${e};38;5;0m ${i} \x1B[0m`:"";return`\x1B[38;5;${e}m${t}\x1B[0m ${s}${a}${l}`}output(e,t={},n=console.log){if(he)return;if(!this.shouldLog(t))return;if(t.verticalSpace)console.log("");if(n(e),t.verticalSpace)console.log("")}cli(e,t={}){let n=this.formatMessage({colorCode:this.colors.cli,label:this.labels.cli,message:e,identifier:t.identifier,muted:t.muted});this.output(n,t)}info(e,t={}){let n=this.formatMessage({colorCode:this.colors.info,label:this.labels.info,message:e,identifier:t.identifier,muted:t.muted});this.output(n,t)}warn(e,t={}){let n=this.formatMessage({colorCode:this.colors.warn,label:this.labels.warn,message:e,identifier:t.identifier,muted:t.muted});this.output(n,t,console.warn)}error(e,t={}){let n=this.formatMessage({colorCode:this.colors.error,label:this.labels.error,message:e,identifier:t.identifier,muted:t.muted});this.output(n,t,console.error)}progress(e,t,n,r){let i=String(e),o=this.colors.default,s,a,l={};if(typeof n==="string")s=n,a=r;else if(n)s=n.size,a=n.identifier,l=n;for(let[p,f]of Object.entries(this.colors.progress))if(i.includes(p)){o=f;break}let u=this.formatMessage({colorCode:o,label:i,message:t,size:s,identifier:a,muted:l.muted});this.output(u,l)}}var c=B.getInstance();var Ye=/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]/gm,Ke=/^\s*export\s+.*from\s+['"]([^'"]+)['"]/gm,Qe=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,Ze=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,ze=/import\s+\w+\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,Je=/\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/g,et=/\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/g;function tt(e){let t=new Set,n=[Ye,Ke,Qe,Ze,ze,Je,et];for(let r of n){let i=e.matchAll(r);for(let o of i)if(o[1])t.add(o[1])}return t}async function xe(e,t,n){let r=new Set([e]),i=[e];while(i.length){let o=i.pop();if(!o)continue;try{let s=await Bun.file(o).text(),a=tt(s);for(let l of a){let u=await _(l,t,n,o);if(!u)continue;if(!r.has(u))r.add(u),i.push(u)}}catch(s){c.warn(`Error processing ${o}: ${h(s)}`)}}return r}import{isolatedDeclaration as nt}from"oxc-transform";async function be(e){let t=new Map;return await Promise.all([...e].map(async(n)=>{try{let r=C(n);if(!await Bun.file(n).exists())return;let o=await Bun.file(n).text(),{code:s}=nt(n,o);if(s)t.set(r,s)}catch(r){c.warn(`Failed to generate declaration for ${n}: ${h(r)}`)}})),t}import ye from"node:fs/promises";import Q from"node:path";import{isolatedDeclaration as rt}from"oxc-transform";async function we(e,t){let n=Q.resolve(e),r=Q.resolve(n,t);if(!await ye.exists(n))throw new d(`Root directory does not exist: ${n}`);if(!await Bun.file(r).exists())throw new d(`Entry file does not exist: ${r}`);if(!r.endsWith(".ts"))throw new d(`Entry file must be a TypeScript file (.ts): ${r}`);if(Q.relative(n,r).startsWith(".."))throw new d(`Entry file must be within rootDir: ${r}`);return{absoluteRootDir:n,absoluteEntry:r}}async function Ee(e){let t=!1;if(await Promise.all([...e].map(async(n)=>{try{let r=n.replace(/\.d\.ts$/,".ts"),i=await Bun.file(r).text(),{errors:o}=rt(r,i);for(let s of o){if(!t)console.log(`
6
+ `);let a=s.labels[0],l=a?st(i,a.start):"",p=`${b(r)}${l}: ${it(s.message)}`;c.warn(p),t=!0}}catch{}})),t)c.info(`
7
7
  You may have noticed some TypeScript warnings above related to missing type annotations. This is because Bunup uses TypeScript's "isolatedDeclarations" approach for generating declaration files. This modern approach requires explicit type annotations on exports for better, more accurate type declarations. Other bundlers might not show these warnings because they use different, potentially less precise methods. Adding the suggested type annotations will not only silence these warnings but also improve the quality of your published type definitions, making your library more reliable for consumers.
8
- `)}function it(e,t){if(t===void 0)return"";let n=e.slice(0,t).split(`
9
- `),r=n.length,i=n[n.length-1].length+1;return` (${r}:${i})`}function ot(e){return e.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}async function Ce(e,t,n,r,i){let{absoluteEntry:s}=await $e(e,t),o=de(r),a=Q(r),l=await ye(s,o,a),u=await we(l);return be(s,u,n,i,o,a)}function L(e){return e.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function A(e){let t=[],n=new Set,r={};function i(s,o){if(n.has(s)){let a=ne(),l=`${s}_${a}`;c.warn(`Output name conflict: "${s}" is used by multiple files.
8
+ `)}function st(e,t){if(t===void 0)return"";let n=e.slice(0,t).split(`
9
+ `),r=n.length,i=n[n.length-1].length+1;return` (${r}:${i})`}function it(e){return e.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}async function $e(e,t,n,r,i){let{absoluteEntry:o}=await we(e,t),s=pe(r),a=K(r),l=await xe(o,s,a),u=await be(l);return ge(o,u,n,i,s,a)}function P(e){return e.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function L(e,{warnOnConflict:t=!0}={}){let n=[],r=new Set,i={};function o(s,a){if(r.has(s)){let l=ee(),u=`${s}_${l}`;if(t)c.warn(`Output name conflict: "${s}" is used by multiple files.
10
10
  Bunup uses filenames without extensions as output names by default.
11
11
 
12
- ${r[s]} -> ${s}.js
13
- ${o} -> ${l}.js (auto-renamed to avoid conflict)
12
+ ${i[s]} -> ${s}.js
13
+ ${a} -> ${u}.js (auto-renamed to avoid conflict)
14
14
 
15
15
  To fix this, use named entries in your configuration:
16
16
  {
17
17
  entry: {
18
- custom_name: "${r[s]}",
19
- another_name: "${o}"
18
+ custom_name: "${i[s]}",
19
+ another_name: "${a}"
20
20
  }
21
21
  }
22
22
 
23
- See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),t.push({name:l,path:o})}else t.push({name:s,path:o}),n.add(s),r[s]=o}if(Array.isArray(e))for(let s of e){let o=L(s);i(o,s)}else if(typeof e==="object")for(let[s,o]of Object.entries(e))i(s,o);else{let s=L(e);i(s,e)}return t}function Oe(e,t){return`[dir]/${e}${t}`}import{loadConfig as Be}from"coffi";async function ve(e,t){return Array.isArray(e)&&"root"in e[0]?e.map((n)=>({rootDir:n.root,options:re(n.config,"name",n.name)})):[{rootDir:t,options:e}]}async function Pe(e){let{config:t,filepath:n}=await Be({name:"package",cwd:e,extensions:[".json"],maxDepth:1});return{packageJson:t,path:n}}async function Te(e,t){let{config:n,filepath:r}=await Be({name:"tsconfig",cwd:e,extensions:[".json"],preferredPath:t,maxDepth:3});return{tsconfig:n,path:r}}function Le(e,t){return{name:"bunup:external-plugin",setup(n){n.onResolve({filter:/.*/},(r)=>{let i=r.path;if(e.some((o)=>o.test(i))&&!t.some((o)=>o.test(i)))return{path:i,external:!0};return null})}}}var C=new Set;async function W(e,t){if(!e.entry||e.entry.length===0||!e.outDir)throw new y("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let{packageJson:n,path:r}=await Pe(t);if(n&&r)c.cli(`Using package.json: ${x(r,2)}`,{muted:!0,identifier:e.name,once:`${r}:${e.name}`});let i=n?.type,s=U(e,n),o=_(e),a=[Le(s,o)],l=A(e.entry),u=ee(e,t),p=e.format.flatMap((f)=>l.map((m)=>{return at(e,t,m,f,i,a,u)}));if(await Promise.all(p),e.dts){let f=await Te(t,e.preferredTsconfigPath);if(f.path)c.cli(`Using tsconfig: ${x(f.path,2)}`,{muted:!0,identifier:e.name,once:`${f.path}:${e.name}`});let m=e.format.filter((E)=>{if(E==="iife"&&!M(i)&&e.format.includes("cjs"))return!1;return!0}),F=typeof e.dts==="object"&&e.dts.entry?A(e.dts.entry):l;try{await Promise.all(F.map(async(E)=>{let Ue=await Ce(t,E.path,e,f,n);await Promise.all(m.map(async(_e)=>{let Ne=ie(_e,i),q=`${t}/${e.outDir}/${E.name}${Ne}`;await Bun.write(q,Ue);let ke=Bun.file(q).size||0;c.progress("DTS",x(q),Y(ke),e.name)}))}))}catch(E){throw new g(h(E))}}}async function at(e,t,n,r,i,s,o){let a=se(r,i),l=await Bun.build({...o,entrypoints:[`${t}/${n.path}`],format:r,naming:{entry:Oe(n.name,a)},splitting:ae(e.splitting,r),bytecode:fe(e.bytecode,r),plugins:s,throw:!1});if(!l.success)for(let f of l.logs){if(f.level==="error")throw new y(f.message);if(f.level==="warning")c.warn(f.message);else if(f.level==="info")c.info(f.message)}let u=`${t}/${e.outDir}/${n.name}${a}`,p=Bun.file(u).size||0;c.progress(r.toUpperCase(),x(u),Y(p),e.name)}var j="0.3.87";var Ae="https://bun.sh/docs/installation",Se="https://bunup.arshadyaseen.com/#cli-options";function b(e){return(t,n)=>{n[e]=t===!0?!0:t==="true"}}function w(e){return(t,n)=>{if(typeof t==="string")n[e]=t;else throw new d(`Option --${e} requires a string value`)}}function De(e){return(t,n)=>{if(typeof t==="string")n[e]=t.split(",");else throw new d(`Option --${e} requires a string value`)}}function ct(){console.log(`
23
+ 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(e))for(let s of e){let a=P(s);o(a,s)}else if(typeof e==="object")for(let[s,a]of Object.entries(e))o(s,a);else{let s=P(e);o(s,e)}return n}function Ce(e,t){return`[dir]/${e}${t}`}import{loadConfig as Re}from"coffi";async function Oe(e,t){return Array.isArray(e)&&"root"in e[0]?e.map((n)=>({rootDir:n.root,options:te(n.config,"name",n.name)})):[{rootDir:t,options:e}]}async function Be(e){let{config:t,filepath:n}=await Re({name:"package",cwd:e,extensions:[".json"],maxDepth:1});return{packageJson:t,path:n}}async function ve(e,t){let{config:n,filepath:r}=await Re({name:"tsconfig",cwd:e,extensions:[".json"],preferredPath:t,maxDepth:3});return{tsconfig:n,path:r}}var Te={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function Pe(e,t){return{outdir:`${t}/${e.outDir}`,minify:ot(e),target:e.target,splitting:e.splitting,sourcemap:e.sourcemap,define:e.define,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer}}function ot(e){let{minify:t,minifyWhitespace:n,minifyIdentifiers:r,minifySyntax:i}=e,o=t===!0;return{whitespace:n??o,identifiers:r??o,syntax:i??o}}function Le(e,t){return{name:"bunup:external-plugin",setup(n){n.onResolve({filter:/.*/},(r)=>{let i=r.path;if(e.some((s)=>s.test(i))&&!t.some((s)=>s.test(i)))return{path:i,external:!0};return null})}}}var R=new Set;async function W(e,t){if(!e.entry||e.entry.length===0||!e.outDir)throw new y("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(e.clean)ae(t,e.outDir);k(e.silent);let{packageJson:n,path:r}=await Be(t);if(n&&r)c.cli(`Using package.json: ${b(r,2)}`,{muted:!0,identifier:e.name,once:`${r}:${e.name}`});let i=n?.type,o=D(e,n),s=U(e),a=[Le(o,s)],l=L(e.entry),u=Pe(e,t),p=e.format.flatMap((f)=>l.map((m)=>{return at(e,t,m,f,i,a,u)}));if(await Promise.all(p),e.dts){let f=await ve(t,e.preferredTsconfigPath);if(f.path)c.cli(`Using tsconfig: ${b(f.path,2)}`,{muted:!0,identifier:e.name,once:`${f.path}:${e.name}`});let m=e.format.filter((E)=>{if(E==="iife"&&!M(i)&&e.format.includes("cjs"))return!1;return!0}),H=typeof e.dts==="object"&&e.dts.entry?L(e.dts.entry):l;try{await Promise.all(H.map(async(E)=>{let Ue=await $e(t,E.path,e,f,n);await Promise.all(m.map(async(_e)=>{let Ne=se(_e,i),q=`${t}/${e.outDir}/${E.name}${Ne}`;await Bun.write(q,Ue);let ke=Bun.file(q).size||0;c.progress("DTS",b(q),X(ke),e.name)}))}))}catch(E){throw new d(h(E))}}}async function at(e,t,n,r,i,o,s){let a=re(r,i),l=await Bun.build({...s,entrypoints:[`${t}/${n.path}`],format:r,naming:{entry:Ce(n.name,a)},splitting:oe(e.splitting,r),bytecode:le(e.bytecode,r),plugins:o,throw:!1});if(!l.success)for(let f of l.logs){if(f.level==="error")throw new y(f.message);if(f.level==="warning")c.warn(f.message);else if(f.level==="info")c.info(f.message)}let u=`${t}/${e.outDir}/${n.name}${a}`,p=Bun.file(u).size||0;c.progress(r.toUpperCase(),b(u),X(p),e.name)}var j="0.3.89";var Se="https://bun.sh/docs/installation",Ae="https://bunup.arshadyaseen.com/#cli-options";function x(e){return(t,n)=>{n[e]=t===!0?!0:t==="true"}}function w(e){return(t,n)=>{if(typeof t==="string")n[e]=t;else throw new g(`Option --${e} requires a string value`)}}function Me(e){return(t,n)=>{if(typeof t==="string")n[e]=t.split(",");else throw new g(`Option --${e} requires a string value`)}}function ct(){console.log(`
24
24
  Bunup - An extremely fast, zero-config bundler for JavaScript and TypeScript, powered by Bun.
25
- `),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${Se}\x1B[0m
26
- `),process.exit(0)}function ut(){console.log(j),process.exit(0)}var ft={name:{flags:["n","name"],handler:w("name")},format:{flags:["f","format"],handler:(e,t)=>{if(typeof e==="string")t.format=e.split(",");else throw new d("Option --format requires a string value")}},outDir:{flags:["o","out-dir"],handler:w("outDir")},minify:{flags:["m","minify"],handler:b("minify")},watch:{flags:["w","watch"],handler:b("watch")},dts:{flags:["d","dts"],handler:b("dts")},banner:{flags:["b","banner"],handler:w("banner")},footer:{flags:["f","footer"],handler:w("footer")},external:{flags:["e","external"],handler:De("external")},sourcemap:{flags:["sm","sourcemap"],handler:w("sourcemap")},target:{flags:["t","target"],handler:w("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:b("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:b("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:b("minifySyntax")},clean:{flags:["c","clean"],handler:b("clean")},splitting:{flags:["s","splitting"],handler:b("splitting")},noExternal:{flags:["ne","no-external"],handler:De("noExternal")},preferredTsconfigPath:{flags:["tsconfig","preferred-tsconfig-path"],handler:w("preferredTsconfigPath")},bytecode:{flags:["bc","bytecode"],handler:b("bytecode")}},pt={resolveDts:{flags:["rd","resolve-dts"],handler:(e,t)=>{if(!t.dts)t.dts={};if(typeof t.dts==="boolean")t.dts={};if(typeof e==="string")if(e==="true"||e==="false")t.dts.resolve=e==="true";else t.dts.resolve=e.split(",");else t.dts.resolve=!0}}},mt={help:{flags:["h","help"],handler:()=>ct()},version:{flags:["v","version"],handler:()=>ut()}},S={};for(let e of Object.values(ft))if(e)for(let t of e.flags)S[t]=e.handler;for(let e of Object.values(pt))for(let t of e.flags)S[t]=e.handler;for(let e of Object.values(mt))for(let t of e.flags)S[t]=e.handler;function Me(e){let t={},n={},r=0;while(r<e.length){let i=e[r];if(i.startsWith("--")){let s,o;if(i.includes("=")){let[a,l]=i.slice(2).split("=",2);s=a,o=l}else{s=i.slice(2);let a=e[r+1];if(o=a&&!a.startsWith("-")?a:!0,typeof o==="string")r++}if(s==="entry")if(typeof o==="string"){let a=L(o);if(n[a])c.warn(`Duplicate entry name '${a}' derived from '${o}'. Overwriting previous entry.`);n[a]=o}else throw new d("Option --entry requires a string value");else if(s.startsWith("entry.")){let a=s.slice(6);if(typeof o==="string"){if(n[a])c.warn(`Duplicate entry name '${a}' provided via --entry.${a}. Overwriting previous entry.`);n[a]=o}else throw new d(`Option --entry.${a} requires a string value`)}else{let a=S[s];if(a)a(o,t);else throw new d(`Unknown option: --${s}`)}}else if(i.startsWith("-")){let s=i.slice(1),o=e[r+1],a=o&&!o.startsWith("-")?o:!0;if(typeof a==="string")r++;let l=S[s];if(l)l(a,t);else throw new d(`Unknown option: -${s}`)}else{let s=L(i);if(n[s])c.warn(`Duplicate entry name '${s}' derived from positional argument '${i}'. Overwriting previous entry.`);n[s]=i}r++}if(Object.keys(n).length>0)t.entry=n;return t}(()=>{if(typeof Bun==="undefined")throw new d(`Bunup requires Bun to run.
27
- To install Bun, visit ${Ae}`)})();import{loadConfig as dt}from"coffi";import H from"node:path";import gt from"chokidar";async function Ie(e,t){let n=new Set,r=A(e.entry);for(let a of r){let l=H.resolve(t,a.path),u=H.dirname(l);n.add(u)}let i=gt.watch(Array.from(n),{persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50},ignoreInitial:!0,atomic:!0,ignorePermissionErrors:!0,ignored:[/[\\/]\.git[\\/]/,/[\\/]node_modules[\\/]/,H.join(t,e.outDir)]}),s=!1,o=async(a=!1)=>{if(s)return;s=!0;try{let l=performance.now();if(await W({...e,entry:r.map((u)=>u.path),clean:!1},t),e.onBuildSuccess?.(),!a)c.cli(`\uD83D\uDCE6 Rebuild finished in ${I(performance.now()-l)}`);await z()}catch(l){V(l)}finally{s=!1}};i.on("change",(a)=>{let l=H.relative(t,a);c.cli(`File changed: ${l}`,{muted:!0}),o()}),i.on("error",(a)=>{throw new D(`Watcher error: ${h(a)}`)}),await o(!0)}async function ht(e=Bun.argv.slice(2)){let t=Me(e),n=process.cwd(),{config:r,filepath:i}=await dt({name:"bunup.config",extensions:[".ts",".js",".mjs",".cjs"],maxDepth:1}),s=!r?[{rootDir:n,options:t}]:await ve(r,n);if(c.cli(`Using bunup v${j} and bun v${Bun.version}`,{muted:!0}),i)c.cli(`Using config file: ${x(i,2)}`,{muted:!0});let o=performance.now();c.cli("Build started");for(let{options:u,rootDir:p}of s){let f=X(u);await Promise.all(f.map((m)=>{if(ue(m.clean))le(p,ce(m.outDir))}))}await Promise.all(s.flatMap(({options:u,rootDir:p})=>{return X(u).map(async(m)=>{let F={...v,...m,...t};return xt(F,p)})}));let a=performance.now()-o,l=I(a);if(c.cli(`\u26A1\uFE0F Build completed in ${l}`),await z(),t.watch)c.cli("\uD83D\uDC40 Watching for file changes");if(!t.watch)process.exit(0)}async function z(){if(C.size>0)await Re(C),C.clear()}async function xt(e,t){if(e.watch)await Ie(e,t);else await W(e,t),e.onBuildSuccess?.()}ht().catch((e)=>J(e));export{z as validateDtsFiles,ht as main};
25
+ `),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${Ae}\x1B[0m
26
+ `),process.exit(0)}function ut(){console.log(j),process.exit(0)}var ft={name:{flags:["n","name"],handler:w("name")},format:{flags:["f","format"],handler:(e,t)=>{if(typeof e==="string")t.format=e.split(",");else throw new g("Option --format requires a string value")}},outDir:{flags:["o","out-dir"],handler:w("outDir")},minify:{flags:["m","minify"],handler:x("minify")},watch:{flags:["w","watch"],handler:x("watch")},dts:{flags:["d","dts"],handler:x("dts")},banner:{flags:["bn","banner"],handler:w("banner")},footer:{flags:["ft","footer"],handler:w("footer")},external:{flags:["e","external"],handler:Me("external")},sourcemap:{flags:["sm","sourcemap"],handler:w("sourcemap")},target:{flags:["t","target"],handler:w("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:x("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:x("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:x("minifySyntax")},clean:{flags:["c","clean"],handler:x("clean")},splitting:{flags:["s","splitting"],handler:x("splitting")},noExternal:{flags:["ne","no-external"],handler:Me("noExternal")},preferredTsconfigPath:{flags:["tsconfig","preferred-tsconfig-path"],handler:w("preferredTsconfigPath")},bytecode:{flags:["bc","bytecode"],handler:x("bytecode")},silent:{flags:["silent"],handler:x("silent")}},pt={resolveDts:{flags:["rd","resolve-dts"],handler:(e,t)=>{if(!t.dts)t.dts={};if(typeof t.dts==="boolean")t.dts={};if(typeof e==="string")if(e==="true"||e==="false")t.dts.resolve=e==="true";else t.dts.resolve=e.split(",");else t.dts.resolve=!0}}},mt={help:{flags:["h","help"],handler:()=>ct()},version:{flags:["v","version"],handler:()=>ut()}},S={};for(let e of Object.values(ft))if(e)for(let t of e.flags)S[t]=e.handler;for(let e of Object.values(pt))for(let t of e.flags)S[t]=e.handler;for(let e of Object.values(mt))for(let t of e.flags)S[t]=e.handler;function Ie(e){let t={},n={},r=0;while(r<e.length){let i=e[r];if(i.startsWith("--")){let o,s;if(i.includes("=")){let[a,l]=i.slice(2).split("=",2);o=a,s=l}else{o=i.slice(2);let a=e[r+1];if(s=a&&!a.startsWith("-")?a:!0,typeof s==="string")r++}if(o==="entry")if(typeof s==="string"){let a=P(s);if(n[a])c.warn(`Duplicate entry name '${a}' derived from '${s}'. Overwriting previous entry.`);n[a]=s}else throw new g("Option --entry requires a string value");else if(o.startsWith("entry.")){let a=o.slice(6);if(typeof s==="string"){if(n[a])c.warn(`Duplicate entry name '${a}' provided via --entry.${a}. Overwriting previous entry.`);n[a]=s}else throw new g(`Option --entry.${a} requires a string value`)}else{let a=S[o];if(a)a(s,t);else throw new g(`Unknown option: --${o}`)}}else if(i.startsWith("-")){let o=i.slice(1),s=e[r+1],a=s&&!s.startsWith("-")?s:!0;if(typeof a==="string")r++;let l=S[o];if(l)l(a,t);else throw new g(`Unknown option: -${o}`)}else{let o=P(i);if(n[o])c.warn(`Duplicate entry name '${o}' derived from positional argument '${i}'. Overwriting previous entry.`);n[o]=i}r++}if(Object.keys(n).length>0)t.entry=n;return t}(()=>{if(typeof Bun==="undefined")throw new g(`Bunup requires Bun to run.
27
+ To install Bun, visit ${Se}`)})();import{loadConfig as gt}from"coffi";import F from"node:path";import dt from"chokidar";async function De(e,t){let n=new Set,r=L(e.entry);for(let a of r){let l=F.resolve(t,a.path),u=F.dirname(l);n.add(u)}let i=dt.watch(Array.from(n),{persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50},ignoreInitial:!0,atomic:!0,ignorePermissionErrors:!0,ignored:[/[\\/]\.git[\\/]/,/[\\/]node_modules[\\/]/,F.join(t,e.outDir)]}),o=!1,s=async(a=!1)=>{if(o)return;o=!0;try{let l=performance.now();if(await W({...e,entry:r.map((u)=>u.path),clean:!1},t),e.onBuildSuccess?.(),!a)c.cli(`\uD83D\uDCE6 Rebuild finished in ${I(performance.now()-l)}`);await Z()}catch(l){V(l)}finally{o=!1}};i.on("change",(a)=>{let l=F.relative(t,a);c.cli(`File changed: ${l}`,{muted:!0}),s()}),i.on("error",(a)=>{throw new A(`Watcher error: ${h(a)}`)}),await s(!0)}async function ht(e=Bun.argv.slice(2)){let t=Ie(e);k(t.silent);let n=process.cwd(),{config:r,filepath:i}=await gt({name:"bunup.config",extensions:[".ts",".js",".mjs",".cjs"],maxDepth:1}),o=!r?[{rootDir:n,options:t}]:await Oe(r,n);if(c.cli(`Using bunup v${j} and bun v${Bun.version}`,{muted:!0}),i)c.cli(`Using config file: ${b(i,2)}`,{muted:!0});let s=performance.now();c.cli("Build started"),await Promise.all(o.flatMap(({options:u,rootDir:p})=>{return ne(u).map(async(m)=>{let H={...Te,...m,...t};return xt(H,p)})}));let a=performance.now()-s,l=I(a);if(c.cli(`\u26A1\uFE0F Build completed in ${l}`),await Z(),t.watch)c.cli("\uD83D\uDC40 Watching for file changes");if(!t.watch)process.exit(0)}async function Z(){if(R.size>0)await Ee(R),R.clear()}async function xt(e,t){if(e.watch)await De(e,t);else await W(e,t),e.onBuildSuccess?.()}ht().catch((e)=>z(e));export{Z as validateDtsFiles,ht as main};
@@ -0,0 +1,15 @@
1
+ var Wt=require("node:module");var St=Object.create;var{getPrototypeOf:At,defineProperty:$,getOwnPropertyNames:G,getOwnPropertyDescriptor:Ot}=Object,q=Object.prototype.hasOwnProperty;var b=(t,e,n)=>{n=t!=null?St(At(t)):{};let r=e||!t||!t.__esModule?$(n,"default",{value:t,enumerable:!0}):n;for(let s of G(t))if(!q.call(r,s))$(r,s,{get:()=>t[s],enumerable:!0});return r},j=new WeakMap,_t=(t)=>{var e=j.get(t),n;if(e)return e;if(e=$({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")G(t).map((r)=>!q.call(e,r)&&$(e,r,{get:()=>t[r],enumerable:!(n=Ot(t,r))||n.enumerable}));return j.set(t,e),e};var Nt=(t,e)=>{for(var n in e)$(t,n,{get:e[n],enumerable:!0,configurable:!0,set:(r)=>e[n]=()=>r})};var Zt={};Nt(Zt,{defineWorkspace:()=>H,defineConfig:()=>X,build:()=>Dt});module.exports=_t(Zt);function X(t){return t}function H(t){return t}var ut=require("rolldown"),ft=require("rolldown-plugin-dts");class A extends Error{constructor(t){super(t);this.name="BunupError"}}class E extends A{constructor(t){super(t);this.name="BunupBuildError"}}class p extends A{constructor(t){super(t);this.name="BunupDTSBuildError"}}var d=(t)=>{if(t instanceof Error)return t.message;return String(t)};var O=b(require("node:fs/promises")),k=b(require("node:path"));function _(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function K(t=8){let e="";while(e.length<t)e+=Math.random().toString(36).substring(2);return e.substring(0,t)}function Y(t,e){switch(t){case"esm":return".mjs";case"cjs":return D(e)?".cjs":".js";case"iife":return".global.js"}}function Q(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 Z(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 N(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 w(t,e=3){return t.split("/").slice(-e).join("/")}async function J(t,e){let n=k.default.join(t,e);try{await O.default.rm(n,{recursive:!0,force:!0})}catch(r){throw new E(`Failed to clean output directory: ${r}`)}await O.default.mkdir(n,{recursive:!0})}function tt(t,e){return e==="cjs"?t:void 0}function et(t){return t.map((e)=>typeof e==="string"?new RegExp(`^${_(e)}($|\\/|\\\\)`):e)}function M(t,e){return et(t.external||[]).concat(Z(e).map((n)=>new RegExp(`^${_(n)}($|\\/|\\\\)`)))}function T(t){return et(t.noExternal||[])}var at=b(require("node:path")),ct=require("oxc-resolver");var x=b(require("node:path"));var P="\x00dts:",nt=(t,e,n)=>{return{name:"bunup:virtual-dts",async resolveId(r,s){if(W(r))return r;if(!s||!W(s))return null;let o=await B(r,e,n,C(s));if(!o)return null;let i=R(o);if(t.has(i))return I(i);return null},load(r){if(r.startsWith(P)){let s=C(r),o=t.get(s);if(o)return rt.add(s),o}return null}}};function st(t){return t.tsconfig?.compilerOptions}function R(t){return t.replace(/\.tsx?$/,".d.ts")}function U(t){let e=x.default.dirname(t.path||""),n=st(t);return n?.baseUrl?x.default.resolve(e,n.baseUrl):e}function it(t){let e=new Map,n=st(t)?.paths;if(!n)return e;let r=U(t);for(let[s,o]of Object.entries(n))if(Array.isArray(o)&&o.length){let i=s.replace(/\*/g,"(.*)"),a=o[0].replace(/\*/g,"$1");e.set(`^${i}$`,x.default.join(r,a))}return e}function Ut(t,e,n){for(let[r,s]of e){let o=new RegExp(r),i=t.match(o);if(i)return s.replace("$1",i[1]||"")}return n?x.default.join(n,t):null}async function vt(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 B(t,e,n,r){let s=t.startsWith(".")?x.default.resolve(x.default.dirname(r||""),t):Ut(t,e,n);if(!s)return Promise.resolve(null);return vt(s)}function W(t){return t.startsWith(P)}function C(t){return t.replace(P,"")}function I(t){return`${P}${t}`}var ot;function lt(t){return{name:"bunup:types-resolve",buildStart(){ot||=new ct.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 s=r?at.default.dirname(r):process.cwd(),{path:o}=await ot.async(s,e);if(!o)return;if(/[cm]?jsx?$/.test(o)){let i=o.replace(/\.([cm]?)jsx?$/,".d.$1ts");return await Bun.file(i).exists()?i:void 0}return o}}}async function gt(t,e,n,r,s,o){let i=R(t),a=I(i),c=M(n,r),u=T(n);try{let{output:g}=await ut.build({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:[nt(e,s,o),typeof n.dts==="object"&&"resolve"in n.dts&&lt(typeof n.dts.resolve==="boolean"?void 0:n.dts.resolve),ft.dts({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 mt=!1;function pt(t){mt=t??!1}class y{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(!y.instance)y.instance=new y;return y.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:s,muted:o}){let i=" ".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=s?` \x1B[48;5;${t};38;5;0m ${s} \x1B[0m`:"";return`\x1B[38;5;${t}m${e}\x1B[0m ${i}${u}${l} \x1B[38;5;${this.colors.size}m${r}\x1B[0m ${g.join(" ")}${m}`}let c=s?` \x1B[48;5;${t};38;5;0m ${s} \x1B[0m`:"";return`\x1B[38;5;${t}m${e}\x1B[0m ${i}${a}${c}`}output(t,e={},n=console.log){if(mt)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 s=String(t),o=this.colors.default,i,a,c={};if(typeof n==="string")i=n,a=r;else if(n)i=n.size,a=n.identifier,c=n;for(let[g,l]of Object.entries(this.colors.progress))if(s.includes(g)){o=l;break}let u=this.formatMessage({colorCode:o,label:s,message:e,size:i,identifier:a,muted:c.muted});this.output(u,c)}}var f=y.getInstance();var Ft=/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]/gm,Vt=/^\s*export\s+.*from\s+['"]([^'"]+)['"]/gm,jt=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,Gt=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,qt=/import\s+\w+\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,Xt=/\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/g,Ht=/\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/g;function kt(t){let e=new Set,n=[Ft,Vt,jt,Gt,qt,Xt,Ht];for(let r of n){let s=t.matchAll(r);for(let o of s)if(o[1])e.add(o[1])}return e}async function dt(t,e,n){let r=new Set([t]),s=[t];while(s.length){let o=s.pop();if(!o)continue;try{let i=await Bun.file(o).text(),a=kt(i);for(let c of a){let u=await B(c,e,n,o);if(!u)continue;if(!r.has(u))r.add(u),s.push(u)}}catch(i){f.warn(`Error processing ${o}: ${d(i)}`)}}return r}var xt=require("oxc-transform");async function ht(t){let e=new Map;return await Promise.all([...t].map(async(n)=>{try{let r=R(n);if(!await Bun.file(n).exists())return;let o=await Bun.file(n).text(),{code:i}=xt.isolatedDeclaration(n,o);if(i)e.set(r,i)}catch(r){f.warn(`Failed to generate declaration for ${n}: ${d(r)}`)}})),e}var v=b(require("node:fs/promises")),L=b(require("node:path")),Kt=require("oxc-transform");async function bt(t,e){let n=L.default.resolve(t),r=L.default.resolve(n,e);if(!await v.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(L.default.relative(n,r).startsWith(".."))throw new p(`Entry file must be within rootDir: ${r}`);return{absoluteRootDir:n,absoluteEntry:r}}async function Et(t,e,n,r,s){let{absoluteEntry:o}=await bt(t,e),i=it(r),a=U(r),c=await dt(o,i,a),u=await ht(c);return gt(o,u,n,s,i,a)}function wt(t){return t.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function F(t,{warnOnConflict:e=!0}={}){let n=[],r=new Set,s={};function o(i,a){if(r.has(i)){let c=K(),u=`${i}_${c}`;if(e)f.warn(`Output name conflict: "${i}" is used by multiple files.
2
+ Bunup uses filenames without extensions as output names by default.
3
+
4
+ ${s[i]} -> ${i}.js
5
+ ${a} -> ${u}.js (auto-renamed to avoid conflict)
6
+
7
+ To fix this, use named entries in your configuration:
8
+ {
9
+ entry: {
10
+ custom_name: "${s[i]}",
11
+ another_name: "${a}"
12
+ }
13
+ }
14
+
15
+ See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0});n.push({name:u,path:a})}else n.push({name:i,path:a}),r.add(i),s[i]=a}if(Array.isArray(t))for(let i of t){let a=wt(i);o(a,i)}else if(typeof t==="object")for(let[i,a]of Object.entries(t))o(i,a);else{let i=wt(t);o(i,t)}return n}function Rt(t,e){return`[dir]/${t}${e}`}var V=require("coffi");async function yt(t){let{config:e,filepath:n}=await V.loadConfig({name:"package",cwd:t,extensions:[".json"],maxDepth:1});return{packageJson:e,path:n}}async function $t(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 Ct(t,e){return{outdir:`${e}/${t.outDir}`,minify:Yt(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 Yt(t){let{minify:e,minifyWhitespace:n,minifyIdentifiers:r,minifySyntax:s}=t,o=e===!0;return{whitespace:n??o,identifiers:r??o,syntax:s??o}}function Pt(t,e){return{name:"bunup:external-plugin",setup(n){n.onResolve({filter:/.*/},(r)=>{let s=r.path;if(t.some((i)=>i.test(s))&&!e.some((i)=>i.test(s)))return{path:s,external:!0};return null})}}}var rt=new Set;async function Dt(t,e){if(!t.entry||t.entry.length===0||!t.outDir)throw new E("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(t.clean)J(e,t.outDir);pt(t.silent);let{packageJson:n,path:r}=await yt(e);if(n&&r)f.cli(`Using package.json: ${w(r,2)}`,{muted:!0,identifier:t.name,once:`${r}:${t.name}`});let s=n?.type,o=M(t,n),i=T(t),a=[Pt(o,i)],c=F(t.entry),u=Ct(t,e),g=t.format.flatMap((l)=>c.map((m)=>{return Qt(t,e,m,l,s,a,u)}));if(await Promise.all(g),t.dts){let l=await $t(e,t.preferredTsconfigPath);if(l.path)f.cli(`Using tsconfig: ${w(l.path,2)}`,{muted:!0,identifier:t.name,once:`${l.path}:${t.name}`});let m=t.format.filter((h)=>{if(h==="iife"&&!D(s)&&t.format.includes("cjs"))return!1;return!0}),Mt=typeof t.dts==="object"&&t.dts.entry?F(t.dts.entry):c;try{await Promise.all(Mt.map(async(h)=>{let Tt=await Et(e,h.path,t,l,n);await Promise.all(m.map(async(Bt)=>{let It=Q(Bt,s),S=`${e}/${t.outDir}/${h.name}${It}`;await Bun.write(S,Tt);let Lt=Bun.file(S).size||0;f.progress("DTS",w(S),N(Lt),t.name)}))}))}catch(h){throw new p(d(h))}}}async function Qt(t,e,n,r,s,o,i){let a=Y(r,s),c=await Bun.build({...i,entrypoints:[`${e}/${n.path}`],format:r,naming:{entry:Rt(n.name,a)},splitting:z(t.splitting,r),bytecode:tt(t.bytecode,r),plugins:o,throw:!1});if(!c.success)for(let l of c.logs){if(l.level==="error")throw new E(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(),w(u),N(g),t.name)}
@@ -0,0 +1,273 @@
1
+ import _Bun from "bun";
2
+
3
+ //#region \0dts:/home/runner/work/bunup/bunup/src/options.d.ts
4
+ type Loader = NonNullable<BunBuildOptions["loader"]>[string];
5
+ type Define = BunBuildOptions["define"];
6
+ type Sourcemap = BunBuildOptions["sourcemap"];
7
+ type Format = Exclude<BunBuildOptions["format"], undefined>;
8
+ type Target = BunBuildOptions["target"];
9
+ type External = (string | RegExp)[];
10
+ type Entry = Arrayable<string> | Record<string, string>;
11
+ type DtsOptions = {
12
+ /**
13
+ * Entry point files for TypeScript declaration file generation
14
+ *
15
+ * This can be:
16
+ * - A string path to a file
17
+ * - An array of file paths
18
+ * - An object where keys are output names and values are input file paths
19
+ *
20
+ * The key names are used for the generated declaration files.
21
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
22
+ *
23
+ * If not specified, the main entry points will be used for declaration file generation.
24
+ *
25
+ * If it's a string or an array of strings, the file name (without extension)
26
+ * will be used as the name for the output declaration file.
27
+ *
28
+ * @example
29
+ * // Using a string path
30
+ * entry: 'src/index.ts' // Generates index.d.ts
31
+ *
32
+ * // Using string paths in an array
33
+ * entry: ['src/index.ts'] // Generates index.d.ts
34
+ *
35
+ * // Using named outputs as an object
36
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
37
+ */
38
+ entry?: Entry
39
+ /**
40
+ * Resolve external types used in dts files from node_modules
41
+ */
42
+ resolve?: boolean | (string | RegExp)[]
43
+ };
44
+ interface BuildOptions {
45
+ /**
46
+ * Name of the build configuration
47
+ * Used for logging and identification purposes
48
+ */
49
+ name?: string;
50
+ /**
51
+ * Entry point files for the build
52
+ *
53
+ * This can be:
54
+ * - A string path to a file
55
+ * - An array of file paths
56
+ * - An object where keys are output names and values are input file paths
57
+ *
58
+ * The key names are used for the generated output files.
59
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.js`
60
+ *
61
+ * If it's a string or an array of strings, the file name (without extension)
62
+ * will be used as the name for the output file.
63
+ *
64
+ * @example
65
+ * // Using a string path
66
+ * entry: 'src/index.ts' // Generates index.js
67
+ *
68
+ * // Using string paths in an array
69
+ * entry: ['src/index.ts'] // Generates index.js
70
+ *
71
+ * // Using named outputs as an object
72
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.js and utils.js
73
+ */
74
+ entry: Entry;
75
+ /**
76
+ * Output directory for the bundled files
77
+ * Defaults to 'dist' if not specified
78
+ */
79
+ outDir: string;
80
+ /**
81
+ * Output formats for the bundle
82
+ * Can include 'esm', 'cjs', and/or 'iife'
83
+ * Defaults to ['cjs'] if not specified
84
+ */
85
+ format: Format[];
86
+ /**
87
+ * Whether to enable all minification options
88
+ * When true, enables minifyWhitespace, minifyIdentifiers, and minifySyntax
89
+ */
90
+ minify?: boolean;
91
+ /**
92
+ * Whether to enable code splitting
93
+ * Defaults to true for ESM format, false for CJS format
94
+ */
95
+ splitting?: boolean;
96
+ /**
97
+ * Whether to minify whitespace in the output
98
+ * Removes unnecessary whitespace to reduce file size
99
+ */
100
+ minifyWhitespace?: boolean;
101
+ /**
102
+ * Whether to minify identifiers in the output
103
+ * Renames variables and functions to shorter names
104
+ */
105
+ minifyIdentifiers?: boolean;
106
+ /**
107
+ * Whether to minify syntax in the output
108
+ * Optimizes code structure for smaller file size
109
+ */
110
+ minifySyntax?: boolean;
111
+ /**
112
+ * Whether to watch for file changes and rebuild automatically
113
+ */
114
+ watch?: boolean;
115
+ /**
116
+ * Whether to generate TypeScript declaration files (.d.ts)
117
+ * When set to true, generates declaration files for all entry points
118
+ * Can also be configured with DtsOptions for more control
119
+ */
120
+ dts?: boolean | DtsOptions;
121
+ /**
122
+ * Path to a preferred tsconfig.json file to use for declaration generation
123
+ *
124
+ * If not specified, the tsconfig.json in the project root will be used.
125
+ * This option allows you to use a different TypeScript configuration
126
+ * specifically for declaration file generation.
127
+ *
128
+ * @example
129
+ * preferredTsconfigPath: './tsconfig.build.json'
130
+ */
131
+ preferredTsconfigPath?: string;
132
+ /**
133
+ * External packages that should not be bundled
134
+ * Useful for dependencies that should be kept as external imports
135
+ */
136
+ external?: External;
137
+ /**
138
+ * Packages that should be bundled even if they are in external
139
+ * Useful for dependencies that should be included in the bundle
140
+ */
141
+ noExternal?: External;
142
+ /**
143
+ * The target environment for the bundle
144
+ * Can be 'browser', 'bun', 'node', etc.
145
+ * Defaults to 'node' if not specified
146
+ */
147
+ target?: Target;
148
+ /**
149
+ * Whether to clean the output directory before building
150
+ * When true, removes all files in the outDir before starting a new build
151
+ * Defaults to true if not specified
152
+ */
153
+ clean?: boolean;
154
+ /**
155
+ * Specifies the type of sourcemap to generate
156
+ * Can be 'none', 'linked', 'external', or 'inline'
157
+ *
158
+ * @see https://bun.sh/docs/bundler#sourcemap
159
+ *
160
+ * @default 'none'
161
+ *
162
+ * @example
163
+ * sourcemap: 'linked'
164
+ */
165
+ sourcemap?: Sourcemap;
166
+ /**
167
+ * Define global constants for the build
168
+ * These values will be replaced at build time
169
+ *
170
+ * @see https://bun.sh/docs/bundler#define
171
+ *
172
+ * @example
173
+ * define: {
174
+ * 'process.env.NODE_ENV': '"production"',
175
+ * 'PACKAGE_VERSION': '"1.0.0"'
176
+ * }
177
+ */
178
+ define?: Define;
179
+ /**
180
+ * A callback function that runs after the build process completes
181
+ * This can be used for custom post-build operations like copying files,
182
+ * running additional tools, or logging build information
183
+ *
184
+ * If watch mode is enabled, this callback runs after each rebuild
185
+ */
186
+ onBuildSuccess?: () => PromiseOr<void>;
187
+ /**
188
+ * 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.
189
+ *
190
+ * @see https://bun.sh/docs/bundler#banner
191
+ *
192
+ * @example
193
+ * banner: '"use client";'
194
+ */
195
+ banner?: string;
196
+ /**
197
+ * 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.
198
+ *
199
+ * @see https://bun.sh/docs/bundler#footer
200
+ *
201
+ * @example
202
+ * footer: '// built with love in SF'
203
+ */
204
+ footer?: string;
205
+ /**
206
+ * 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.
207
+ *
208
+ * @see https://bun.sh/docs/bundler#drop
209
+ *
210
+ * @example
211
+ * drop: ["console", "debugger", "anyIdentifier.or.propertyAccess"]
212
+ */
213
+ drop?: string[];
214
+ /**
215
+ * 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.
216
+ *
217
+ * @see https://bun.sh/docs/bundler#loader
218
+ *
219
+ * @example
220
+ * loader: {
221
+ * ".png": "dataurl",
222
+ * ".txt": "file",
223
+ * }
224
+ */
225
+ loader?: Record<string, Loader>;
226
+ /**
227
+ * Generate bytecode for the output. This can dramatically improve cold start times, but will make the final output larger and slightly increase memory usage.
228
+ *
229
+ * Bytecode is currently only supported for CommonJS (format: "cjs").
230
+ *
231
+ * Must be target: "bun"
232
+ *
233
+ * @see https://bun.sh/docs/bundler#bytecode
234
+ *
235
+ * @default false
236
+ */
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;
244
+ }
245
+
246
+ //#endregion
247
+ //#region \0dts:/home/runner/work/bunup/bunup/src/types.d.ts
248
+ type PromiseOr<T> = Promise<T> | T;
249
+ type WithOptional<
250
+ T,
251
+ K extends keyof T
252
+ > = Omit<T, K> & Partial<Pick<T, K>>;
253
+ type Arrayable<T> = T | T[];
254
+ type Bun = typeof _Bun;
255
+ type BunBuildOptions = Parameters<Bun["build"]>[0];
256
+ type DefineConfigItem = Omit<WithOptional<BuildOptions, "outDir" | "format">, "watch">;
257
+ type DefineWorkspaceItem = {
258
+ name: string
259
+ root: string
260
+ config: DefineConfigItem | DefineConfigItem[]
261
+ };
262
+
263
+ //#endregion
264
+ //#region \0dts:/home/runner/work/bunup/bunup/src/define.d.ts
265
+ declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
266
+ declare function defineWorkspace(options: DefineWorkspaceItem[]): DefineWorkspaceItem[];
267
+
268
+ //#endregion
269
+ //#region \0dts:/home/runner/work/bunup/bunup/src/build.d.ts
270
+ declare function build(options: BuildOptions, rootDir: string): Promise<void>;
271
+
272
+ //#endregion
273
+ export { BuildOptions, DefineConfigItem, DefineWorkspaceItem, build, defineConfig, defineWorkspace };