bunup 0.3.64 → 0.3.65
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 +1 -1
- package/package.json +2 -2
package/build/cli.mjs
CHANGED
|
@@ -34,7 +34,7 @@ To fix this, use named entries in your configuration:
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),n.push({name:c,path:o})}else n.push({name:i,path:o}),e.add(i),s[i]=o}if(Array.isArray(t))for(let i of t){let o=M(i);r(o,i)}else if(typeof t==="object")Object.entries(t).forEach(([i,o])=>{r(i,o)});else{let i=M(t);r(i,t)}return n}function Ot(t,n){return`[dir]/${t}${n}`}import{loadTsConfig as tn}from"load-tsconfig";function vt(t){try{return tn(".",t)}catch(n){return l.warn(`Failed to load tsconfig: ${p(n)}`),{path:t,data:{},files:[]}}}import Z from"node:path";async function Ct(t){let n=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let e of n){let s=Z.join(t,`bunup.config${e}`);try{if(!await Bun.file(s).exists())continue;let i=await nn(s,e);if(!i)continue;return{configs:rn(i,t),configFilePath:s}}catch(r){throw new b(`Failed to load config from ${s}: ${p(r)}`)}}return{configs:[],configFilePath:""}}async function nn(t,n){if(n===".json"||n===".jsonc")return en(t);return sn(t)}async function en(t){try{let n=await Bun.file(t).text(),e=JSON.parse(n);return e.bunup||e}catch(n){throw new Error(`Invalid JSON in config file. ${p(n)}`)}}async function sn(t){try{let n=await import(`file://${t}`),e=n.default||n;if(!e)return l.warn(`No export found in ${t}. Make sure you're exporting your configuration.`),{};return e}catch(n){throw new Error(`Failed to import config file. ${p(n)}`)}}function rn(t,n){let e=[];if(on(t))an(t,n,e);else if(Array.isArray(t))cn(t,n,e);else if(t&&typeof t==="object")e.push({options:t,rootDir:n});else throw new Error("Invalid configuration format. Expected an object, array, or workspace configuration.");return e}function on(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 an(t,n,e){for(let s of t){let r=Z.resolve(n,s.root);if(Array.isArray(s.config))for(let i of s.config)e.push({options:{name:s.name,...i},rootDir:r});else e.push({options:{name:s.name,...s.config},rootDir:r})}}function cn(t,n,e){for(let s of t){if(!s||typeof s!=="object")throw new Error("Invalid configuration item. Expected an object.");e.push({options:s,rootDir:n})}}async function Et(t){let n=Z.join(t,"package.json");try{if(!await Bun.file(n).exists())return{packageJson:null,path:n};let s=await Bun.file(n).text();return{packageJson:JSON.parse(s),path:n}}catch(e){return l.warn(`Failed to load package.json at ${n}: ${p(e)}`),{packageJson:null,path:n}}}function Pt(t,n){return{name:"bunup:external-plugin",setup(e){e.onResolve({filter:/.*/},(s)=>{let r=s.path;if(t.some((o)=>o.test(r))&&!n.some((o)=>o.test(r)))return{path:r,external:!0};return null})}}}var E=new Set;async function F(t,n){if(!t.entry||t.entry.length===0||!t.outDir)throw new b("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let{packageJson:e,path:s}=await Et(n);if(e)l.cli(`Using package.json: ${x(s,2)}`,{muted:!0,once:s,identifier:t.name});let r=e?.type,i=_(t,e),o=D(t),a=[Pt(i,o)],c=B(t.entry),f=nt(t,n),g=t.format.flatMap((u)=>c.map((h)=>{return ln(t,n,h,u,r,a,f)}));if(await Promise.all(g),t.dts){let u=vt(t.preferredTsconfigPath);if(u.path)l.cli(`Using tsconfig: ${x(u.path,2)}`,{muted:!0,once:u.path,identifier:t.name});let h=t.format.filter(($)=>{if($==="iife"&&!L(r)&&t.format.includes("cjs"))return!1;return!0}),Tt=typeof t.dts==="object"&&t.dts.entry?B(t.dts.entry):c;try{await Promise.all(Tt.map(async($)=>{let Lt=await $t(n,$.path,t,u,e);await Promise.all(h.map(async(jt)=>{let _t=rt(jt,r),k=`${n}/${t.outDir}/${$.name}${_t}`;await Bun.write(k,Lt);let Dt=Bun.file(k).size||0;l.progress("DTS",x(k),G(Dt),t.name)}))}))}catch($){throw new d(p($))}}}async function ln(t,n,e,s,r,i,o){let a=it(s,r),c=await Bun.build({...o,entrypoints:[`${n}/${e.path}`],format:s,naming:{entry:Ot(e.name,a)},splitting:at(t.splitting,s),bytecode:lt(t.bytecode,s),plugins:i,throw:!1});if(!c.success)c.logs.forEach((u)=>{if(u.level==="error")throw new b(u.message);else if(u.level==="warning")l.warn(u.message);else if(u.level==="info")l.info(u.message)});let f=`${n}/${t.outDir}/${e.name}${a}`,g=Bun.file(f).size||0;l.progress(s.toUpperCase(),x(f),G(g),t.name)}var H="0.3.
|
|
37
|
+
See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),n.push({name:c,path:o})}else n.push({name:i,path:o}),e.add(i),s[i]=o}if(Array.isArray(t))for(let i of t){let o=M(i);r(o,i)}else if(typeof t==="object")Object.entries(t).forEach(([i,o])=>{r(i,o)});else{let i=M(t);r(i,t)}return n}function Ot(t,n){return`[dir]/${t}${n}`}import{loadTsConfig as tn}from"load-tsconfig";function vt(t){try{return tn(".",t)}catch(n){return l.warn(`Failed to load tsconfig: ${p(n)}`),{path:t,data:{},files:[]}}}import Z from"node:path";async function Ct(t){let n=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let e of n){let s=Z.join(t,`bunup.config${e}`);try{if(!await Bun.file(s).exists())continue;let i=await nn(s,e);if(!i)continue;return{configs:rn(i,t),configFilePath:s}}catch(r){throw new b(`Failed to load config from ${s}: ${p(r)}`)}}return{configs:[],configFilePath:""}}async function nn(t,n){if(n===".json"||n===".jsonc")return en(t);return sn(t)}async function en(t){try{let n=await Bun.file(t).text(),e=JSON.parse(n);return e.bunup||e}catch(n){throw new Error(`Invalid JSON in config file. ${p(n)}`)}}async function sn(t){try{let n=await import(`file://${t}`),e=n.default||n;if(!e)return l.warn(`No export found in ${t}. Make sure you're exporting your configuration.`),{};return e}catch(n){throw new Error(`Failed to import config file. ${p(n)}`)}}function rn(t,n){let e=[];if(on(t))an(t,n,e);else if(Array.isArray(t))cn(t,n,e);else if(t&&typeof t==="object")e.push({options:t,rootDir:n});else throw new Error("Invalid configuration format. Expected an object, array, or workspace configuration.");return e}function on(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 an(t,n,e){for(let s of t){let r=Z.resolve(n,s.root);if(Array.isArray(s.config))for(let i of s.config)e.push({options:{name:s.name,...i},rootDir:r});else e.push({options:{name:s.name,...s.config},rootDir:r})}}function cn(t,n,e){for(let s of t){if(!s||typeof s!=="object")throw new Error("Invalid configuration item. Expected an object.");e.push({options:s,rootDir:n})}}async function Et(t){let n=Z.join(t,"package.json");try{if(!await Bun.file(n).exists())return{packageJson:null,path:n};let s=await Bun.file(n).text();return{packageJson:JSON.parse(s),path:n}}catch(e){return l.warn(`Failed to load package.json at ${n}: ${p(e)}`),{packageJson:null,path:n}}}function Pt(t,n){return{name:"bunup:external-plugin",setup(e){e.onResolve({filter:/.*/},(s)=>{let r=s.path;if(t.some((o)=>o.test(r))&&!n.some((o)=>o.test(r)))return{path:r,external:!0};return null})}}}var E=new Set;async function F(t,n){if(!t.entry||t.entry.length===0||!t.outDir)throw new b("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let{packageJson:e,path:s}=await Et(n);if(e)l.cli(`Using package.json: ${x(s,2)}`,{muted:!0,once:s,identifier:t.name});let r=e?.type,i=_(t,e),o=D(t),a=[Pt(i,o)],c=B(t.entry),f=nt(t,n),g=t.format.flatMap((u)=>c.map((h)=>{return ln(t,n,h,u,r,a,f)}));if(await Promise.all(g),t.dts){let u=vt(t.preferredTsconfigPath);if(u.path)l.cli(`Using tsconfig: ${x(u.path,2)}`,{muted:!0,once:u.path,identifier:t.name});let h=t.format.filter(($)=>{if($==="iife"&&!L(r)&&t.format.includes("cjs"))return!1;return!0}),Tt=typeof t.dts==="object"&&t.dts.entry?B(t.dts.entry):c;try{await Promise.all(Tt.map(async($)=>{let Lt=await $t(n,$.path,t,u,e);await Promise.all(h.map(async(jt)=>{let _t=rt(jt,r),k=`${n}/${t.outDir}/${$.name}${_t}`;await Bun.write(k,Lt);let Dt=Bun.file(k).size||0;l.progress("DTS",x(k),G(Dt),t.name)}))}))}catch($){throw new d(p($))}}}async function ln(t,n,e,s,r,i,o){let a=it(s,r),c=await Bun.build({...o,entrypoints:[`${n}/${e.path}`],format:s,naming:{entry:Ot(e.name,a)},splitting:at(t.splitting,s),bytecode:lt(t.bytecode,s),plugins:i,throw:!1});if(!c.success)c.logs.forEach((u)=>{if(u.level==="error")throw new b(u.message);else if(u.level==="warning")l.warn(u.message);else if(u.level==="info")l.info(u.message)});let f=`${n}/${t.outDir}/${e.name}${a}`,g=Bun.file(f).size||0;l.progress(s.toUpperCase(),x(f),G(g),t.name)}var H="0.3.65";var Rt="https://bun.sh/docs/installation",At="https://bunup.arshadyaseen.com/#cli-options";function w(t){return(n,e)=>{e[t]=n===!0?!0:n==="true"}}function y(t){return(n,e)=>{if(typeof n==="string")e[t]=n;else throw new m(`Option --${t} requires a string value`)}}function It(t){return(n,e)=>{if(typeof n==="string")e[t]=n.split(",");else throw new m(`Option --${t} requires a string value`)}}function un(){console.log(`
|
|
38
38
|
Bunup - An extremely fast, zero-config bundler for JavaScript and TypeScript, powered by Bun.
|
|
39
39
|
`),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${At}\x1B[0m
|
|
40
40
|
`),process.exit(0)}function pn(){console.log(H),process.exit(0)}var gn={name:{flags:["n","name"],handler:y("name")},format:{flags:["f","format"],handler:(t,n)=>{if(typeof t==="string")n.format=t.split(",");else throw new m("Option --format requires a string value")}},outDir:{flags:["o","out-dir"],handler:y("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:y("banner")},footer:{flags:["f","footer"],handler:y("footer")},external:{flags:["e","external"],handler:It("external")},sourcemap:{flags:["sm","sourcemap"],handler:y("sourcemap")},target:{flags:["t","target"],handler:y("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:It("noExternal")},preferredTsconfigPath:{flags:["tsconfig","preferred-tsconfig-path"],handler:y("preferredTsconfigPath")},bytecode:{flags:["bc","bytecode"],handler:w("bytecode")}},dn={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:()=>un()},version:{flags:["v","version"],handler:()=>pn()}},S={};for(let t of Object.values(gn))if(t)for(let n of t.flags)S[n]=t.handler;for(let t of Object.values(dn))for(let n of t.flags)S[n]=t.handler;for(let t of Object.values(mn))for(let n of t.flags)S[n]=t.handler;function Mt(t){let n={},e={},s=0;while(s<t.length){let r=t[s];if(r.startsWith("--")){let i,o;if(r.includes("=")){let[a,c]=r.slice(2).split("=",2);i=a,o=c}else{i=r.slice(2);let a=t[s+1];if(o=a&&!a.startsWith("-")?a:!0,typeof o==="string")s++}if(i==="entry")if(typeof o==="string"){let a=M(o);if(e[a])l.warn(`Duplicate entry name '${a}' derived from '${o}'. Overwriting previous entry.`);e[a]=o}else throw new m("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 m(`Option --entry.${a} requires a string value`)}else{let a=S[i];if(a)a(o,n);else throw new m(`Unknown option: --${i}`)}}else if(r.startsWith("-")){let i=r.slice(1),o=t[s+1],a=o&&!o.startsWith("-")?o:!0;if(typeof a==="string")s++;let c=S[i];if(c)c(a,n);else throw new m(`Unknown option: -${i}`)}else{let i=M(r);if(e[i])l.warn(`Duplicate entry name '${i}' derived from positional argument '${r}'. Overwriting previous entry.`);e[i]=r}s++}if(Object.keys(e).length>0)n.entry=e;return n}(()=>{if(typeof Bun==="undefined")throw new m(`Bunup requires Bun to run.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunup",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.65",
|
|
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.
|
|
27
|
+
"create-bunup": "0.3.65"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"typescript": ">=4.5.0"
|