bunup 0.3.55 → 0.3.56
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 +12 -12
- package/package.json +2 -2
package/build/cli.mjs
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{build as
|
|
3
|
+
import{build as Xt}from"rolldown";import{dts as vt}from"rolldown-plugin-types";class y extends Error{constructor(t){super(t);this.name="BunupError"}}class h extends y{constructor(t){super(t);this.name="BunupBuildError"}}class d extends y{constructor(t){super(t);this.name="BunupDTSBuildError"}}class g extends y{constructor(t){super(t);this.name="BunupCLIError"}}class S extends y{constructor(t){super(t);this.name="BunupWatchError"}}var p=(t)=>{if(t instanceof Error)return t.message;return String(t)},v=(t,n)=>{let s=p(t),e=n?`[${n}] `:"",r="ERROR";if(t instanceof h)r="BUILD ERROR";else if(t instanceof d)r="DTS ERROR";else if(t instanceof g)r="CLI ERROR";else if(t instanceof S)r="WATCH ERROR";else if(t instanceof y)r="BUNUP ERROR";if(console.error(`\x1B[31m${r}\x1B[0m ${e}${s}`),t instanceof Error&&t.stack)console.error("\x1B[2m"+t.stack.split(`
|
|
4
4
|
`).slice(1).join(`
|
|
5
|
-
`)+"\x1B[0m")},tt=(t,n)=>{
|
|
6
|
-
`);let
|
|
5
|
+
`)+"\x1B[0m")},tt=(t,n)=>{v(t,n),process.exit(1)};import st from"node:fs/promises";import Ft from"node:path";var R={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function nt(t,n){return{outdir:`${n}/${t.outDir}`,minify:Ut(t),target:t.target,splitting:t.splitting,sourcemap:t.sourcemap,define:t.define,loader:t.loader,drop:t.drop,banner:t.banner,footer:t.footer}}function Ut(t){let{minify:n,minifyWhitespace:s,minifyIdentifiers:e,minifySyntax:r}=t,i=n===!0;return{whitespace:s??i,identifiers:e??i,syntax:r??i}}function Y(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function et(t=8){return Math.random().toString(36).substring(2,2+t)}function rt(t,n){switch(t){case"esm":return".mjs";case"cjs":return D(n)?".cjs":".js";case"iife":return".global.js"}}function it(t,n){switch(t){case"esm":return".d.mts";case"cjs":return D(n)?".d.cts":".d.ts";case"iife":return".d.ts"}}function D(t){return t==="module"}function L(t){return t>=1000?`${(t/1000).toFixed(2)}s`:`${Math.round(t)}ms`}function ot(t){if(!t)return[];return Array.from(new Set([...Object.keys(t.dependencies||{}),...Object.keys(t.peerDependencies||{})]))}function ct(t,n){return t===void 0?n==="esm":t}function J(t){if(t===0)return"0 B";let n=["B","KB","MB","GB"],s=Math.floor(Math.log(t)/Math.log(1024));if(s===0)return`${t} ${n[s]}`;return`${(t/Math.pow(1024,s)).toFixed(2)} ${n[s]}`}function b(t,n=3){return t.split("/").slice(-n).join("/")}async function q(t,n){let s=Ft.join(t,n);try{await st.rm(s,{recursive:!0,force:!0})}catch(e){throw new h(`Failed to clean output directory: ${e}`)}await st.mkdir(s,{recursive:!0})}function K(t){return t||R.outDir}function ut(t){return t===void 0?R.clean:t}function at(t){return t.map((n)=>typeof n==="string"?new RegExp(`^${Y(n)}($|\\/|\\\\)`):n)}function _(t,n){return at(t.external||[]).concat(ot(n).map((s)=>new RegExp(`^${Y(s)}($|\\/|\\\\)`)))}function U(t){return at(t.noExternal||[])}import Gt from"node:path";import{ResolverFactory as Vt}from"oxc-resolver";import B from"node:path";var O="\x00dts:",ft=(t,n,s)=>{return{name:"bunup:virtual-dts",async resolveId(e,r){if(Q(e))return e;if(!r||!Q(r))return null;let i=await F(e,n,s,T(r));if(!i)return null;let o=C(i);if(t.has(o))return N(o);return null},load(e){if(e.startsWith(O)){let r=T(e),i=t.get(r);if(i)return M.add(r),i}return null}}};function C(t){return t.replace(/\.tsx?$/,".d.ts")}function Z(t){let n=B.dirname(t.path||"");return t.data?.compilerOptions?.baseUrl?B.resolve(n,t.data.compilerOptions.baseUrl):n}function lt(t){let n=new Map,s=t.data?.compilerOptions?.paths;if(!s)return n;let e=Z(t);for(let[r,i]of Object.entries(s))if(Array.isArray(i)&&i.length){let o=r.replace(/\*/g,"(.*)"),c=i[0].replace(/\*/g,"$1");n.set(`^${o}$`,B.join(e,c))}return n}function Nt(t,n,s){for(let[e,r]of n){let i=new RegExp(e),o=t.match(i);if(o)return r.replace("$1",o[1]||"")}return s?B.join(s,t):null}async function Wt(t){let n=["",".ts",".tsx","/index.ts","/index.tsx"];for(let s of n){let e=`${t}${s}`;if(await Bun.file(e).exists()&&(e.endsWith(".ts")||e.endsWith(".tsx")))return e}return null}function F(t,n,s,e){let r=t.startsWith(".")?B.resolve(B.dirname(e||""),t):Nt(t,n,s);if(!r)return Promise.resolve(null);return Wt(r)}function Q(t){return t.startsWith(O)}function T(t){return t.replace(O,"")}function N(t){return`${O}${t}`}var pt;function mt(t){return{name:"bunup:types-resolve",buildStart(){pt||=new Vt({mainFields:["types"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".ts"],modules:["node_modules","node_modules/@types"]})},async resolveId(n,s){if(s=s?T(s):void 0,/\0/.test(n))return;if(t){if(!t.some((o)=>{let c=!1;if(typeof o==="string")c=o===n||!!(s&&s.includes(o));else c=o.test(n)||!!(s&&o.test(s));return c}))return}let e=s?Gt.dirname(s):process.cwd(),{path:r}=await pt.async(e,n);if(!r)return;if(/[cm]?jsx?$/.test(r)){let i=r.replace(/\.([cm]?)jsx?$/,".d.$1ts");return await Bun.file(i).exists()?i:void 0}return r}}}async function dt(t,n,s,e,r,i){let o=C(t),c=N(o),u=_(s,e),f=U(s);try{let{output:m}=await Xt({input:c,output:{dir:s.outDir,inlineDynamicImports:!0},write:!1,onwarn(l,x){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(l.code??""))return;x(l)},plugins:[ft(n,r,i),typeof s.dts==="object"&&"resolve"in s.dts&&mt(typeof s.dts.resolve==="boolean"?void 0:s.dts.resolve),vt()],external:(l)=>u.some((x)=>x.test(l))&&!f.some((x)=>x.test(l))});if(!m[0]?.code)throw new d("Generated bundle is empty");return m[0].code}catch(m){throw new d(`DTS bundling failed: ${p(m)}`)}}class P{static instance;loggedOnceMessages=new Set;MAX_LABEL_LENGTH=3;MAX_MESSAGE_LENGTH=25;colors={cli:"147",info:"245",warn:"179",error:"174",progress:{ESM:"172",CJS:"108",IIFE:"146",DTS:"110"},default:"252",size:"65"};labels={cli:"CLI",info:"INFO",warn:"WARN",error:"ERROR"};constructor(){}static getInstance(){if(!P.instance)P.instance=new P;return P.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(t){if(!t?.once)return!0;if(this.loggedOnceMessages.has(t.once))return!1;return this.loggedOnceMessages.add(t.once),!0}formatMessage({colorCode:t,label:n,message:s,size:e,identifier:r,muted:i}){let o=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-n.length)),c=i?`\x1B[38;5;${this.colors.info}m${s}\x1B[0m`:s;if(e){let[f,...m]=c.split(" "),l=" ".repeat(Math.max(0,this.MAX_MESSAGE_LENGTH-f.length)),x=r?` \x1B[48;5;${t};38;5;0m ${r} \x1B[0m`:"";return`\x1B[38;5;${t}m${n}\x1B[0m ${o}${f}${l} \x1B[38;5;${this.colors.size}m${e}\x1B[0m ${m.join(" ")}${x}`}let u=r?` \x1B[48;5;${t};38;5;0m ${r} \x1B[0m`:"";return`\x1B[38;5;${t}m${n}\x1B[0m ${o}${c}${u}`}output(t,n={},s=console.log){if(!this.shouldLog(n))return;if(n.verticalSpace)console.log("");if(s(t),n.verticalSpace)console.log("")}cli(t,n={}){let s=this.formatMessage({colorCode:this.colors.cli,label:this.labels.cli,message:t,identifier:n.identifier,muted:n.muted});this.output(s,n)}info(t,n={}){let s=this.formatMessage({colorCode:this.colors.info,label:this.labels.info,message:t,identifier:n.identifier,muted:n.muted});this.output(s,n)}warn(t,n={}){let s=this.formatMessage({colorCode:this.colors.warn,label:this.labels.warn,message:t,identifier:n.identifier,muted:n.muted});this.output(s,n,console.warn)}error(t,n={}){let s=this.formatMessage({colorCode:this.colors.error,label:this.labels.error,message:t,identifier:n.identifier,muted:n.muted});this.output(s,n,console.error)}progress(t,n,s,e){let r=String(t),i=this.colors.default,o,c,u={};if(typeof s==="string")o=s,c=e;else if(s)o=s.size,c=s.identifier,u=s;for(let[m,l]of Object.entries(this.colors.progress))if(r.includes(m)){i=l;break}let f=this.formatMessage({colorCode:i,label:r,message:n,size:o,identifier:c,muted:u.muted});this.output(f,u)}}var a=P.getInstance();var Yt=/(?:import|export)(?:[\s\n]*(?:type[\s\n]+)?(?:\*|\{[^}]*\}|[\w$]+)[\s\n]+from[\s\n]*|[\s\n]+)(["'`])([^'"]+)\1/g,Jt=/import\s*\(\s*(["'`])([^'"]+)\1\s*\)/g;async function gt(t,n,s){let e=new Set([t]),r=[t];while(r.length){let i=r.pop();if(!i)continue;try{let o=await Bun.file(i).text(),c=qt(o);for(let u of c){let f=await F(u,n,s,i);if(!f)continue;if(!e.has(f))e.add(f),r.push(f)}}catch(o){a.warn(`Error processing ${i}: ${p(o)}`)}}return e}function qt(t){let n=new Set;for(let s of[Yt,Jt]){let e;while((e=s.exec(t))!==null)n.add(e[2])}return Array.from(n)}import{isolatedDeclaration as Kt}from"oxc-transform";async function xt(t){let n=new Map;return await Promise.all([...t].map(async(s)=>{try{let e=C(s);if(!await Bun.file(s).exists())return;let i=await Bun.file(s).text(),{code:o}=Kt(s,i);if(o)n.set(e,o)}catch(e){a.warn(`Failed to generate declaration for ${s}: ${p(e)}`)}})),n}import ht from"node:fs/promises";import z from"node:path";import{isolatedDeclaration as Qt}from"oxc-transform";async function bt(t,n){let s=z.resolve(t),e=z.resolve(s,n);if(!await ht.exists(s))throw new d(`Root directory does not exist: ${s}`);if(!await Bun.file(e).exists())throw new d(`Entry file does not exist: ${e}`);if(!e.endsWith(".ts"))throw new d(`Entry file must be a TypeScript file (.ts): ${e}`);if(z.relative(s,e).startsWith(".."))throw new d(`Entry file must be within rootDir: ${e}`);return{absoluteRootDir:s,absoluteEntry:e}}async function wt(t){let n=!1;if(await Promise.all([...t].map(async(s)=>{try{let e=s.replace(/\.d\.ts$/,".ts"),r=await Bun.file(e).text(),{errors:i}=Qt(e,r);i.forEach((o)=>{if(!n)console.log(`
|
|
6
|
+
`);let c=o.labels[0],u=c?Zt(r,c.start):"",m=`${b(e)}${u}: ${zt(o.message)}`;a.warn(m),n=!0})}catch{}})),n)a.info(`
|
|
7
7
|
You may have noticed some TypeScript warnings above related to missing type annotations. This is because Bunup uses TypeScript's "isolatedDeclarations" approach for generating declaration files. This modern approach requires explicit type annotations on exports for better, more accurate type declarations. Other bundlers might not show these warnings because they use different, potentially less precise methods. Adding the suggested type annotations will not only silence these warnings but also improve the quality of your published type definitions, making your library more reliable for consumers.
|
|
8
|
-
`)}function
|
|
9
|
-
`),
|
|
8
|
+
`)}function Zt(t,n){if(n===void 0)return"";let s=t.slice(0,n).split(`
|
|
9
|
+
`),e=s.length,r=s[s.length-1].length+1;return` (${e}:${r})`}function zt(t){return t.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}async function $t(t,n,s,e,r){let{absoluteEntry:i}=await bt(t,n),o=lt(e),c=Z(e),u=await gt(i,o,c),f=await xt(u);return dt(i,f,s,r,o,c)}function A(t){return t.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function j(t){let n=[],s=new Set,e={};function r(i,o){if(s.has(i)){let c=et(),u=`${i}_${c}`;a.warn(`Output name conflict: "${i}" is used by multiple files.
|
|
10
10
|
Bunup uses filenames without extensions as output names by default.
|
|
11
11
|
|
|
12
|
-
${
|
|
13
|
-
${o} -> ${
|
|
12
|
+
${e[i]} -> ${i}.js
|
|
13
|
+
${o} -> ${u}.js (auto-renamed to avoid conflict)
|
|
14
14
|
|
|
15
15
|
To fix this, use named entries in your configuration:
|
|
16
16
|
{
|
|
17
17
|
entry: {
|
|
18
|
-
custom_name: "${
|
|
18
|
+
custom_name: "${e[i]}",
|
|
19
19
|
another_name: "${o}"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),n.push({name:
|
|
23
|
+
See: https://bunup.arshadyaseen.com/#named-entries`,{muted:!0,verticalSpace:!0}),n.push({name:u,path:o})}else n.push({name:i,path:o}),s.add(i),e[i]=o}if(Array.isArray(t))for(let i of t){let o=A(i);r(o,i)}else if(typeof t==="object")Object.entries(t).forEach(([i,o])=>{r(i,o)});else{let i=A(t);r(i,t)}return n}function Et(t,n){return`[dir]/${t}${n}`}import{loadTsConfig as Ht}from"load-tsconfig";function yt(t){try{return Ht(".",t)}catch(n){return a.warn(`Failed to load tsconfig: ${p(n)}`),{path:t,data:{},files:[]}}}import H from"node:path";async function Rt(t){let n=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"];for(let s of n){let e=H.join(t,`bunup.config${s}`);try{if(!await Bun.file(e).exists())continue;let i=await kt(e,s);if(!i)continue;return{configs:sn(i,t),configFilePath:e}}catch(r){throw new h(`Failed to load config from ${e}: ${p(r)}`)}}return{configs:[],configFilePath:""}}async function kt(t,n){if(n===".json"||n===".jsonc")return tn(t);return nn(t)}async function tn(t){try{let n=await Bun.file(t).text(),s=JSON.parse(n);return s.bunup||s}catch(n){throw new Error(`Invalid JSON in config file. ${p(n)}`)}}async function nn(t){try{let n=await import(`file://${t}`),s=n.default||n;if(!s)return a.warn(`No export found in ${t}. Make sure you're exporting your configuration.`),{};return s}catch(n){throw new Error(`Failed to import config file. ${p(n)}`)}}function sn(t,n){let s=[];if(en(t))rn(t,n,s);else if(Array.isArray(t))on(t,n,s);else if(t&&typeof t==="object")s.push({options:t,rootDir:n});else throw new Error("Invalid configuration format. Expected an object, array, or workspace configuration.");return s}function en(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 rn(t,n,s){for(let e of t){let r=H.resolve(n,e.root);if(Array.isArray(e.config))for(let i of e.config)s.push({options:{name:e.name,...i},rootDir:r});else s.push({options:{name:e.name,...e.config},rootDir:r})}}function on(t,n,s){for(let e of t){if(!e||typeof e!=="object")throw new Error("Invalid configuration item. Expected an object.");s.push({options:e,rootDir:n})}}async function Ct(t){let n=H.join(t,"package.json");try{if(!await Bun.file(n).exists())return{packageJson:null,path:n};let e=await Bun.file(n).text();return{packageJson:JSON.parse(e),path:n}}catch(s){return a.warn(`Failed to load package.json at ${n}: ${p(s)}`),{packageJson:null,path:n}}}function Mt(t,n){return{name:"bunup:external-plugin",setup(s){s.onResolve({filter:/.*/},(e)=>{let r=e.path;if(t.some((o)=>o.test(r))&&!n.some((o)=>o.test(r)))return{path:r,external:!0};return null})}}}var M=new Set;async function W(t,n){if(!t.entry||t.entry.length===0||!t.outDir)throw new h("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let{packageJson:s,path:e}=await Ct(n);if(s)a.cli(`Using package.json: ${b(e,2)}`,{muted:!0,once:e,identifier:t.name});let r=s?.type,i=_(t,s),o=U(t),c=[Mt(i,o)],u=j(t.entry),f=nt(t,n),m=t.format.flatMap((l)=>u.map((x)=>{return cn(t,n,x,l,r,c,f)}));if(await Promise.all(m),t.dts){let l=yt(t.preferredTsconfigPath);if(l.path)a.cli(`Using tsconfig: ${b(l.path,2)}`,{muted:!0,once:l.path,identifier:t.name});let x=t.format.filter((E)=>{if(E==="iife"&&!D(r)&&t.format.includes("cjs"))return!1;return!0}),It=typeof t.dts==="object"&&t.dts.entry?j(t.dts.entry):u;try{await Promise.all(It.map(async(E)=>{let St=await $t(n,E.path,t,l,s);await Promise.all(x.map(async(Dt)=>{let Lt=it(Dt,r),X=`${n}/${t.outDir}/${E.name}${Lt}`;await Bun.write(X,St);let _t=Bun.file(X).size||0;a.progress("DTS",b(X),J(_t),t.name)}))}))}catch(E){throw new d(p(E))}}}async function cn(t,n,s,e,r,i,o){let c=rt(e,r),u=await Bun.build({...o,entrypoints:[`${n}/${s.path}`],format:e,naming:{entry:Et(s.name,c)},splitting:ct(t.splitting,e),plugins:i,throw:!1});if(!u.success)u.logs.forEach((l)=>{if(l.level==="error")throw new h(l.message);else if(l.level==="warning")a.warn(l.message);else if(l.level==="info")a.info(l.message)});let f=`${n}/${t.outDir}/${s.name}${c}`,m=Bun.file(f).size||0;a.progress(e.toUpperCase(),b(f),J(m),t.name)}var G="0.3.56";var Bt="https://bun.sh/docs/installation",Pt="https://bunup.arshadyaseen.com/#cli-options";function w(t){return(n,s)=>{s[t]=n===!0?!0:n==="true"}}function $(t){return(n,s)=>{if(typeof n==="string")s[t]=n;else throw new g(`Option --${t} requires a string value`)}}function Tt(t){return(n,s)=>{if(typeof n==="string")s[t]=n.split(",");else throw new g(`Option --${t} requires a string value`)}}function an(){console.log(`
|
|
24
24
|
Bunup - An extremely fast, zero-config bundler for JavaScript and TypeScript, powered by Bun.
|
|
25
|
-
`),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${
|
|
26
|
-
`),process.exit(0)}function
|
|
27
|
-
To install Bun, visit `+Bt)})();import
|
|
25
|
+
`),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${Pt}\x1B[0m
|
|
26
|
+
`),process.exit(0)}function fn(){console.log(G),process.exit(0)}var ln={name:{flags:["n","name"],handler:$("name")},format:{flags:["f","format"],handler:(t,n)=>{if(typeof t==="string")n.format=t.split(",");else throw new g("Option --format requires a string value")}},outDir:{flags:["o","out-dir"],handler:$("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:$("banner")},footer:{flags:["f","footer"],handler:$("footer")},external:{flags:["e","external"],handler:Tt("external")},sourcemap:{flags:["sm","sourcemap"],handler:$("sourcemap")},target:{flags:["t","target"],handler:$("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:Tt("noExternal")},preferredTsconfigPath:{flags:["tsconfig","preferred-tsconfig-path"],handler:$("preferredTsconfigPath")}},pn={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:()=>an()},version:{flags:["v","version"],handler:()=>fn()}},I={};for(let t of Object.values(ln))if(t)for(let n of t.flags)I[n]=t.handler;for(let t of Object.values(pn))for(let n of t.flags)I[n]=t.handler;for(let t of Object.values(mn))for(let n of t.flags)I[n]=t.handler;function Ot(t){let n={},s={},e=0;while(e<t.length){let r=t[e];if(r.startsWith("--")){let i,o;if(r.includes("=")){let[c,u]=r.slice(2).split("=",2);i=c,o=u}else{i=r.slice(2);let c=t[e+1];if(o=c&&!c.startsWith("-")?c:!0,typeof o==="string")e++}if(i==="entry")if(typeof o==="string"){let c=A(o);if(s[c])a.warn(`Duplicate entry name '${c}' derived from '${o}'. Overwriting previous entry.`);s[c]=o}else throw new g("Option --entry requires a string value");else if(i.startsWith("entry.")){let c=i.slice(6);if(typeof o==="string"){if(s[c])a.warn(`Duplicate entry name '${c}' provided via --entry.${c}. Overwriting previous entry.`);s[c]=o}else throw new g(`Option --entry.${c} requires a string value`)}else{let c=I[i];if(c)c(o,n);else throw new g(`Unknown option: --${i}`)}}else if(r.startsWith("-")){let i=r.slice(1),o=t[e+1],c=o&&!o.startsWith("-")?o:!0;if(typeof c==="string")e++;let u=I[i];if(u)u(c,n);else throw new g(`Unknown option: -${i}`)}else{let i=A(r);if(s[i])a.warn(`Duplicate entry name '${i}' derived from positional argument '${r}'. Overwriting previous entry.`);s[i]=r}e++}if(Object.keys(s).length>0)n.entry=s;return n}(()=>{if(typeof Bun==="undefined")throw new g(`Bunup requires Bun to run.
|
|
27
|
+
To install Bun, visit `+Bt)})();import V from"node:path";import dn from"chokidar";async function At(t,n){let s=new Set,e=j(t.entry);e.forEach((c)=>{let u=V.resolve(n,c.path),f=V.dirname(u);s.add(f)});let r=dn.watch(Array.from(s),{persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50},ignoreInitial:!0,atomic:!0,ignorePermissionErrors:!0,ignored:[/[\\/]\.git[\\/]/,/[\\/]node_modules[\\/]/,V.join(n,t.outDir)]}),i=!1,o=async(c=!1)=>{if(i)return;i=!0;try{let u=performance.now();if(await W({...t,entry:e.map((f)=>f.path),clean:!1},n),t.onBuildSuccess?.(),!c)a.cli(`\uD83D\uDCE6 Rebuild finished in ${L(performance.now()-u)}`);await k()}catch(u){v(u)}finally{i=!1}};r.on("change",(c)=>{let u=V.relative(n,c);a.cli(`File changed: ${u}`,{muted:!0}),o()}),r.on("error",(c)=>{throw new S(`Watcher error: ${p(c)}`)}),await o(!0)}async function gn(t=Bun.argv.slice(2)){let n=Ot(t),{configs:s,configFilePath:e}=await Rt(process.cwd());if(a.cli(`Using bunup v${G} and bun v${Bun.version}`,{muted:!0}),e)a.cli(`Using config file: ${b(e,2)}`,{muted:!0});let r=performance.now();if(a.cli("Build started"),s.length===0){let c={...R,...n},u=process.cwd();if(c.clean)q(u,K(c.outDir));await jt(c,u)}else{for(let{options:c,rootDir:u}of s)if(ut(c.clean))q(u,K(c.outDir));await Promise.all(s.map(async({options:c,rootDir:u})=>{let f={...R,...c,...n};await jt(f,u)}))}let i=performance.now()-r,o=L(i);if(a.cli(`\u26A1\uFE0F Build completed in ${o}`),await k(),n.watch)a.cli("\uD83D\uDC40 Watching for file changes");if(!n.watch)process.exit(0);a.dispose()}async function k(){if(M.size>0)await wt(M),M.clear()}async function jt(t,n){if(t.watch)await At(t,n);else await W(t,n),t.onBuildSuccess?.()}gn().catch((t)=>tt(t));export{k as validateDtsFiles,gn as main};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunup",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.56",
|
|
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.56"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"typescript": ">=4.5.0"
|