bunup 0.4.38 → 0.4.40

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
@@ -8,9 +8,9 @@ Bunup is the **high-performance build tool** for TypeScript and JavaScript libra
8
8
  | Bundler | Format | Build Time | Build Time (with dts) |
9
9
  | ------- | -------- | -------------- | --------------------- |
10
10
  | bunup | esm, cjs | **3.52ms ⚡️** | **20.84ms ⚡️** |
11
- | tsdown | esm, cjs | 5.65ms | 434.67ms |
12
- | unbuild | esm, cjs | 43.13ms | 275.80ms |
13
- | tsup | esm, cjs | 63.39ms | 904.67ms |
11
+ | tsdown | esm, cjs | 5.81ms | 35.84ms |
12
+ | unbuild | esm, cjs | 42.47ms | 314.54ms |
13
+ | tsup | esm, cjs | 63.59ms | 943.61ms |
14
14
 
15
15
  _Lower is better. Benchmarks run on identical code and output formats._
16
16
 
package/build/cli.mjs CHANGED
@@ -31,7 +31,7 @@ See: https://bunup.arshadyaseen.com/documentation/#named-entries`,{muted:!0,vert
31
31
  const importMetaUrl = pathToFileURL(__filename).href;
32
32
 
33
33
  `}};function Ue({format:e,target:n,shims:t}){let s=dn(t).map((o)=>Z[o]).filter((o)=>o.appliesTo(e,n));if(s.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(o){o.onLoad({filter:pn},async({path:i})=>{let a=await Bun.file(i).text(),c=s.filter((m)=>m.isNeededInFile(a));if(c.length===0)return;let{shebangLine:l,codeContent:f}=gn(a),p=c.map((m)=>m.generateCode()).join("");return{contents:l+p+f}})}}}function dn(e){if(e===!0)return Object.keys(Z);if(!e)return[];return Object.entries(e).filter(([n,t])=>t&&(n in Z)).map(([n])=>n)}function gn(e){if(!e.startsWith("#!"))return{shebangLine:"",codeContent:e};let n=e.indexOf(`
