bunup 0.4.6 → 0.4.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/README.md CHANGED
@@ -53,7 +53,7 @@ Create a simple TypeScript file:
53
53
  ```typescript
54
54
  // src/index.ts
55
55
  export function greet(name: string): string {
56
- return `Hello, ${name}!`;
56
+ return `Hello, ${name}!`;
57
57
  }
58
58
  ```
59
59
 
@@ -71,10 +71,10 @@ Add a build script to your `package.json`:
71
71
 
72
72
  ```json
73
73
  {
74
- "name": "my-package",
75
- "scripts": {
76
- "build": "bunup src/index.ts --format esm,cjs --dts"
77
- }
74
+ "name": "my-package",
75
+ "scripts": {
76
+ "build": "bunup src/index.ts --format esm,cjs --dts"
77
+ }
78
78
  }
79
79
  ```
80
80
 
@@ -89,14 +89,14 @@ npm run build
89
89
  Create a `bunup.config.ts` file for more control:
90
90
 
91
91
  ```typescript
92
- import {defineConfig} from 'bunup';
92
+ import { defineConfig } from "bunup";
93
93
 
94
94
  export default defineConfig({
95
- entry: ['src/index.ts'],
96
- outDir: 'dist',
97
- format: ['esm', 'cjs'],
98
- dts: true,
99
- minify: true,
95
+ entry: ["src/index.ts"],
96
+ outDir: "dist",
97
+ format: ["esm", "cjs"],
98
+ dts: true,
99
+ minify: true,
100
100
  });
101
101
  ```
