bunup 0.3.51 → 0.3.52

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 +2 -2
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}),n.push({name:c,path:o})}else n.push({name:i,path:o}),e.add(i),r[i]=o}if(Array.isArray(t))for(let i of t){let o=M(i);s(o,i)}else if(typeof t==="object")Object.entries(t).forEach(([i,o])=>{s(i,o)});else{let i=M(t);s(i,t)}return n}function Et(t,n){return`[dir]/${t}${n}`}import{loadTsConfig as Zt}from"load-tsconfig";function $t(t){try{return Zt(".",t)}catch(n){return l.warn(`Failed to load tsconfig: ${p(n)}`),{path:t,data:{},files:[]}}}import Z from"node:path";async function Ot(t){let n=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let e of n){let r=Z.join(t,`bunup.config${e}`);try{if(!await Bun.file(r).exists())continue;let i=await zt(r,e);if(!i)continue;return{configs:en(i,t),configFilePath:r}}catch(s){throw new x(`Failed to load config from ${r}: ${p(s)}`)}}return{configs:[],configFilePath:""}}async function zt(t,n){if(n===".json"||n===".jsonc")return tn(t);return nn(t)}async function tn(t){try{let n=await Bun.file(t).text(),e=JSON.parse(n);return e.bunup||e}catch(n){throw new Error(`Invalid JSON in config file. ${p(n)}`)}}async function nn(t){try{let n=await import(`file://${t}`),e=n.default||n;if(!e)return l.warn(`No export found in ${t}. Make sure you're exporting your configuration.`),{};return e}catch(n){throw new Error(`Failed to import config file. ${p(n)}`)}}function en(t,n){let e=[];if(rn(t))sn(t,n,e);else if(Array.isArray(t))on(t,n,e);else if(t&&typeof t==="object")e.push({options:t,rootDir:n});else throw new Error("Invalid configuration format. Expected an object, array, or workspace configuration.");return e}function rn(t){return Array.isArray(t)&&t.length>0&&t.every((n)=>typeof n==="object"&&n!==null&&("name"in n)&&("root"in n)&&("config"in n))}function sn(t,n,e){for(let r of t){let s=Z.resolve(n,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 on(t,n,e){for(let r of t){if(!r||typeof r!=="object")throw new Error("Invalid configuration item. Expected an object.");e.push({options:r,rootDir:n})}}async function vt(t){let n=Z.join(t,"package.json");try{if(!await Bun.file(n).exists())return{packageJson:null,path:n};let r=await Bun.file(n).text();return{packageJson:JSON.parse(r),path:n}}catch(e){return l.warn(`Failed to load package.json at ${n}: ${p(e)}`),{packageJson:null,path:n}}}function Ct(t,n){return{name:"bunup:external-plugin",setup(e){e.onResolve({filter:/.*/},(r)=>{let s=r.path;if(t.some((o)=>o.test(s))&&!n.some((o)=>o.test(s)))return{path:s,external:!0};return null})}}}var v=new Set;async function U(t,n){if(!t.entry||t.entry.length===0||!t.outDir)throw new x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let{packageJson:e,path:r}=await vt(n);if(e)l.cli(`Using package.json: ${b(r,2)}`,{muted:!0,once:r,identifier:t.name});let s=e?.type,i=j(t,e),o=D(t),a=[Ct(i,o)],c=A(t.entry),u=nt(t,n),g=t.format.flatMap((f)=>c.map((h)=>{return an(t,n,h,f,s,a,u)}));if(await Promise.all(g),t.dts){let f=$t(t.preferredTsconfigPath);if(f.path)l.cli(`Using tsconfig: ${b(f.path,2)}`,{muted:!0,once:f.path,identifier:t.name});let h=t.format.filter((y)=>{if(y==="iife"&&!S(s)&&t.format.includes("cjs"))return!1;return!0}),It=typeof t.dts==="object"&&t.dts.entry?A(t.dts.entry):c;try{await Promise.all(It.map(async(y)=>{let St=await yt(n,y.path,t,f,e);await Promise.all(h.map(async(Lt)=>{let jt=it(Lt,s),H=`${n}/${t.outDir}/${y.name}${jt}`;await Bun.write(H,St);let Dt=Bun.file(H).size||0;l.progress("DTS",b(H),X(Dt),t.name)}))}))}catch(y){throw new m(p(y))}}}async function an(t,n,e,r,s,i,o){let a=st(r,s),c=await Bun.build({...o,entrypoints:[`${n}/${e.path}`],format:r,naming:{entry:Et(e.name,a)},splitting:at(t.splitting,r),plugins:i,throw:!1});if(!c.success)c.logs.forEach((f)=>{if(f.level==="error")throw new x(f.message);else if(f.level==="warning")l.warn(f.message);else if(f.level==="info")l.info(f.message)});let u=`${n}/${t.outDir}/${e.name}${a}`,g=Bun.file(u).size||0;l.progress(r.toUpperCase(),b(u),X(g),t.name)}var F="0.3.51";var Bt="https://bun.sh/docs/installation",Rt="https://bunup.arshadyaseen.com/#cli-options";function w(t){return(n,e)=>{e[t]=n===!0?!0:n==="true"}}function R(t){return(n,e)=>{if(typeof n==="string")e[t]=n;else throw new d(`Option --${t} requires a string value`)}}function Pt(t){return(n,e)=>{if(typeof n==="string")e[t]=n.split(",");else throw new d(`Option --${t} requires a string value`)}}function ln(){console.log(`
23
+ See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),n.push({name:c,path:o})}else n.push({name:i,path:o}),e.add(i),r[i]=o}if(Array.isArray(t))for(let i of t){let o=M(i);s(o,i)}else if(typeof t==="object")Object.entries(t).forEach(([i,o])=>{s(i,o)});else{let i=M(t);s(i,t)}return n}function Et(t,n){return`[dir]/${t}${n}`}import{loadTsConfig as Zt}from"load-tsconfig";function $t(t){try{return Zt(".",t)}catch(n){return l.warn(`Failed to load tsconfig: ${p(n)}`),{path:t,data:{},files:[]}}}import Z from"node:path";async function Ot(t){let n=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let e of n){let r=Z.join(t,`bunup.config${e}`);try{if(!await Bun.file(r).exists())continue;let i=await zt(r,e);if(!i)continue;return{configs:en(i,t),configFilePath:r}}catch(s){throw new x(`Failed to load config from ${r}: ${p(s)}`)}}return{configs:[],configFilePath:""}}async function zt(t,n){if(n===".json"||n===".jsonc")return tn(t);return nn(t)}async function tn(t){try{let n=await Bun.file(t).text(),e=JSON.parse(n);return e.bunup||e}catch(n){throw new Error(`Invalid JSON in config file. ${p(n)}`)}}async function nn(t){try{let n=await import(`file://${t}`),e=n.default||n;if(!e)return l.warn(`No export found in ${t}. Make sure you're exporting your configuration.`),{};return e}catch(n){throw new Error(`Failed to import config file. ${p(n)}`)}}function en(t,n){let e=[];if(rn(t))sn(t,n,e);else if(Array.isArray(t))on(t,n,e);else if(t&&typeof t==="object")e.push({options:t,rootDir:n});else throw new Error("Invalid configuration format. Expected an object, array, or workspace configuration.");return e}function rn(t){return Array.isArray(t)&&t.length>0&&t.every((n)=>typeof n==="object"&&n!==null&&("name"in n)&&("root"in n)&&("config"in n))}function sn(t,n,e){for(let r of t){let s=Z.resolve(n,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 on(t,n,e){for(let r of t){if(!r||typeof r!=="object")throw new Error("Invalid configuration item. Expected an object.");e.push({options:r,rootDir:n})}}async function vt(t){let n=Z.join(t,"package.json");try{if(!await Bun.file(n).exists())return{packageJson:null,path:n};let r=await Bun.file(n).text();return{packageJson:JSON.parse(r),path:n}}catch(e){return l.warn(`Failed to load package.json at ${n}: ${p(e)}`),{packageJson:null,path:n}}}function Ct(t,n){return{name:"bunup:external-plugin",setup(e){e.onResolve({filter:/.*/},(r)=>{let s=r.path;if(t.some((o)=>o.test(s))&&!n.some((o)=>o.test(s)))return{path:s,external:!0};return null})}}}var v=new Set;async function U(t,n){if(!t.entry||t.entry.length===0||!t.outDir)throw new x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let{packageJson:e,path:r}=await vt(n);if(e)l.cli(`Using package.json: ${b(r,2)}`,{muted:!0,once:r,identifier:t.name});let s=e?.type,i=j(t,e),o=D(t),a=[Ct(i,o)],c=A(t.entry),u=nt(t,n),g=t.format.flatMap((f)=>c.map((h)=>{return an(t,n,h,f,s,a,u)}));if(await Promise.all(g),t.dts){let f=$t(t.preferredTsconfigPath);if(f.path)l.cli(`Using tsconfig: ${b(f.path,2)}`,{muted:!0,once:f.path,identifier:t.name});let h=t.format.filter((y)=>{if(y==="iife"&&!S(s)&&t.format.includes("cjs"))return!1;return!0}),It=typeof t.dts==="object"&&t.dts.entry?A(t.dts.entry):c;try{await Promise.all(It.map(async(y)=>{let St=await yt(n,y.path,t,f,e);await Promise.all(h.map(async(Lt)=>{let jt=it(Lt,s),H=`${n}/${t.outDir}/${y.name}${jt}`;await Bun.write(H,St);let Dt=Bun.file(H).size||0;l.progress("DTS",b(H),X(Dt),t.name)}))}))}catch(y){throw new m(p(y))}}}async function an(t,n,e,r,s,i,o){let a=st(r,s),c=await Bun.build({...o,entrypoints:[`${n}/${e.path}`],format:r,naming:{entry:Et(e.name,a)},splitting:at(t.splitting,r),plugins:i,throw:!1});if(!c.success)c.logs.forEach((f)=>{if(f.level==="error")throw new x(f.message);else if(f.level==="warning")l.warn(f.message);else if(f.level==="info")l.info(f.message)});let u=`${n}/${t.outDir}/${e.name}${a}`,g=Bun.file(u).size||0;l.progress(r.toUpperCase(),b(u),X(g),t.name)}var F="0.3.52";var Bt="https://bun.sh/docs/installation",Rt="https://bunup.arshadyaseen.com/#cli-options";function w(t){return(n,e)=>{e[t]=n===!0?!0:n==="true"}}function R(t){return(n,e)=>{if(typeof n==="string")e[t]=n;else throw new d(`Option --${t} requires a string value`)}}function Pt(t){return(n,e)=>{if(typeof n==="string")e[t]=n.split(",");else throw new d(`Option --${t} requires a string value`)}}function ln(){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${Rt}\x1B[0m
26
26
  `),process.exit(0)}function un(){console.log(F),process.exit(0)}var fn={name:{flags:["n","name"],handler:R("name")},format:{flags:["f","format"],handler:(t,n)=>{if(typeof t==="string")n.format=t.split(",");else throw new d("Option --format requires a string value")}},outDir:{flags:["o","out-dir"],handler:R("outDir")},minify:{flags:["m","minify"],handler:w("minify")},watch:{flags:["w","watch"],handler:w("watch")},dts:{flags:["d","dts"],handler:w("dts")},banner:{flags:["b","banner"],handler:R("banner")},footer:{flags:["f","footer"],handler:R("footer")},external:{flags:["e","external"],handler:Pt("external")},sourcemap:{flags:["sm","sourcemap"],handler:R("sourcemap")},target:{flags:["t","target"],handler:R("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:Pt("noExternal")}},pn={help:{flags:["h","help"],handler:()=>ln()},version:{flags:["v","version"],handler:()=>un()}},k={};for(let t of Object.values(fn))if(t)for(let n of t.flags)k[n]=t.handler;for(let t of Object.values(pn))for(let n of t.flags)k[n]=t.handler;function Tt(t){let n={},e={},r=0;while(r<t.length){let s=t[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=t[r+1];if(o=a&&!a.startsWith("-")?a:!0,typeof o==="string")r++}if(i==="entry")if(typeof o==="string"){let a=M(o);if(e[a])l.warn(`Duplicate entry name '${a}' derived from '${o}'. Overwriting previous entry.`);e[a]=o}else throw new d("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 d(`Option --entry.${a} requires a string value`)}else{let a=k[i];if(a)a(o,n);else throw new d(`Unknown option: --${i}`)}}else if(s.startsWith("-")){let i=s.slice(1),o=t[r+1],a=o&&!o.startsWith("-")?o:!0;if(typeof a==="string")r++;let c=k[i];if(c)c(a,n);else throw new d(`Unknown option: -${i}`)}else{let i=M(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)n.entry=e;return n}(()=>{if(typeof Bun==="undefined")throw new d(`Bunup requires Bun to run.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunup",
3
- "version": "0.3.51",
3
+ "version": "0.3.52",
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",
@@ -24,7 +24,7 @@
24
24
  "prettier": "^3.5.3",
25
25
  "typescript": "^5.8.3",
26
26
  "vitest": "^2.1.9",
27
- "create-bunup": "0.3.51"
27
+ "create-bunup": "0.3.52"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "typescript": ">=4.5.0"