bunup 0.2.6 → 0.2.7
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
|
@@ -6,7 +6,7 @@ import{loadTsConfig as jn}from"load-tsconfig";class C extends Error{constructor(
|
|
|
6
6
|
`);let i=a.labels[0],c=i?zn(s,i.start):"",m=`${$(e)}${c}: ${Xn(a.message)}`;l.warn(m),r=!0})}catch{}})),r)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 zn(n,r){if(r===void 0)return"";let t=n.slice(0,r).split(`
|
|
9
|
-
`),e=t.length,s=t[t.length-1].length+1;return` (${e}:${s})`}function Xn(n){return n.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}async function wn(n,r,t){let{absoluteRootDir:e,absoluteEntry:s}=xn(n,r),o=X(t.preferredTsconfigPath),a=await dn(s,o),i=await hn(a);return fn(s,i,t,e,o)}function D(n){return n.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function S(n){let r=[],t=new Set;function e(s,o){if(t.has(s)){let a=nn();r.push({name:`${s}_${a}`,path:o})}else r.push({name:s,path:o}),t.add(s)}if(Array.isArray(n))for(let s of n){let o=D(s);e(o,s)}else Object.entries(n).forEach(([s,o])=>{e(s,o)});return r}function bn(n,r){return`[dir]/${n}${r}`}function On(n,r){return{name:"bunup:external-plugin",setup(t){t.onResolve({filter:/.*/},(e)=>{let s=e.path;if(n.some((a)=>a.test(s))&&!r.some((a)=>a.test(s)))return{path:s,external:!0};return null})}}}var E=new Set;async function U(n,r){if(!n.entry||n.entry.length===0||!n.outDir)throw new y("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let t=k(r),e=t?.type,s=N(n,t),o=T(n),a=[On(s,o)],i=S(n.entry),c=V(n,r),p=n.format.flatMap((m)=>i.map((f)=>{return Vn(n,r,f,m,e,a,c)}));try{await Promise.all(p)}catch(m){throw console.error(m),new y("Build process encountered errors")}if(n.dts){let m=n.format.filter((h)=>{if(h==="iife"&&!A(e)&&n.format.includes("cjs"))return!1;return!0}),f=n.dts===!0?i:S(n.dts.entry);try{await Promise.all(f.map(async(h)=>{let b=await wn(r,h.path,n);await Promise.all(m.map(async(O)=>{let An=tn(O,e),L=`${r}/${n.outDir}/${h.name}${An}`;await Bun.write(L,b);let Nn=Bun.file(L).size||0;l.progress("DTS",$(L),q(Nn),n.name)}))}))}catch(h){throw new g(`DTS build process encountered errors: ${u(h)}`)}}}async function Vn(n,r,t,e,s,o,a){let i=rn(e,s),c=await Bun.build({...a,entrypoints:[`${r}/${t.path}`],format:e,naming:{entry:bn(t.name,i)},splitting:on(n.splitting,e),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 y(`Build failed for ${t.path} (${e})`);let p=`${r}/${n.outDir}/${t.name}${i}`,m=Bun.file(p).size||0;l.progress(e.toUpperCase(),$(p),q(m),n.name)}var $n="0.2.
|
|
9
|
+
`),e=t.length,s=t[t.length-1].length+1;return` (${e}:${s})`}function Xn(n){return n.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}async function wn(n,r,t){let{absoluteRootDir:e,absoluteEntry:s}=xn(n,r),o=X(t.preferredTsconfigPath),a=await dn(s,o),i=await hn(a);return fn(s,i,t,e,o)}function D(n){return n.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function S(n){let r=[],t=new Set;function e(s,o){if(t.has(s)){let a=nn();r.push({name:`${s}_${a}`,path:o})}else r.push({name:s,path:o}),t.add(s)}if(Array.isArray(n))for(let s of n){let o=D(s);e(o,s)}else Object.entries(n).forEach(([s,o])=>{e(s,o)});return r}function bn(n,r){return`[dir]/${n}${r}`}function On(n,r){return{name:"bunup:external-plugin",setup(t){t.onResolve({filter:/.*/},(e)=>{let s=e.path;if(n.some((a)=>a.test(s))&&!r.some((a)=>a.test(s)))return{path:s,external:!0};return null})}}}var E=new Set;async function U(n,r){if(!n.entry||n.entry.length===0||!n.outDir)throw new y("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let t=k(r),e=t?.type,s=N(n,t),o=T(n),a=[On(s,o)],i=S(n.entry),c=V(n,r),p=n.format.flatMap((m)=>i.map((f)=>{return Vn(n,r,f,m,e,a,c)}));try{await Promise.all(p)}catch(m){throw console.error(m),new y("Build process encountered errors")}if(n.dts){let m=n.format.filter((h)=>{if(h==="iife"&&!A(e)&&n.format.includes("cjs"))return!1;return!0}),f=n.dts===!0?i:S(n.dts.entry);try{await Promise.all(f.map(async(h)=>{let b=await wn(r,h.path,n);await Promise.all(m.map(async(O)=>{let An=tn(O,e),L=`${r}/${n.outDir}/${h.name}${An}`;await Bun.write(L,b);let Nn=Bun.file(L).size||0;l.progress("DTS",$(L),q(Nn),n.name)}))}))}catch(h){throw new g(`DTS build process encountered errors: ${u(h)}`)}}}async function Vn(n,r,t,e,s,o,a){let i=rn(e,s),c=await Bun.build({...a,entrypoints:[`${r}/${t.path}`],format:e,naming:{entry:bn(t.name,i)},splitting:on(n.splitting,e),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 y(`Build failed for ${t.path} (${e})`);let p=`${r}/${n.outDir}/${t.name}${i}`,m=Bun.file(p).size||0;l.progress(e.toUpperCase(),$(p),q(m),n.name)}var $n="0.2.7";var Cn="https://bun.sh/docs/installation",vn="https://bunup.arshadyaseen.com/#cli-options";function w(n){return(r,t)=>{t[n]=r===!0?!0:r==="true"}}function H(n){return(r,t)=>{if(typeof r==="string")t[n]=r;else throw new d(`Option --${n} requires a string value`)}}function En(n){return(r,t)=>{if(typeof r==="string")t[n]=r.split(",");else throw new d(`Option --${n} requires a string value`)}}function rr(){console.log(`
|
|
10
10
|
Bunup - An extremely fast, zero-config bundler for JavaScript and TypeScript, powered by Bun.
|
|
11
11
|
`),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${vn}\x1B[0m
|
|
12
12
|
`),process.exit(0)}function tr(){console.log($n),process.exit(0)}var er={name:{flags:["n","name"],handler:H("name")},format:{flags:["f","format"],handler:(n,r)=>{if(typeof n==="string")r.format=n.split(",");else throw new d("Option --format requires a string value")}},outDir:{flags:["o","out-dir"],handler:H("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:En("external")},sourcemap:{flags:["sm","sourcemap"],handler:H("sourcemap")},target:{flags:["t","target"],handler:H("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:En("noExternal")}},sr={help:{flags:["h","help"],handler:()=>rr()},version:{flags:["v","version"],handler:()=>tr()}},W={};for(let n of Object.values(er))if(n)for(let r of n.flags)W[r]=n.handler;for(let n of Object.values(sr))for(let r of n.flags)W[r]=n.handler;function Bn(n){let r={},t={},e=0;while(e<n.length){let s=n[e];if(s.startsWith("--")){let o,a;if(s.includes("=")){let[i,c]=s.slice(2).split("=",2);o=i,a=c}else{o=s.slice(2);let i=n[e+1];if(a=i&&!i.startsWith("-")?i:!0,typeof a==="string")e++}if(o==="entry")if(typeof a==="string"){let i=D(a);if(t[i])l.warn(`Duplicate entry name '${i}' derived from '${a}'. Overwriting previous entry.`);t[i]=a}else throw new d("Option --entry requires a string value");else if(o.startsWith("entry.")){let i=o.slice(6);if(typeof a==="string"){if(t[i])l.warn(`Duplicate entry name '${i}' provided via --entry.${i}. Overwriting previous entry.`);t[i]=a}else throw new d(`Option --entry.${i} requires a string value`)}else{let i=W[o];if(i)i(a,r);else throw new d(`Unknown option: --${o}`)}}else if(s.startsWith("-")){let o=s.slice(1),a=n[e+1],i=a&&!a.startsWith("-")?a:!0;if(typeof i==="string")e++;let c=W[o];if(c)c(i,r);else throw new d(`Unknown option: -${o}`)}else{let o=D(s);if(t[o])l.warn(`Duplicate entry name '${o}' derived from positional argument '${s}'. Overwriting previous entry.`);t[o]=s}e++}if(Object.keys(t).length>0)r.entry=t;return r}(()=>{if(typeof Bun==="undefined")throw new d(`Bunup requires Bun to run.
|