bunup 0.3.20 → 0.3.24

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 +7 -6
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=S(i);s(o,i)}else if(typeof n==="object")Object.entries(n).forEach(([i,o])=>{s(i,o)});else{let i=S(n);s(i,n)}return t}function dn(n,t){return`[dir]/${n}${t}`}import{loadTsConfig as Kn}from"load-tsconfig";function hn(n){try{return Kn(".",n)}catch(t){return l.warn(`Failed to load tsconfig: ${g(t)}`),{path:n,data:{},files:[]}}}import J from"node:path";async function wn(n){let t=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let e of t){let r=J.join(n,`bunup.config${e}`);try{if(!await Bun.file(r).exists())continue;let i=await Qn(r,e);if(!i)continue;return{configs:Fn(i,n),configFilePath:r}}catch(s){throw new w(`Failed to load config from ${r}: ${g(s)}`)}}return{configs:[],configFilePath:""}}async function Qn(n,t){if(t===".json"||t===".jsonc")return Zn(n);return Xn(n)}async function Zn(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 Xn(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 Fn(n,t){let e=[];if(Vn(n))nt(n,t,e);else if(Array.isArray(n))tt(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 Vn(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 nt(n,t,e){for(let r of n){let s=J.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 tt(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 xn(n){let t=J.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 yn(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 xn(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=[yn(i,o)],c=M(n.entry),f=K(n,t),p=n.format.flatMap((u)=>c.map((j)=>{return et(n,t,j,u,s,a,f)}));if(await Promise.all(p),n.dts){let u=hn(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}),vn=typeof n.dts==="object"&&n.dts.entry?M(n.dts.entry):c;try{await Promise.all(vn.map(async(b)=>{let Rn=await mn(t,b.path,n,u,e);await Promise.all(j.map(async(jn)=>{let An=F(jn,s),G=`${t}/${n.outDir}/${b.name}${An}`;await Bun.write(G,Rn);let Sn=Bun.file(G).size||0;l.progress("DTS",x(G),q(Sn),n.name)}))}))}catch(b){throw new d(g(b))}}}async function et(n,t,e,r,s,i,o){let a=X(r,s),c=await Bun.build({...o,entrypoints:[`${t}/${e.path}`],format:r,naming:{entry:dn(e.name,a)},splitting:nn(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),q(p),n.name)}var H="0.3.20";var bn="https://bun.sh/docs/installation",$n="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 On(n){return(t,e)=>{if(typeof t==="string")e[n]=t.split(",");else throw new h(`Option --${n} requires a string value`)}}function st(){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=S(i);s(o,i)}else if(typeof n==="object")Object.entries(n).forEach(([i,o])=>{s(i,o)});else{let i=S(n);s(i,n)}return t}function dn(n,t){return`[dir]/${n}${t}`}import{loadTsConfig as Kn}from"load-tsconfig";function hn(n){try{return Kn(".",n)}catch(t){return l.warn(`Failed to load tsconfig: ${g(t)}`),{path:n,data:{},files:[]}}}import J from"node:path";async function wn(n){let t=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let e of t){let r=J.join(n,`bunup.config${e}`);try{if(!await Bun.file(r).exists())continue;let i=await Qn(r,e);if(!i)continue;return{configs:Fn(i,n),configFilePath:r}}catch(s){throw new w(`Failed to load config from ${r}: ${g(s)}`)}}return{configs:[],configFilePath:""}}async function Qn(n,t){if(t===".json"||t===".jsonc")return Zn(n);return Xn(n)}async function Zn(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 Xn(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 Fn(n,t){let e=[];if(Vn(n))nt(n,t,e);else if(Array.isArray(n))tt(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 Vn(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 nt(n,t,e){for(let r of n){let s=J.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 tt(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 xn(n){let t=J.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 yn(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 xn(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=[yn(i,o)],c=M(n.entry),f=K(n,t),p=n.format.flatMap((u)=>c.map((j)=>{return et(n,t,j,u,s,a,f)}));if(await Promise.all(p),n.dts){let u=hn(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}),vn=typeof n.dts==="object"&&n.dts.entry?M(n.dts.entry):c;try{await Promise.all(vn.map(async(b)=>{let Rn=await mn(t,b.path,n,u,e);await Promise.all(j.map(async(jn)=>{let An=F(jn,s),G=`${t}/${n.outDir}/${b.name}${An}`;await Bun.write(G,Rn);let Sn=Bun.file(G).size||0;l.progress("DTS",x(G),q(Sn),n.name)}))}))}catch(b){throw new d(g(b))}}}async function et(n,t,e,r,s,i,o){let a=X(r,s),c=await Bun.build({...o,entrypoints:[`${t}/${e.path}`],format:r,naming:{entry:dn(e.name,a)},splitting:nn(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),q(p),n.name)}var H="0.3.24";var bn="https://bun.sh/docs/installation",$n="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 On(n){return(t,e)=>{if(typeof t==="string")e[n]=t.split(",");else throw new h(`Option --${n} requires a string value`)}}function st(){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${$n}\x1B[0m
26
26
  `),process.exit(0)}function it(){console.log(H),process.exit(0)}var ot={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:On("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:On("noExternal")}},at={help:{flags:["h","help"],handler:()=>st()},version:{flags:["v","version"],handler:()=>it()}},U={};for(let n of Object.values(ot))if(n)for(let t of n.flags)U[t]=n.handler;for(let n of Object.values(at))for(let t of n.flags)U[t]=n.handler;function Cn(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=S(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=S(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.20",
3
+ "version": "0.3.24",
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",
@@ -18,12 +18,13 @@
18
18
  "@types/bun": "^1.2.5",
19
19
  "@typescript-eslint/eslint-plugin": "^7.3.1",
20
20
  "bumpp": "^10.1.0",
21
- "bunup": "^0.3.19",
21
+ "bunup": "^0.3.20",
22
22
  "eslint": "^8.57.1",
23
23
  "husky": "^9.1.7",
24
24
  "prettier": "^3.5.3",
25
25
  "typescript": "^5.8.2",
26
- "vitest": "^2.1.9"
26
+ "vitest": "^2.1.9",
27
+ "create-bunup": "0.3.24"
27
28
  },
28
29
  "peerDependencies": {
29
30
  "typescript": ">=4.5.0"
@@ -64,15 +65,15 @@
64
65
  "build": "bunup",
65
66
  "dev": "bunup --watch",
66
67
  "build:docs": "pnpm -C docs build",
68
+ "create-bunup": "create-bunup",
67
69
  "dev:docs": "pnpm -C docs dev",
68
70
  "test-build": "pnpm -C tests build",
69
71
  "test": "vitest run",
70
72
  "tsc": "tsc --noEmit",
71
73
  "lint": "eslint src --fix",
72
- "validate": "pnpm run tsc && pnpm run lint",
73
74
  "format": "prettier --write .",
74
- "release": "bumpp",
75
- "publish:ci": "pnpm publish --access public --no-git-checks",
75
+ "release": "bumpp -r --commit --push --tag",
76
+ "publish:ci": "pnpm --filter bunup --filter create-bunup publish --access public --no-git-checks",
76
77
  "benchmark": "pnpm -C benchmarks benchmark",
77
78
  "fresh-deps": "pnpx taze -r -w"
78
79
  }