34
- `);return n===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,n+1),codeContent:e.slice(n+1)}}function He(e){return e.filter((n)=>n.type==="bun").map((n)=>n.plugin)}var B=new Set;async function H(e,n){let t=U(e);if(!t.entry||t.entry.length===0||!t.outDir)throw new C("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(t.clean)ue(n,t.outDir);A(t.silent);let{packageJson:r,path:s}=await Ae(n);if(r&&s)u.cli(`Using package.json: ${y(s,2)}`,{muted:!0,identifier:t.name,once:`${s}:${t.name}`});let o=R(t.entry),i=r?.type,a=k(t,r),c=_(t);if(!t.dtsOnly){let l=[Pe(a,c),...He(t.plugins??[])],f=t.format.flatMap((p)=>o.map((m)=>{return hn(t,n,m,p,i,l)}));await Promise.all(f)}if(t.dts||t.dtsOnly){let l=await Me(n,t.preferredTsconfigPath);if(l.path)u.cli(`Using tsconfig: ${y(l.path,2)}`,{muted:!0,identifier:t.name,once:`${l.path}:${t.name}`});let f=t.format.filter((m)=>{if(m==="iife"&&!S(i)&&t.format.includes("cjs"))return!1;return!0}),p=typeof t.dts==="object"&&t.dts.entry?R(t.dts.entry):Te(o);try{await Promise.all(p.map(async(m)=>{let T=await Be(n,m.path,t,l,r);await Promise.all(f.map(async(ee)=>{let Fe=t.outputExtension?.({format:ee,packageType:i,options:t,entry:m}).dts??ce(ee,i),q=`${n}/${t.outDir}/${m.name}${Fe}`;await Bun.write(q,T);let Ge=Bun.file(q).size||0;u.progress("DTS",y(q),Y(Ge),t.name)}))}))}catch(m){throw new g(h(m))}}if(t.onBuildSuccess)await t.onBuildSuccess(t)}async function hn(e,n,t,r,s,o){let i=e.outputExtension?.({format:r,packageType:s,options:e,entry:t}).js??ae(r,s),a=await Bun.build({entrypoints:[`${n}/${t.path}`],format:r,naming:{entry:Ee(t.name,i)},splitting:_e(e.splitting,r),bytecode:Ie(e.bytecode,r),define:ke(e.define,e.shims,e.env,r),minify:je(e),outdir:`${n}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:Ne(e.env),plugins:[...o,Ue({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 C(f.message);if(f.level==="warning")u.warn(f.message);else if(f.level==="info")u.info(f.message)}let c=`${n}/${e.outDir}/${t.name}${i}`,l=Bun.file(c).size||0;u.progress(r.toUpperCase(),y(c),Y(l),e.name)}var W="0.4.38";var We="https://bunup.arshadyaseen.com/documentation/#cli-options";function d(e){return(n,t)=>{t[e]=n===!0||n==="true"}}function x(e){return(n,t)=>{if(typeof n==="string")t[e]=n;else throw new b(`Option --${e} requires a string value`)}}function J(e){return(n,t)=>{if(typeof n==="string")t[e]=n.split(",");else throw new b(`Option --${e} requires a string value`)}}function xn(e){return(n,t)=>{if(typeof n==="boolean")t[e]=n;else if(typeof n==="string")if(n.toLowerCase()==="true"||n.toLowerCase()==="false")t[e]=n.toLowerCase()==="true";else t[e]=n;else throw new b(`Option --${e} requires a boolean or string value`)}}function yn(){console.log(`
34
+ `);return n===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,n+1),codeContent:e.slice(n+1)}}function He(e){return e.filter((n)=>n.type==="bun").map((n)=>n.plugin)}var B=new Set;async function H(e,n=process.cwd()){let t=U(e);if(!t.entry||t.entry.length===0||!t.outDir)throw new C("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(t.clean)ue(n,t.outDir);A(t.silent);let{packageJson:r,path:s}=await Ae(n);if(r&&s)u.cli(`Using package.json: ${y(s,2)}`,{muted:!0,identifier:t.name,once:`${s}:${t.name}`});let o=R(t.entry),i=r?.type,a=k(t,r),c=_(t);if(!t.dtsOnly){let l=[Pe(a,c),...He(t.plugins??[])],f=t.format.flatMap((p)=>o.map((m)=>{return hn(t,n,m,p,i,l)}));await Promise.all(f)}if(t.dts||t.dtsOnly){let l=await Me(n,t.preferredTsconfigPath);if(l.path)u.cli(`Using tsconfig: ${y(l.path,2)}`,{muted:!0,identifier:t.name,once:`${l.path}:${t.name}`});let f=t.format.filter((m)=>{if(m==="iife"&&!S(i)&&t.format.includes("cjs"))return!1;return!0}),p=typeof t.dts==="object"&&t.dts.entry?R(t.dts.entry):Te(o);try{await Promise.all(p.map(async(m)=>{let T=await Be(n,m.path,t,l,r);await Promise.all(f.map(async(ee)=>{let Fe=t.outputExtension?.({format:ee,packageType:i,options:t,entry:m}).dts??ce(ee,i),q=`${n}/${t.outDir}/${m.name}${Fe}`;await Bun.write(q,T);let Ge=Bun.file(q).size||0;u.progress("DTS",y(q),Y(Ge),t.name)}))}))}catch(m){throw new g(h(m))}}if(t.onBuildSuccess)await t.onBuildSuccess(t)}async function hn(e,n,t,r,s,o){let i=e.outputExtension?.({format:r,packageType:s,options:e,entry:t}).js??ae(r,s),a=await Bun.build({entrypoints:[`${n}/${t.path}`],format:r,naming:{entry:Ee(t.name,i)},splitting:_e(e.splitting,r),bytecode:Ie(e.bytecode,r),define:ke(e.define,e.shims,e.env,r),minify:je(e),outdir:`${n}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:Ne(e.env),plugins:[...o,Ue({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 C(f.message);if(f.level==="warning")u.warn(f.message);else if(f.level==="info")u.info(f.message)}let c=`${n}/${e.outDir}/${t.name}${i}`,l=Bun.file(c).size||0;u.progress(r.toUpperCase(),y(c),Y(l),e.name)}var W="0.4.40";var We="https://bunup.arshadyaseen.com/documentation/#cli-options";function d(e){return(n,t)=>{t[e]=n===!0||n==="true"}}function x(e){return(n,t)=>{if(typeof n==="string")t[e]=n;else throw new b(`Option --${e} requires a string value`)}}function J(e){return(n,t)=>{if(typeof n==="string")t[e]=n.split(",");else throw new b(`Option --${e} requires a string value`)}}function xn(e){return(n,t)=>{if(typeof n==="boolean")t[e]=n;else if(typeof n==="string")if(n.toLowerCase()==="true"||n.toLowerCase()==="false")t[e]=n.toLowerCase()==="true";else t[e]=n;else throw new b(`Option --${e} requires a boolean or string value`)}}function yn(){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${We}\x1B[0m
37
37
  `),process.exit(0)}function wn(){console.log(W),process.exit(0)}var De={name:{flags:["n","name"],handler:x("name")},format:{flags:["f","format"],handler:J("format")},outDir:{flags:["o","out-dir"],handler:x("outDir")},minify:{flags:["m","minify"],handler:d("minify")},watch:{flags:["w","watch"],handler:d("watch")},dts:{flags:["d","dts"],handler:d("dts")},banner:{flags:["bn","banner"],handler:x("banner")},footer:{flags:["ft","footer"],handler:x("footer")},external:{flags:["e","external"],handler:J("external")},sourcemap:{flags:["sm","sourcemap"],handler:xn("sourcemap")},target:{flags:["t","target"],handler:x("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:d("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:d("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:d("minifySyntax")},clean:{flags:["c","clean"],handler:d("clean")},splitting:{flags:["s","splitting"],handler:d("splitting")},noExternal:{flags:["ne","no-external"],handler:J("noExternal")},preferredTsconfigPath:{flags:["tsconfig","preferred-tsconfig-path"],handler:x("preferredTsconfigPath")},bytecode:{flags:["bc","bytecode"],handler:d("bytecode")},dtsOnly:{flags:["do","dts-only"],handler:d("dtsOnly")},silent:{flags:["silent"],handler:d("silent")},config:{flags:["config"],handler:x("config")},publicPath:{flags:["pp","public-path"],handler:x("publicPath")},env:{flags:["env"],handler:x("env")},shims:{flags:["shims"],handler:d("shims")},onSuccess:{flags:["onSuccess"],handler:x("onSuccess")},entry:{flags:["entry"],handler:(e,n,t)=>{if(typeof e!=="string")throw new b(`Entry${t?` --entry.${t}`:""} requires a string value`);let r=n.entry||{};if(t){if(r[t])u.warn(`Duplicate entry name '${t}' provided via --entry.${t}. Overwriting previous entry.`);r[t]=e}else{let s=P(e);if(r[s])u.warn(`Duplicate entry name '${s}' derived from '${e}'. Overwriting previous entry.`);r[s]=e}n.entry=r}},resolveDts:{flags:["rd","resolve-dts"],handler:(e,n)=>{if(!n.dts)n.dts={};if(typeof n.dts==="boolean")n.dts={};if(typeof e==="string")if(e==="true"||e==="false")n.dts.resolve=e==="true";else n.dts.resolve=e.split(",");else n.dts.resolve=!0}},help:{flags:["h","help"],handler:()=>yn()},version:{flags:["v","version"],handler:()=>wn()}},D={};for(let e of Object.values(De))for(let n of e.flags)D[n]=e.handler;function ve(e){let n={};for(let t=0;t<e.length;t++){let r=e[t];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[t+1];if(o=i&&!i.startsWith("-")?i:!0,typeof o==="string")t++}if(s.includes(".")){let[i,a]=s.split(".",2),c=D[i];if(c)c(o,n,a);else throw new b(`Unknown option: --${s}`)}else{let i=D[s];if(i)i(o,n);else throw new b(`Unknown option: --${s}`)}}else if(r.startsWith("-")){let s=r.slice(1),o=e[t+1],i=o&&!o.startsWith("-")?o:!0;if(typeof i==="string")t++;let a=D[s];if(a)a(i,n);else throw new b(`Unknown option: -${s}`)}else De.entry.handler(r,n,void 0)}return n}import{loadConfig as On}from"coffi";import v from"node:path";import Cn from"chokidar";async function qe(e,n){let t=new Set,r=U(e),s=R(r.entry);for(let c of s){let l=v.resolve(n,c.path),f=v.dirname(l);t.add(f)}let o=Cn.watch(Array.from(t),{persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50},ignoreInitial:!0,atomic:!0,ignorePermissionErrors:!0,ignored:[/[\\/]\.git[\\/]/,/[\\/]node_modules[\\/]/,v.join(n,r.outDir)]}),i=!1,a=async(c=!1)=>{if(i)return;i=!0;try{let l=performance.now();if(await H({...r,entry:s.map((f)=>f.path),clean:!1},n),!c)u.cli(`\uD83D\uDCE6 Rebuild finished in ${j(performance.now()-l)}`);await V()}catch(l){F(l)}finally{i=!1}};o.on("change",(c)=>{let l=v.relative(n,c);u.cli(`File changed: ${l}`,{muted:!0,once:l}),a()}),o.on("error",(c)=>{throw new M(`Watcher error: ${h(c)}`)}),await a(!0)}async function Sn(e=Bun.argv.slice(2)){let n=ve(e);A(n.silent);let t=process.cwd(),{config:r,filepath:s}=await On({name:"bunup.config",extensions:[".ts",".js",".mjs",".cjs"],maxDepth:1,preferredPath:n.config}),o=!r?[{rootDir:t,options:n}]:await Re(r,t);if(u.cli(`Using bunup v${W} and bun v${Bun.version}`,{muted:!0}),s)u.cli(`Using config file: ${y(s,2)}`,{muted:!0});let i=performance.now();u.cli("Build started"),await Promise.all(o.flatMap(({options:l,rootDir:f})=>{return oe(l).map(async(m)=>{let T={...m,...Bn(n)};return Tn(T,f)})}));let a=performance.now()-i,c=j(a);if(u.cli(`\u26A1\uFE0F Build completed in ${c}`),await V(),n.watch)u.cli("\uD83D\uDC40 Watching for file changes");if(n.onSuccess)u.cli(`Running command: ${n.onSuccess}`,{muted:!0}),$n(n.onSuccess,[],{nodeOptions:{shell:!0,stdio:"inherit"}});if(!n.watch)process.exit(0)}function Bn(e){return{...e,onSuccess:void 0,config:void 0}}async function V(){if(B.size>0)await Se(B),B.clear()}async function Tn(e,n){if(e.watch)await qe(e,n);else await H(e,n)}Sn().catch((e)=>te(e));export{V as validateDtsFiles};
package/build/index.d.mts CHANGED
@@ -423,7 +423,7 @@ declare function defineWorkspace(options: DefineWorkspaceItem[]): DefineWorkspac
423
423
 
424
424
  //#endregion
425
425
  //#region \0dts:/home/runner/work/bunup/bunup/src/build.d.ts
426
- declare function build(partialOptions: Partial<BuildOptions>, rootDir: string): Promise<void>;
426
+ declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
427
427
 
428
428
  //#endregion
429
429
  export { BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin, build, defineConfig, defineWorkspace };
package/build/index.d.ts CHANGED
@@ -423,7 +423,7 @@ declare function defineWorkspace(options: DefineWorkspaceItem[]): DefineWorkspac
423
423
 
424
424
  //#endregion
425
425
  //#region \0dts:/home/runner/work/bunup/bunup/src/build.d.ts
426
- declare function build(partialOptions: Partial<BuildOptions>, rootDir: string): Promise<void>;
426
+ declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
427
427
 
428
428
  //#endregion
429
429
  export { BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin, build, defineConfig, defineWorkspace };
package/build/index.js CHANGED
@@ -23,4 +23,4 @@ See: https://bunup.arshadyaseen.com/documentation/#named-entries`,{muted:!0,vert
23
23
  const importMetaUrl = pathToFileURL(__filename).href;
24
24
 
25
25
  `}};function _e({format:e,target:r,shims:t}){let s=nr(t).map((o)=>F[o]).filter((o)=>o.appliesTo(e,r));if(s.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(o){o.onLoad({filter:tr},async({path:i})=>{let a=await Bun.file(i).text(),u=s.filter((l)=>l.isNeededInFile(a));if(u.length===0)return;let{shebangLine:c,codeContent:m}=sr(a),g=u.map((l)=>l.generateCode()).join("");return{contents:c+g+m}})}}}function nr(e){if(e===!0)return Object.keys(F);if(!e)return[];return Object.entries(e).filter(([r,t])=>t&&(r in F)).map(([r])=>r)}function sr(e){if(!e.startsWith("#!"))return{shebangLine:"",codeContent:e};let r=e.indexOf(`
26
- `);return r===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,r+1),codeContent:e.slice(r+1)}}function De(e){return e.filter((r)=>r.type==="bun").map((r)=>r.plugin)}var ae=new Set;async function We(e,r){let t=Oe(e);if(!t.entry||t.entry.length===0||!t.outDir)throw new h("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(t.clean)ne(r,t.outDir);J(t.silent);let{packageJson:n,path:s}=await Te(r);if(n&&s)f.cli(`Using package.json: ${w(s,2)}`,{muted:!0,identifier:t.name,once:`${s}:${t.name}`});let o=G(t.entry),i=n?.type,a=T(t,n),u=R(t);if(!t.dtsOnly){let c=[Ne(a,u),...De(t.plugins??[])],m=t.format.flatMap((g)=>o.map((l)=>{return ir(t,r,l,g,i,c)}));await Promise.all(m)}if(t.dts||t.dtsOnly){let c=await Re(r,t.preferredTsconfigPath);if(c.path)f.cli(`Using tsconfig: ${w(c.path,2)}`,{muted:!0,identifier:t.name,once:`${c.path}:${t.name}`});let m=t.format.filter((l)=>{if(l==="iife"&&!y(i)&&t.format.includes("cjs"))return!1;return!0}),g=typeof t.dts==="object"&&t.dts.entry?G(t.dts.entry):Se(o);try{await Promise.all(g.map(async(l)=>{let M=await $e(r,l.path,t,c,n);await Promise.all(m.map(async(H)=>{let ke=t.outputExtension?.({format:H,packageType:i,options:t,entry:l}).dts??re(H,i),A=`${r}/${t.outDir}/${l.name}${ke}`;await Bun.write(A,M);let Pe=Bun.file(A).size||0;f.progress("DTS",w(A),D(Pe),t.name)}))}))}catch(l){throw new p(d(l))}}if(t.onBuildSuccess)await t.onBuildSuccess(t)}async function ir(e,r,t,n,s,o){let i=e.outputExtension?.({format:n,packageType:s,options:e,entry:t}).js??ee(n,s),a=await Bun.build({entrypoints:[`${r}/${t.path}`],format:n,naming:{entry:Be(t.name,i)},splitting:je(e.splitting,n),bytecode:Me(e.bytecode,n),define:Ae(e.define,e.shims,e.env,n),minify:Le(e),outdir:`${r}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:Ie(e.env),plugins:[...o,_e({format:n,target:e.target,shims:e.shims})],throw:!1});if(!a.success)for(let m of a.logs){if(m.level==="error")throw new h(m.message);if(m.level==="warning")f.warn(m.message);else if(m.level==="info")f.info(m.message)}let u=`${r}/${e.outDir}/${t.name}${i}`,c=Bun.file(u).size||0;f.progress(n.toUpperCase(),w(u),D(c),e.name)}
26
+ `);return r===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,r+1),codeContent:e.slice(r+1)}}function De(e){return e.filter((r)=>r.type==="bun").map((r)=>r.plugin)}var ae=new Set;async function We(e,r=process.cwd()){let t=Oe(e);if(!t.entry||t.entry.length===0||!t.outDir)throw new h("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(t.clean)ne(r,t.outDir);J(t.silent);let{packageJson:n,path:s}=await Te(r);if(n&&s)f.cli(`Using package.json: ${w(s,2)}`,{muted:!0,identifier:t.name,once:`${s}:${t.name}`});let o=G(t.entry),i=n?.type,a=T(t,n),u=R(t);if(!t.dtsOnly){let c=[Ne(a,u),...De(t.plugins??[])],m=t.format.flatMap((g)=>o.map((l)=>{return ir(t,r,l,g,i,c)}));await Promise.all(m)}if(t.dts||t.dtsOnly){let c=await Re(r,t.preferredTsconfigPath);if(c.path)f.cli(`Using tsconfig: ${w(c.path,2)}`,{muted:!0,identifier:t.name,once:`${c.path}:${t.name}`});let m=t.format.filter((l)=>{if(l==="iife"&&!y(i)&&t.format.includes("cjs"))return!1;return!0}),g=typeof t.dts==="object"&&t.dts.entry?G(t.dts.entry):Se(o);try{await Promise.all(g.map(async(l)=>{let M=await $e(r,l.path,t,c,n);await Promise.all(m.map(async(H)=>{let ke=t.outputExtension?.({format:H,packageType:i,options:t,entry:l}).dts??re(H,i),A=`${r}/${t.outDir}/${l.name}${ke}`;await Bun.write(A,M);let Pe=Bun.file(A).size||0;f.progress("DTS",w(A),D(Pe),t.name)}))}))}catch(l){throw new p(d(l))}}if(t.onBuildSuccess)await t.onBuildSuccess(t)}async function ir(e,r,t,n,s,o){let i=e.outputExtension?.({format:n,packageType:s,options:e,entry:t}).js??ee(n,s),a=await Bun.build({entrypoints:[`${r}/${t.path}`],format:n,naming:{entry:Be(t.name,i)},splitting:je(e.splitting,n),bytecode:Me(e.bytecode,n),define:Ae(e.define,e.shims,e.env,n),minify:Le(e),outdir:`${r}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:Ie(e.env),plugins:[...o,_e({format:n,target:e.target,shims:e.shims})],throw:!1});if(!a.success)for(let m of a.logs){if(m.level==="error")throw new h(m.message);if(m.level==="warning")f.warn(m.message);else if(m.level==="info")f.info(m.message)}let u=`${r}/${e.outDir}/${t.name}${i}`,c=Bun.file(u).size||0;f.progress(n.toUpperCase(),w(u),D(c),e.name)}
package/build/index.mjs CHANGED
@@ -23,4 +23,4 @@ See: https://bunup.arshadyaseen.com/documentation/#named-entries`,{muted:!0,vert
23
23
  const importMetaUrl = pathToFileURL(__filename).href;
