bunup 0.3.6 → 0.3.8

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.
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/#using-a-configuration-file-with-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=U(i);s(o,i)}else Object.entries(n).forEach(([i,o])=>{s(i,o)});return t}function $n(n,t){return`[dir]/${n}${t}`}function On(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 v=new Set;async function D(n,t){if(!n.entry||n.entry.length===0||!n.outDir)throw new x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let e=H(t),r=e?.type,s=M(n,e),i=k(n),o=[On(s,i)],a=T(n.entry),c=nn(n,t),u=n.format.flatMap((p)=>a.map((f)=>{return st(n,t,f,p,r,o,c)}));try{await Promise.all(u)}catch(p){throw console.error(p),new x("Build process encountered errors")}if(n.dts){let p=n.format.filter((g)=>{if(g==="iife"&&!N(r)&&n.format.includes("cjs"))return!1;return!0}),f=typeof n.dts==="object"&&n.dts.entry?T(n.dts.entry):a;try{await Promise.all(f.map(async(g)=>{let b=await bn(t,g.path,n);await Promise.all(p.map(async($)=>{let jn=rn($,r),q=`${t}/${n.outDir}/${g.name}${jn}`;await Bun.write(q,b);let Tn=Bun.file(q).size||0;l.progress("DTS",O(q),Y(Tn),n.name)}))}))}catch(g){throw new h(`DTS build process encountered errors: ${m(g)}`)}}}async function st(n,t,e,r,s,i,o){let a=en(r,s),c=await Bun.build({...o,entrypoints:[`${t}/${e.path}`],format:r,naming:{entry:$n(e.name,a)},splitting:on(n.splitting,r),plugins:i,throw:!1});if(!c.success)throw c.logs.forEach((f)=>{if(f.level==="error")l.error(f.message);else if(f.level==="warning")l.warn(f.message);else if(f.level==="info")l.info(f.message)}),new x(`Build failed for ${e.path} (${r})`);let u=`${t}/${n.outDir}/${e.name}${a}`,p=Bun.file(u).size||0;l.progress(r.toUpperCase(),O(u),Y(p),n.name)}var W="0.3.6";var Cn="https://bun.sh/docs/installation",En="https://bunup.arshadyaseen.com/#cli-options";function w(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 y(`Option --${n} requires a string value`)}}function Bn(n){return(t,e)=>{if(typeof t==="string")e[n]=t.split(",");else throw new y(`Option --${n} requires a string value`)}}function ot(){console.log(`
23
+ See: https://bunup.arshadyaseen.com/#using-a-configuration-file-with-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=U(i);s(o,i)}else Object.entries(n).forEach(([i,o])=>{s(i,o)});return t}function $n(n,t){return`[dir]/${n}${t}`}function On(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 v=new Set;async function D(n,t){if(!n.entry||n.entry.length===0||!n.outDir)throw new x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let e=H(t),r=e?.type,s=M(n,e),i=k(n),o=[On(s,i)],a=T(n.entry),c=nn(n,t),u=n.format.flatMap((p)=>a.map((f)=>{return st(n,t,f,p,r,o,c)}));try{await Promise.all(u)}catch(p){throw console.error(p),new x("Build process encountered errors")}if(n.dts){let p=n.format.filter((g)=>{if(g==="iife"&&!N(r)&&n.format.includes("cjs"))return!1;return!0}),f=typeof n.dts==="object"&&n.dts.entry?T(n.dts.entry):a;try{await Promise.all(f.map(async(g)=>{let b=await bn(t,g.path,n);await Promise.all(p.map(async($)=>{let jn=rn($,r),q=`${t}/${n.outDir}/${g.name}${jn}`;await Bun.write(q,b);let Tn=Bun.file(q).size||0;l.progress("DTS",O(q),Y(Tn),n.name)}))}))}catch(g){throw new h(`DTS build process encountered errors: ${m(g)}`)}}}async function st(n,t,e,r,s,i,o){let a=en(r,s),c=await Bun.build({...o,entrypoints:[`${t}/${e.path}`],format:r,naming:{entry:$n(e.name,a)},splitting:on(n.splitting,r),plugins:i,throw:!1});if(!c.success)throw c.logs.forEach((f)=>{if(f.level==="error")l.error(f.message);else if(f.level==="warning")l.warn(f.message);else if(f.level==="info")l.info(f.message)}),new x(`Build failed for ${e.path} (${r})`);let u=`${t}/${n.outDir}/${e.name}${a}`,p=Bun.file(u).size||0;l.progress(r.toUpperCase(),O(u),Y(p),n.name)}var W="0.3.8";var Cn="https://bun.sh/docs/installation",En="https://bunup.arshadyaseen.com/#cli-options";function w(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 y(`Option --${n} requires a string value`)}}function Bn(n){return(t,e)=>{if(typeof t==="string")e[n]=t.split(",");else throw new y(`Option --${n} requires a string value`)}}function ot(){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${En}\x1B[0m
26
26
  `),process.exit(0)}function at(){console.log(W),process.exit(0)}var ct={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 y("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:Bn("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:Bn("noExternal")}},lt={help:{flags:["h","help"],handler:()=>ot()},version:{flags:["v","version"],handler:()=>at()}},G={};for(let n of Object.values(ct))if(n)for(let t of n.flags)G[t]=n.handler;for(let n of Object.values(lt))for(let t of n.flags)G[t]=n.handler;function vn(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=U(o);if(e[a])l.warn(`Duplicate entry name '${a}' derived from '${o}'. Overwriting previous entry.`);e[a]=o}else throw new y("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 y(`Option --entry.${a} requires a string value`)}else{let a=G[i];if(a)a(o,t);else throw new y(`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=G[i];if(c)c(a,t);else throw new y(`Unknown option: -${i}`)}else{let i=U(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 y(`Bunup requires Bun to run.
package/build/index.d.mts CHANGED
@@ -1,16 +1,11 @@
1
- /** https://bun.sh/docs/bundler/loaders */
2
- type Loader = "js" | "jsx" | "ts" | "tsx" | "json" | "toml" | "file" | "napi" | "wasm" | "text" | "css" | "html";
3
- /** https://bun.sh/docs/bundler#format */
4
- type Format = "esm" | "cjs" | "iife";
5
- /** https://bun.sh/docs/bundler#target */
6
- type Target = "bun" | "node" | "browser";
7
- /** https://bun.sh/docs/bundler#external */
8
- type External = string[];
9
- /** https://bun.sh/docs/bundler#sourcemap */
10
- type Sourcemap = "none" | "linked" | "external" | "inline";
11
- /** https://bun.sh/docs/bundler#define */
12
- type Define = Record<string, string>;
13
- /** https://bun.sh/docs/bundler#entry */
1
+ import * as bun from 'bun';
2
+
3
+ type Loader = NonNullable<BunBuildOptions["loader"]>[string];
4
+ type Define = BunBuildOptions["define"];
5
+ type Sourcemap = BunBuildOptions["sourcemap"];
6
+ type Format = Exclude<BunBuildOptions["format"], undefined>;
7
+ type Target = BunBuildOptions["target"];
8
+ type External = (string | RegExp)[];
14
9
  type Entry = string[] | Record<string, string>;
15
10
  type DtsOptions = {
16
11
  /**
@@ -226,6 +221,8 @@ type WithOptional<
226
221
  T,
227
222
  K extends keyof T
228
223
  > = Omit<T, K> & Partial<Pick<T, K>>;
224
+ type Bun = typeof bun;
225
+ type BunBuildOptions = Parameters<Bun["build"]>[0];
229
226
  type DefineConfigEntry = Omit<WithOptional<BunupOptions, "outDir" | "format">, "watch">;
230
227
  type DefineWorkspaceEntry = {
231
228
  name: string
package/build/index.d.ts CHANGED
@@ -1,16 +1,11 @@
1
- /** https://bun.sh/docs/bundler/loaders */
2
- type Loader = "js" | "jsx" | "ts" | "tsx" | "json" | "toml" | "file" | "napi" | "wasm" | "text" | "css" | "html";
3
- /** https://bun.sh/docs/bundler#format */
4
- type Format = "esm" | "cjs" | "iife";
5
- /** https://bun.sh/docs/bundler#target */
6
- type Target = "bun" | "node" | "browser";
7
- /** https://bun.sh/docs/bundler#external */
8
- type External = string[];
9
- /** https://bun.sh/docs/bundler#sourcemap */
10
- type Sourcemap = "none" | "linked" | "external" | "inline";
11
- /** https://bun.sh/docs/bundler#define */
12
- type Define = Record<string, string>;
13
- /** https://bun.sh/docs/bundler#entry */
1
+ import * as bun from 'bun';
2
+
3
+ type Loader = NonNullable<BunBuildOptions["loader"]>[string];
4
+ type Define = BunBuildOptions["define"];
5
+ type Sourcemap = BunBuildOptions["sourcemap"];
6
+ type Format = Exclude<BunBuildOptions["format"], undefined>;
7
+ type Target = BunBuildOptions["target"];
8
+ type External = (string | RegExp)[];
14
9
  type Entry = string[] | Record<string, string>;
15
10
  type DtsOptions = {
16
11
  /**
@@ -226,6 +221,8 @@ type WithOptional<
226
221
  T,
227
222
  K extends keyof T
228
223
  > = Omit<T, K> & Partial<Pick<T, K>>;
224
+ type Bun = typeof bun;
225
+ type BunBuildOptions = Parameters<Bun["build"]>[0];
229
226
  type DefineConfigEntry = Omit<WithOptional<BunupOptions, "outDir" | "format">, "watch">;
230
227
  type DefineWorkspaceEntry = {
231
228
  name: string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunup",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
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,7 +18,7 @@
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.5",
21
+ "bunup": "^0.3.7",
22
22
  "eslint": "^8.57.1",
23
23
  "husky": "^9.1.7",
24
24
  "prettier": "^3.5.3",