bunup 0.3.25 → 0.3.28
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 +4 -4
- package/build/cli.mjs +6 -6
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -7,10 +7,10 @@ An extremely fast, zero-config bundler for TypeScript & JavaScript, powered by [
|
|
|
7
7
|
|
|
8
8
|
| Bundler | Format | Build Time | Build Time (with dts) |
|
|
9
9
|
| ------- | -------- | -------------- | --------------------- |
|
|
10
|
-
| bunup | esm, cjs | **
|
|
11
|
-
| tsdown | esm, cjs |
|
|
12
|
-
| unbuild | esm, cjs |
|
|
13
|
-
| tsup | esm, cjs |
|
|
10
|
+
| bunup | esm, cjs | **3.09ms ⚡️** | **19.55ms ⚡️** |
|
|
11
|
+
| tsdown | esm, cjs | 5.75ms | 43.89ms |
|
|
12
|
+
| unbuild | esm, cjs | 42.26ms | 322.66ms |
|
|
13
|
+
| tsup | esm, cjs | 63.81ms | 948.24ms |
|
|
14
14
|
|
|
15
15
|
_Lower build time is better. Benchmark run on the same code with identical output formats._
|
|
16
16
|
|
package/build/cli.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{rolldown as Dn}from"rolldown";import{dts as Hn}from"rolldown-plugin-dts";class $ extends Error{constructor(n){super(n);this.name="BunupError"}}class w extends ${constructor(n){super(n);this.name="BunupBuildError"}}class d extends ${constructor(n){super(n);this.name="BunupDTSBuildError"}}class h extends ${constructor(n){super(n);this.name="BunupCLIError"}}class A extends ${constructor(n){super(n);this.name="BunupWatchError"}}var
|
|
3
|
+
import{rolldown as Dn}from"rolldown";import{dts as Hn}from"rolldown-plugin-dts";class $ extends Error{constructor(n){super(n);this.name="BunupError"}}class w extends ${constructor(n){super(n);this.name="BunupBuildError"}}class d extends ${constructor(n){super(n);this.name="BunupDTSBuildError"}}class h extends ${constructor(n){super(n);this.name="BunupCLIError"}}class A extends ${constructor(n){super(n);this.name="BunupWatchError"}}var p=(n)=>{if(n instanceof Error)return n.message;return String(n)},Mn=(n,t)=>{let e=p(n),r=t?`[${t}] `:"",s="ERROR";if(n instanceof w)s="BUILD ERROR";else if(n instanceof d)s="DTS ERROR";else if(n instanceof h)s="CLI ERROR";else if(n instanceof A)s="WATCH ERROR";else if(n instanceof $)s="BUNUP ERROR";if(console.error(`\x1B[31m${s}\x1B[0m ${r}${e}`),n instanceof Error&&n.stack)console.error("\x1B[2m"+n.stack.split(`
|
|
4
4
|
`).slice(1).join(`
|
|
5
|
-
`)+"\x1B[0m")},z=(n,t)=>{Mn(n,t),process.exit(1)};import Q from"node:fs/promises";import Tn from"node:path";var O={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function K(n,t){return{outdir:`${t}/${n.outDir}`,minify:Nn(n),target:n.target,splitting:n.splitting,sourcemap:n.sourcemap,define:n.define,loader:n.loader,drop:n.drop,banner:n.banner,footer:n.footer}}function Nn(n){let{minify:t,minifyWhitespace:e,minifyIdentifiers:r,minifySyntax:s}=n,i=t===!0;return{whitespace:e??i,identifiers:r??i,syntax:s??i}}function _(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Z(n=8){return Math.random().toString(36).substring(2,2+n)}function X(n,t){switch(n){case"esm":return".mjs";case"cjs":return N(t)?".cjs":".js";case"iife":return".global.js"}}function F(n,t){switch(n){case"esm":return".d.mts";case"cjs":return N(t)?".d.cts":".d.ts";case"iife":return".d.ts"}}function N(n){return n==="module"}function T(n){return n>=1000?`${(n/1000).toFixed(2)}s`:`${Math.round(n)}ms`}function V(n){if(!n)return[];return Array.from(new Set([...Object.keys(n.dependencies||{}),...Object.keys(n.peerDependencies||{})]))}function nn(n,t){return n===void 0?t==="esm":n}function q(n){if(n===0)return"0 B";let t=["B","KB","MB","GB"],e=Math.floor(Math.log(n)/Math.log(1024));if(e===0)return`${n} ${t[e]}`;return`${(n/Math.pow(1024,e)).toFixed(2)} ${t[e]}`}function x(n,t=3){return n.split("/").slice(-t).join("/")}async function I(n,t){let e=Tn.join(n,t);try{await Q.rm(e,{recursive:!0,force:!0})}catch(r){throw new w(`Failed to clean output directory: ${r}`)}await Q.mkdir(e,{recursive:!0})}function P(n){return n||O.outDir}function tn(n){return n===void 0?O.clean:n}function en(n){return n.map((t)=>typeof t==="string"?new RegExp(`^${_(t)}($|\\/|\\\\)`):t)}function k(n,t){return en(n.external||[]).concat(V(t).map((e)=>new RegExp(`^${_(e)}($|\\/|\\\\)`)))}function L(n){return en(n.noExternal||[])}import kn from"node:path";import{ResolverFactory as Ln}from"oxc-resolver";import C from"path";var m="\x00virtual:",rn=(n)=>{return{name:"bunup:virtual-dts",resolveId(t,e){if(t.startsWith(m))return t;if(!e?.startsWith(m)||!t.startsWith("."))return null;let r=e.slice(m.length),s=C.resolve(C.dirname(r),t);if(t==="."){let o=C.join(C.dirname(r),"index.d.ts");if(n.has(o))return`${m}${o}`;s=C.dirname(r)}if(n.has(s))return`${m}${s}`;let i=`${s}.d.ts`;if(n.has(i))return`${m}${i}`;if(t.startsWith(".")){let o=C.join(s,"index.d.ts");if(n.has(o))return`${m}${o}`}return null},load(t){if(t.startsWith(m)){let e=t.slice(m.length),r=n.get(e);if(r)return B.add(e),r}return null}}};var sn;function on(n){return{name:"bunup:types-resolve",buildStart(){sn||=new Ln({mainFields:["types"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".ts"],modules:["node_modules","node_modules/@types"]})},async resolveId(t,e){if(e=e?.replace(m,""),/\0/.test(t))return;if(n){if(!n.some((o)=>{let a=!1;if(typeof o==="string")a=o===t||!!(e&&e.includes(o));else a=o.test(t)||!!(e&&o.test(e));return a}))return}let r=e?kn.dirname(e):process.cwd(),{path:s}=await sn.async(r,t);if(!s)return;if(/[cm]?jsx?$/.test(s)){let i=s.replace(/\.([cm]?)jsx?$/,".d.$1ts");return await Bun.file(i).exists()?i:void 0}return s}}}async function an(n,t,e,r){let s=n.replace(/\.tsx?$/,".d.ts"),i=`${m}${s}`,o=k(e,r),a=L(e),c;try{c=await Dn({input:i,onwarn(
|
|
6
|
-
`);let a=o.labels[0],c=a?Jn(s,a.start):"",
|
|
5
|
+
`)+"\x1B[0m")},z=(n,t)=>{Mn(n,t),process.exit(1)};import Q from"node:fs/promises";import Tn from"node:path";var O={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function K(n,t){return{outdir:`${t}/${n.outDir}`,minify:Nn(n),target:n.target,splitting:n.splitting,sourcemap:n.sourcemap,define:n.define,loader:n.loader,drop:n.drop,banner:n.banner,footer:n.footer}}function Nn(n){let{minify:t,minifyWhitespace:e,minifyIdentifiers:r,minifySyntax:s}=n,i=t===!0;return{whitespace:e??i,identifiers:r??i,syntax:s??i}}function _(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Z(n=8){return Math.random().toString(36).substring(2,2+n)}function X(n,t){switch(n){case"esm":return".mjs";case"cjs":return N(t)?".cjs":".js";case"iife":return".global.js"}}function F(n,t){switch(n){case"esm":return".d.mts";case"cjs":return N(t)?".d.cts":".d.ts";case"iife":return".d.ts"}}function N(n){return n==="module"}function T(n){return n>=1000?`${(n/1000).toFixed(2)}s`:`${Math.round(n)}ms`}function V(n){if(!n)return[];return Array.from(new Set([...Object.keys(n.dependencies||{}),...Object.keys(n.peerDependencies||{})]))}function nn(n,t){return n===void 0?t==="esm":n}function q(n){if(n===0)return"0 B";let t=["B","KB","MB","GB"],e=Math.floor(Math.log(n)/Math.log(1024));if(e===0)return`${n} ${t[e]}`;return`${(n/Math.pow(1024,e)).toFixed(2)} ${t[e]}`}function x(n,t=3){return n.split("/").slice(-t).join("/")}async function I(n,t){let e=Tn.join(n,t);try{await Q.rm(e,{recursive:!0,force:!0})}catch(r){throw new w(`Failed to clean output directory: ${r}`)}await Q.mkdir(e,{recursive:!0})}function P(n){return n||O.outDir}function tn(n){return n===void 0?O.clean:n}function en(n){return n.map((t)=>typeof t==="string"?new RegExp(`^${_(t)}($|\\/|\\\\)`):t)}function k(n,t){return en(n.external||[]).concat(V(t).map((e)=>new RegExp(`^${_(e)}($|\\/|\\\\)`)))}function L(n){return en(n.noExternal||[])}import kn from"node:path";import{ResolverFactory as Ln}from"oxc-resolver";import C from"path";var m="\x00virtual:",rn=(n)=>{return{name:"bunup:virtual-dts",resolveId(t,e){if(t.startsWith(m))return t;if(!e?.startsWith(m)||!t.startsWith("."))return null;let r=e.slice(m.length),s=C.resolve(C.dirname(r),t);if(t==="."){let o=C.join(C.dirname(r),"index.d.ts");if(n.has(o))return`${m}${o}`;s=C.dirname(r)}if(n.has(s))return`${m}${s}`;let i=`${s}.d.ts`;if(n.has(i))return`${m}${i}`;if(t.startsWith(".")){let o=C.join(s,"index.d.ts");if(n.has(o))return`${m}${o}`}return null},load(t){if(t.startsWith(m)){let e=t.slice(m.length),r=n.get(e);if(r)return B.add(e),r}return null}}};var sn;function on(n){return{name:"bunup:types-resolve",buildStart(){sn||=new Ln({mainFields:["types"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".ts"],modules:["node_modules","node_modules/@types"]})},async resolveId(t,e){if(e=e?.replace(m,""),/\0/.test(t))return;if(n){if(!n.some((o)=>{let a=!1;if(typeof o==="string")a=o===t||!!(e&&e.includes(o));else a=o.test(t)||!!(e&&o.test(e));return a}))return}let r=e?kn.dirname(e):process.cwd(),{path:s}=await sn.async(r,t);if(!s)return;if(/[cm]?jsx?$/.test(s)){let i=s.replace(/\.([cm]?)jsx?$/,".d.$1ts");return await Bun.file(i).exists()?i:void 0}return s}}}async function an(n,t,e,r){let s=n.replace(/\.tsx?$/,".d.ts"),i=`${m}${s}`,o=k(e,r),a=L(e),c;try{c=await Dn({input:i,onwarn(g,u){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(g.code??""))return;u(g)},plugins:[rn(t),typeof e.dts==="object"&&"resolve"in e.dts&&on(typeof e.dts.resolve==="boolean"?void 0:e.dts.resolve),Hn()],external:(g)=>o.some((u)=>u.test(g))&&!a.some((u)=>u.test(g))});let{output:f}=await c.generate({});if(!f[0]?.code)throw new d("Generated bundle is empty");return f[0].code}catch(f){throw new d(`DTS bundling failed: ${p(f)}`)}finally{if(c)await c.close()}}import v from"node:path";class E{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(!E.instance)E.instance=new E;return E.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(n){if(!n?.once)return!0;if(this.loggedOnceMessages.has(n.once))return!1;return this.loggedOnceMessages.add(n.once),!0}formatMessage({colorCode:n,label:t,message:e,size:r,identifier:s,muted:i}){let o=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-t.length)),a=i?`\x1B[38;5;${this.colors.info}m${e}\x1B[0m`:e;if(r){let[f,...g]=a.split(" "),u=" ".repeat(Math.max(0,this.MAX_MESSAGE_LENGTH-f.length)),j=s?` \x1B[48;5;${n};38;5;0m ${s} \x1B[0m`:"";return`\x1B[38;5;${n}m${t}\x1B[0m ${o}${f}${u} \x1B[38;5;${this.colors.size}m${r}\x1B[0m ${g.join(" ")}${j}`}let c=s?` \x1B[48;5;${n};38;5;0m ${s} \x1B[0m`:"";return`\x1B[38;5;${n}m${t}\x1B[0m ${o}${a}${c}`}output(n,t={},e=console.log){if(!this.shouldLog(t))return;if(t.verticalSpace)console.log("");if(e(n),t.verticalSpace)console.log("")}cli(n,t={}){let e=this.formatMessage({colorCode:this.colors.cli,label:this.labels.cli,message:n,identifier:t.identifier,muted:t.muted});this.output(e,t)}info(n,t={}){let e=this.formatMessage({colorCode:this.colors.info,label:this.labels.info,message:n,identifier:t.identifier,muted:t.muted});this.output(e,t)}warn(n,t={}){let e=this.formatMessage({colorCode:this.colors.warn,label:this.labels.warn,message:n,identifier:t.identifier,muted:t.muted});this.output(e,t,console.warn)}error(n,t={}){let e=this.formatMessage({colorCode:this.colors.error,label:this.labels.error,message:n,identifier:t.identifier,muted:t.muted});this.output(e,t,console.error)}progress(n,t,e,r){let s=String(n),i=this.colors.default,o,a,c={};if(typeof e==="string")o=e,a=r;else if(e)o=e.size,a=e.identifier,c=e;for(let[g,u]of Object.entries(this.colors.progress))if(s.includes(g)){i=u;break}let f=this.formatMessage({colorCode:i,label:s,message:t,size:o,identifier:a,muted:c.muted});this.output(f,c)}}var l=E.getInstance();var Un=/(?:import|export)(?:[\s\n]*(?:type[\s\n]+)?(?:\*|\{[^}]*\}|[\w$]+)[\s\n]+from[\s\n]*|[\s\n]+)(["'`])([^'"]+)\1/g,Wn=/import\s*\(\s*(["'`])([^'"]+)\1\s*\)/g;async function cn(n,t){let e=new Set([n]),r=[n],s=qn(t),i=ln(t);while(r.length){let o=r.pop();if(!o)continue;try{let a=await Bun.file(o).text(),c=Gn(a);for(let f of c){let g=f.startsWith(".")?v.resolve(v.dirname(o),f):In(f,s,i);if(!g)continue;let u=await _n(g);if(u&&!e.has(u))e.add(u),r.push(u)}}catch(a){l.warn(`Error processing ${o}: ${p(a)}`)}}return e}function Gn(n){let t=new Set;for(let e of[Un,Wn]){let r;while((r=e.exec(n))!==null)t.add(r[2])}return Array.from(t)}async function _n(n){let t=["",".ts",".tsx","/index.ts","/index.tsx"];for(let e of t){let r=`${n}${e}`;if(await Bun.file(r).exists()&&(r.endsWith(".ts")||r.endsWith(".tsx")))return r}return null}function ln(n){let t=v.dirname(n.path||"");return n.data?.compilerOptions?.baseUrl?v.resolve(t,n.data.compilerOptions.baseUrl):t}function qn(n){let t=new Map,e=n.data?.compilerOptions?.paths;if(!e)return t;let r=ln(n);for(let[s,i]of Object.entries(e))if(Array.isArray(i)&&i.length){let o=s.replace(/\*/g,"(.*)"),a=i[0].replace(/\*/g,"$1");t.set(`^${o}$`,v.join(r,a))}return t}function In(n,t,e){for(let[r,s]of t){let i=new RegExp(r),o=n.match(i);if(o)return s.replace("$1",o[1]||"")}return e?v.join(e,n):null}import{isolatedDeclaration as Pn}from"oxc-transform";async function un(n){let t=new Map;return await Promise.all([...n].map(async(e)=>{try{let r=e.replace(/\.tsx?$/,".d.ts");if(!await Bun.file(e).exists())return;let i=await Bun.file(e).text(),{code:o}=Pn(e,i);if(o)t.set(r,o)}catch(r){l.warn(`Failed to generate declaration for ${e}: ${p(r)}`)}})),t}import fn from"node:fs/promises";import Y from"node:path";import{isolatedDeclaration as Yn}from"oxc-transform";async function pn(n,t){let e=Y.resolve(n),r=Y.resolve(e,t);if(!await fn.exists(e))throw new d(`Root directory does not exist: ${e}`);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(Y.relative(e,r).startsWith(".."))throw new d(`Entry file must be within rootDir: ${r}`);return{absoluteRootDir:e,absoluteEntry:r}}async function gn(n){let t=!1;if(await Promise.all([...n].map(async(e)=>{try{let r=e.replace(/\.d\.ts$/,".ts"),s=await Bun.file(r).text(),{errors:i}=Yn(r,s);i.forEach((o)=>{if(!t)console.log(`
|
|
6
|
+
`);let a=o.labels[0],c=a?Jn(s,a.start):"",g=`${x(r)}${c}: ${zn(o.message)}`;l.warn(g),t=!0})}catch{}})),t)l.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
8
|
`)}function Jn(n,t){if(t===void 0)return"";let e=n.slice(0,t).split(`
|
|
9
|
-
`),r=e.length,s=e[e.length-1].length+1;return` (${r}:${s})`}function zn(n){return n.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}async function mn(n,t,e,r,s){let{absoluteEntry:i}=await
|
|
9
|
+
`),r=e.length,s=e[e.length-1].length+1;return` (${r}:${s})`}function zn(n){return n.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}async function mn(n,t,e,r,s){let{absoluteEntry:i}=await pn(n,t),o=await cn(i,r),a=await un(o);return an(i,a,e,s)}function S(n){return n.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function M(n){let t=[],e=new Set,r={};function s(i,o){if(e.has(i)){let a=Z(),c=`${i}_${a}`;l.warn(`Output name conflict: "${i}" is used by multiple files.
|
|
10
10
|
Bunup uses filenames without extensions as output names by default.
|
|
11
11
|
|
|
12
12
|
${r[i]} -> ${i}.js
|
|
@@ -20,8 +20,8 @@ To fix this, use named entries in your configuration:
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),t.push({name:c,path:o})}else t.push({name:i,path:o}),e.add(i),r[i]=o}if(Array.isArray(n))for(let i of n){let o=S(i);s(o,i)}else if(typeof n==="object")Object.entries(n).forEach(([i,o])=>{s(i,o)});else{let i=S(n);s(i,n)}return t}function dn(n,t){return`[dir]/${n}${t}`}import{loadTsConfig as Kn}from"load-tsconfig";function hn(n){try{return Kn(".",n)}catch(t){return l.warn(`Failed to load tsconfig: ${
|
|
23
|
+
See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),t.push({name:c,path:o})}else t.push({name:i,path:o}),e.add(i),r[i]=o}if(Array.isArray(n))for(let i of n){let o=S(i);s(o,i)}else if(typeof n==="object")Object.entries(n).forEach(([i,o])=>{s(i,o)});else{let i=S(n);s(i,n)}return t}function dn(n,t){return`[dir]/${n}${t}`}import{loadTsConfig as Kn}from"load-tsconfig";function hn(n){try{return Kn(".",n)}catch(t){return l.warn(`Failed to load tsconfig: ${p(t)}`),{path:n,data:{},files:[]}}}import J from"node:path";async function wn(n){let t=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let e of t){let r=J.join(n,`bunup.config${e}`);try{if(!await Bun.file(r).exists())continue;let i=await Qn(r,e);if(!i)continue;return{configs:Fn(i,n),configFilePath:r}}catch(s){throw new w(`Failed to load config from ${r}: ${p(s)}`)}}return{configs:[],configFilePath:""}}async function Qn(n,t){if(t===".json"||t===".jsonc")return Zn(n);return Xn(n)}async function Zn(n){try{let t=await Bun.file(n).text(),e=JSON.parse(t);return e.bunup||e}catch(t){throw new Error(`Invalid JSON in config file. ${p(t)}`)}}async function Xn(n){try{let t=await import(`file://${n}`),e=t.default||t;if(!e)return l.warn(`No export found in ${n}. Make sure you're exporting your configuration.`),{};return e}catch(t){throw new Error(`Failed to import config file. ${p(t)}`)}}function Fn(n,t){let e=[];if(Vn(n))nt(n,t,e);else if(Array.isArray(n))tt(n,t,e);else if(n&&typeof n==="object")e.push({options:n,rootDir:t});else throw new Error("Invalid configuration format. Expected an object, array, or workspace configuration.");return e}function Vn(n){return Array.isArray(n)&&n.length>0&&n.every((t)=>typeof t==="object"&&t!==null&&("name"in t)&&("root"in t)&&("config"in t))}function nt(n,t,e){for(let r of n){let s=J.resolve(t,r.root);if(Array.isArray(r.config))for(let i of r.config)e.push({options:{name:r.name,...i},rootDir:s});else e.push({options:{name:r.name,...r.config},rootDir:s})}}function tt(n,t,e){for(let r of n){if(!r||typeof r!=="object")throw new Error("Invalid configuration item. Expected an object.");e.push({options:r,rootDir:t})}}async function xn(n){let t=J.join(n,"package.json");try{if(!await Bun.file(t).exists())return{packageJson:null,path:t};let r=await Bun.file(t).text();return{packageJson:JSON.parse(r),path:t}}catch(e){return l.warn(`Failed to load package.json at ${t}: ${p(e)}`),{packageJson:null,path:t}}}function yn(n,t){return{name:"bunup:external-plugin",setup(e){e.onResolve({filter:/.*/},(r)=>{let s=r.path;if(n.some((o)=>o.test(s))&&!t.some((o)=>o.test(s)))return{path:s,external:!0};return null})}}}var B=new Set;async function D(n,t){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.");let{packageJson:e,path:r}=await xn(t);if(e)l.cli(`Using package.json: ${x(r,2)}`,{muted:!0,once:r,identifier:n.name});let s=e?.type,i=k(n,e),o=L(n),a=[yn(i,o)],c=M(n.entry),f=K(n,t),g=n.format.flatMap((u)=>c.map((j)=>{return et(n,t,j,u,s,a,f)}));if(await Promise.all(g),n.dts){let u=hn(n.preferredTsconfigPath);if(u.path)l.cli(`Using tsconfig: ${x(u.path,2)}`,{muted:!0,once:u.path,identifier:n.name});let j=n.format.filter((b)=>{if(b==="iife"&&!N(s)&&n.format.includes("cjs"))return!1;return!0}),vn=typeof n.dts==="object"&&n.dts.entry?M(n.dts.entry):c;try{await Promise.all(vn.map(async(b)=>{let Rn=await mn(t,b.path,n,u,e);await Promise.all(j.map(async(jn)=>{let An=F(jn,s),G=`${t}/${n.outDir}/${b.name}${An}`;await Bun.write(G,Rn);let Sn=Bun.file(G).size||0;l.progress("DTS",x(G),q(Sn),n.name)}))}))}catch(b){throw new d(p(b))}}}async function et(n,t,e,r,s,i,o){let a=X(r,s),c=await Bun.build({...o,entrypoints:[`${t}/${e.path}`],format:r,naming:{entry:dn(e.name,a)},splitting:nn(n.splitting,r),plugins:i,throw:!1});if(!c.success)c.logs.forEach((u)=>{if(u.level==="error")throw new w(u.message);else if(u.level==="warning")l.warn(u.message);else if(u.level==="info")l.info(u.message)});let f=`${t}/${n.outDir}/${e.name}${a}`,g=Bun.file(f).size||0;l.progress(r.toUpperCase(),x(f),q(g),n.name)}var H="0.3.28";var bn="https://bun.sh/docs/installation",$n="https://bunup.arshadyaseen.com/#cli-options";function y(n){return(t,e)=>{e[n]=t===!0?!0:t==="true"}}function R(n){return(t,e)=>{if(typeof t==="string")e[n]=t;else throw new h(`Option --${n} requires a string value`)}}function On(n){return(t,e)=>{if(typeof t==="string")e[n]=t.split(",");else throw new h(`Option --${n} requires a string value`)}}function st(){console.log(`
|
|
24
24
|
Bunup - An extremely fast, zero-config bundler for JavaScript and TypeScript, powered by Bun.
|
|
25
25
|
`),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${$n}\x1B[0m
|
|
26
26
|
`),process.exit(0)}function it(){console.log(H),process.exit(0)}var ot={name:{flags:["n","name"],handler:R("name")},format:{flags:["f","format"],handler:(n,t)=>{if(typeof n==="string")t.format=n.split(",");else throw new h("Option --format requires a string value")}},outDir:{flags:["o","out-dir"],handler:R("outDir")},minify:{flags:["m","minify"],handler:y("minify")},watch:{flags:["w","watch"],handler:y("watch")},dts:{flags:["d","dts"],handler:y("dts")},banner:{flags:["b","banner"],handler:R("banner")},footer:{flags:["f","footer"],handler:R("footer")},external:{flags:["e","external"],handler:On("external")},sourcemap:{flags:["sm","sourcemap"],handler:R("sourcemap")},target:{flags:["t","target"],handler:R("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:y("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:y("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:y("minifySyntax")},clean:{flags:["c","clean"],handler:y("clean")},splitting:{flags:["s","splitting"],handler:y("splitting")},noExternal:{flags:["ne","no-external"],handler:On("noExternal")}},at={help:{flags:["h","help"],handler:()=>st()},version:{flags:["v","version"],handler:()=>it()}},U={};for(let n of Object.values(ot))if(n)for(let t of n.flags)U[t]=n.handler;for(let n of Object.values(at))for(let t of n.flags)U[t]=n.handler;function Cn(n){let t={},e={},r=0;while(r<n.length){let s=n[r];if(s.startsWith("--")){let i,o;if(s.includes("=")){let[a,c]=s.slice(2).split("=",2);i=a,o=c}else{i=s.slice(2);let a=n[r+1];if(o=a&&!a.startsWith("-")?a:!0,typeof o==="string")r++}if(i==="entry")if(typeof o==="string"){let a=S(o);if(e[a])l.warn(`Duplicate entry name '${a}' derived from '${o}'. Overwriting previous entry.`);e[a]=o}else throw new h("Option --entry requires a string value");else if(i.startsWith("entry.")){let a=i.slice(6);if(typeof o==="string"){if(e[a])l.warn(`Duplicate entry name '${a}' provided via --entry.${a}. Overwriting previous entry.`);e[a]=o}else throw new h(`Option --entry.${a} requires a string value`)}else{let a=U[i];if(a)a(o,t);else throw new h(`Unknown option: --${i}`)}}else if(s.startsWith("-")){let i=s.slice(1),o=n[r+1],a=o&&!o.startsWith("-")?o:!0;if(typeof a==="string")r++;let c=U[i];if(c)c(a,t);else throw new h(`Unknown option: -${i}`)}else{let i=S(s);if(e[i])l.warn(`Duplicate entry name '${i}' derived from positional argument '${s}'. Overwriting previous entry.`);e[i]=s}r++}if(Object.keys(e).length>0)t.entry=e;return t}(()=>{if(typeof Bun==="undefined")throw new h(`Bunup requires Bun to run.
|
|
27
|
-
To install Bun, visit `+bn)})();import W from"node:path";import ct from"chokidar";async function Bn(n,t){let e=new Set,r=M(n.entry);r.forEach((a)=>{let c=W.resolve(t,a.path),f=W.dirname(c);e.add(f)});let s=ct.watch(Array.from(e),{persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50},ignoreInitial:!0,atomic:!0,ignorePermissionErrors:!0,ignored:[/[\\/]\.git[\\/]/,/[\\/]node_modules[\\/]/,W.join(t,n.outDir)]}),i=!1,o=async(a=!1)=>{if(i)return;i=!0;try{let c=performance.now();if(await D({...n,entry:r.map((f)=>f.path),clean:!1},t),n.onBuildSuccess?.(),!a)l.cli(`\uD83D\uDCE6 Rebuild finished in ${T(performance.now()-c)}`)}catch(c){throw new A(`Build failed: ${
|
|
27
|
+
To install Bun, visit `+bn)})();import W from"node:path";import ct from"chokidar";async function Bn(n,t){let e=new Set,r=M(n.entry);r.forEach((a)=>{let c=W.resolve(t,a.path),f=W.dirname(c);e.add(f)});let s=ct.watch(Array.from(e),{persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50},ignoreInitial:!0,atomic:!0,ignorePermissionErrors:!0,ignored:[/[\\/]\.git[\\/]/,/[\\/]node_modules[\\/]/,W.join(t,n.outDir)]}),i=!1,o=async(a=!1)=>{if(i)return;i=!0;try{let c=performance.now();if(await D({...n,entry:r.map((f)=>f.path),clean:!1},t),n.onBuildSuccess?.(),!a)l.cli(`\uD83D\uDCE6 Rebuild finished in ${T(performance.now()-c)}`)}catch(c){throw new A(`Build failed: ${p(c)}`)}finally{i=!1}};s.on("change",(a)=>{let c=W.relative(t,a);l.cli(`File changed: ${c}`),o()}),s.on("error",(a)=>{throw new A(`Watcher error: ${p(a)}`)}),await o(!0)}async function lt(n=Bun.argv.slice(2)){let t=Cn(n),{configs:e,configFilePath:r}=await wn(process.cwd());if(l.cli(`Using bunup v${H} and bun v${Bun.version}`,{muted:!0}),r)l.cli(`Using config file: ${x(r,2)}`,{muted:!0});let s=performance.now();if(l.cli("Build started"),e.length===0){let a={...O,...t},c=process.cwd();if(a.clean)I(c,P(a.outDir));await En(a,c)}else{for(let{options:a,rootDir:c}of e)if(tn(a.clean))I(c,P(a.outDir));await Promise.all(e.map(async({options:a,rootDir:c})=>{let f={...O,...a,...t};await En(f,c)}))}let i=performance.now()-s,o=T(i);if(l.cli(`\u26A1\uFE0F Build completed in ${o}`),B.size>0)await gn(B),B.clear();if(t.watch)l.cli("\uD83D\uDC40 Watching for file changes");if(!t.watch)process.exit(0);l.dispose()}async function En(n,t){if(n.watch)await Bn(n,t);else await D(n,t),n.onBuildSuccess?.()}lt().catch((n)=>z(n));export{lt as main};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunup",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.28",
|
|
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",
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
"@commitlint/config-conventional": "^19.5.0",
|
|
17
17
|
"@ianvs/prettier-plugin-sort-imports": "^4.2.1",
|
|
18
18
|
"@types/bun": "^1.2.5",
|
|
19
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
19
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
20
20
|
"bumpp": "^10.1.0",
|
|
21
|
-
"bunup": "^0.3.
|
|
21
|
+
"bunup": "^0.3.26",
|
|
22
22
|
"eslint": "^8.57.1",
|
|
23
23
|
"husky": "^9.1.7",
|
|
24
24
|
"prettier": "^3.5.3",
|
|
25
25
|
"typescript": "^5.8.2",
|
|
26
26
|
"vitest": "^2.1.9",
|
|
27
|
-
"create-bunup": "0.3.
|
|
27
|
+
"create-bunup": "0.3.28"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"typescript": ">=4.5.0"
|
|
@@ -75,6 +75,6 @@
|
|
|
75
75
|
"release": "bumpp -r --commit --push --tag",
|
|
76
76
|
"publish:ci": "pnpm --filter bunup --filter create-bunup publish --access public --no-git-checks",
|
|
77
77
|
"benchmark": "pnpm -C benchmarks benchmark",
|
|
78
|
-
"
|
|
78
|
+
"upgrade-deps": "pnpx taze -r -w && pnpm install && git add . && git commit -m 'chore: upgrade deps' && pnpm release --yes"
|
|
79
79
|
}
|
|
80
80
|
}
|