bunup 0.4.45 → 0.4.47
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 +1 -92
- package/build/cli.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,8 +14,6 @@ Bunup is the **high-performance build tool** for TypeScript and JavaScript libra
|
|
|
14
14
|
|
|
15
15
|
_Lower is better. Benchmarks run on identical code and output formats._
|
|
16
16
|
|
|
17
|
-
Want proof? Clone the repo, run `pnpm benchmark`, and check `benchmarks/results.md` for yourself!
|
|
18
|
-
|
|
19
17
|
## Key Features
|
|
20
18
|
|
|
21
19
|
- ⚡️ **Ultra Fast Builds**: Lightning-fast performance powered by [Bun](https://bun.sh/)'s native bundler and [Oxc](https://oxc.rs).
|
|
@@ -28,98 +26,9 @@ Want proof? Clone the repo, run `pnpm benchmark`, and check `benchmarks/results.
|
|
|
28
26
|
|
|
29
27
|
- 🎯 **Bun Targeting**: Optimize for Bun runtime with `--target bun` for native features.
|
|
30
28
|
|
|
31
|
-
## 🚀 Quick Start
|
|
32
|
-
|
|
33
|
-
### Installations
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
# Using Bun
|
|
37
|
-
bun add bunup -d
|
|
38
|
-
|
|
39
|
-
# Using pnpm
|
|
40
|
-
pnpm add bunup -D
|
|
41
|
-
|
|
42
|
-
# Using npm
|
|
43
|
-
npm i bunup -D
|
|
44
|
-
|
|
45
|
-
# Using Yarn
|
|
46
|
-
yarn add bunup --dev
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Basic Usage
|
|
50
|
-
|
|
51
|
-
Create a simple TypeScript file:
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
// src/index.ts
|
|
55
|
-
export function greet(name: string): string {
|
|
56
|
-
return `Hello, ${name}!`;
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Bundle it with bunup:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
bunup src/index.ts
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
This will create a bundled output in the `dist` directory.
|
|
67
|
-
|
|
68
|
-
### Using with package.json
|
|
69
|
-
|
|
70
|
-
Add a build script to your `package.json`:
|
|
71
|
-
|
|
72
|
-
```json
|
|
73
|
-
{
|
|
74
|
-
"name": "my-package",
|
|
75
|
-
"scripts": {
|
|
76
|
-
"build": "bunup src/index.ts --format esm,cjs --dts"
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Then run:
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
npm run build
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### ⚙️ Configuration File
|
|
88
|
-
|
|
89
|
-
Create a `bunup.config.ts` file for more control:
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
import { defineConfig } from "bunup";
|
|
93
|
-
|
|
94
|
-
export default defineConfig({
|
|
95
|
-
entry: ["src/index.ts"],
|
|
96
|
-
outDir: "dist",
|
|
97
|
-
format: ["esm", "cjs"],
|
|
98
|
-
dts: true,
|
|
99
|
-
minify: true,
|
|
100
|
-
});
|
|
101
|
-
```
|
|
102
|
-
|
|
103
29
|
## 📚 Documentation
|
|
104
30
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
## ⚡️ Create TypeScript Libraries Faster
|
|
108
|
-
|
|
109
|
-
Quickly scaffold modern TypeScript library in 10 seconds. Powered by bunup.
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
# Using bun
|
|
113
|
-
bunx create-bunup@latest
|
|
114
|
-
|
|
115
|
-
# Using npm
|
|
116
|
-
npx create-bunup@latest
|
|
117
|
-
|
|
118
|
-
# Using pnpm
|
|
119
|
-
pnpx create-bunup@latest
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Check out our [TypeScript Library Starter documentation](https://bunup.arshadyaseen.com/typescript-library-starter.html) for more details.
|
|
31
|
+
To get started, visit the [documentation](https://bunup.arshadyaseen.com/documentation).
|
|
123
32
|
|
|
124
33
|
## ❤️ Contributing
|
|
125
34
|
|
package/build/cli.mjs
CHANGED
|
@@ -29,7 +29,7 @@ See: https://bunup.arshadyaseen.com/documentation/#named-entries`,{muted:!0,vert
|
|
|
29
29
|
const importMetaUrl = pathToFileURL(__filename).href;
|
|
30
30
|
|
|
31
31
|
`}};function He({format:e,target:n,shims:t}){let s=gn(t).map((o)=>P[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:dn},async({path:i})=>{let a=await Bun.file(i).text(),c=s.filter((p)=>p.isNeededInFile(a));if(c.length===0)return;let{shebangLine:u,codeContent:m}=bn(a),f=c.map((p)=>p.generateCode()).join("");return{contents:u+f+m}})}}}function gn(e){if(e===!0)return Object.keys(P);if(!e)return[];return Object.entries(e).filter(([n,t])=>t&&(n in P)).map(([n])=>n)}function bn(e){if(!e.startsWith("#!"))return{shebangLine:"",codeContent:e};let n=e.indexOf(`
|
|
32
|
-
`);return n===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,n+1),codeContent:e.slice(n+1)}}function We(e){return e.filter((n)=>n.type==="bun").map((n)=>n.plugin)}var S=new Set;async function H(e,n=process.cwd()){let t=D(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)pe(n,t.outDir);R(t.silent);let{packageJson:r,path:s}=await Me(n);if(r&&s)l.cli(`Using package.json: ${y(s,2)}`,{muted:!0,identifier:t.name,once:`${s}:${t.name}`});let o=A(t.entry),i=r?.type,a=I(t,r),c=_(t);if(!t.dtsOnly){let u=[De(a,c),...We(t.plugins??[])],m=t.format.flatMap((f)=>o.map((p)=>{return hn(t,n,p,f,i,u)}));await Promise.all(m)}if(t.dts||t.dtsOnly){let u=await je(n,t.preferredTsconfigPath);if(u.path)l.cli(`Using tsconfig: ${y(u.path,2)}`,{muted:!0,identifier:t.name,once:`${u.path}:${t.name}`});let m=t.format.filter((p)=>{if(p==="iife"&&!B(i)&&t.format.includes("cjs"))return!1;return!0}),f=typeof t.dts==="object"&&t.dts.entry?A(t.dts.entry):Ee(o);try{await Promise.all(f.map(async(p)=>{let T=await Te(n,p.path,t,u,r);await Promise.all(m.map(async(te)=>{let Ke=t.outputExtension?.({format:te,packageType:i,options:t,entry:p}).dts??le(te,i),F=`${n}/${t.outDir}/${p.name}${Ke}`;await Bun.write(F,T);let Ye=Bun.file(F).size||0;l.progress("DTS",y(F),z(Ye),t.name)}))}))}catch(p){throw new g(b(p))}}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??ue(r,s),a=await Bun.build({entrypoints:[`${n}/${t.path}`],format:r,naming:{entry:Le(t.name,i)},splitting:Ne(e.splitting,r),bytecode:Ie(e.bytecode,r),define:_e(e.define,e.shims,e.env,r),minify:ke(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:Ue(e.env),plugins:[...o,He({format:r,target:e.target,shims:e.shims})],throw:!1});if(!a.success)for(let m of a.logs){if(m.level==="error")throw new C(m.message);if(m.level==="warning")l.warn(m.message);else if(m.level==="info")l.info(m.message)}let c=`${n}/${e.outDir}/${t.name}${i}`,u=Bun.file(c).size||0;l.progress(r.toUpperCase(),y(c),z(u),e.name)}var W="0.4.
|
|
32
|
+
`);return n===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,n+1),codeContent:e.slice(n+1)}}function We(e){return e.filter((n)=>n.type==="bun").map((n)=>n.plugin)}var S=new Set;async function H(e,n=process.cwd()){let t=D(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)pe(n,t.outDir);R(t.silent);let{packageJson:r,path:s}=await Me(n);if(r&&s)l.cli(`Using package.json: ${y(s,2)}`,{muted:!0,identifier:t.name,once:`${s}:${t.name}`});let o=A(t.entry),i=r?.type,a=I(t,r),c=_(t);if(!t.dtsOnly){let u=[De(a,c),...We(t.plugins??[])],m=t.format.flatMap((f)=>o.map((p)=>{return hn(t,n,p,f,i,u)}));await Promise.all(m)}if(t.dts||t.dtsOnly){let u=await je(n,t.preferredTsconfigPath);if(u.path)l.cli(`Using tsconfig: ${y(u.path,2)}`,{muted:!0,identifier:t.name,once:`${u.path}:${t.name}`});let m=t.format.filter((p)=>{if(p==="iife"&&!B(i)&&t.format.includes("cjs"))return!1;return!0}),f=typeof t.dts==="object"&&t.dts.entry?A(t.dts.entry):Ee(o);try{await Promise.all(f.map(async(p)=>{let T=await Te(n,p.path,t,u,r);await Promise.all(m.map(async(te)=>{let Ke=t.outputExtension?.({format:te,packageType:i,options:t,entry:p}).dts??le(te,i),F=`${n}/${t.outDir}/${p.name}${Ke}`;await Bun.write(F,T);let Ye=Bun.file(F).size||0;l.progress("DTS",y(F),z(Ye),t.name)}))}))}catch(p){throw new g(b(p))}}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??ue(r,s),a=await Bun.build({entrypoints:[`${n}/${t.path}`],format:r,naming:{entry:Le(t.name,i)},splitting:Ne(e.splitting,r),bytecode:Ie(e.bytecode,r),define:_e(e.define,e.shims,e.env,r),minify:ke(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:Ue(e.env),plugins:[...o,He({format:r,target:e.target,shims:e.shims})],throw:!1});if(!a.success)for(let m of a.logs){if(m.level==="error")throw new C(m.message);if(m.level==="warning")l.warn(m.message);else if(m.level==="info")l.info(m.message)}let c=`${n}/${e.outDir}/${t.name}${i}`,u=Bun.file(c).size||0;l.progress(r.toUpperCase(),y(c),z(u),e.name)}var W="0.4.47";var ve="https://bunup.arshadyaseen.com/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 h(`Option --${e} requires a string value`)}}function ee(e){return(n,t)=>{if(typeof n==="string")t[e]=n.split(",");else throw new h(`Option --${e} requires a string value`)}}function yn(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 h(`Option --${e} requires a boolean or string value`)}}function wn(){console.log(`
|
|
33
33
|
Bunup - A blazing-fast build tool for your libraries built with Bun.
|
|
34
34
|
`),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${ve}\x1B[0m
|
|
35
35
|
`),process.exit(0)}function Cn(){console.log(W),process.exit(0)}var qe={name:{flags:["n","name"],handler:x("name")},format:{flags:["f","format"],handler:ee("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:ee("external")},sourcemap:{flags:["sm","sourcemap"],handler:yn("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:ee("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 h(`Entry${t?` --entry.${t}`:""} requires a string value`);let r=n.entry||{};if(t){if(r[t])l.warn(`Duplicate entry name '${t}' provided via --entry.${t}. Overwriting previous entry.`);r[t]=e}else{let s=U(e);if(r[s])l.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:()=>wn()},version:{flags:["v","version"],handler:()=>Cn()}},v={};for(let e of Object.values(qe))for(let n of e.flags)v[n]=e.handler;function Fe(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=v[i];if(c)c(o,n,a);else throw new h(`Unknown option: --${s}`)}else{let i=v[s];if(i)i(o,n);else throw new h(`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=v[s];if(a)a(i,n);else throw new h(`Unknown option: -${s}`)}else qe.entry.handler(r,n,void 0)}return n}import{loadConfig as Bn}from"coffi";import q from"node:path";import $n from"chokidar";async function Ge(e,n){let t=new Set,r=D(e),s=A(r.entry);for(let c of s){let u=q.resolve(n,c.path),m=q.dirname(u);t.add(m)}let o=$n.watch(Array.from(t),{persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50},ignoreInitial:!0,atomic:!0,ignorePermissionErrors:!0,ignored:[/[\\/]\.git[\\/]/,/[\\/]node_modules[\\/]/,q.join(n,r.outDir)]}),i=!1,a=async(c=!1)=>{if(i)return;i=!0;try{let u=performance.now();if(await H({...r,entry:s.map((m)=>m.path),clean:!1},n),!c)l.cli(`\uD83D\uDCE6 Rebuild finished in ${j(performance.now()-u)}`);await ne()}catch(u){G(u)}finally{i=!1}};o.on("change",(c)=>{let u=q.relative(n,c);l.cli(`File changed: ${u}`,{muted:!0,once:u}),a()}),o.on("error",(c)=>{throw new M(`Watcher error: ${b(c)}`)}),await a(!0)}async function Sn(e=Bun.argv.slice(2)){let n=Fe(e);R(n.silent);let t=process.cwd(),{config:r,filepath:s}=await Bn({name:"bunup.config",extensions:[".ts",".js",".mjs",".cjs"],maxDepth:1,preferredPath:n.config,packageJsonProperty:"bunup"}),o=!r?[{rootDir:t,options:n}]:await Re(r,t);if(l.cli(`Using bunup v${W} and bun v${Bun.version}`,{muted:!0}),s)l.cli(`Using config file: ${y(s,2)}`,{muted:!0});let i=performance.now();l.cli("Build started"),await Promise.all(o.flatMap(({options:u,rootDir:m})=>{return ce(u).map(async(p)=>{let T={...p,...Tn(n)};return En(T,m)})}));let a=performance.now()-i,c=j(a);if(l.cli(`\u26A1\uFE0F Build completed in ${c}`),await ne(),n.watch)l.cli("\uD83D\uDC40 Watching for file changes");if(n.onSuccess)l.cli(`Running command: ${n.onSuccess}`,{muted:!0}),On(n.onSuccess,[],{nodeOptions:{shell:!0,stdio:"inherit"}});if(!n.watch)process.exit(0)}function Tn(e){return{...e,onSuccess:void 0,config:void 0}}async function ne(){if(S.size>0)await Se(S),S.clear()}async function En(e,n){if(e.watch)await Ge(e,n);else await H(e,n)}Sn().catch((e)=>se(e));export{ne as validateDtsFiles};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunup",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.47",
|
|
4
4
|
"description": "A blazing-fast build tool for your libraries built with Bun.",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"bunup": "^0.4.23",
|
|
21
21
|
"husky": "^9.1.7",
|
|
22
22
|
"typescript": "^5.8.3",
|
|
23
|
-
"create-bunup": "0.4.
|
|
23
|
+
"create-bunup": "0.4.47"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"typescript": ">=4.5.0"
|