bunup 0.3.56 → 0.3.57

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