102
102
 
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:c,path:a})}else n.push({name:i,path:a}),r.add(i),s[i]=a}if(Array.isArray(e))for(let i of e){let a=j(i);o(a,i)}else if(typeof e==="object")for(let[i,a]of Object.entries(e))o(i,a);else{let i=j(e);o(i,e)}return n}function Re(e){return e.filter((t)=>I(t.path))}function Se(e,t){return`[dir]/${e}${t}`}import{loadConfig as Oe}from"coffi";async function Pe(e,t){return Array.isArray(e)&&"root"in e[0]?e.map((n)=>({rootDir:n.root,options:ie(n.config,"name",n.name)})):[{rootDir:t,options:e}]}async function Be(e){let{config:t,filepath:n}=await Oe({name:"package",cwd:e,extensions:[".json"],maxDepth:1});return{packageJson:t,path:n}}async function Le(e,t){let{config:n,filepath:r}=await Oe({name:"tsconfig",cwd:e,extensions:[".json"],preferredPath:t,maxDepth:3});return{tsconfig:n,path:r}}var pt={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function U(e){return{...pt,...e}}function Ae(e){let{minify:t,minifyWhitespace:n,minifyIdentifiers:r,minifySyntax:s}=e,o=t===!0;return{whitespace:n??o,identifiers:r??o,syntax:s??o}}function Ie(e,t){return t==="cjs"?e:void 0}function Me(e,t,n,r){return{...e,...r==="cjs"&&(t===!0||typeof t==="object"&&t.importMetaUrl)&&{"import.meta.url":"importMetaUrl"},...typeof n==="object"&&Object.keys(n).reduce((s,o)=>{let i=JSON.stringify(n[o]);return s[`process.env.${o}`]=i,s[`import.meta.env.${o}`]=i,s},{})}}function De(e,t){return e===void 0?t==="esm":e}function _e(e){return typeof e==="string"?e:void 0}function ve(e,t){return{name:"bunup:external-plugin",setup(n){n.onResolve({filter:/.*/},(r)=>{let s=r.path;if(e.some((i)=>i.test(s))&&!t.some((i)=>i.test(s)))return{path:s,external:!0};return null})}}}var N={dirnameFilename:{appliesTo:(e,t)=>e==="esm"&&K(t),isNeededInFile:(e)=>/\b__dirname\b/.test(e)||/\b__filename\b/.test(e),generateCode:()=>`import { fileURLToPath } from 'url';
23
+ See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0});n.push({name:c,path:a})}else n.push({name:i,path:a}),r.add(i),s[i]=a}if(Array.isArray(e))for(let i of e){let a=j(i);o(a,i)}else if(typeof e==="object")for(let[i,a]of Object.entries(e))o(i,a);else{let i=j(e);o(i,e)}return n}function Re(e){return e.filter((t)=>I(t.path))}function Se(e,t){return`[dir]/${e}${t}`}import{loadConfig as Oe}from"coffi";async function Pe(e,t){return Array.isArray(e)&&"root"in e[0]?e.map((n)=>({rootDir:n.root,options:ie(n.config,"name",n.name)})):[{rootDir:t,options:e}]}async function Be(e){let{config:t,filepath:n}=await Oe({name:"package",cwd:e,extensions:[".json"],maxDepth:1});return{packageJson:t,path:n}}async function Le(e,t){let{config:n,filepath:r}=await Oe({name:"tsconfig",cwd:e,extensions:[".json"],preferredPath:t,maxDepth:3});return{tsconfig:n,path:r}}var pt={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function U(e){return{...pt,...e}}function Ae(e){let{minify:t,minifyWhitespace:n,minifyIdentifiers:r,minifySyntax:s}=e,o=t===!0;return{whitespace:n??o,identifiers:r??o,syntax:s??o}}function Ie(e,t){return t==="cjs"?e:void 0}function Me(e,t,n,r){return{...typeof n==="object"&&Object.keys(n).reduce((s,o)=>{let i=JSON.stringify(n[o]);return s[`process.env.${o}`]=i,s[`import.meta.env.${o}`]=i,s},{}),...e,...r==="cjs"&&(t===!0||typeof t==="object"&&t.importMetaUrl)&&{"import.meta.url":"importMetaUrl"}}}function De(e,t){return e===void 0?t==="esm":e}function _e(e){return typeof e==="string"?e:void 0}function ve(e,t){return{name:"bunup:external-plugin",setup(n){n.onResolve({filter:/.*/},(r)=>{let s=r.path;if(e.some((i)=>i.test(s))&&!t.some((i)=>i.test(s)))return{path:s,external:!0};return null})}}}var N={dirnameFilename:{appliesTo:(e,t)=>e==="esm"&&K(t),isNeededInFile:(e)=>/\b__dirname\b/.test(e)||/\b__filename\b/.test(e),generateCode:()=>`import { fileURLToPath } from 'url';
24
24
  import { dirname } from 'path';
25
25
 
26
26
  const __filename = fileURLToPath(import.meta.url);
@@ -31,7 +31,7 @@ See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0})
31
31
  const importMetaUrl = pathToFileURL(__filename).href;
32
32
 
33
33
  `}};var mt=/\.(js|ts|jsx|tsx|mts|cts)$/;function ke({format:e,target:t,shims:n}){let s=dt(n).map((o)=>N[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:mt},async({path:i})=>{let a=await Bun.file(i).text(),l=s.filter((p)=>p.isNeededInFile(a));if(l.length===0)return;let{shebangLine:c,codeContent:f}=gt(a),m=l.map((p)=>p.generateCode()).join("");return{contents:c+m+f}})}}}function dt(e){if(e===!0)return Object.keys(N);if(!e)return[];return Object.entries(e).filter(([t,n])=>n&&(t in N)).map(([t])=>t)}function gt(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 $=new Set;async function F(e,t){let n=U(e);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.");if(n.clean)ue(t,n.outDir);_(n.silent);let{packageJson:r,path:s}=await Be(t);if(r&&s)u.cli(`Using package.json: ${x(s,2)}`,{muted:!0,identifier:n.name,once:`${s}:${n.name}`});let o=P(n.entry),i=r?.type,a=M(n,r),l=D(n);if(!n.dtsOnly){let c=[ve(a,l)],f=n.format.flatMap((m)=>o.map((p)=>{return ht(n,t,p,m,i,c)}));await Promise.all(f)}if(n.dts||n.dtsOnly){let c=await Le(t,n.preferredTsconfigPath);if(c.path)u.cli(`Using tsconfig: ${x(c.path,2)}`,{muted:!0,identifier:n.name,once:`${c.path}:${n.name}`});let f=n.format.filter((p)=>{if(p==="iife"&&!L(i)&&n.format.includes("cjs"))return!1;return!0}),m=typeof n.dts==="object"&&n.dts.entry?P(n.dts.entry):Re(o);try{await Promise.all(m.map(async(p)=>{let G=await $e(t,p.path,n,c,r);await Promise.all(f.map(async(He)=>{let qe=le(He,i),V=`${t}/${n.outDir}/${p.name}${qe}`;await Bun.write(V,G);let Ge=Bun.file(V).size||0;u.progress("DTS",x(V),J(Ge),n.name)}))}))}catch(p){throw new h(b(p))}}}async function ht(e,t,n,r,s,o){let i=ae(r,s),a=await Bun.build({entrypoints:[`${t}/${n.path}`],format:r,naming:{entry:Se(n.name,i)},splitting:De(e.splitting,r),bytecode:Ie(e.bytecode,r),define:Me(e.define,e.shims,e.env,r),minify:Ae(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:_e(e.env),plugins:[...o,ke({format:r,target:e.target,shims:e.shims})],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 l=`${t}/${e.outDir}/${n.name}${i}`,c=Bun.file(l).size||0;u.progress(r.toUpperCase(),x(l),J(c),e.name)}var W="0.4.6";var je="https://bun.sh/docs/installation",Ue="https://bunup.arshadyaseen.com/#cli-options";function g(e){return(t,n)=>{n[e]=t===!0||t==="true"}}function y(e){return(t,n)=>{if(typeof t==="string")n[e]=t;else throw new d(`Option --${e} requires a string value`)}}function ee(e){return(t,n)=>{if(typeof t==="string")n[e]=t.split(",");else throw new d(`Option --${e} requires a string value`)}}function xt(e){return(t,n)=>{if(typeof t==="boolean")n[e]=t;else if(typeof t==="string")if(t.toLowerCase()==="true"||t.toLowerCase()==="false")n[e]=t.toLowerCase()==="true";else n[e]=t;else throw new d(`Option --${e} requires a boolean or string value`)}}function yt(){console.log(`
34
+ `);return t===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,t+1),codeContent:e.slice(t+1)}}var $=new Set;async function F(e,t){let n=U(e);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.");if(n.clean)ue(t,n.outDir);_(n.silent);let{packageJson:r,path:s}=await Be(t);if(r&&s)u.cli(`Using package.json: ${x(s,2)}`,{muted:!0,identifier:n.name,once:`${s}:${n.name}`});let o=P(n.entry),i=r?.type,a=M(n,r),l=D(n);if(!n.dtsOnly){let c=[ve(a,l)],f=n.format.flatMap((m)=>o.map((p)=>{return ht(n,t,p,m,i,c)}));await Promise.all(f)}if(n.dts||n.dtsOnly){let c=await Le(t,n.preferredTsconfigPath);if(c.path)u.cli(`Using tsconfig: ${x(c.path,2)}`,{muted:!0,identifier:n.name,once:`${c.path}:${n.name}`});let f=n.format.filter((p)=>{if(p==="iife"&&!L(i)&&n.format.includes("cjs"))return!1;return!0}),m=typeof n.dts==="object"&&n.dts.entry?P(n.dts.entry):Re(o);try{await Promise.all(m.map(async(p)=>{let G=await $e(t,p.path,n,c,r);await Promise.all(f.map(async(He)=>{let qe=le(He,i),V=`${t}/${n.outDir}/${p.name}${qe}`;await Bun.write(V,G);let Ge=Bun.file(V).size||0;u.progress("DTS",x(V),J(Ge),n.name)}))}))}catch(p){throw new h(b(p))}}}async function ht(e,t,n,r,s,o){let i=ae(r,s),a=await Bun.build({entrypoints:[`${t}/${n.path}`],format:r,naming:{entry:Se(n.name,i)},splitting:De(e.splitting,r),bytecode:Ie(e.bytecode,r),define:Me(e.define,e.shims,e.env,r),minify:Ae(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:_e(e.env),plugins:[...o,ke({format:r,target:e.target,shims:e.shims})],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 l=`${t}/${e.outDir}/${n.name}${i}`,c=Bun.file(l).size||0;u.progress(r.toUpperCase(),x(l),J(c),e.name)}var W="0.4.8";var je="https://bun.sh/docs/installation",Ue="https://bunup.arshadyaseen.com/#cli-options";function g(e){return(t,n)=>{n[e]=t===!0||t==="true"}}function y(e){return(t,n)=>{if(typeof t==="string")n[e]=t;else throw new d(`Option --${e} requires a string value`)}}function ee(e){return(t,n)=>{if(typeof t==="string")n[e]=t.split(",");else throw new d(`Option --${e} requires a string value`)}}function xt(e){return(t,n)=>{if(typeof t==="boolean")n[e]=t;else if(typeof t==="string")if(t.toLowerCase()==="true"||t.toLowerCase()==="false")n[e]=t.toLowerCase()==="true";else n[e]=t;else throw new d(`Option --${e} requires a boolean or string value`)}}function yt(){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${Ue}\x1B[0m
37
37
  `),process.exit(0)}function wt(){console.log(W),process.exit(0)}var Ne={name:{flags:["n","name"],handler:y("name")},format:{flags:["f","format"],handler:ee("format")},outDir:{flags:["o","out-dir"],handler:y("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:y("banner")},footer:{flags:["ft","footer"],handler:y("footer")},external:{flags:["e","external"],handler:ee("external")},sourcemap:{flags:["sm","sourcemap"],handler:xt("sourcemap")},target:{flags:["t","target"],handler:y("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:ee("noExternal")},preferredTsconfigPath:{flags:["tsconfig","preferred-tsconfig-path"],handler:y("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:y("config")},publicPath:{flags:["pp","public-path"],handler:y("publicPath")},env:{flags:["env"],handler:y("env")},shims:{flags:["shims"],handler:g("shims")},entry:{flags:["entry"],handler:(e,t,n)=>{if(typeof e!=="string")throw new d(`Entry${n?` --entry.${n}`:""} requires a string value`);let r=t.entry||{};if(n){if(r[n])u.warn(`Duplicate entry name '${n}' provided via --entry.${n}. Overwriting previous entry.`);r[n]=e}else{let s=j(e);if(r[s])u.warn(`Duplicate entry name '${s}' derived from '${e}'. Overwriting previous entry.`);r[s]=e}t.entry=r}},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:()=>yt()},version:{flags:["v","version"],handler:()=>wt()}},H={};for(let e of Object.values(Ne))for(let t of e.flags)H[t]=e.handler;function Fe(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r.startsWith("--")){let s,o;if(r.includes("=")){let[i,a]=r.slice(2).split("=",2);s=i,o=a}else{s=r.slice(2);let i=e[n+1];if(o=i&&!i.startsWith("-")?i:!0,typeof o==="string")n++}if(s.includes(".")){let[i,a]=s.split(".",2),l=H[i];if(l)l(o,t,a);else throw new d(`Unknown option: --${s}`)}else{let i=H[s];if(i)i(o,t);else throw new d(`Unknown option: --${s}`)}}else if(r.startsWith("-")){let s=r.slice(1),o=e[n+1],i=o&&!o.startsWith("-")?o:!0;if(typeof i==="string")n++;let a=H[s];if(a)a(i,t);else throw new d(`Unknown option: -${s}`)}else Ne.entry.handler(r,t,void 0)}return t}(()=>{if(typeof Bun==="undefined")throw new d(`Bunup requires Bun to run.
package/build/index.d.mts CHANGED
@@ -304,33 +304,31 @@ interface BuildOptions {
304
304
  * Controls how environment variables are handled during bundling.
305
305
  *
306
306
  * Can be one of:
307
- * - `"inline"`: Injects environment variables into the bundled output by converting `process.env.FOO`
308
- * references to string literals containing the actual environment variable values
309
- * - `"disable"`: Disables environment variable injection entirely
310
- * - A string ending in `*`: Inlines environment variables that match the given prefix.
311
- * For example, `"MY_PUBLIC_*"` will only include env vars starting with "MY_PUBLIC_"
312
- * - An object of key-value pairs where the key is the env name and value is the value
307
+ * - `"inline"`: Replaces all `process.env.FOO` references in your code with the actual values
308
+ * of those environment variables at the time the build runs.
309
+ * - `"disable"`: Disables environment variable injection entirely, leaving `process.env.*` as-is.
310
+ * - A string ending in `*`: Only inlines environment variables matching the given prefix.
311
+ * For example, `"MY_PUBLIC_*"` will inline variables like `MY_PUBLIC_API_URL`.
312
+ * - An object of key-value pairs: Replaces both `process.env.KEY` and `import.meta.env.KEY`
313
+ * with the provided values, regardless of the runtime environment.
313
314
  *
314
- * @see https://bun.sh/docs/bundler#env to learn more about inline, disable and prefix methods
315
+ * Note: Values are injected at build time. Secrets or private keys should be excluded
316
+ * from inlining when targeting browser environments.
317
+ *
318
+ * @see https://bun.sh/docs/bundler#env to learn more about inline, disable, prefix, and object modes
315
319
  *
316
320
  * @example
317
- * // Inline all environment variables
321
+ * // Inline all environment variables available at build time
318
322
  * env: "inline"
319
323
  *
320
- * // Disable environment variable injection
324
+ * // Disable all environment variable injection
321
325
  * env: "disable"
322
326
  *
323
327
  * // Only inline environment variables with a specific prefix
324
328
  * env: "PUBLIC_*"
325
329
  *
326
- * // Provide specific environment variables
330
+ * // Provide specific environment variables manually
327
331
  * env: { API_URL: "https://api.example.com", DEBUG: "false" }
328
- *
329
- * @example [CLI]
330
- * To inline specific environment variables at build time:
331
- * ```sh
332
- * FOO=bar API_KEY=secret bunup src/index.ts --env inline
333
- * ```
334
332
  */
335
333
  env?: Env;
336
334
  }
package/build/index.d.ts CHANGED
@@ -304,33 +304,31 @@ interface BuildOptions {
304
304
  * Controls how environment variables are handled during bundling.
305
305
  *
306
306
  * Can be one of:
307
- * - `"inline"`: Injects environment variables into the bundled output by converting `process.env.FOO`
308
- * references to string literals containing the actual environment variable values
309
- * - `"disable"`: Disables environment variable injection entirely
310
- * - A string ending in `*`: Inlines environment variables that match the given prefix.
311
- * For example, `"MY_PUBLIC_*"` will only include env vars starting with "MY_PUBLIC_"
312
- * - An object of key-value pairs where the key is the env name and value is the value
307
+ * - `"inline"`: Replaces all `process.env.FOO` references in your code with the actual values
308
+ * of those environment variables at the time the build runs.
309
+ * - `"disable"`: Disables environment variable injection entirely, leaving `process.env.*` as-is.
310
+ * - A string ending in `*`: Only inlines environment variables matching the given prefix.
311
+ * For example, `"MY_PUBLIC_*"` will inline variables like `MY_PUBLIC_API_URL`.
312
+ * - An object of key-value pairs: Replaces both `process.env.KEY` and `import.meta.env.KEY`
313
+ * with the provided values, regardless of the runtime environment.
313
314
  *
314
- * @see https://bun.sh/docs/bundler#env to learn more about inline, disable and prefix methods
315
+ * Note: Values are injected at build time. Secrets or private keys should be excluded
316
+ * from inlining when targeting browser environments.
317
+ *
318
+ * @see https://bun.sh/docs/bundler#env to learn more about inline, disable, prefix, and object modes
315
319
  *
316
320
  * @example
317
- * // Inline all environment variables
321
+ * // Inline all environment variables available at build time
318
322
  * env: "inline"
319
323
  *
320
- * // Disable environment variable injection
324
+ * // Disable all environment variable injection
321
325
  * env: "disable"
322
326
  *
323
327
  * // Only inline environment variables with a specific prefix
324
328
  * env: "PUBLIC_*"
325
329
  *
326
- * // Provide specific environment variables
330
+ * // Provide specific environment variables manually
327
331
  * env: { API_URL: "https://api.example.com", DEBUG: "false" }
328
- *
329
- * @example [CLI]
330
- * To inline specific environment variables at build time:
331
- * ```sh
332
- * FOO=bar API_KEY=secret bunup src/index.ts --env inline
333
- * ```
334
332
  */
335
333
  env?: Env;
336
334
  }
package/build/index.js CHANGED
@@ -12,7 +12,7 @@ To fix this, use named entries in your configuration:
12
12
  }
13
13
  }
14
14
 
15
- See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0});r.push({name:c,path:a})}else r.push({name:i,path:a}),n.add(i),s[i]=a}if(Array.isArray(t))for(let i of t){let a=Et(i);o(a,i)}else if(typeof t==="object")for(let[i,a]of Object.entries(t))o(i,a);else{let i=Et(t);o(i,t)}return r}function wt(t){return t.filter((e)=>C(e.path))}function Rt(t,e){return`[dir]/${t}${e}`}var v=require("coffi");async function Tt(t){let{config:e,filepath:r}=await v.loadConfig({name:"package",cwd:t,extensions:[".json"],maxDepth:1});return{packageJson:e,path:r}}async function $t(t,e){let{config:r,filepath:n}=await v.loadConfig({name:"tsconfig",cwd:t,extensions:[".json"],preferredPath:e,maxDepth:3});return{tsconfig:r,path:n}}var ee={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function St(t){return{...ee,...t}}function Ct(t){let{minify:e,minifyWhitespace:r,minifyIdentifiers:n,minifySyntax:s}=t,o=e===!0;return{whitespace:r??o,identifiers:n??o,syntax:s??o}}function Pt(t,e){return e==="cjs"?t:void 0}function Bt(t,e,r,n){return{...t,...n==="cjs"&&(e===!0||typeof e==="object"&&e.importMetaUrl)&&{"import.meta.url":"importMetaUrl"},...typeof r==="object"&&Object.keys(r).reduce((s,o)=>{let i=JSON.stringify(r[o]);return s[`process.env.${o}`]=i,s[`import.meta.env.${o}`]=i,s},{})}}function Dt(t,e){return t===void 0?e==="esm":t}function Mt(t){return typeof t==="string"?t:void 0}function It(t,e){return{name:"bunup:external-plugin",setup(r){r.onResolve({filter:/.*/},(n)=>{let s=n.path;if(t.some((i)=>i.test(s))&&!e.some((i)=>i.test(s)))return{path:s,external:!0};return null})}}}var L={dirnameFilename:{appliesTo:(t,e)=>t==="esm"&&F(e),isNeededInFile:(t)=>/\b__dirname\b/.test(t)||/\b__filename\b/.test(t),generateCode:()=>`import { fileURLToPath } from 'url';
15
+ See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0});r.push({name:c,path:a})}else r.push({name:i,path:a}),n.add(i),s[i]=a}if(Array.isArray(t))for(let i of t){let a=Et(i);o(a,i)}else if(typeof t==="object")for(let[i,a]of Object.entries(t))o(i,a);else{let i=Et(t);o(i,t)}return r}function wt(t){return t.filter((e)=>C(e.path))}function Rt(t,e){return`[dir]/${t}${e}`}var v=require("coffi");async function Tt(t){let{config:e,filepath:r}=await v.loadConfig({name:"package",cwd:t,extensions:[".json"],maxDepth:1});return{packageJson:e,path:r}}async function $t(t,e){let{config:r,filepath:n}=await v.loadConfig({name:"tsconfig",cwd:t,extensions:[".json"],preferredPath:e,maxDepth:3});return{tsconfig:r,path:n}}var ee={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function St(t){return{...ee,...t}}function Ct(t){let{minify:e,minifyWhitespace:r,minifyIdentifiers:n,minifySyntax:s}=t,o=e===!0;return{whitespace:r??o,identifiers:n??o,syntax:s??o}}function Pt(t,e){return e==="cjs"?t:void 0}function Bt(t,e,r,n){return{...typeof r==="object"&&Object.keys(r).reduce((s,o)=>{let i=JSON.stringify(r[o]);return s[`process.env.${o}`]=i,s[`import.meta.env.${o}`]=i,s},{}),...t,...n==="cjs"&&(e===!0||typeof e==="object"&&e.importMetaUrl)&&{"import.meta.url":"importMetaUrl"}}}function Dt(t,e){return t===void 0?e==="esm":t}function Mt(t){return typeof t==="string"?t:void 0}function It(t,e){return{name:"bunup:external-plugin",setup(r){r.onResolve({filter:/.*/},(n)=>{let s=n.path;if(t.some((i)=>i.test(s))&&!e.some((i)=>i.test(s)))return{path:s,external:!0};return null})}}}var L={dirnameFilename:{appliesTo:(t,e)=>t==="esm"&&F(e),isNeededInFile:(t)=>/\b__dirname\b/.test(t)||/\b__filename\b/.test(t),generateCode:()=>`import { fileURLToPath } from 'url';
16
16
  import { dirname } from 'path';
17
17
 
18
18
  const __filename = fileURLToPath(import.meta.url);
package/build/index.mjs CHANGED
@@ -12,7 +12,7 @@ To fix this, use named entries in your configuration:
12
12
  }
13
13
  }
14
14
 
15
- See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0});r.push({name:c,path:a})}else r.push({name:s,path:a}),n.add(s),o[s]=a}if(Array.isArray(t))for(let s of t){let a=ot(s);i(a,s)}else if(typeof t==="object")for(let[s,a]of Object.entries(t))i(s,a);else{let s=ot(t);i(s,t)}return r}function at(t){return t.filter((e)=>$(e.path))}function ct(t,e){return`[dir]/${t}${e}`}import{loadConfig as ut}from"coffi";async function lt(t){let{config:e,filepath:r}=await ut({name:"package",cwd:t,extensions:[".json"],maxDepth:1});return{packageJson:e,path:r}}async function ft(t,e){let{config:r,filepath:n}=await ut({name:"tsconfig",cwd:t,extensions:[".json"],preferredPath:e,maxDepth:3});return{tsconfig:r,path:n}}var Gt={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function gt(t){return{...Gt,...t}}function mt(t){let{minify:e,minifyWhitespace:r,minifyIdentifiers:n,minifySyntax:o}=t,i=e===!0;return{whitespace:r??i,identifiers:n??i,syntax:o??i}}function pt(t,e){return e==="cjs"?t:void 0}function dt(t,e,r,n){return{...t,...n==="cjs"&&(e===!0||typeof e==="object"&&e.importMetaUrl)&&{"import.meta.url":"importMetaUrl"},...typeof r==="object"&&Object.keys(r).reduce((o,i)=>{let s=JSON.stringify(r[i]);return o[`process.env.${i}`]=s,o[`import.meta.env.${i}`]=s,o},{})}}function xt(t,e){return t===void 0?e==="esm":t}function ht(t){return typeof t==="string"?t:void 0}function bt(t,e){return{name:"bunup:external-plugin",setup(r){r.onResolve({filter:/.*/},(n)=>{let o=n.path;if(t.some((s)=>s.test(o))&&!e.some((s)=>s.test(o)))return{path:o,external:!0};return null})}}}var D={dirnameFilename:{appliesTo:(t,e)=>t==="esm"&&O(e),isNeededInFile:(t)=>/\b__dirname\b/.test(t)||/\b__filename\b/.test(t),generateCode:()=>`import { fileURLToPath } from 'url';
15
+ See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0});r.push({name:c,path:a})}else r.push({name:s,path:a}),n.add(s),o[s]=a}if(Array.isArray(t))for(let s of t){let a=ot(s);i(a,s)}else if(typeof t==="object")for(let[s,a]of Object.entries(t))i(s,a);else{let s=ot(t);i(s,t)}return r}function at(t){return t.filter((e)=>$(e.path))}function ct(t,e){return`[dir]/${t}${e}`}import{loadConfig as ut}from"coffi";async function lt(t){let{config:e,filepath:r}=await ut({name:"package",cwd:t,extensions:[".json"],maxDepth:1});return{packageJson:e,path:r}}async function ft(t,e){let{config:r,filepath:n}=await ut({name:"tsconfig",cwd:t,extensions:[".json"],preferredPath:e,maxDepth:3});return{tsconfig:r,path:n}}var Gt={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function gt(t){return{...Gt,...t}}function mt(t){let{minify:e,minifyWhitespace:r,minifyIdentifiers:n,minifySyntax:o}=t,i=e===!0;return{whitespace:r??i,identifiers:n??i,syntax:o??i}}function pt(t,e){return e==="cjs"?t:void 0}function dt(t,e,r,n){return{...typeof r==="object"&&Object.keys(r).reduce((o,i)=>{let s=JSON.stringify(r[i]);return o[`process.env.${i}`]=s,o[`import.meta.env.${i}`]=s,o},{}),...t,...n==="cjs"&&(e===!0||typeof e==="object"&&e.importMetaUrl)&&{"import.meta.url":"importMetaUrl"}}}function xt(t,e){return t===void 0?e==="esm":t}function ht(t){return typeof t==="string"?t:void 0}function bt(t,e){return{name:"bunup:external-plugin",setup(r){r.onResolve({filter:/.*/},(n)=>{let o=n.path;if(t.some((s)=>s.test(o))&&!e.some((s)=>s.test(o)))return{path:o,external:!0};return null})}}}var D={dirnameFilename:{appliesTo:(t,e)=>t==="esm"&&O(e),isNeededInFile:(t)=>/\b__dirname\b/.test(t)||/\b__filename\b/.test(t),generateCode:()=>`import { fileURLToPath } from 'url';
16
16
  import { dirname } from 'path';
17
17
 
18
18
  const __filename = fileURLToPath(import.meta.url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunup",
3
- "version": "0.4.6",
3
+ "version": "0.4.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",
@@ -17,10 +17,10 @@
17
17
  "@commitlint/config-conventional": "^19.5.0",
18
18
  "@types/bun": "^1.2.5",
19
19
  "bumpp": "^10.1.0",
20
- "bunup": "^0.4.1",
20
+ "bunup": "^0.4.7",
21
21
  "husky": "^9.1.7",
22
22
  "typescript": "^5.8.3",
23
- "create-bunup": "0.4.6"
23
+ "create-bunup": "0.4.8"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "typescript": ">=4.5.0"