bunup 0.3.19 → 0.3.23

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
@@ -20,7 +20,7 @@ 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: ${g(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}: ${g(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. ${g(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. ${g(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}: ${g(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});let s=e?.type,i=k(n,e),o=L(n),a=[yn(i,o)],c=M(n.entry),f=K(n,t),p=n.format.flatMap((u)=>c.map((j)=>{return et(n,t,j,u,s,a,f)}));if(await Promise.all(p),n.dts){let u=hn(n.preferredTsconfigPath);if(u.path)l.cli(`Using tsconfig: ${x(u.path,2)}`,{muted:!0,once:u.path});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(g(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}`,p=Bun.file(f).size||0;l.progress(r.toUpperCase(),x(f),q(p),n.name)}var H="0.3.19";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(`
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: ${g(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}: ${g(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. ${g(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. ${g(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}: ${g(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),p=n.format.flatMap((u)=>c.map((j)=>{return et(n,t,j,u,s,a,f)}));if(await Promise.all(p),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(g(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}`,p=Bun.file(f).size||0;l.progress(r.toUpperCase(),x(f),q(p),n.name)}var H="0.3.23";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.
package/build/index.js CHANGED
@@ -12,4 +12,4 @@ To fix this, use named entries in your configuration:
12
12
  }
13
13
  }
14
14
 
15
- See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),t.push({name:f,path:o})}else t.push({name:s,path:o}),r.add(s),e[s]=o}if(Array.isArray(n))for(let s of n){let o=fn(s);i(o,s)}else if(typeof n==="object")Object.entries(n).forEach(([s,o])=>{i(s,o)});else{let s=fn(n);i(s,n)}return t}function un(n,t){return`[dir]/${n}${t}`}var gn=require("load-tsconfig");function ln(n){try{return gn.loadTsConfig(".",n)}catch(t){return g.warn(`Failed to load tsconfig: ${p(t)}`),{path:n,data:{},files:[]}}}var mn=x(require("node:path"));async function pn(n){let t=mn.default.join(n,"package.json");try{if(!await Bun.file(t).exists())return{packageJson:null,path:t};let e=await Bun.file(t).text();return{packageJson:JSON.parse(e),path:t}}catch(r){return g.warn(`Failed to load package.json at ${t}: ${p(r)}`),{packageJson:null,path:t}}}function dn(n,t){return{name:"bunup:external-plugin",setup(r){r.onResolve({filter:/.*/},(e)=>{let i=e.path;if(n.some((o)=>o.test(i))&&!t.some((o)=>o.test(i)))return{path:i,external:!0};return null})}}}var _=new Set;async function xn(n,t){if(!n.entry||n.entry.length===0||!n.outDir)throw new b("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let{packageJson:r,path:e}=await pn(t);if(r)g.cli(`Using package.json: ${y(e,2)}`,{muted:!0,once:e});let i=r?.type,s=O(n,r),o=j(n),a=[dn(s,o)],f=v(n.entry),u=Y(n,t),l=n.format.flatMap((c)=>f.map((C)=>{return Hn(n,t,C,c,i,a,u)}));if(await Promise.all(l),n.dts){let c=ln(n.preferredTsconfigPath);if(c.path)g.cli(`Using tsconfig: ${y(c.path,2)}`,{muted:!0,once:c.path});let C=n.format.filter(($)=>{if($==="iife"&&!B(i)&&n.format.includes("cjs"))return!1;return!0}),wn=typeof n.dts==="object"&&n.dts.entry?v(n.dts.entry):f;try{await Promise.all(wn.map(async($)=>{let En=await an(t,$.path,n,c,r);await Promise.all(C.map(async($n)=>{let bn=K($n,i),A=`${t}/${n.outDir}/${$.name}${bn}`;await Bun.write(A,En);let yn=Bun.file(A).size||0;g.progress("DTS",y(A),D(yn),n.name)}))}))}catch($){throw new d(p($))}}}async function Hn(n,t,r,e,i,s,o){let a=q(e,i),f=await Bun.build({...o,entrypoints:[`${t}/${r.path}`],format:e,naming:{entry:un(r.name,a)},splitting:Z(n.splitting,e),plugins:s,throw:!1});if(!f.success)f.logs.forEach((c)=>{if(c.level==="error")throw new b(c.message);else if(c.level==="warning")g.warn(c.message);else if(c.level==="info")g.info(c.message)});let u=`${t}/${n.outDir}/${r.name}${a}`,l=Bun.file(u).size||0;g.progress(e.toUpperCase(),y(u),D(l),n.name)}
15
+ See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),t.push({name:f,path:o})}else t.push({name:s,path:o}),r.add(s),e[s]=o}if(Array.isArray(n))for(let s of n){let o=fn(s);i(o,s)}else if(typeof n==="object")Object.entries(n).forEach(([s,o])=>{i(s,o)});else{let s=fn(n);i(s,n)}return t}function un(n,t){return`[dir]/${n}${t}`}var gn=require("load-tsconfig");function ln(n){try{return gn.loadTsConfig(".",n)}catch(t){return g.warn(`Failed to load tsconfig: ${p(t)}`),{path:n,data:{},files:[]}}}var mn=x(require("node:path"));async function pn(n){let t=mn.default.join(n,"package.json");try{if(!await Bun.file(t).exists())return{packageJson:null,path:t};let e=await Bun.file(t).text();return{packageJson:JSON.parse(e),path:t}}catch(r){return g.warn(`Failed to load package.json at ${t}: ${p(r)}`),{packageJson:null,path:t}}}function dn(n,t){return{name:"bunup:external-plugin",setup(r){r.onResolve({filter:/.*/},(e)=>{let i=e.path;if(n.some((o)=>o.test(i))&&!t.some((o)=>o.test(i)))return{path:i,external:!0};return null})}}}var _=new Set;async function xn(n,t){if(!n.entry||n.entry.length===0||!n.outDir)throw new b("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let{packageJson:r,path:e}=await pn(t);if(r)g.cli(`Using package.json: ${y(e,2)}`,{muted:!0,once:e,identifier:n.name});let i=r?.type,s=O(n,r),o=j(n),a=[dn(s,o)],f=v(n.entry),u=Y(n,t),l=n.format.flatMap((c)=>f.map((C)=>{return Hn(n,t,C,c,i,a,u)}));if(await Promise.all(l),n.dts){let c=ln(n.preferredTsconfigPath);if(c.path)g.cli(`Using tsconfig: ${y(c.path,2)}`,{muted:!0,once:c.path,identifier:n.name});let C=n.format.filter(($)=>{if($==="iife"&&!B(i)&&n.format.includes("cjs"))return!1;return!0}),wn=typeof n.dts==="object"&&n.dts.entry?v(n.dts.entry):f;try{await Promise.all(wn.map(async($)=>{let En=await an(t,$.path,n,c,r);await Promise.all(C.map(async($n)=>{let bn=K($n,i),A=`${t}/${n.outDir}/${$.name}${bn}`;await Bun.write(A,En);let yn=Bun.file(A).size||0;g.progress("DTS",y(A),D(yn),n.name)}))}))}catch($){throw new d(p($))}}}async function Hn(n,t,r,e,i,s,o){let a=q(e,i),f=await Bun.build({...o,entrypoints:[`${t}/${r.path}`],format:e,naming:{entry:un(r.name,a)},splitting:Z(n.splitting,e),plugins:s,throw:!1});if(!f.success)f.logs.forEach((c)=>{if(c.level==="error")throw new b(c.message);else if(c.level==="warning")g.warn(c.message);else if(c.level==="info")g.info(c.message)});let u=`${t}/${n.outDir}/${r.name}${a}`,l=Bun.file(u).size||0;g.progress(e.toUpperCase(),y(u),D(l),n.name)}
package/build/index.mjs CHANGED
@@ -12,4 +12,4 @@ To fix this, use named entries in your configuration:
12
12
  }
13
13
  }
14
14
 
15
- See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),t.push({name:f,path:o})}else t.push({name:s,path:o}),r.add(s),e[s]=o}if(Array.isArray(n))for(let s of n){let o=X(s);i(o,s)}else if(typeof n==="object")Object.entries(n).forEach(([s,o])=>{i(s,o)});else{let s=X(n);i(s,n)}return t}function I(n,t){return`[dir]/${n}${t}`}import{loadTsConfig as yn}from"load-tsconfig";function V(n){try{return yn(".",n)}catch(t){return g.warn(`Failed to load tsconfig: ${p(t)}`),{path:n,data:{},files:[]}}}import hn from"node:path";async function F(n){let t=hn.join(n,"package.json");try{if(!await Bun.file(t).exists())return{packageJson:null,path:t};let e=await Bun.file(t).text();return{packageJson:JSON.parse(e),path:t}}catch(r){return g.warn(`Failed to load package.json at ${t}: ${p(r)}`),{packageJson:null,path:t}}}function nn(n,t){return{name:"bunup:external-plugin",setup(r){r.onResolve({filter:/.*/},(e)=>{let i=e.path;if(n.some((o)=>o.test(i))&&!t.some((o)=>o.test(i)))return{path:i,external:!0};return null})}}}var Y=new Set;async function Cn(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:r,path:e}=await F(t);if(r)g.cli(`Using package.json: ${E(e,2)}`,{muted:!0,once:e});let i=r?.type,s=R(n,r),o=B(n),a=[nn(s,o)],f=S(n.entry),u=D(n,t),l=n.format.flatMap((c)=>f.map((h)=>{return Rn(n,t,h,c,i,a,u)}));if(await Promise.all(l),n.dts){let c=V(n.preferredTsconfigPath);if(c.path)g.cli(`Using tsconfig: ${E(c.path,2)}`,{muted:!0,once:c.path});let h=n.format.filter((x)=>{if(x==="iife"&&!C(i)&&n.format.includes("cjs"))return!1;return!0}),tn=typeof n.dts==="object"&&n.dts.entry?S(n.dts.entry):f;try{await Promise.all(tn.map(async(x)=>{let rn=await z(t,x.path,n,c,r);await Promise.all(h.map(async(en)=>{let sn=T(en,i),O=`${t}/${n.outDir}/${x.name}${sn}`;await Bun.write(O,rn);let on=Bun.file(O).size||0;g.progress("DTS",E(O),A(on),n.name)}))}))}catch(x){throw new d(p(x))}}}async function Rn(n,t,r,e,i,s,o){let a=v(e,i),f=await Bun.build({...o,entrypoints:[`${t}/${r.path}`],format:e,naming:{entry:I(r.name,a)},splitting:k(n.splitting,e),plugins:s,throw:!1});if(!f.success)f.logs.forEach((c)=>{if(c.level==="error")throw new w(c.message);else if(c.level==="warning")g.warn(c.message);else if(c.level==="info")g.info(c.message)});let u=`${t}/${n.outDir}/${r.name}${a}`,l=Bun.file(u).size||0;g.progress(e.toUpperCase(),E(u),A(l),n.name)}export{an as defineWorkspace,cn as defineConfig,Cn as build};
15
+ See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),t.push({name:f,path:o})}else t.push({name:s,path:o}),r.add(s),e[s]=o}if(Array.isArray(n))for(let s of n){let o=X(s);i(o,s)}else if(typeof n==="object")Object.entries(n).forEach(([s,o])=>{i(s,o)});else{let s=X(n);i(s,n)}return t}function I(n,t){return`[dir]/${n}${t}`}import{loadTsConfig as yn}from"load-tsconfig";function V(n){try{return yn(".",n)}catch(t){return g.warn(`Failed to load tsconfig: ${p(t)}`),{path:n,data:{},files:[]}}}import hn from"node:path";async function F(n){let t=hn.join(n,"package.json");try{if(!await Bun.file(t).exists())return{packageJson:null,path:t};let e=await Bun.file(t).text();return{packageJson:JSON.parse(e),path:t}}catch(r){return g.warn(`Failed to load package.json at ${t}: ${p(r)}`),{packageJson:null,path:t}}}function nn(n,t){return{name:"bunup:external-plugin",setup(r){r.onResolve({filter:/.*/},(e)=>{let i=e.path;if(n.some((o)=>o.test(i))&&!t.some((o)=>o.test(i)))return{path:i,external:!0};return null})}}}var Y=new Set;async function Cn(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:r,path:e}=await F(t);if(r)g.cli(`Using package.json: ${E(e,2)}`,{muted:!0,once:e,identifier:n.name});let i=r?.type,s=R(n,r),o=B(n),a=[nn(s,o)],f=S(n.entry),u=D(n,t),l=n.format.flatMap((c)=>f.map((h)=>{return Rn(n,t,h,c,i,a,u)}));if(await Promise.all(l),n.dts){let c=V(n.preferredTsconfigPath);if(c.path)g.cli(`Using tsconfig: ${E(c.path,2)}`,{muted:!0,once:c.path,identifier:n.name});let h=n.format.filter((x)=>{if(x==="iife"&&!C(i)&&n.format.includes("cjs"))return!1;return!0}),tn=typeof n.dts==="object"&&n.dts.entry?S(n.dts.entry):f;try{await Promise.all(tn.map(async(x)=>{let rn=await z(t,x.path,n,c,r);await Promise.all(h.map(async(en)=>{let sn=T(en,i),O=`${t}/${n.outDir}/${x.name}${sn}`;await Bun.write(O,rn);let on=Bun.file(O).size||0;g.progress("DTS",E(O),A(on),n.name)}))}))}catch(x){throw new d(p(x))}}}async function Rn(n,t,r,e,i,s,o){let a=v(e,i),f=await Bun.build({...o,entrypoints:[`${t}/${r.path}`],format:e,naming:{entry:I(r.name,a)},splitting:k(n.splitting,e),plugins:s,throw:!1});if(!f.success)f.logs.forEach((c)=>{if(c.level==="error")throw new w(c.message);else if(c.level==="warning")g.warn(c.message);else if(c.level==="info")g.info(c.message)});let u=`${t}/${n.outDir}/${r.name}${a}`,l=Bun.file(u).size||0;g.progress(e.toUpperCase(),E(u),A(l),n.name)}export{an as defineWorkspace,cn as defineConfig,Cn as build};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunup",
3
- "version": "0.3.19",
3
+ "version": "0.3.23",
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",
@@ -18,12 +18,13 @@
18
18
  "@types/bun": "^1.2.5",
19
19
  "@typescript-eslint/eslint-plugin": "^7.3.1",
20
20
  "bumpp": "^10.1.0",
21
- "bunup": "^0.3.18",
21
+ "bunup": "^0.3.20",
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
- "vitest": "^2.1.9"
26
+ "vitest": "^2.1.9",
27
+ "create-bunup": "0.3.23"
27
28
  },
28
29
  "peerDependencies": {
29
30
  "typescript": ">=4.5.0"
@@ -64,15 +65,15 @@
64
65
  "build": "bunup",
65
66
  "dev": "bunup --watch",
66
67
  "build:docs": "pnpm -C docs build",
68
+ "create-bunup": "create-bunup",
67
69
  "dev:docs": "pnpm -C docs dev",
68
70
  "test-build": "pnpm -C tests build",
69
71
  "test": "vitest run",
70
72
  "tsc": "tsc --noEmit",
71
73
  "lint": "eslint src --fix",
72
- "validate": "pnpm run tsc && pnpm run lint",
73
74
  "format": "prettier --write .",
74
- "release": "bumpp",
75
- "publish:ci": "pnpm publish --access public --no-git-checks",
75
+ "release": "bumpp -r --commit --push --tag",
76
+ "publish:ci": "pnpm --filter bunup --filter create-bunup publish --access public --no-git-checks",
76
77
  "benchmark": "pnpm -C benchmarks benchmark",
77
78
  "fresh-deps": "pnpx taze -r -w"
78
79
  }