bunup 0.3.4 → 0.3.5

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 (2) hide show
  1. package/build/cli.mjs +1 -1
  2. package/package.json +1 -1
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/#using-a-configuration-file-with-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=U(i);s(o,i)}else Object.entries(n).forEach(([i,o])=>{s(i,o)});return t}function wn(n,t){return`[dir]/${n}${t}`}function bn(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 H(n,t){if(!n.entry||n.entry.length===0||!n.outDir)throw new x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let e=L(t),r=e?.type,s=A(n,e),i=M(n),o=[bn(s,i)],a=T(n.entry),c=nn(n,t),u=n.format.flatMap((m)=>a.map((f)=>{return Vn(n,t,f,m,r,o,c)}));try{await Promise.all(u)}catch(m){throw console.error(m),new x("Build process encountered errors")}if(n.dts){let m=n.format.filter((g)=>{if(g==="iife"&&!j(r)&&n.format.includes("cjs"))return!1;return!0}),f=n.dts===!0?a:T(n.dts.entry);try{await Promise.all(f.map(async(g)=>{let b=await xn(t,g.path,n);await Promise.all(m.map(async($)=>{let Sn=rn($,r),q=`${t}/${n.outDir}/${g.name}${Sn}`;await Bun.write(q,b);let Rn=Bun.file(q).size||0;l.progress("DTS",O(q),J(Rn),n.name)}))}))}catch(g){throw new d(`DTS build process encountered errors: ${p(g)}`)}}}async function Vn(n,t,e,r,s,i,o){let a=en(r,s),c=await Bun.build({...o,entrypoints:[`${t}/${e.path}`],format:r,naming:{entry:wn(e.name,a)},splitting:on(n.splitting,r),plugins:i,throw:!1});if(!c.success)throw c.logs.forEach((f)=>{if(f.level==="error")l.error(f.message);else if(f.level==="warning")l.warn(f.message);else if(f.level==="info")l.info(f.message)}),new x(`Build failed for ${e.path} (${r})`);let u=`${t}/${n.outDir}/${e.name}${a}`,m=Bun.file(u).size||0;l.progress(r.toUpperCase(),O(u),J(m),n.name)}var D="0.3.4";var $n="https://bun.sh/docs/installation",On="https://bunup.arshadyaseen.com/#cli-options";function w(n){return(t,e)=>{e[n]=t===!0?!0:t==="true"}}function W(n){return(t,e)=>{if(typeof t==="string")e[n]=t;else throw new h(`Option --${n} requires a string value`)}}function vn(n){return(t,e)=>{if(typeof t==="string")e[n]=t.split(",");else throw new h(`Option --${n} requires a string value`)}}function tt(){console.log(`
23
+ See: https://bunup.arshadyaseen.com/#using-a-configuration-file-with-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=U(i);s(o,i)}else Object.entries(n).forEach(([i,o])=>{s(i,o)});return t}function wn(n,t){return`[dir]/${n}${t}`}function bn(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 H(n,t){if(!n.entry||n.entry.length===0||!n.outDir)throw new x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let e=L(t),r=e?.type,s=A(n,e),i=M(n),o=[bn(s,i)],a=T(n.entry),c=nn(n,t),u=n.format.flatMap((m)=>a.map((f)=>{return Vn(n,t,f,m,r,o,c)}));try{await Promise.all(u)}catch(m){throw console.error(m),new x("Build process encountered errors")}if(n.dts){let m=n.format.filter((g)=>{if(g==="iife"&&!j(r)&&n.format.includes("cjs"))return!1;return!0}),f=n.dts===!0?a:T(n.dts.entry);try{await Promise.all(f.map(async(g)=>{let b=await xn(t,g.path,n);await Promise.all(m.map(async($)=>{let Sn=rn($,r),q=`${t}/${n.outDir}/${g.name}${Sn}`;await Bun.write(q,b);let Rn=Bun.file(q).size||0;l.progress("DTS",O(q),J(Rn),n.name)}))}))}catch(g){throw new d(`DTS build process encountered errors: ${p(g)}`)}}}async function Vn(n,t,e,r,s,i,o){let a=en(r,s),c=await Bun.build({...o,entrypoints:[`${t}/${e.path}`],format:r,naming:{entry:wn(e.name,a)},splitting:on(n.splitting,r),plugins:i,throw:!1});if(!c.success)throw c.logs.forEach((f)=>{if(f.level==="error")l.error(f.message);else if(f.level==="warning")l.warn(f.message);else if(f.level==="info")l.info(f.message)}),new x(`Build failed for ${e.path} (${r})`);let u=`${t}/${n.outDir}/${e.name}${a}`,m=Bun.file(u).size||0;l.progress(r.toUpperCase(),O(u),J(m),n.name)}var D="0.3.5";var $n="https://bun.sh/docs/installation",On="https://bunup.arshadyaseen.com/#cli-options";function w(n){return(t,e)=>{e[n]=t===!0?!0:t==="true"}}function W(n){return(t,e)=>{if(typeof t==="string")e[n]=t;else throw new h(`Option --${n} requires a string value`)}}function vn(n){return(t,e)=>{if(typeof t==="string")e[n]=t.split(",");else throw new h(`Option --${n} requires a string value`)}}function tt(){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${On}\x1B[0m
26
26
  `),process.exit(0)}function et(){console.log(D),process.exit(0)}var rt={name:{flags:["n","name"],handler:W("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:W("outDir")},minify:{flags:["m","minify"],handler:w("minify")},watch:{flags:["w","watch"],handler:w("watch")},dts:{flags:["d","dts"],handler:w("dts")},external:{flags:["e","external"],handler:vn("external")},sourcemap:{flags:["sm","sourcemap"],handler:W("sourcemap")},target:{flags:["t","target"],handler:W("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:w("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:w("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:w("minifySyntax")},clean:{flags:["c","clean"],handler:w("clean")},splitting:{flags:["s","splitting"],handler:w("splitting")},noExternal:{flags:["ne","no-external"],handler:vn("noExternal")}},st={help:{flags:["h","help"],handler:()=>tt()},version:{flags:["v","version"],handler:()=>et()}},_={};for(let n of Object.values(rt))if(n)for(let t of n.flags)_[t]=n.handler;for(let n of Object.values(st))for(let t of n.flags)_[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=U(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=_[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=_[i];if(c)c(a,t);else throw new h(`Unknown option: -${i}`)}else{let i=U(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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunup",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
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",