bunup 0.3.42 → 0.3.44

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}),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=A(i);s(o,i)}else if(typeof n==="object")Object.entries(n).forEach(([i,o])=>{s(i,o)});else{let i=A(n);s(i,n)}return t}function wn(n,t){return`[dir]/${n}${t}`}import{loadTsConfig as Qn}from"load-tsconfig";function xn(n){try{return Qn(".",n)}catch(t){return l.warn(`Failed to load tsconfig: ${g(t)}`),{path:n,data:{},files:[]}}}import z from"node:path";async function yn(n){let t=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let e of t){let r=z.join(n,`bunup.config${e}`);try{if(!await Bun.file(r).exists())continue;let i=await Zn(r,e);if(!i)continue;return{configs:Vn(i,n),configFilePath:r}}catch(s){throw new w(`Failed to load config from ${r}: ${g(s)}`)}}return{configs:[],configFilePath:""}}async function Zn(n,t){if(t===".json"||t===".jsonc")return Xn(n);return Fn(n)}async function Xn(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 Fn(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 Vn(n,t){let e=[];if(nt(n))tt(n,t,e);else if(Array.isArray(n))et(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 nt(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 tt(n,t,e){for(let r of n){let s=z.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 et(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 bn(n){let t=z.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 $n(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 bn(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=[$n(i,o)],c=S(n.entry),f=Z(n,t),p=n.format.flatMap((u)=>c.map((j)=>{return rt(n,t,j,u,s,a,f)}));if(await Promise.all(p),n.dts){let u=xn(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}),jn=typeof n.dts==="object"&&n.dts.entry?S(n.dts.entry):c;try{await Promise.all(jn.map(async(b)=>{let An=await hn(t,b.path,n,u,e);await Promise.all(j.map(async(Sn)=>{let Mn=nn(Sn,s),G=`${t}/${n.outDir}/${b.name}${Mn}`;await Bun.write(G,An);let Nn=Bun.file(G).size||0;l.progress("DTS",x(G),I(Nn),n.name)}))}))}catch(b){throw new d(g(b))}}}async function rt(n,t,e,r,s,i,o){let a=V(r,s),c=await Bun.build({...o,entrypoints:[`${t}/${e.path}`],format:r,naming:{entry:wn(e.name,a)},splitting:en(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),I(p),n.name)}var H="0.3.42";var On="https://bun.sh/docs/installation",Cn="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 Bn(n){return(t,e)=>{if(typeof t==="string")e[n]=t.split(",");else throw new h(`Option --${n} requires a string value`)}}function it(){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=A(i);s(o,i)}else if(typeof n==="object")Object.entries(n).forEach(([i,o])=>{s(i,o)});else{let i=A(n);s(i,n)}return t}function wn(n,t){return`[dir]/${n}${t}`}import{loadTsConfig as Qn}from"load-tsconfig";function xn(n){try{return Qn(".",n)}catch(t){return l.warn(`Failed to load tsconfig: ${g(t)}`),{path:n,data:{},files:[]}}}import z from"node:path";async function yn(n){let t=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let e of t){let r=z.join(n,`bunup.config${e}`);try{if(!await Bun.file(r).exists())continue;let i=await Zn(r,e);if(!i)continue;return{configs:Vn(i,n),configFilePath:r}}catch(s){throw new w(`Failed to load config from ${r}: ${g(s)}`)}}return{configs:[],configFilePath:""}}async function Zn(n,t){if(t===".json"||t===".jsonc")return Xn(n);return Fn(n)}async function Xn(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 Fn(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 Vn(n,t){let e=[];if(nt(n))tt(n,t,e);else if(Array.isArray(n))et(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 nt(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 tt(n,t,e){for(let r of n){let s=z.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 et(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 bn(n){let t=z.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 $n(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 bn(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=[$n(i,o)],c=S(n.entry),f=Z(n,t),p=n.format.flatMap((u)=>c.map((j)=>{return rt(n,t,j,u,s,a,f)}));if(await Promise.all(p),n.dts){let u=xn(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}),jn=typeof n.dts==="object"&&n.dts.entry?S(n.dts.entry):c;try{await Promise.all(jn.map(async(b)=>{let An=await hn(t,b.path,n,u,e);await Promise.all(j.map(async(Sn)=>{let Mn=nn(Sn,s),G=`${t}/${n.outDir}/${b.name}${Mn}`;await Bun.write(G,An);let Nn=Bun.file(G).size||0;l.progress("DTS",x(G),I(Nn),n.name)}))}))}catch(b){throw new d(g(b))}}}async function rt(n,t,e,r,s,i,o){let a=V(r,s),c=await Bun.build({...o,entrypoints:[`${t}/${e.path}`],format:r,naming:{entry:wn(e.name,a)},splitting:en(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),I(p),n.name)}var H="0.3.44";var On="https://bun.sh/docs/installation",Cn="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 Bn(n){return(t,e)=>{if(typeof t==="string")e[n]=t.split(",");else throw new h(`Option --${n} requires a string value`)}}function it(){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${Cn}\x1B[0m
26
26
  `),process.exit(0)}function ot(){console.log(H),process.exit(0)}var at={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:Bn("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:Bn("noExternal")}},ct={help:{flags:["h","help"],handler:()=>it()},version:{flags:["v","version"],handler:()=>ot()}},U={};for(let n of Object.values(at))if(n)for(let t of n.flags)U[t]=n.handler;for(let n of Object.values(ct))for(let t of n.flags)U[t]=n.handler;function En(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=A(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=A(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.42",
3
+ "version": "0.3.44",
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.2",
26
26
  "vitest": "^2.1.9",
27
- "create-bunup": "0.3.42"
27
+ "create-bunup": "0.3.44"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "typescript": ">=4.5.0"