bunup 0.4.9 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/cli.mjs CHANGED
@@ -31,7 +31,7 @@ See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0})
31
31
  const importMetaUrl = pathToFileURL(__filename).href;
32
32
 
33
33
  `}};var mt=/\.(js|ts|jsx|tsx|mts|cts)$/;function ke({format:e,target:t,shims:n}){let s=dt(n).map((o)=>N[o]).filter((o)=>o.appliesTo(e,t));if(s.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(o){o.onLoad({filter:mt},async({path:i})=>{let a=await Bun.file(i).text(),l=s.filter((p)=>p.isNeededInFile(a));if(l.length===0)return;let{shebangLine:c,codeContent:f}=gt(a),m=l.map((p)=>p.generateCode()).join("");return{contents:c+m+f}})}}}function dt(e){if(e===!0)return Object.keys(N);if(!e)return[];return Object.entries(e).filter(([t,n])=>n&&(t in N)).map(([t])=>t)}function gt(e){if(!e.startsWith("#!"))return{shebangLine:"",codeContent:e};let t=e.indexOf(`
34
- `);return t===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,t+1),codeContent:e.slice(t+1)}}var $=new Set;async function F(e,t){let n=U(e);if(!n.entry||n.entry.length===0||!n.outDir)throw new w("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(n.clean)ue(t,n.outDir);_(n.silent);let{packageJson:r,path:s}=await Be(t);if(r&&s)u.cli(`Using package.json: ${x(s,2)}`,{muted:!0,identifier:n.name,once:`${s}:${n.name}`});let o=P(n.entry),i=r?.type,a=M(n,r),l=D(n);if(!n.dtsOnly){let c=[ve(a,l)],f=n.format.flatMap((m)=>o.map((p)=>{return ht(n,t,p,m,i,c)}));await Promise.all(f)}if(n.dts||n.dtsOnly){let c=await Le(t,n.preferredTsconfigPath);if(c.path)u.cli(`Using tsconfig: ${x(c.path,2)}`,{muted:!0,identifier:n.name,once:`${c.path}:${n.name}`});let f=n.format.filter((p)=>{if(p==="iife"&&!L(i)&&n.format.includes("cjs"))return!1;return!0}),m=typeof n.dts==="object"&&n.dts.entry?P(n.dts.entry):Re(o);try{await Promise.all(m.map(async(p)=>{let G=await $e(t,p.path,n,c,r);await Promise.all(f.map(async(He)=>{let qe=le(He,i),V=`${t}/${n.outDir}/${p.name}${qe}`;await Bun.write(V,G);let Ge=Bun.file(V).size||0;u.progress("DTS",x(V),J(Ge),n.name)}))}))}catch(p){throw new h(b(p))}}}async function ht(e,t,n,r,s,o){let i=ae(r,s),a=await Bun.build({entrypoints:[`${t}/${n.path}`],format:r,naming:{entry:Se(n.name,i)},splitting:De(e.splitting,r),bytecode:Ie(e.bytecode,r),define:Me(e.define,e.shims,e.env,r),minify:Ae(e),outdir:`${t}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:_e(e.env),plugins:[...o,ke({format:r,target:e.target,shims:e.shims})],throw:!1});if(!a.success)for(let f of a.logs){if(f.level==="error")throw new w(f.message);if(f.level==="warning")u.warn(f.message);else if(f.level==="info")u.info(f.message)}let l=`${t}/${e.outDir}/${n.name}${i}`,c=Bun.file(l).size||0;u.progress(r.toUpperCase(),x(l),J(c),e.name)}var W="0.4.9";var je="https://bun.sh/docs/installation",Ue="https://bunup.arshadyaseen.com/#cli-options";function g(e){return(t,n)=>{n[e]=t===!0||t==="true"}}function y(e){return(t,n)=>{if(typeof t==="string")n[e]=t;else throw new d(`Option --${e} requires a string value`)}}function ee(e){return(t,n)=>{if(typeof t==="string")n[e]=t.split(",");else throw new d(`Option --${e} requires a string value`)}}function xt(e){return(t,n)=>{if(typeof t==="boolean")n[e]=t;else if(typeof t==="string")if(t.toLowerCase()==="true"||t.toLowerCase()==="false")n[e]=t.toLowerCase()==="true";else n[e]=t;else throw new d(`Option --${e} requires a boolean or string value`)}}function yt(){console.log(`
34
+ `);return t===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,t+1),codeContent:e.slice(t+1)}}var $=new Set;async function F(e,t){let n=U(e);if(!n.entry||n.entry.length===0||!n.outDir)throw new w("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(n.clean)ue(t,n.outDir);_(n.silent);let{packageJson:r,path:s}=await Be(t);if(r&&s)u.cli(`Using package.json: ${x(s,2)}`,{muted:!0,identifier:n.name,once:`${s}:${n.name}`});let o=P(n.entry),i=r?.type,a=M(n,r),l=D(n);if(!n.dtsOnly){let c=[ve(a,l)],f=n.format.flatMap((m)=>o.map((p)=>{return ht(n,t,p,m,i,c)}));await Promise.all(f)}if(n.dts||n.dtsOnly){let c=await Le(t,n.preferredTsconfigPath);if(c.path)u.cli(`Using tsconfig: ${x(c.path,2)}`,{muted:!0,identifier:n.name,once:`${c.path}:${n.name}`});let f=n.format.filter((p)=>{if(p==="iife"&&!L(i)&&n.format.includes("cjs"))return!1;return!0}),m=typeof n.dts==="object"&&n.dts.entry?P(n.dts.entry):Re(o);try{await Promise.all(m.map(async(p)=>{let G=await $e(t,p.path,n,c,r);await Promise.all(f.map(async(He)=>{let qe=le(He,i),V=`${t}/${n.outDir}/${p.name}${qe}`;await Bun.write(V,G);let Ge=Bun.file(V).size||0;u.progress("DTS",x(V),J(Ge),n.name)}))}))}catch(p){throw new h(b(p))}}}async function ht(e,t,n,r,s,o){let i=ae(r,s),a=await Bun.build({entrypoints:[`${t}/${n.path}`],format:r,naming:{entry:Se(n.name,i)},splitting:De(e.splitting,r),bytecode:Ie(e.bytecode,r),define:Me(e.define,e.shims,e.env,r),minify:Ae(e),outdir:`${t}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:_e(e.env),plugins:[...o,ke({format:r,target:e.target,shims:e.shims}),...e.bunBuildPlugins??[]],throw:!1});if(!a.success)for(let f of a.logs){if(f.level==="error")throw new w(f.message);if(f.level==="warning")u.warn(f.message);else if(f.level==="info")u.info(f.message)}let l=`${t}/${e.outDir}/${n.name}${i}`,c=Bun.file(l).size||0;u.progress(r.toUpperCase(),x(l),J(c),e.name)}var W="0.4.10";var je="https://bun.sh/docs/installation",Ue="https://bunup.arshadyaseen.com/#cli-options";function g(e){return(t,n)=>{n[e]=t===!0||t==="true"}}function y(e){return(t,n)=>{if(typeof t==="string")n[e]=t;else throw new d(`Option --${e} requires a string value`)}}function ee(e){return(t,n)=>{if(typeof t==="string")n[e]=t.split(",");else throw new d(`Option --${e} requires a string value`)}}function xt(e){return(t,n)=>{if(typeof t==="boolean")n[e]=t;else if(typeof t==="string")if(t.toLowerCase()==="true"||t.toLowerCase()==="false")n[e]=t.toLowerCase()==="true";else n[e]=t;else throw new d(`Option --${e} requires a boolean or string value`)}}function yt(){console.log(`
35
35
  Bunup - An extremely fast, zero-config bundler for JavaScript and TypeScript, powered by Bun.
36
36
  `),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${Ue}\x1B[0m
37
37
  `),process.exit(0)}function wt(){console.log(W),process.exit(0)}var Ne={name:{flags:["n","name"],handler:y("name")},format:{flags:["f","format"],handler:ee("format")},outDir:{flags:["o","out-dir"],handler:y("outDir")},minify:{flags:["m","minify"],handler:g("minify")},watch:{flags:["w","watch"],handler:g("watch")},dts:{flags:["d","dts"],handler:g("dts")},banner:{flags:["bn","banner"],handler:y("banner")},footer:{flags:["ft","footer"],handler:y("footer")},external:{flags:["e","external"],handler:ee("external")},sourcemap:{flags:["sm","sourcemap"],handler:xt("sourcemap")},target:{flags:["t","target"],handler:y("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:g("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:g("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:g("minifySyntax")},clean:{flags:["c","clean"],handler:g("clean")},splitting:{flags:["s","splitting"],handler:g("splitting")},noExternal:{flags:["ne","no-external"],handler:ee("noExternal")},preferredTsconfigPath:{flags:["tsconfig","preferred-tsconfig-path"],handler:y("preferredTsconfigPath")},bytecode:{flags:["bc","bytecode"],handler:g("bytecode")},dtsOnly:{flags:["do","dts-only"],handler:g("dtsOnly")},silent:{flags:["silent"],handler:g("silent")},config:{flags:["config"],handler:y("config")},publicPath:{flags:["pp","public-path"],handler:y("publicPath")},env:{flags:["env"],handler:y("env")},shims:{flags:["shims"],handler:g("shims")},entry:{flags:["entry"],handler:(e,t,n)=>{if(typeof e!=="string")throw new d(`Entry${n?` --entry.${n}`:""} requires a string value`);let r=t.entry||{};if(n){if(r[n])u.warn(`Duplicate entry name '${n}' provided via --entry.${n}. Overwriting previous entry.`);r[n]=e}else{let s=j(e);if(r[s])u.warn(`Duplicate entry name '${s}' derived from '${e}'. Overwriting previous entry.`);r[s]=e}t.entry=r}},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}},help:{flags:["h","help"],handler:()=>yt()},version:{flags:["v","version"],handler:()=>wt()}},H={};for(let e of Object.values(Ne))for(let t of e.flags)H[t]=e.handler;function Fe(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r.startsWith("--")){let s,o;if(r.includes("=")){let[i,a]=r.slice(2).split("=",2);s=i,o=a}else{s=r.slice(2);let i=e[n+1];if(o=i&&!i.startsWith("-")?i:!0,typeof o==="string")n++}if(s.includes(".")){let[i,a]=s.split(".",2),l=H[i];if(l)l(o,t,a);else throw new d(`Unknown option: --${s}`)}else{let i=H[s];if(i)i(o,t);else throw new d(`Unknown option: --${s}`)}}else if(r.startsWith("-")){let s=r.slice(1),o=e[n+1],i=o&&!o.startsWith("-")?o:!0;if(typeof i==="string")n++;let a=H[s];if(a)a(i,t);else throw new d(`Unknown option: -${s}`)}else Ne.entry.handler(r,t,void 0)}return t}(()=>{if(typeof Bun==="undefined")throw new d(`Bunup requires Bun to run.
package/build/index.d.mts CHANGED
@@ -331,6 +331,12 @@ interface BuildOptions {
331
331
  * env: { API_URL: "https://api.example.com", DEBUG: "false" }
332
332
  */
333
333
  env?: Env;
334
+ /**
335
+ * Custom Bun.build plugins to be applied during the build process..
336
+ *
337
+ * @see https://bun.sh/docs/bundler/plugins for more information about Bun's plugin system
338
+ */
339
+ bunBuildPlugins?: BunPlugin[];
334
340
  }
335
341
 
336
342
  //#endregion
@@ -343,6 +349,7 @@ type WithOptional<
343
349
  type Arrayable<T> = T | T[];
344
350
  type Bun = typeof _Bun;
345
351
  type BunBuildOptions = Parameters<Bun["build"]>[0];
352
+ type BunPlugin = Exclude<BunBuildOptions["plugins"], undefined>[number];
346
353
  type DefineConfigItem = Omit<WithOptional<BuildOptions, "outDir" | "format">, "watch">;
347
354
  type DefineWorkspaceItem = {
348
355
  name: string
package/build/index.d.ts CHANGED
@@ -331,6 +331,12 @@ interface BuildOptions {
331
331
  * env: { API_URL: "https://api.example.com", DEBUG: "false" }
332
332
  */
333
333
  env?: Env;
334
+ /**
335
+ * Custom Bun.build plugins to be applied during the build process..
336
+ *
337
+ * @see https://bun.sh/docs/bundler/plugins for more information about Bun's plugin system
338
+ */
339
+ bunBuildPlugins?: BunPlugin[];
334
340
  }
335
341
 
336
342
  //#endregion
@@ -343,6 +349,7 @@ type WithOptional<
343
349
  type Arrayable<T> = T | T[];
344
350
  type Bun = typeof _Bun;
345
351
  type BunBuildOptions = Parameters<Bun["build"]>[0];
352
+ type BunPlugin = Exclude<BunBuildOptions["plugins"], undefined>[number];
346
353
  type DefineConfigItem = Omit<WithOptional<BuildOptions, "outDir" | "format">, "watch">;
347
354
  type DefineWorkspaceItem = {
348
355
  name: string
package/build/index.js CHANGED
@@ -23,4 +23,4 @@ See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0})
23
23
  const importMetaUrl = pathToFileURL(__filename).href;
24
24
 
25
25
  `}};var re=/\.(js|ts|jsx|tsx|mts|cts)$/;function Lt({format:t,target:e,shims:r}){let s=ne(r).map((o)=>L[o]).filter((o)=>o.appliesTo(t,e));if(s.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(o){o.onLoad({filter:re},async({path:i})=>{let a=await Bun.file(i).text(),u=s.filter((f)=>f.isNeededInFile(a));if(u.length===0)return;let{shebangLine:c,codeContent:l}=se(a),m=u.map((f)=>f.generateCode()).join("");return{contents:c+m+l}})}}}function ne(t){if(t===!0)return Object.keys(L);if(!t)return[];return Object.entries(t).filter(([e,r])=>r&&(e in L)).map(([e])=>e)}function se(t){if(!t.startsWith("#!"))return{shebangLine:"",codeContent:t};let e=t.indexOf(`
26
- `);return e===-1?{shebangLine:"",codeContent:t}:{shebangLine:t.slice(0,e+1),codeContent:t.slice(e+1)}}var it=new Set;async function Ot(t,e){let r=St(t);if(!r.entry||r.entry.length===0||!r.outDir)throw new b("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(r.clean)tt(e,r.outDir);nt(r.silent);let{packageJson:n,path:s}=await Tt(e);if(n&&s)g.cli(`Using package.json: ${y(s,2)}`,{muted:!0,identifier:r.name,once:`${s}:${r.name}`});let o=G(r.entry),i=n?.type,a=P(r,n),u=B(r);if(!r.dtsOnly){let c=[It(a,u)],l=r.format.flatMap((m)=>o.map((f)=>{return ie(r,e,f,m,i,c)}));await Promise.all(l)}if(r.dts||r.dtsOnly){let c=await $t(e,r.preferredTsconfigPath);if(c.path)g.cli(`Using tsconfig: ${y(c.path,2)}`,{muted:!0,identifier:r.name,once:`${c.path}:${r.name}`});let l=r.format.filter((f)=>{if(f==="iife"&&!S(i)&&r.format.includes("cjs"))return!1;return!0}),m=typeof r.dts==="object"&&r.dts.entry?G(r.dts.entry):wt(o);try{await Promise.all(m.map(async(f)=>{let At=await yt(e,f.path,r,c,n);await Promise.all(l.map(async(_t)=>{let jt=z(_t,i),O=`${e}/${r.outDir}/${f.name}${jt}`;await Bun.write(O,At);let Ft=Bun.file(O).size||0;g.progress("DTS",y(O),N(Ft),r.name)}))}))}catch(f){throw new p(d(f))}}}async function ie(t,e,r,n,s,o){let i=Z(n,s),a=await Bun.build({entrypoints:[`${e}/${r.path}`],format:n,naming:{entry:Rt(r.name,i)},splitting:Dt(t.splitting,n),bytecode:Pt(t.bytecode,n),define:Bt(t.define,t.shims,t.env,n),minify:Ct(t),outdir:`${e}/${t.outDir}`,target:t.target,sourcemap:t.sourcemap,loader:t.loader,drop:t.drop,banner:t.banner,footer:t.footer,publicPath:t.publicPath,env:Mt(t.env),plugins:[...o,Lt({format:n,target:t.target,shims:t.shims})],throw:!1});if(!a.success)for(let l of a.logs){if(l.level==="error")throw new b(l.message);if(l.level==="warning")g.warn(l.message);else if(l.level==="info")g.info(l.message)}let u=`${e}/${t.outDir}/${r.name}${i}`,c=Bun.file(u).size||0;g.progress(n.toUpperCase(),y(u),N(c),t.name)}
26
+ `);return e===-1?{shebangLine:"",codeContent:t}:{shebangLine:t.slice(0,e+1),codeContent:t.slice(e+1)}}var it=new Set;async function Ot(t,e){let r=St(t);if(!r.entry||r.entry.length===0||!r.outDir)throw new b("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(r.clean)tt(e,r.outDir);nt(r.silent);let{packageJson:n,path:s}=await Tt(e);if(n&&s)g.cli(`Using package.json: ${y(s,2)}`,{muted:!0,identifier:r.name,once:`${s}:${r.name}`});let o=G(r.entry),i=n?.type,a=P(r,n),u=B(r);if(!r.dtsOnly){let c=[It(a,u)],l=r.format.flatMap((m)=>o.map((f)=>{return ie(r,e,f,m,i,c)}));await Promise.all(l)}if(r.dts||r.dtsOnly){let c=await $t(e,r.preferredTsconfigPath);if(c.path)g.cli(`Using tsconfig: ${y(c.path,2)}`,{muted:!0,identifier:r.name,once:`${c.path}:${r.name}`});let l=r.format.filter((f)=>{if(f==="iife"&&!S(i)&&r.format.includes("cjs"))return!1;return!0}),m=typeof r.dts==="object"&&r.dts.entry?G(r.dts.entry):wt(o);try{await Promise.all(m.map(async(f)=>{let At=await yt(e,f.path,r,c,n);await Promise.all(l.map(async(_t)=>{let jt=z(_t,i),O=`${e}/${r.outDir}/${f.name}${jt}`;await Bun.write(O,At);let Ft=Bun.file(O).size||0;g.progress("DTS",y(O),N(Ft),r.name)}))}))}catch(f){throw new p(d(f))}}}async function ie(t,e,r,n,s,o){let i=Z(n,s),a=await Bun.build({entrypoints:[`${e}/${r.path}`],format:n,naming:{entry:Rt(r.name,i)},splitting:Dt(t.splitting,n),bytecode:Pt(t.bytecode,n),define:Bt(t.define,t.shims,t.env,n),minify:Ct(t),outdir:`${e}/${t.outDir}`,target:t.target,sourcemap:t.sourcemap,loader:t.loader,drop:t.drop,banner:t.banner,footer:t.footer,publicPath:t.publicPath,env:Mt(t.env),plugins:[...o,Lt({format:n,target:t.target,shims:t.shims}),...t.bunBuildPlugins??[]],throw:!1});if(!a.success)for(let l of a.logs){if(l.level==="error")throw new b(l.message);if(l.level==="warning")g.warn(l.message);else if(l.level==="info")g.info(l.message)}let u=`${e}/${t.outDir}/${r.name}${i}`,c=Bun.file(u).size||0;g.progress(n.toUpperCase(),y(u),N(c),t.name)}
package/build/index.mjs CHANGED
@@ -23,4 +23,4 @@ See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0})
23
23
  const importMetaUrl = pathToFileURL(__filename).href;
24
24
 
25
25
  `}};var vt=/\.(js|ts|jsx|tsx|mts|cts)$/;function yt({format:t,target:e,shims:r}){let o=Vt(r).map((i)=>D[i]).filter((i)=>i.appliesTo(t,e));if(o.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(i){i.onLoad({filter:vt},async({path:s})=>{let a=await Bun.file(s).text(),u=o.filter((f)=>f.isNeededInFile(a));if(u.length===0)return;let{shebangLine:c,codeContent:l}=Ht(a),m=u.map((f)=>f.generateCode()).join("");return{contents:c+m+l}})}}}function Vt(t){if(t===!0)return Object.keys(D);if(!t)return[];return Object.entries(t).filter(([e,r])=>r&&(e in D)).map(([e])=>e)}function Ht(t){if(!t.startsWith("#!"))return{shebangLine:"",codeContent:t};let e=t.indexOf(`
26
- `);return e===-1?{shebangLine:"",codeContent:t}:{shebangLine:t.slice(0,e+1),codeContent:t.slice(e+1)}}var K=new Set;async function qt(t,e){let r=gt(t);if(!r.entry||r.entry.length===0||!r.outDir)throw new x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(r.clean)V(e,r.outDir);X(r.silent);let{packageJson:n,path:o}=await lt(e);if(n&&o)g.cli(`Using package.json: ${h(o,2)}`,{muted:!0,identifier:r.name,once:`${o}:${r.name}`});let i=N(r.entry),s=n?.type,a=S(r,n),u=C(r);if(!r.dtsOnly){let c=[bt(a,u)],l=r.format.flatMap((m)=>i.map((f)=>{return Xt(r,e,f,m,s,c)}));await Promise.all(l)}if(r.dts||r.dtsOnly){let c=await ft(e,r.preferredTsconfigPath);if(c.path)g.cli(`Using tsconfig: ${h(c.path,2)}`,{muted:!0,identifier:r.name,once:`${c.path}:${r.name}`});let l=r.format.filter((f)=>{if(f==="iife"&&!T(s)&&r.format.includes("cjs"))return!1;return!0}),m=typeof r.dts==="object"&&r.dts.entry?N(r.dts.entry):at(i);try{await Promise.all(m.map(async(f)=>{let Et=await it(e,f.path,r,c,n);await Promise.all(l.map(async(wt)=>{let Rt=G(wt,s),M=`${e}/${r.outDir}/${f.name}${Rt}`;await Bun.write(M,Et);let Tt=Bun.file(M).size||0;g.progress("DTS",h(M),A(Tt),r.name)}))}))}catch(f){throw new p(d(f))}}}async function Xt(t,e,r,n,o,i){let s=W(n,o),a=await Bun.build({entrypoints:[`${e}/${r.path}`],format:n,naming:{entry:ct(r.name,s)},splitting:xt(t.splitting,n),bytecode:pt(t.bytecode,n),define:dt(t.define,t.shims,t.env,n),minify:mt(t),outdir:`${e}/${t.outDir}`,target:t.target,sourcemap:t.sourcemap,loader:t.loader,drop:t.drop,banner:t.banner,footer:t.footer,publicPath:t.publicPath,env:ht(t.env),plugins:[...i,yt({format:n,target:t.target,shims:t.shims})],throw:!1});if(!a.success)for(let l of a.logs){if(l.level==="error")throw new x(l.message);if(l.level==="warning")g.warn(l.message);else if(l.level==="info")g.info(l.message)}let u=`${e}/${t.outDir}/${r.name}${s}`,c=Bun.file(u).size||0;g.progress(n.toUpperCase(),h(u),A(c),t.name)}export{St as defineWorkspace,$t as defineConfig,qt as build};
26
+ `);return e===-1?{shebangLine:"",codeContent:t}:{shebangLine:t.slice(0,e+1),codeContent:t.slice(e+1)}}var K=new Set;async function qt(t,e){let r=gt(t);if(!r.entry||r.entry.length===0||!r.outDir)throw new x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(r.clean)V(e,r.outDir);X(r.silent);let{packageJson:n,path:o}=await lt(e);if(n&&o)g.cli(`Using package.json: ${h(o,2)}`,{muted:!0,identifier:r.name,once:`${o}:${r.name}`});let i=N(r.entry),s=n?.type,a=S(r,n),u=C(r);if(!r.dtsOnly){let c=[bt(a,u)],l=r.format.flatMap((m)=>i.map((f)=>{return Xt(r,e,f,m,s,c)}));await Promise.all(l)}if(r.dts||r.dtsOnly){let c=await ft(e,r.preferredTsconfigPath);if(c.path)g.cli(`Using tsconfig: ${h(c.path,2)}`,{muted:!0,identifier:r.name,once:`${c.path}:${r.name}`});let l=r.format.filter((f)=>{if(f==="iife"&&!T(s)&&r.format.includes("cjs"))return!1;return!0}),m=typeof r.dts==="object"&&r.dts.entry?N(r.dts.entry):at(i);try{await Promise.all(m.map(async(f)=>{let Et=await it(e,f.path,r,c,n);await Promise.all(l.map(async(wt)=>{let Rt=G(wt,s),M=`${e}/${r.outDir}/${f.name}${Rt}`;await Bun.write(M,Et);let Tt=Bun.file(M).size||0;g.progress("DTS",h(M),A(Tt),r.name)}))}))}catch(f){throw new p(d(f))}}}async function Xt(t,e,r,n,o,i){let s=W(n,o),a=await Bun.build({entrypoints:[`${e}/${r.path}`],format:n,naming:{entry:ct(r.name,s)},splitting:xt(t.splitting,n),bytecode:pt(t.bytecode,n),define:dt(t.define,t.shims,t.env,n),minify:mt(t),outdir:`${e}/${t.outDir}`,target:t.target,sourcemap:t.sourcemap,loader:t.loader,drop:t.drop,banner:t.banner,footer:t.footer,publicPath:t.publicPath,env:ht(t.env),plugins:[...i,yt({format:n,target:t.target,shims:t.shims}),...t.bunBuildPlugins??[]],throw:!1});if(!a.success)for(let l of a.logs){if(l.level==="error")throw new x(l.message);if(l.level==="warning")g.warn(l.message);else if(l.level==="info")g.info(l.message)}let u=`${e}/${t.outDir}/${r.name}${s}`,c=Bun.file(u).size||0;g.progress(n.toUpperCase(),h(u),A(c),t.name)}export{St as defineWorkspace,$t as defineConfig,qt as build};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunup",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
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",
@@ -20,7 +20,7 @@
20
20
  "bunup": "^0.4.7",
21
21
  "husky": "^9.1.7",
22
22
  "typescript": "^5.8.3",
23
- "create-bunup": "0.4.9"
23
+ "create-bunup": "0.4.10"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "typescript": ">=4.5.0"