24
24
 
25
25
  `}};function Ce({format:e,target:r,shims:t}){let s=He(t).map((o)=>W[o]).filter((o)=>o.appliesTo(e,r));if(s.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(o){o.onLoad({filter:Fe},async({path:i})=>{let a=await Bun.file(i).text(),u=s.filter((l)=>l.isNeededInFile(a));if(u.length===0)return;let{shebangLine:c,codeContent:m}=Ke(a),g=u.map((l)=>l.generateCode()).join("");return{contents:c+g+m}})}}}function He(e){if(e===!0)return Object.keys(W);if(!e)return[];return Object.entries(e).filter(([r,t])=>t&&(r in W)).map(([r])=>r)}function Ke(e){if(!e.startsWith("#!"))return{shebangLine:"",codeContent:e};let r=e.indexOf(`
26
- `);return r===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,r+1),codeContent:e.slice(r+1)}}function $e(e){return e.filter((r)=>r.type==="bun").map((r)=>r.plugin)}var Z=new Set;async function Xe(e,r){let t=pe(e);if(!t.entry||t.entry.length===0||!t.outDir)throw new h("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(t.clean)X(r,t.outDir);U(t.silent);let{packageJson:n,path:s}=await fe(r);if(n&&s)f.cli(`Using package.json: ${w(s,2)}`,{muted:!0,identifier:t.name,once:`${s}:${t.name}`});let o=D(t.entry),i=n?.type,a=S(t,n),u=B(t);if(!t.dtsOnly){let c=[we(a,u),...$e(t.plugins??[])],m=t.format.flatMap((g)=>o.map((l)=>{return Ye(t,r,l,g,i,c)}));await Promise.all(m)}if(t.dts||t.dtsOnly){let c=await ge(r,t.preferredTsconfigPath);if(c.path)f.cli(`Using tsconfig: ${w(c.path,2)}`,{muted:!0,identifier:t.name,once:`${c.path}:${t.name}`});let m=t.format.filter((l)=>{if(l==="iife"&&!y(i)&&t.format.includes("cjs"))return!1;return!0}),g=typeof t.dts==="object"&&t.dts.entry?D(t.dts.entry):ce(o);try{await Promise.all(g.map(async(l)=>{let R=await ae(r,l.path,t,c,n);await Promise.all(m.map(async(k)=>{let Ee=t.outputExtension?.({format:k,packageType:i,options:t,entry:l}).dts??H(k,i),O=`${r}/${t.outDir}/${l.name}${Ee}`;await Bun.write(O,R);let Se=Bun.file(O).size||0;f.progress("DTS",w(O),j(Se),t.name)}))}))}catch(l){throw new p(d(l))}}if(t.onBuildSuccess)await t.onBuildSuccess(t)}async function Ye(e,r,t,n,s,o){let i=e.outputExtension?.({format:n,packageType:s,options:e,entry:t}).js??F(n,s),a=await Bun.build({entrypoints:[`${r}/${t.path}`],format:n,naming:{entry:me(t.name,i)},splitting:he(e.splitting,n),bytecode:xe(e.bytecode,n),define:be(e.define,e.shims,e.env,n),minify:de(e),outdir:`${r}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:ye(e.env),plugins:[...o,Ce({format:n,target:e.target,shims:e.shims})],throw:!1});if(!a.success)for(let m of a.logs){if(m.level==="error")throw new h(m.message);if(m.level==="warning")f.warn(m.message);else if(m.level==="info")f.info(m.message)}let u=`${r}/${e.outDir}/${t.name}${i}`,c=Bun.file(u).size||0;f.progress(n.toUpperCase(),w(u),j(c),e.name)}export{Te as defineWorkspace,Be as defineConfig,Xe as build};
26
+ `);return r===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,r+1),codeContent:e.slice(r+1)}}function $e(e){return e.filter((r)=>r.type==="bun").map((r)=>r.plugin)}var Z=new Set;async function Xe(e,r=process.cwd()){let t=pe(e);if(!t.entry||t.entry.length===0||!t.outDir)throw new h("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(t.clean)X(r,t.outDir);U(t.silent);let{packageJson:n,path:s}=await fe(r);if(n&&s)f.cli(`Using package.json: ${w(s,2)}`,{muted:!0,identifier:t.name,once:`${s}:${t.name}`});let o=D(t.entry),i=n?.type,a=S(t,n),u=B(t);if(!t.dtsOnly){let c=[we(a,u),...$e(t.plugins??[])],m=t.format.flatMap((g)=>o.map((l)=>{return Ye(t,r,l,g,i,c)}));await Promise.all(m)}if(t.dts||t.dtsOnly){let c=await ge(r,t.preferredTsconfigPath);if(c.path)f.cli(`Using tsconfig: ${w(c.path,2)}`,{muted:!0,identifier:t.name,once:`${c.path}:${t.name}`});let m=t.format.filter((l)=>{if(l==="iife"&&!y(i)&&t.format.includes("cjs"))return!1;return!0}),g=typeof t.dts==="object"&&t.dts.entry?D(t.dts.entry):ce(o);try{await Promise.all(g.map(async(l)=>{let R=await ae(r,l.path,t,c,n);await Promise.all(m.map(async(k)=>{let Ee=t.outputExtension?.({format:k,packageType:i,options:t,entry:l}).dts??H(k,i),O=`${r}/${t.outDir}/${l.name}${Ee}`;await Bun.write(O,R);let Se=Bun.file(O).size||0;f.progress("DTS",w(O),j(Se),t.name)}))}))}catch(l){throw new p(d(l))}}if(t.onBuildSuccess)await t.onBuildSuccess(t)}async function Ye(e,r,t,n,s,o){let i=e.outputExtension?.({format:n,packageType:s,options:e,entry:t}).js??F(n,s),a=await Bun.build({entrypoints:[`${r}/${t.path}`],format:n,naming:{entry:me(t.name,i)},splitting:he(e.splitting,n),bytecode:xe(e.bytecode,n),define:be(e.define,e.shims,e.env,n),minify:de(e),outdir:`${r}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:ye(e.env),plugins:[...o,Ce({format:n,target:e.target,shims:e.shims})],throw:!1});if(!a.success)for(let m of a.logs){if(m.level==="error")throw new h(m.message);if(m.level==="warning")f.warn(m.message);else if(m.level==="info")f.info(m.message)}let u=`${r}/${e.outDir}/${t.name}${i}`,c=Bun.file(u).size||0;f.progress(n.toUpperCase(),w(u),j(c),e.name)}export{Te as defineWorkspace,Be as defineConfig,Xe as build};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunup",
3
- "version": "0.4.38",
3
+ "version": "0.4.40",
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",
@@ -21,7 +21,7 @@
21
21
  "bunup": "^0.4.23",
22
22
  "husky": "^9.1.7",
23
23
  "typescript": "^5.8.3",
24
- "create-bunup": "0.4.38"
24
+ "create-bunup": "0.4.40"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "typescript": ">=4.5.0"