bunup 0.2.12 → 0.3.0
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 +1 -1
- 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:i})}else t.push({name:o,path:i}),e.add(o),r[o]=i}if(Array.isArray(n))for(let o of n){let i=L(o);s(i,o)}else Object.entries(n).forEach(([o,i])=>{s(o,i)});return t}function $n(n,t){return`[dir]/${n}${t}`}function On(n,t){return{name:"bunup:external-plugin",setup(e){e.onResolve({filter:/.*/},(r)=>{let s=r.path;if(n.some((i)=>i.test(s))&&!t.some((i)=>i.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 x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let e=M(t),r=e?.type,s=N(n,e),o=T(n),i=[On(s,o)],a=R(n.entry),c=V(n,t),u=n.format.flatMap((p)=>a.map((f)=>{return nt(n,t,f,p,r,i,c)}));try{await Promise.all(u)}catch(p){throw console.error(p),new x("Build process encountered errors")}if(n.dts){let p=n.format.filter((g)=>{if(g==="iife"&&!j(r)&&n.format.includes("cjs"))return!1;return!0}),f=n.dts===!0?a:R(n.dts.entry);try{await Promise.all(f.map(async(g)=>{let b=await bn(t,g.path,n);await Promise.all(p.map(async($)=>{let Nn=en($,r),W=`${t}/${n.outDir}/${g.name}${Nn}`;await Bun.write(W,b);let Tn=Bun.file(W).size||0;l.progress("DTS",O(W),q(Tn),n.name)}))}))}catch(g){throw new d(`DTS build process encountered errors: ${m(g)}`)}}}async function nt(n,t,e,r,s,o,i){let a=tn(r,s),c=await Bun.build({...i,entrypoints:[`${t}/${e.path}`],format:r,naming:{entry:$n(e.name,a)},splitting:on(n.splitting,r),plugins:o,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}`,p=Bun.file(u).size||0;l.progress(r.toUpperCase(),O(u),q(p),n.name)}var Cn="0.
|
|
23
|
+
See: https://bunup.arshadyaseen.com/#using-a-configuration-file-with-named-entries`,{muted:!0,verticalSpace:!0}),t.push({name:c,path:i})}else t.push({name:o,path:i}),e.add(o),r[o]=i}if(Array.isArray(n))for(let o of n){let i=L(o);s(i,o)}else Object.entries(n).forEach(([o,i])=>{s(o,i)});return t}function $n(n,t){return`[dir]/${n}${t}`}function On(n,t){return{name:"bunup:external-plugin",setup(e){e.onResolve({filter:/.*/},(r)=>{let s=r.path;if(n.some((i)=>i.test(s))&&!t.some((i)=>i.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 x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let e=M(t),r=e?.type,s=N(n,e),o=T(n),i=[On(s,o)],a=R(n.entry),c=V(n,t),u=n.format.flatMap((p)=>a.map((f)=>{return nt(n,t,f,p,r,i,c)}));try{await Promise.all(u)}catch(p){throw console.error(p),new x("Build process encountered errors")}if(n.dts){let p=n.format.filter((g)=>{if(g==="iife"&&!j(r)&&n.format.includes("cjs"))return!1;return!0}),f=n.dts===!0?a:R(n.dts.entry);try{await Promise.all(f.map(async(g)=>{let b=await bn(t,g.path,n);await Promise.all(p.map(async($)=>{let Nn=en($,r),W=`${t}/${n.outDir}/${g.name}${Nn}`;await Bun.write(W,b);let Tn=Bun.file(W).size||0;l.progress("DTS",O(W),q(Tn),n.name)}))}))}catch(g){throw new d(`DTS build process encountered errors: ${m(g)}`)}}}async function nt(n,t,e,r,s,o,i){let a=tn(r,s),c=await Bun.build({...i,entrypoints:[`${t}/${e.path}`],format:r,naming:{entry:$n(e.name,a)},splitting:on(n.splitting,r),plugins:o,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}`,p=Bun.file(u).size||0;l.progress(r.toUpperCase(),O(u),q(p),n.name)}var Cn="0.3.0";var vn="https://bun.sh/docs/installation",En="https://bunup.arshadyaseen.com/#cli-options";function w(n){return(t,e)=>{e[n]=t===!0?!0:t==="true"}}function U(n){return(t,e)=>{if(typeof t==="string")e[n]=t;else throw new h(`Option --${n} requires a string value`)}}function Bn(n){return(t,e)=>{if(typeof t==="string")e[n]=t.split(",");else throw new h(`Option --${n} requires a string value`)}}function et(){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${En}\x1B[0m
|
|
26
26
|
`),process.exit(0)}function rt(){console.log(Cn),process.exit(0)}var st={name:{flags:["n","name"],handler:U("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:U("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:Bn("external")},sourcemap:{flags:["sm","sourcemap"],handler:U("sourcemap")},target:{flags:["t","target"],handler:U("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:Bn("noExternal")}},ot={help:{flags:["h","help"],handler:()=>et()},version:{flags:["v","version"],handler:()=>rt()}},H={};for(let n of Object.values(st))if(n)for(let t of n.flags)H[t]=n.handler;for(let n of Object.values(ot))for(let t of n.flags)H[t]=n.handler;function Sn(n){let t={},e={},r=0;while(r<n.length){let s=n[r];if(s.startsWith("--")){let o,i;if(s.includes("=")){let[a,c]=s.slice(2).split("=",2);o=a,i=c}else{o=s.slice(2);let a=n[r+1];if(i=a&&!a.startsWith("-")?a:!0,typeof i==="string")r++}if(o==="entry")if(typeof i==="string"){let a=L(i);if(e[a])l.warn(`Duplicate entry name '${a}' derived from '${i}'. Overwriting previous entry.`);e[a]=i}else throw new h("Option --entry requires a string value");else if(o.startsWith("entry.")){let a=o.slice(6);if(typeof i==="string"){if(e[a])l.warn(`Duplicate entry name '${a}' provided via --entry.${a}. Overwriting previous entry.`);e[a]=i}else throw new h(`Option --entry.${a} requires a string value`)}else{let a=H[o];if(a)a(i,t);else throw new h(`Unknown option: --${o}`)}}else if(s.startsWith("-")){let o=s.slice(1),i=n[r+1],a=i&&!i.startsWith("-")?i:!0;if(typeof a==="string")r++;let c=H[o];if(c)c(a,t);else throw new h(`Unknown option: -${o}`)}else{let o=L(s);if(e[o])l.warn(`Duplicate entry name '${o}' derived from positional argument '${s}'. Overwriting previous entry.`);e[o]=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.
|