bunup 0.3.71 → 0.3.72
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
|
@@ -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}),e.push({name:c,path:o})}else e.push({name:s,path:o}),n.add(s),r[s]=o}if(Array.isArray(t))for(let s of t){let o=S(s);i(o,s)}else if(typeof t==="object")for(let[s,o]of Object.entries(t))i(s,o);else{let s=S(t);i(s,t)}return e}function Et(t,e){return`[dir]/${t}${e}`}import{loadTsConfig as ie}from"load-tsconfig";function Ot(t){try{return ie(".",t)}catch(e){return l.warn(`Failed to load tsconfig: ${p(e)}`),{path:t,data:{},files:[]}}}import Z from"node:path";async function vt(t){let e=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let n of e){let r=Z.join(t,`bunup.config${n}`);try{if(!await Bun.file(r).exists())continue;let s=await oe(r,n);if(!s)continue;return{configs:le(s,t),configFilePath:r}}catch(i){throw new x(`Failed to load config from ${r}: ${p(i)}`)}}return{configs:[],configFilePath:""}}async function oe(t,e){if(e===".json"||e===".jsonc")return ae(t);return ce(t)}async function ae(t){try{let e=await Bun.file(t).text(),n=JSON.parse(e);return n.bunup||n}catch(e){throw new Error(`Invalid JSON in config file. ${p(e)}`)}}async function ce(t){try{let e=await import(`file://${t}`),n=e.default||e;if(!n)return l.warn(`No export found in ${t}. Make sure you're exporting your configuration.`),{};return n}catch(e){throw new Error(`Failed to import config file. ${p(e)}`)}}function le(t,e){let n=[];if(ue(t))fe(t,e,n);else if(Array.isArray(t))pe(t,e,n);else if(t&&typeof t==="object")n.push({options:t,rootDir:e});else throw new Error("Invalid configuration format. Expected an object, array, or workspace configuration.");return n}function ue(t){return Array.isArray(t)&&t.length>0&&t.every((e)=>typeof e==="object"&&e!==null&&("name"in e)&&("root"in e)&&("config"in e))}function fe(t,e,n){for(let r of t){let i=Z.resolve(e,r.root);if(Array.isArray(r.config))for(let s of r.config)n.push({options:{name:r.name,...s},rootDir:i});else n.push({options:{name:r.name,...r.config},rootDir:i})}}function pe(t,e,n){for(let r of t){if(!r||typeof r!=="object")throw new Error("Invalid configuration item. Expected an object.");n.push({options:r,rootDir:e})}}async function Rt(t){let e=Z.join(t,"package.json");try{if(!await Bun.file(e).exists())return{packageJson:null,path:e};let r=await Bun.file(e).text();return{packageJson:JSON.parse(r),path:e}}catch(n){return l.warn(`Failed to load package.json at ${e}: ${p(n)}`),{packageJson:null,path:e}}}function Bt(t,e){return{name:"bunup:external-plugin",setup(n){n.onResolve({filter:/.*/},(r)=>{let i=r.path;if(t.some((o)=>o.test(i))&&!e.some((o)=>o.test(i)))return{path:i,external:!0};return null})}}}var R=new Set;async function k(t,e){if(!t.entry||t.entry.length===0||!t.outDir)throw new x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let{packageJson:n,path:r}=await Rt(e);if(n)l.cli(`Using package.json: ${y(r,2)}`,{muted:!0,once:r,identifier:t.name});let i=n?.type,s=j(t,n),o=U(t),a=[Bt(s,o)],c=A(t.entry),u=et(t,e),g=t.format.flatMap((f)=>c.map((h)=>{return ge(t,e,h,f,i,a,u)}));if(await Promise.all(g),t.dts){let f=Ot(t.preferredTsconfigPath);if(f.path)l.cli(`Using tsconfig: ${y(f.path,2)}`,{muted:!0,once:f.path,identifier:t.name});let h=t.format.filter(($)=>{if($==="iife"&&!I(i)&&t.format.includes("cjs"))return!1;return!0}),Lt=typeof t.dts==="object"&&t.dts.entry?A(t.dts.entry):c;try{await Promise.all(Lt.map(async($)=>{let It=await $t(e,$.path,t,f,n);await Promise.all(h.map(async(Dt)=>{let jt=it(Dt,i),H=`${e}/${t.outDir}/${$.name}${jt}`;await Bun.write(H,It);let Ut=Bun.file(H).size||0;l.progress("DTS",y(H),G(Ut),t.name)}))}))}catch($){throw new m(p($))}}}async function ge(t,e,n,r,i,s,o){let a=st(r,i),c=await Bun.build({...o,entrypoints:[`${e}/${n.path}`],format:r,naming:{entry:Et(n.name,a)},splitting:at(t.splitting,r),bytecode:lt(t.bytecode,r),plugins:s,throw:!1});if(!c.success)for(let f of c.logs){if(f.level==="error")throw new x(f.message);if(f.level==="warning")l.warn(f.message);else if(f.level==="info")l.info(f.message)}let u=`${e}/${t.outDir}/${n.name}${a}`,g=Bun.file(u).size||0;l.progress(r.toUpperCase(),y(u),G(g),t.name)}var F="0.3.
|
|
23
|
+
See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),e.push({name:c,path:o})}else e.push({name:s,path:o}),n.add(s),r[s]=o}if(Array.isArray(t))for(let s of t){let o=S(s);i(o,s)}else if(typeof t==="object")for(let[s,o]of Object.entries(t))i(s,o);else{let s=S(t);i(s,t)}return e}function Et(t,e){return`[dir]/${t}${e}`}import{loadTsConfig as ie}from"load-tsconfig";function Ot(t){try{return ie(".",t)}catch(e){return l.warn(`Failed to load tsconfig: ${p(e)}`),{path:t,data:{},files:[]}}}import Z from"node:path";async function vt(t){let e=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let n of e){let r=Z.join(t,`bunup.config${n}`);try{if(!await Bun.file(r).exists())continue;let s=await oe(r,n);if(!s)continue;return{configs:le(s,t),configFilePath:r}}catch(i){throw new x(`Failed to load config from ${r}: ${p(i)}`)}}return{configs:[],configFilePath:""}}async function oe(t,e){if(e===".json"||e===".jsonc")return ae(t);return ce(t)}async function ae(t){try{let e=await Bun.file(t).text(),n=JSON.parse(e);return n.bunup||n}catch(e){throw new Error(`Invalid JSON in config file. ${p(e)}`)}}async function ce(t){try{let e=await import(`file://${t}`),n=e.default||e;if(!n)return l.warn(`No export found in ${t}. Make sure you're exporting your configuration.`),{};return n}catch(e){throw new Error(`Failed to import config file. ${p(e)}`)}}function le(t,e){let n=[];if(ue(t))fe(t,e,n);else if(Array.isArray(t))pe(t,e,n);else if(t&&typeof t==="object")n.push({options:t,rootDir:e});else throw new Error("Invalid configuration format. Expected an object, array, or workspace configuration.");return n}function ue(t){return Array.isArray(t)&&t.length>0&&t.every((e)=>typeof e==="object"&&e!==null&&("name"in e)&&("root"in e)&&("config"in e))}function fe(t,e,n){for(let r of t){let i=Z.resolve(e,r.root);if(Array.isArray(r.config))for(let s of r.config)n.push({options:{name:r.name,...s},rootDir:i});else n.push({options:{name:r.name,...r.config},rootDir:i})}}function pe(t,e,n){for(let r of t){if(!r||typeof r!=="object")throw new Error("Invalid configuration item. Expected an object.");n.push({options:r,rootDir:e})}}async function Rt(t){let e=Z.join(t,"package.json");try{if(!await Bun.file(e).exists())return{packageJson:null,path:e};let r=await Bun.file(e).text();return{packageJson:JSON.parse(r),path:e}}catch(n){return l.warn(`Failed to load package.json at ${e}: ${p(n)}`),{packageJson:null,path:e}}}function Bt(t,e){return{name:"bunup:external-plugin",setup(n){n.onResolve({filter:/.*/},(r)=>{let i=r.path;if(t.some((o)=>o.test(i))&&!e.some((o)=>o.test(i)))return{path:i,external:!0};return null})}}}var R=new Set;async function k(t,e){if(!t.entry||t.entry.length===0||!t.outDir)throw new x("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let{packageJson:n,path:r}=await Rt(e);if(n)l.cli(`Using package.json: ${y(r,2)}`,{muted:!0,once:r,identifier:t.name});let i=n?.type,s=j(t,n),o=U(t),a=[Bt(s,o)],c=A(t.entry),u=et(t,e),g=t.format.flatMap((f)=>c.map((h)=>{return ge(t,e,h,f,i,a,u)}));if(await Promise.all(g),t.dts){let f=Ot(t.preferredTsconfigPath);if(f.path)l.cli(`Using tsconfig: ${y(f.path,2)}`,{muted:!0,once:f.path,identifier:t.name});let h=t.format.filter(($)=>{if($==="iife"&&!I(i)&&t.format.includes("cjs"))return!1;return!0}),Lt=typeof t.dts==="object"&&t.dts.entry?A(t.dts.entry):c;try{await Promise.all(Lt.map(async($)=>{let It=await $t(e,$.path,t,f,n);await Promise.all(h.map(async(Dt)=>{let jt=it(Dt,i),H=`${e}/${t.outDir}/${$.name}${jt}`;await Bun.write(H,It);let Ut=Bun.file(H).size||0;l.progress("DTS",y(H),G(Ut),t.name)}))}))}catch($){throw new m(p($))}}}async function ge(t,e,n,r,i,s,o){let a=st(r,i),c=await Bun.build({...o,entrypoints:[`${e}/${n.path}`],format:r,naming:{entry:Et(n.name,a)},splitting:at(t.splitting,r),bytecode:lt(t.bytecode,r),plugins:s,throw:!1});if(!c.success)for(let f of c.logs){if(f.level==="error")throw new x(f.message);if(f.level==="warning")l.warn(f.message);else if(f.level==="info")l.info(f.message)}let u=`${e}/${t.outDir}/${n.name}${a}`,g=Bun.file(u).size||0;l.progress(r.toUpperCase(),y(u),G(g),t.name)}var F="0.3.72";var Ct="https://bun.sh/docs/installation",Pt="https://bunup.arshadyaseen.com/#cli-options";function b(t){return(e,n)=>{n[t]=e===!0?!0:e==="true"}}function w(t){return(e,n)=>{if(typeof e==="string")n[t]=e;else throw new d(`Option --${t} requires a string value`)}}function Tt(t){return(e,n)=>{if(typeof e==="string")n[t]=e.split(",");else throw new d(`Option --${t} requires a string value`)}}function de(){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${Pt}\x1B[0m
|
|
26
26
|
`),process.exit(0)}function he(){console.log(F),process.exit(0)}var xe={name:{flags:["n","name"],handler:w("name")},format:{flags:["f","format"],handler:(t,e)=>{if(typeof t==="string")e.format=t.split(",");else throw new d("Option --format requires a string value")}},outDir:{flags:["o","out-dir"],handler:w("outDir")},minify:{flags:["m","minify"],handler:b("minify")},watch:{flags:["w","watch"],handler:b("watch")},dts:{flags:["d","dts"],handler:b("dts")},banner:{flags:["b","banner"],handler:w("banner")},footer:{flags:["f","footer"],handler:w("footer")},external:{flags:["e","external"],handler:Tt("external")},sourcemap:{flags:["sm","sourcemap"],handler:w("sourcemap")},target:{flags:["t","target"],handler:w("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:b("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:b("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:b("minifySyntax")},clean:{flags:["c","clean"],handler:b("clean")},splitting:{flags:["s","splitting"],handler:b("splitting")},noExternal:{flags:["ne","no-external"],handler:Tt("noExternal")},preferredTsconfigPath:{flags:["tsconfig","preferred-tsconfig-path"],handler:w("preferredTsconfigPath")},bytecode:{flags:["bc","bytecode"],handler:b("bytecode")}},ye={resolveDts:{flags:["rd","resolve-dts"],handler:(t,e)=>{if(!e.dts)e.dts={};if(typeof e.dts==="boolean")e.dts={};if(typeof t==="string")if(t==="true"||t==="false")e.dts.resolve=t==="true";else e.dts.resolve=t.split(",");else e.dts.resolve=!0}}},be={help:{flags:["h","help"],handler:()=>de()},version:{flags:["v","version"],handler:()=>he()}},M={};for(let t of Object.values(xe))if(t)for(let e of t.flags)M[e]=t.handler;for(let t of Object.values(ye))for(let e of t.flags)M[e]=t.handler;for(let t of Object.values(be))for(let e of t.flags)M[e]=t.handler;function St(t){let e={},n={},r=0;while(r<t.length){let i=t[r];if(i.startsWith("--")){let s,o;if(i.includes("=")){let[a,c]=i.slice(2).split("=",2);s=a,o=c}else{s=i.slice(2);let a=t[r+1];if(o=a&&!a.startsWith("-")?a:!0,typeof o==="string")r++}if(s==="entry")if(typeof o==="string"){let a=S(o);if(n[a])l.warn(`Duplicate entry name '${a}' derived from '${o}'. Overwriting previous entry.`);n[a]=o}else throw new d("Option --entry requires a string value");else if(s.startsWith("entry.")){let a=s.slice(6);if(typeof o==="string"){if(n[a])l.warn(`Duplicate entry name '${a}' provided via --entry.${a}. Overwriting previous entry.`);n[a]=o}else throw new d(`Option --entry.${a} requires a string value`)}else{let a=M[s];if(a)a(o,e);else throw new d(`Unknown option: --${s}`)}}else if(i.startsWith("-")){let s=i.slice(1),o=t[r+1],a=o&&!o.startsWith("-")?o:!0;if(typeof a==="string")r++;let c=M[s];if(c)c(a,e);else throw new d(`Unknown option: -${s}`)}else{let s=S(i);if(n[s])l.warn(`Duplicate entry name '${s}' derived from positional argument '${i}'. Overwriting previous entry.`);n[s]=i}r++}if(Object.keys(n).length>0)e.entry=n;return e}(()=>{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.3.
|
|
3
|
+
"version": "0.3.72",
|
|
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",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"husky": "^9.1.7",
|
|
22
22
|
"typescript": "^5.8.3",
|
|
23
23
|
"vitest": "^2.1.9",
|
|
24
|
-
"create-bunup": "0.3.
|
|
24
|
+
"create-bunup": "0.3.72"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"typescript": ">=4.5.0"
|