bunup 0.4.26 → 0.4.27

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 +3 -3
package/build/cli.mjs CHANGED
@@ -31,7 +31,7 @@ See: https://bunup.arshadyaseen.com/documentation/#named-entries`,{muted:!0,vert
31
31
  const importMetaUrl = pathToFileURL(__filename).href;
32
32
 
33
33
  `}};function De({format:e,target:t,shims:r}){let s=ct(r).map((o)=>J[o]).filter((o)=>o.appliesTo(e,t));if(s.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(o){o.onLoad({filter:lt},async({path:i})=>{let a=await Bun.file(i).text(),c=s.filter((m)=>m.isNeededInFile(a));if(c.length===0)return;let{shebangLine:l,codeContent:f}=ut(a),p=c.map((m)=>m.generateCode()).join("");return{contents:l+p+f}})}}}function ct(e){if(e===!0)return Object.keys(J);if(!e)return[];return Object.entries(e).filter(([t,r])=>r&&(t in J)).map(([t])=>t)}function ut(e){if(!e.startsWith("#!"))return{shebangLine:"",codeContent:e};let t=e.indexOf(`
34
- `);return t===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,t+1),codeContent:e.slice(t+1)}}var T=new Set;async function k(e,t){let r=j(e);if(!r.entry||r.entry.length===0||!r.outDir)throw new w("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(r.clean)ce(t,r.outDir);B(r.silent);let{packageJson:n,path:s}=await Te(t);if(n&&s)u.cli(`Using package.json: ${y(s,2)}`,{muted:!0,identifier:r.name,once:`${s}:${r.name}`});let o=P(r.entry),i=n?.type,a=D(r,n),c=A(r);if(!r.dtsOnly){let l=[Ie(a,c)],f=r.format.flatMap((p)=>o.map((m)=>{return ft(r,t,m,p,i,l)}));await Promise.all(f)}if(r.dts||r.dtsOnly){let l=await Se(t,r.preferredTsconfigPath);if(l.path)u.cli(`Using tsconfig: ${y(l.path,2)}`,{muted:!0,identifier:r.name,once:`${l.path}:${r.name}`});let f=r.format.filter((m)=>{if(m==="iife"&&!R(i)&&r.format.includes("cjs"))return!1;return!0}),p=typeof r.dts==="object"&&r.dts.entry?P(r.dts.entry):Ce(o);try{await Promise.all(p.map(async(m)=>{let W=await we(t,m.path,r,l,n);await Promise.all(f.map(async(Z)=>{let Ne=r.outputExtension?.({format:Z,packageType:i,options:r,entry:m}).dts??ae(Z,i),H=`${t}/${r.outDir}/${m.name}${Ne}`;await Bun.write(H,W);let Ue=Bun.file(H).size||0;u.progress("DTS",y(H),X(Ue),r.name)}))}))}catch(m){throw new h(b(m))}}}async function ft(e,t,r,n,s,o){let i=e.outputExtension?.({format:n,packageType:s,options:e,entry:r}).js??oe(n,s),a=await Bun.build({entrypoints:[`${t}/${r.path}`],format:n,naming:{entry:Ee(r.name,i)},splitting:ve(e.splitting,n),bytecode:Pe(e.bytecode,n),define:Be(e.define,e.shims,e.env,n),minify:Oe(e),outdir:`${t}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:Le(e.env),plugins:[...o,De({format:n,target:e.target,shims:e.shims}),...e.bunBuildPlugins??[]],throw:!1});if(!a.success)for(let f of a.logs){if(f.level==="error")throw new w(f.message);if(f.level==="warning")u.warn(f.message);else if(f.level==="info")u.info(f.message)}let c=`${t}/${e.outDir}/${r.name}${i}`,l=Bun.file(c).size||0;u.progress(n.toUpperCase(),y(c),X(l),e.name)}var N="0.4.26";var Ae="https://bun.sh/docs/installation",_e="https://bunup.arshadyaseen.com/documentation/#cli-options";function g(e){return(t,r)=>{r[e]=t===!0||t==="true"}}function x(e){return(t,r)=>{if(typeof t==="string")r[e]=t;else throw new d(`Option --${e} requires a string value`)}}function z(e){return(t,r)=>{if(typeof t==="string")r[e]=t.split(",");else throw new d(`Option --${e} requires a string value`)}}function pt(e){return(t,r)=>{if(typeof t==="boolean")r[e]=t;else if(typeof t==="string")if(t.toLowerCase()==="true"||t.toLowerCase()==="false")r[e]=t.toLowerCase()==="true";else r[e]=t;else throw new d(`Option --${e} requires a boolean or string value`)}}function dt(){console.log(`
34
+ `);return t===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,t+1),codeContent:e.slice(t+1)}}var T=new Set;async function k(e,t){let r=j(e);if(!r.entry||r.entry.length===0||!r.outDir)throw new w("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(r.clean)ce(t,r.outDir);B(r.silent);let{packageJson:n,path:s}=await Te(t);if(n&&s)u.cli(`Using package.json: ${y(s,2)}`,{muted:!0,identifier:r.name,once:`${s}:${r.name}`});let o=P(r.entry),i=n?.type,a=D(r,n),c=A(r);if(!r.dtsOnly){let l=[Ie(a,c)],f=r.format.flatMap((p)=>o.map((m)=>{return ft(r,t,m,p,i,l)}));await Promise.all(f)}if(r.dts||r.dtsOnly){let l=await Se(t,r.preferredTsconfigPath);if(l.path)u.cli(`Using tsconfig: ${y(l.path,2)}`,{muted:!0,identifier:r.name,once:`${l.path}:${r.name}`});let f=r.format.filter((m)=>{if(m==="iife"&&!R(i)&&r.format.includes("cjs"))return!1;return!0}),p=typeof r.dts==="object"&&r.dts.entry?P(r.dts.entry):Ce(o);try{await Promise.all(p.map(async(m)=>{let W=await we(t,m.path,r,l,n);await Promise.all(f.map(async(Z)=>{let Ne=r.outputExtension?.({format:Z,packageType:i,options:r,entry:m}).dts??ae(Z,i),H=`${t}/${r.outDir}/${m.name}${Ne}`;await Bun.write(H,W);let Ue=Bun.file(H).size||0;u.progress("DTS",y(H),X(Ue),r.name)}))}))}catch(m){throw new h(b(m))}}}async function ft(e,t,r,n,s,o){let i=e.outputExtension?.({format:n,packageType:s,options:e,entry:r}).js??oe(n,s),a=await Bun.build({entrypoints:[`${t}/${r.path}`],format:n,naming:{entry:Ee(r.name,i)},splitting:ve(e.splitting,n),bytecode:Pe(e.bytecode,n),define:Be(e.define,e.shims,e.env,n),minify:Oe(e),outdir:`${t}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:Le(e.env),plugins:[...o,De({format:n,target:e.target,shims:e.shims}),...e.bunBuildPlugins??[]],throw:!1});if(!a.success)for(let f of a.logs){if(f.level==="error")throw new w(f.message);if(f.level==="warning")u.warn(f.message);else if(f.level==="info")u.info(f.message)}let c=`${t}/${e.outDir}/${r.name}${i}`,l=Bun.file(c).size||0;u.progress(n.toUpperCase(),y(c),X(l),e.name)}var N="0.4.27";var Ae="https://bun.sh/docs/installation",_e="https://bunup.arshadyaseen.com/documentation/#cli-options";function g(e){return(t,r)=>{r[e]=t===!0||t==="true"}}function x(e){return(t,r)=>{if(typeof t==="string")r[e]=t;else throw new d(`Option --${e} requires a string value`)}}function z(e){return(t,r)=>{if(typeof t==="string")r[e]=t.split(",");else throw new d(`Option --${e} requires a string value`)}}function pt(e){return(t,r)=>{if(typeof t==="boolean")r[e]=t;else if(typeof t==="string")if(t.toLowerCase()==="true"||t.toLowerCase()==="false")r[e]=t.toLowerCase()==="true";else r[e]=t;else throw new d(`Option --${e} requires a boolean or string value`)}}function dt(){console.log(`
35
35
  Bunup - An extremely fast, zero-config bundler for JavaScript and TypeScript, powered by Bun.
36
36
  `),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${_e}\x1B[0m
37
37
  `),process.exit(0)}function gt(){console.log(N),process.exit(0)}var Me={name:{flags:["n","name"],handler:x("name")},format:{flags:["f","format"],handler:z("format")},outDir:{flags:["o","out-dir"],handler:x("outDir")},minify:{flags:["m","minify"],handler:g("minify")},watch:{flags:["w","watch"],handler:g("watch")},dts:{flags:["d","dts"],handler:g("dts")},banner:{flags:["bn","banner"],handler:x("banner")},footer:{flags:["ft","footer"],handler:x("footer")},external:{flags:["e","external"],handler:z("external")},sourcemap:{flags:["sm","sourcemap"],handler:pt("sourcemap")},target:{flags:["t","target"],handler:x("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:g("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:g("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:g("minifySyntax")},clean:{flags:["c","clean"],handler:g("clean")},splitting:{flags:["s","splitting"],handler:g("splitting")},noExternal:{flags:["ne","no-external"],handler:z("noExternal")},preferredTsconfigPath:{flags:["tsconfig","preferred-tsconfig-path"],handler:x("preferredTsconfigPath")},bytecode:{flags:["bc","bytecode"],handler:g("bytecode")},dtsOnly:{flags:["do","dts-only"],handler:g("dtsOnly")},silent:{flags:["silent"],handler:g("silent")},config:{flags:["config"],handler:x("config")},publicPath:{flags:["pp","public-path"],handler:x("publicPath")},env:{flags:["env"],handler:x("env")},shims:{flags:["shims"],handler:g("shims")},entry:{flags:["entry"],handler:(e,t,r)=>{if(typeof e!=="string")throw new d(`Entry${r?` --entry.${r}`:""} requires a string value`);let n=t.entry||{};if(r){if(n[r])u.warn(`Duplicate entry name '${r}' provided via --entry.${r}. Overwriting previous entry.`);n[r]=e}else{let s=M(e);if(n[s])u.warn(`Duplicate entry name '${s}' derived from '${e}'. Overwriting previous entry.`);n[s]=e}t.entry=n}},resolveDts:{flags:["rd","resolve-dts"],handler:(e,t)=>{if(!t.dts)t.dts={};if(typeof t.dts==="boolean")t.dts={};if(typeof e==="string")if(e==="true"||e==="false")t.dts.resolve=e==="true";else t.dts.resolve=e.split(",");else t.dts.resolve=!0}},help:{flags:["h","help"],handler:()=>dt()},version:{flags:["v","version"],handler:()=>gt()}},U={};for(let e of Object.values(Me))for(let t of e.flags)U[t]=e.handler;function je(e){let t={};for(let r=0;r<e.length;r++){let n=e[r];if(n.startsWith("--")){let s,o;if(n.includes("=")){let[i,a]=n.slice(2).split("=",2);s=i,o=a}else{s=n.slice(2);let i=e[r+1];if(o=i&&!i.startsWith("-")?i:!0,typeof o==="string")r++}if(s.includes(".")){let[i,a]=s.split(".",2),c=U[i];if(c)c(o,t,a);else throw new d(`Unknown option: --${s}`)}else{let i=U[s];if(i)i(o,t);else throw new d(`Unknown option: --${s}`)}}else if(n.startsWith("-")){let s=n.slice(1),o=e[r+1],i=o&&!o.startsWith("-")?o:!0;if(typeof i==="string")r++;let a=U[s];if(a)a(i,t);else throw new d(`Unknown option: -${s}`)}else Me.entry.handler(n,t,void 0)}return t}(()=>{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.4.26",
3
+ "version": "0.4.27",
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",
@@ -20,7 +20,7 @@
20
20
  "bunup": "^0.4.23",
21
21
  "husky": "^9.1.7",
22
22
  "typescript": "^5.8.3",
23
- "create-bunup": "0.4.26"
23
+ "create-bunup": "0.4.27"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "typescript": ">=4.5.0"
@@ -55,7 +55,7 @@
55
55
  "oxc-resolver": "^5.0.1",
56
56
  "oxc-transform": "^0.58.1",
57
57
  "rolldown": "1.0.0-beta.7",
58
- "rolldown-plugin-dts": "^0.4.0",
58
+ "rolldown-plugin-dts": "^0.6.0",
59
59
  "ts-import-resolver": "^0.1.9"
60
60
  },
61
61
  "scripts": {