bunup 0.4.66 → 0.4.67

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.
Files changed (3) hide show
  1. package/README.md +11 -16
  2. package/dist/cli.mjs +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -3,28 +3,22 @@
3
3
  [![npm version](https://img.shields.io/npm/v/bunup.svg?style=flat-square)](https://www.npmjs.com/package/bunup)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/bunup.svg?style=flat-square)](https://www.npmjs.com/package/bunup)
5
5
 
6
- Bunup is the **high-performance build tool** for TypeScript and JavaScript libraries, designed for beautiful developer experience and speed. It provides **first-class support** for libraries built with [Bun](https://bun.sh/) and delivers **lightning-fast builds** — up to **~50× faster than Tsup**.
6
+ Bunup is the **blazing-fast build tool** for TypeScript and JavaScript libraries, designed for beautiful developer experience and speed, **powered by Bun's native bundler** — up to **~50× faster than Tsup**.
7
7
 
8
- | Bundler | Format | Build Time | Build Time (with dts) |
9
- | ------- | -------- | -------------- | --------------------- |
10
- | bunup | esm, cjs | **3.52ms ⚡️** | **20.84ms ⚡️** |
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
-
15
- _Lower is better. Benchmarks run on identical code and output formats._
8
+ | Bundler | Format | Build Time | Build Time (with dts) |
9
+ | --------- | ------------ | -------------- | --------------------- |
10
+ | **bunup** | **esm, cjs** | **3.52ms ⚡️** | **20.84ms ⚡️** |
11
+ | tsdown | esm, cjs | 5.81ms | 35.84ms |
12
+ | unbuild | esm, cjs | 42.47ms | 314.54ms |
13
+ | tsup | esm, cjs | 63.59ms | 943.61ms |
16
14
 
17
15
  ## Key Features
18
16
 
19
- - ⚡️ **Ultra Fast Builds**: Lightning-fast performance powered by [Bun](https://bun.sh/)'s native bundler and [Oxc](https://oxc.rs).
20
-
17
+ - 🚀 **Easy to Use**: Bunup preconfigures everything you need out-of-the-box. Just focus on your code.
21
18
  - 🔥 **Bytecode Generation**: Faster startups by compiling to Bun bytecode—perfect for CLIs.
22
-
23
- - 📦 **Workspace Support**: Build multiple packages with [defineWorkspace()](https://bunup.dev/documentation/#workspaces) in one config file and command.
24
-
19
+ - 📦 **[Workspace](https://bunup.dev/workspaces) Support**: Build multiple packages within one config file and command.
25
20
  - 🔄 **Tsup Familiarity**: Familiar tsup-like CLI and config.
26
-
27
- - 🎯 **Bun Targeting**: Optimize for Bun runtime with `--target bun` for native features.
21
+ - 🎯 **Bun Target**: First-class bundling support for libraries built with Bun.
28
22
 
29
23
  ## 📚 Documentation
30
24
 
@@ -35,3 +29,4 @@ To get started, visit the [documentation](https://bunup.dev/documentation).
35
29
  For guidelines on contributing, please read the [contributing guide](https://github.com/arshad-yaseen/bunup/blob/main/CONTRIBUTING.md).
36
30
 
37
31
  We welcome contributions from the community to enhance Bunup's capabilities and make it even more powerful.
32
+ 1
package/dist/cli.mjs CHANGED
@@ -15,7 +15,7 @@ import{createRequire as Vn}from"node:module";var Qn=Object.create;var{getPrototy
15
15
  const importMetaUrl = pathToFileURL(__filename).href;
16
16
 
17
17
  `}};function vn({format:n,target:e,shims:r}){let s=$e(r).map((o)=>z[o]).filter((o)=>o.appliesTo(n,e));if(s.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(o){o.onLoad({filter:Be},async({path:i})=>{let c=await Bun.file(i).text(),a=s.filter((d)=>d.isNeededInFile(c));if(a.length===0)return;let{shebangLine:l,codeContent:u}=Oe(c),f=a.map((d)=>d.generateCode()).join("");return{contents:l+f+u}})}}}function $e(n){if(n===!0)return Object.keys(z);if(!n)return[];return Object.entries(n).filter(([e,r])=>r&&(e in z)).map(([e])=>e)}function Oe(n){if(!n.startsWith("#!"))return{shebangLine:"",codeContent:n};let e=n.indexOf(`
18
- `);return e===-1?{shebangLine:"",codeContent:n}:{shebangLine:n.slice(0,e+1),codeContent:n.slice(e+1)}}function qn(n){return n.filter((e)=>e.type==="bun").map((e)=>e.plugin)}var S=new Set;async function W(n,e=process.cwd()){let r=D(n);if(!r.entry||r.entry.length===0||!r.outDir)throw new y("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(r.clean)dn(e,r.outDir);M(r.silent);let{packageJson:t,path:s}=await In(e);if(t&&s)m.cli(`Using package.json: ${C(s,2)}`,{muted:!0,identifier:r.name,once:`${s}:${r.name}`});let o=k(r.entry),i=t?.type;if(!r.dtsOnly){let c=[Hn(r,t),...qn(r.plugins??[])],a=r.format.flatMap((l)=>o.map((u)=>{return Se(r,e,u,l,i,c)}));await Promise.all(a)}if(r.dts||r.dtsOnly){let c=await Rn(e,r.preferredTsconfigPath);if(c.path)m.cli(`Using tsconfig: ${C(c.path,2)}`,{muted:!0,identifier:r.name,once:`${c.path}:${r.name}`});let a=r.format.filter((u)=>{if(u==="iife"&&!O(i)&&r.format.includes("cjs"))return!1;return!0}),l=typeof r.dts==="object"&&r.dts.entry?k(r.dts.entry):An(o);try{await Promise.all(l.map(async(u)=>{let f=await Ln(e,u.fullEntryPath,r,c,t);await Promise.all(a.map(async(d)=>{let T=r.outputExtension?.({format:d,packageType:i,options:r,entry:u}).dts??mn(d,i),P=`${r.outDir}/${u.name}${T}`,nn=`${e}/${P}`;await Bun.write(nn,f);let Nn=Bun.file(nn).size||0;m.progress("DTS",P,K(Nn),r.name)}))}))}catch(u){throw new g(b(u))}}if(r.onBuildSuccess)await r.onBuildSuccess(r)}async function Se(n,e,r,t,s,o){let i=n.outputExtension?.({format:t,packageType:s,options:n,entry:r}).js??un(t,s),c=await Bun.build({entrypoints:[`${e}/${r.fullEntryPath}`],format:t,naming:{entry:kn(r.name,i)},splitting:Dn(n.splitting,t),bytecode:Un(n.bytecode,t),define:_n(n.define,n.shims,n.env,t),minify:jn(n),outdir:`${e}/${n.outDir}`,target:n.target,sourcemap:n.sourcemap,loader:n.loader,drop:n.drop,banner:n.banner,footer:n.footer,publicPath:n.publicPath,env:Wn(n.env),plugins:[...o,vn({format:t,target:n.target,shims:n.shims})],throw:!1});if(!c.success)for(let f of c.logs){if(f.level==="error")throw new y(f.message);if(f.level==="warning")m.warn(f.message);else if(f.level==="info")m.info(f.message)}let a=`${n.outDir}/${r.name}${i}`,l=`${e}/${a}`,u=Bun.file(l).size||0;m.progress(t.toUpperCase(),a,K(u),n.name)}var H="0.4.66";var Fn="https://bunup.dev/cli-options";function p(n){return(e,r)=>{r[n]=e===!0||e==="true"}}function x(n){return(e,r)=>{if(typeof e==="string")r[n]=e;else throw new h(`Option --${n} requires a string value`)}}function V(n){return(e,r)=>{if(typeof e==="string")r[n]=e.split(",");else throw new h(`Option --${n} requires a string value`)}}function Le(n){return(e,r)=>{if(typeof e==="boolean")r[n]=e;else if(typeof e==="string")if(e.toLowerCase()==="true"||e.toLowerCase()==="false")r[n]=e.toLowerCase()==="true";else r[n]=e;else throw new h(`Option --${n} requires a boolean or string value`)}}function Ae(){console.log(`
18
+ `);return e===-1?{shebangLine:"",codeContent:n}:{shebangLine:n.slice(0,e+1),codeContent:n.slice(e+1)}}function qn(n){return n.filter((e)=>e.type==="bun").map((e)=>e.plugin)}var S=new Set;async function W(n,e=process.cwd()){let r=D(n);if(!r.entry||r.entry.length===0||!r.outDir)throw new y("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(r.clean)dn(e,r.outDir);M(r.silent);let{packageJson:t,path:s}=await In(e);if(t&&s)m.cli(`Using package.json: ${C(s,2)}`,{muted:!0,identifier:r.name,once:`${s}:${r.name}`});let o=k(r.entry),i=t?.type;if(!r.dtsOnly){let c=[Hn(r,t),...qn(r.plugins??[])],a=r.format.flatMap((l)=>o.map((u)=>{return Se(r,e,u,l,i,c)}));await Promise.all(a)}if(r.dts||r.dtsOnly){let c=await Rn(e,r.preferredTsconfigPath);if(c.path)m.cli(`Using tsconfig: ${C(c.path,2)}`,{muted:!0,identifier:r.name,once:`${c.path}:${r.name}`});let a=r.format.filter((u)=>{if(u==="iife"&&!O(i)&&r.format.includes("cjs"))return!1;return!0}),l=typeof r.dts==="object"&&r.dts.entry?k(r.dts.entry):An(o);try{await Promise.all(l.map(async(u)=>{let f=await Ln(e,u.fullEntryPath,r,c,t);await Promise.all(a.map(async(d)=>{let T=r.outputExtension?.({format:d,packageType:i,options:r,entry:u}).dts??mn(d,i),P=`${r.outDir}/${u.name}${T}`,nn=`${e}/${P}`;await Bun.write(nn,f);let Nn=Bun.file(nn).size||0;m.progress("DTS",P,K(Nn),r.name)}))}))}catch(u){throw new g(b(u))}}if(r.onBuildSuccess)await r.onBuildSuccess(r)}async function Se(n,e,r,t,s,o){let i=n.outputExtension?.({format:t,packageType:s,options:n,entry:r}).js??un(t,s),c=await Bun.build({entrypoints:[`${e}/${r.fullEntryPath}`],format:t,naming:{entry:kn(r.name,i)},splitting:Dn(n.splitting,t),bytecode:Un(n.bytecode,t),define:_n(n.define,n.shims,n.env,t),minify:jn(n),outdir:`${e}/${n.outDir}`,target:n.target,sourcemap:n.sourcemap,loader:n.loader,drop:n.drop,banner:n.banner,footer:n.footer,publicPath:n.publicPath,env:Wn(n.env),plugins:[...o,vn({format:t,target:n.target,shims:n.shims})],throw:!1});if(!c.success)for(let f of c.logs){if(f.level==="error")throw new y(f.message);if(f.level==="warning")m.warn(f.message);else if(f.level==="info")m.info(f.message)}let a=`${n.outDir}/${r.name}${i}`,l=`${e}/${a}`,u=Bun.file(l).size||0;m.progress(t.toUpperCase(),a,K(u),n.name)}var H="0.4.67";var Fn="https://bunup.dev/cli-options";function p(n){return(e,r)=>{r[n]=e===!0||e==="true"}}function x(n){return(e,r)=>{if(typeof e==="string")r[n]=e;else throw new h(`Option --${n} requires a string value`)}}function V(n){return(e,r)=>{if(typeof e==="string")r[n]=e.split(",");else throw new h(`Option --${n} requires a string value`)}}function Le(n){return(e,r)=>{if(typeof e==="boolean")r[n]=e;else if(typeof e==="string")if(e.toLowerCase()==="true"||e.toLowerCase()==="false")r[n]=e.toLowerCase()==="true";else r[n]=e;else throw new h(`Option --${n} requires a boolean or string value`)}}function Ae(){console.log(`
19
19
  Bunup - A blazing-fast build tool for your libraries built with Bun.
20
20
  `),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${Fn}\x1B[0m
21
21
  `),process.exit(0)}function ke(){console.log(H),process.exit(0)}var Gn={name:{flags:["n","name"],handler:x("name")},format:{flags:["f","format"],handler:V("format")},outDir:{flags:["o","out-dir"],handler:x("outDir")},minify:{flags:["m","minify"],handler:p("minify")},watch:{flags:["w","watch"],handler:p("watch")},dts:{flags:["d","dts"],handler:p("dts")},banner:{flags:["bn","banner"],handler:x("banner")},footer:{flags:["ft","footer"],handler:x("footer")},external:{flags:["e","external"],handler:V("external")},sourcemap:{flags:["sm","sourcemap"],handler:Le("sourcemap")},target:{flags:["t","target"],handler:x("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:p("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:p("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:p("minifySyntax")},clean:{flags:["c","clean"],handler:p("clean")},splitting:{flags:["s","splitting"],handler:p("splitting")},noExternal:{flags:["ne","no-external"],handler:V("noExternal")},preferredTsconfigPath:{flags:["tsconfig","preferred-tsconfig-path"],handler:x("preferredTsconfigPath")},bytecode:{flags:["bc","bytecode"],handler:p("bytecode")},dtsOnly:{flags:["do","dts-only"],handler:p("dtsOnly")},silent:{flags:["silent"],handler:p("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:p("shims")},onSuccess:{flags:["onSuccess"],handler:x("onSuccess")},entry:{flags:["entry"],handler:(n,e,r)=>{if(typeof n!=="string")throw new h(`Entry${r?` --entry.${r}`:""} requires a string value`);let t=e.entry||{};if(r){if(t[r])m.warn(`Duplicate entry name '${r}' provided via --entry.${r}. Overwriting previous entry.`);t[r]=n}else{let s=_(n);if(t[s])m.warn(`Duplicate entry name '${s}' derived from '${n}'. Overwriting previous entry.`);t[s]=n}e.entry=t}},resolveDts:{flags:["rd","resolve-dts"],handler:(n,e)=>{if(!e.dts)e.dts={};if(typeof e.dts==="boolean")e.dts={};if(typeof n==="string")if(n==="true"||n==="false")e.dts.resolve=n==="true";else e.dts.resolve=n.split(",");else e.dts.resolve=!0}},help:{flags:["h","help"],handler:()=>Ae()},version:{flags:["v","version"],handler:()=>ke()}},v={};for(let n of Object.values(Gn))for(let e of n.flags)v[e]=n.handler;function Kn(n){let e={};for(let r=0;r<n.length;r++){let t=n[r];if(t.startsWith("--")){let s,o;if(t.includes("=")){let[i,c]=t.slice(2).split("=",2);s=i,o=c}else{s=t.slice(2);let i=n[r+1];if(o=i&&!i.startsWith("-")?i:!0,typeof o==="string")r++}if(s.includes(".")){let[i,c]=s.split(".",2),a=v[i];if(a)a(o,e,c);else throw new h(`Unknown option: --${s}`)}else{let i=v[s];if(i)i(o,e);else throw new h(`Unknown option: --${s}`)}}else if(t.startsWith("-")){let s=t.slice(1),o=n[r+1],i=o&&!o.startsWith("-")?o:!0;if(typeof i==="string")r++;let c=v[s];if(c)c(i,e);else throw new h(`Unknown option: -${s}`)}else Gn.entry.handler(t,e,void 0)}return e}import{loadConfig as Ie}from"coffi";import q from"node:path";import Me from"chokidar";async function Yn(n,e){let r=new Set,t=D(n),s=k(t.entry);for(let a of s){let l=q.resolve(e,a.fullEntryPath),u=q.dirname(l);r.add(u)}let o=Me.watch(Array.from(r),{persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50},ignoreInitial:!0,atomic:!0,ignorePermissionErrors:!0,ignored:[/[\\/]\.git[\\/]/,/[\\/]node_modules[\\/]/,q.join(e,t.outDir)]}),i=!1,c=async(a=!1)=>{if(i)return;i=!0;try{let l=performance.now();if(await W({...t,entry:s.map((u)=>u.fullEntryPath),clean:!1},e),!a)m.cli(`\uD83D\uDCE6 Rebuild finished in ${I(performance.now()-l)}`);await J()}catch(l){F(l)}finally{i=!1}};o.on("change",(a)=>{let l=q.relative(e,a);m.cli(`File changed: ${l}`,{muted:!0,once:l}),c()}),o.on("error",(a)=>{throw new E(`Watcher error: ${b(a)}`)}),await c(!0)}async function Re(n=Bun.argv.slice(2)){let e=Kn(n);M(e.silent);let r=process.cwd(),{config:t,filepath:s}=await Ie({name:"bunup.config",extensions:[".ts",".js",".mjs",".cjs"],maxDepth:1,preferredPath:e.config,packageJsonProperty:"bunup"}),o=!t?[{rootDir:r,options:e}]:await En(t,r);if(m.cli(`Using bunup v${H} and bun v${Bun.version}`,{muted:!0}),s)m.cli(`Using config file: ${C(s,2)}`,{muted:!0});let i=performance.now();m.cli("Build started"),await Promise.all(o.flatMap(({options:l,rootDir:u})=>{return ln(l).map(async(d)=>{let T={...d,...je(e)};return Ue(T,u)})}));let c=performance.now()-i,a=I(c);if(m.cli(`\u26A1\uFE0F Build completed in ${a}`),await J(),e.watch)m.cli("\uD83D\uDC40 Watching for file changes");if(e.onSuccess)m.cli(`Running command: ${e.onSuccess}`,{muted:!0}),await Ee(e.onSuccess,[],{nodeOptions:{shell:!0,stdio:"inherit"}});if(!e.watch)process.exit(0)}function je(n){return{...n,onSuccess:void 0,config:void 0}}async function J(){if(S.size>0)await Tn(S),S.clear()}async function Ue(n,e){if(n.watch)await Yn(n,e);else await W(n,e)}Re().catch((n)=>on(n));export{J as validateDtsFiles};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bunup",
3
3
  "description": "⚡ A blazing-fast build tool for your libraries built with Bun.",
4
- "version": "0.4.66",
4
+ "version": "0.4.67",
5
5
  "license": "MIT",
6
6
  "author": "Arshad Yaseen <m@arshadyaseen.com> (https://arshadyaseen.com)",
7
7
  "maintainers": [