bunup 0.1.30 → 0.1.32
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 +2 -0
- package/build/cli.mjs +6 -6
- package/build/dtsWorker.js +6 -6
- package/build/index.d.mts +21 -0
- package/build/index.d.ts +21 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,6 +85,8 @@ export default defineConfig({
|
|
|
85
85
|
|
|
86
86
|
For complete documentation, visit [the full documentation](https://bunup.arshadyaseen.com/).
|
|
87
87
|
|
|
88
|
+
For options API reference, visit [the API documentation](https://tsdocs.dev/docs/bunup/latest/interfaces/_internal_.BunupOptions.html).
|
|
89
|
+
|
|
88
90
|
## Contributing
|
|
89
91
|
|
|
90
92
|
For guidelines on contributing, please read the [contributing guide](https://github.com/arshad-yaseen/bunup/blob/main/CONTRIBUTING.md).
|
package/build/cli.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import Q from"fs";import Vt from"path";import{isMainThread as Zt}from"worker_threads";import{isMainThread as qt,parentPort as
|
|
3
|
+
import Q from"fs";import Vt from"path";import{isMainThread as Zt}from"worker_threads";import{isMainThread as qt,parentPort as H,Worker as Gt,workerData as Xt}from"node:worker_threads";class O extends Error{constructor(t){super(t);this.name="BunupError"}}class w extends O{constructor(t){super(t);this.name="BunupBuildError"}}class p extends O{constructor(t){super(t);this.name="BunupDTSBuildError"}}class h extends O{constructor(t){super(t);this.name="BunupCLIError"}}class b extends O{constructor(t){super(t);this.name="BunupWatchError"}}var m=(t)=>{if(t instanceof Error)return t.message;return String(t)},St=(t,n)=>{let r=m(t),e=n?`[${n}] `:"",s="ERROR";if(t instanceof w)s="BUILD ERROR";else if(t instanceof p)s="DTS ERROR";else if(t instanceof h)s="CLI ERROR";else if(t instanceof b)s="WATCH ERROR";else if(t instanceof O)s="BUNUP ERROR";if(console.error(`\x1B[31m[${s}]\x1B[0m ${e}${r}`),t instanceof Error&&t.stack)console.error("\x1B[2m"+t.stack.split(`
|
|
4
4
|
`).slice(1).join(`
|
|
5
|
-
`)+"\x1B[0m")},Z=(t,n)=>{St(t,n),process.exit(1)};var c={MAX_LABEL_LENGTH:5,colors:{cli:"183",info:"240",warn:"221",error:"203",progress:{ESM:"214",CJS:"114",IIFE:"105",DTS:"75"},default:"255"},labels:{cli:"BUNUP",info:"INFO",warn:"WARN",error:"ERROR"},formatMessage(t,n,r){let e=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-n.length));return`\x1B[38;5;${t}m[${n}]\x1B[0m ${e}${r}`},cli(t){let n=this.labels.cli;console.log(this.formatMessage(this.colors.cli,n,t))},info(t){console.log(`\x1B[38;5;${this.colors.info}m${t}\x1B[0m`)},warn(t){let n=this.labels.warn;console.warn(this.formatMessage(this.colors.warn,n,t))},error(t){let n=this.labels.error;console.error(this.formatMessage(this.colors.error,n,t))},progress(t,n){let r=String(t),e=this.colors.default;for(let[s,i]of Object.entries(this.colors.progress))if(r.includes(s)){e=i;break}console.log(this.formatMessage(e,r,n))}};function
|
|
6
|
-
`);let a=o.labels[0],l=a?
|
|
5
|
+
`)+"\x1B[0m")},Z=(t,n)=>{St(t,n),process.exit(1)};var c={MAX_LABEL_LENGTH:5,colors:{cli:"183",info:"240",warn:"221",error:"203",progress:{ESM:"214",CJS:"114",IIFE:"105",DTS:"75"},default:"255"},labels:{cli:"BUNUP",info:"INFO",warn:"WARN",error:"ERROR"},formatMessage(t,n,r){let e=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-n.length));return`\x1B[38;5;${t}m[${n}]\x1B[0m ${e}${r}`},cli(t){let n=this.labels.cli;console.log(this.formatMessage(this.colors.cli,n,t))},info(t){console.log(`\x1B[38;5;${this.colors.info}m${t}\x1B[0m`)},warn(t){let n=this.labels.warn;console.warn(this.formatMessage(this.colors.warn,n,t))},error(t){let n=this.labels.error;console.error(this.formatMessage(this.colors.error,n,t))},progress(t,n){let r=String(t),e=this.colors.default;for(let[s,i]of Object.entries(this.colors.progress))if(r.includes(s)){e=i;break}console.log(this.formatMessage(e,r,n))}};function z(t,n){return`${n?`${n.replace(/-/g,"_")}_`:""}${t}`.toUpperCase()}function U(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k(t=8){return Math.random().toString(36).substring(2,2+t)}function D(t,n){switch(t){case"esm":return".mjs";case"cjs":return N(n)?".cjs":".js";case"iife":return".global.js"}}function tt(t,n){switch(t){case"esm":return".d.mts";case"cjs":return N(n)?".d.cts":".d.ts";case"iife":return".d.ts"}}function N(t){return t==="module"}function j(t){return t>=1000?`${(t/1000).toFixed(2)}s`:`${Math.round(t)}ms`}function nt(t){if(!t)return[];return Array.from(new Set([...Object.keys(t.dependencies||{}),...Object.keys(t.peerDependencies||{})]))}function rt(t,n){return t===void 0?n==="esm":t}import{loadTsConfig as Bt}from"load-tsconfig";function et(t){try{return Bt(".",t)}catch(n){return c.warn(`Failed to load tsconfig: ${m(n)}`),{path:t,data:{},files:[]}}}import P from"node:path";import{rollup as At}from"rollup";import Nt from"rollup-plugin-dts";import q from"typescript";function st(t){return t.map((n)=>typeof n==="string"?new RegExp(`^${U(n)}($|\\/|\\\\)`):n)}function I(t,n){return st(t.external||[]).concat(nt(n).map((r)=>new RegExp(`^${U(r)}($|\\/|\\\\)`)))}function L(t){return st(t.noExternal||[])}import F from"node:fs";import ot from"node:path";var R={entry:[],format:["cjs"],outDir:"dist",minify:!1,watch:!1,dts:!1,target:"node",external:[],clean:!0,sourcemap:"none"};function it(t,n){return{outdir:`${n}/${t.outDir}`,minify:bt(t),target:t.target,splitting:t.splitting,sourcemap:t.sourcemap}}function bt(t){let{minify:n,minifyWhitespace:r,minifyIdentifiers:e,minifySyntax:s}=t,i=n===!0;return{whitespace:r??i,identifiers:e??i,syntax:s??i}}async function at(t){let n=[];for(let r of[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"]){let e=ot.join(t,`bunup.config${r}`);try{if(!F.existsSync(e))continue;let s;if(r===".json"||r===".jsonc"){let i=F.readFileSync(e,"utf8");s=JSON.parse(i)}else{let i=await import(`file://${e}`);if(s=i.default||i,!s)c.warn(`No default export found in ${e}`),s={}}if(Array.isArray(s))for(let i of s)n.push({options:{...R,...i},rootDir:t});else n.push({options:{...R,...s},rootDir:t});break}catch(s){throw new w(`Failed to load config from ${e}: ${m(s)}`)}if(n.length>0)break}return n}function M(t){let n=ot.join(t,"package.json");try{if(!F.existsSync(n))return null;let r=F.readFileSync(n,"utf8");return JSON.parse(r)}catch(r){return c.warn(`Failed to load package.json at ${n}: ${m(r)}`),null}}var jt=()=>{return global.allFilesUsedToBundleDts||C||new Set};async function lt(t,n,r,e,s){let a=`\x00virtual:${t.replace(/\.tsx?$/,".d.ts")}`,l=s.data?.compilerOptions,u={name:"bunup:virtual-dts",resolveId(d,y){if(d.startsWith("\x00virtual:"))return d;if(!y?.startsWith("\x00virtual:")||!d.startsWith("."))return null;let x=y.slice(9),S=P.resolve(P.dirname(x),d);if(d==="."){let B=P.join(P.dirname(x),"index.d.ts");if(n.has(B))return`\x00virtual:${B}`;S=P.dirname(x)}if(n.has(S))return`\x00virtual:${S}`;let V=`${S}.d.ts`;if(n.has(V))return`\x00virtual:${V}`;if(d.startsWith(".")){let B=P.join(S,"index.d.ts");if(n.has(B))return`\x00virtual:${B}`}return null},load(d){if(d.startsWith("\x00virtual:")){let y=d.slice(9),x=n.get(y);if(x)return jt().add(y),x}return null}},g=M(e),f=I(r,g),$=L(r),E;try{E=await At({input:a,onwarn(y,x){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(y.code??""))return;x(y)},plugins:[u,Nt({tsconfig:s.path,compilerOptions:{...l?q.parseJsonConfigFileContent({compilerOptions:l},q.sys,"./").options:{},declaration:!0,noEmit:!1,emitDeclarationOnly:!0,noEmitOnError:!0,checkJs:!1,declarationMap:!1,skipLibCheck:!0,preserveSymlinks:!1,target:q.ScriptTarget.ESNext}})],external:(y)=>f.some((x)=>x.test(y))&&!$.some((x)=>x.test(y))});let{output:d}=await E.generate({});if(!d[0]?.code)throw new p("Generated bundle is empty");return d[0].code}catch(d){throw new p(`DTS bundling failed: ${m(d)}`)}finally{if(E)await E.close()}}import mt from"node:fs";import ut from"node:path";import W from"node:path";function G(t){let n=W.dirname(t.path||"");return t.data?.compilerOptions?.baseUrl?W.resolve(n,t.data.compilerOptions.baseUrl):n}function ct(t){let n=new Map,r=t.data?.compilerOptions?.paths;if(!r)return n;let e=G(t);for(let[s,i]of Object.entries(r))if(Array.isArray(i)&&i.length){let o=s.replace(/\*/g,"(.*)"),a=i[0].replace(/\*/g,"$1");n.set(`^${o}$`,W.join(e,a))}return n}function ft(t,n,r){for(let[e,s]of n){let i=new RegExp(e),o=t.match(i);if(o)return s.replace("$1",o[1]||"")}return r?W.join(r,t):null}var It=/(?:import|export)(?:[\s\n]*(?:type[\s\n]+)?(?:\*|\{[^}]*\}|[\w$]+)[\s\n]+from[\s\n]*|[\s\n]+)(["'`])([^'"]+)\1/g,Lt=/import\s*\(\s*(["'`])([^'"]+)\1\s*\)/g;async function gt(t,n){let r=new Set([t]),e=[t],s=ct(n),i=G(n);while(e.length){let o=e.pop();if(!o)continue;try{let a=await mt.promises.readFile(o,"utf8"),l=Ft(a);for(let u of l){let g=u.startsWith(".")?ut.resolve(ut.dirname(o),u):ft(u,s,i);if(!g)continue;let f=Mt(g);if(f&&!r.has(f))r.add(f),e.push(f)}}catch(a){c.warn(`Error processing ${o}: ${m(a)}`)}}return r}function Ft(t){let n=new Set;for(let r of[It,Lt]){let e;while((e=r.exec(t))!==null)n.add(e[2])}return Array.from(n)}function Mt(t){let n=["",".ts",".tsx","/index.ts","/index.tsx"];for(let r of n){let e=`${t}${r}`;if(mt.existsSync(e)&&(e.endsWith(".ts")||e.endsWith(".tsx")))return e}return null}import Wt from"node:fs";import{isolatedDeclaration as Ht}from"oxc-transform";async function pt(t){let n=new Map;return await Promise.all([...t].map(async(r)=>{try{let e=r.replace(/\.tsx?$/,".d.ts"),s=await Wt.promises.readFile(r,"utf8"),{code:i}=Ht(r,s);if(i)n.set(e,i)}catch(e){c.warn(`Failed to generate declaration for ${r}: ${m(e)}`)}})),n}import Y from"node:fs";import X from"node:path";import{isolatedDeclaration as _t}from"oxc-transform";function dt(t,n){let r=X.resolve(t),e=X.resolve(r,n);if(!Y.existsSync(r))throw new p(`Root directory does not exist: ${r}`);if(!Y.existsSync(e))throw new p(`Entry file does not exist: ${e}`);if(!e.endsWith(".ts"))throw new p(`Entry file must be a TypeScript file (.ts): ${e}`);if(X.relative(r,e).startsWith(".."))throw new p(`Entry file must be within rootDir: ${e}`);return{absoluteRootDir:r,absoluteEntry:e}}async function xt(t){let n=!1;if(await Promise.all([...t].map(async(r)=>{try{let e=r.replace(/\.d\.ts$/,".ts"),s=await Y.promises.readFile(e,"utf8"),{errors:i}=_t(e,s);i.forEach((o)=>{if(!n)console.log(`
|
|
6
|
+
`);let a=o.labels[0],l=a?Tt(s,a.start):"",f=`${e.split("/").slice(-3).join("/")}${l}: ${Ut(o.message)}`;c.warn(f),n=!0})}catch{}})),n)c.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
|
-
`),e=r.length,s=r[r.length-1].length+1;return` (${e}:${s})`}function Ut(t){return t.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}async function
|
|
10
|
-
To install Bun, visit https://bun.sh/docs/installation`)})();import K from"node:path";import Qt from"chokidar";async function Ot(t,n){let r=new Set,e=A(t.entry);e.forEach((l)=>{let
|
|
8
|
+
`)}function Tt(t,n){if(n===void 0)return"";let r=t.slice(0,n).split(`
|
|
9
|
+
`),e=r.length,s=r[r.length-1].length+1;return` (${e}:${s})`}function Ut(t){return t.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}async function ht(t,n,r){let{absoluteRootDir:e,absoluteEntry:s}=dt(t,n),i=et(r.preferredTsconfigPath),o=await gt(s,i),a=await pt(o);return lt(s,a,r,e,i)}async function yt(t,n,r,e,s){return new Promise((i,o)=>{let{onBuildEnd:a,...l}=e,u={rootDir:t,entries:n,formats:r,options:l,packageType:s},g=new Gt(new URL("./dtsWorker.js",import.meta.url),{workerData:u});g.on("message",async(f)=>{if(f.success){let $=j(f.timeMs);if(c.progress("DTS",`Bundled types in ${$}`),f.filesUsed)f.filesUsed.forEach((E)=>C.add(E));i()}else o(new p(f.error||"Unknown DTS worker error"))}),g.on("error",o),g.on("exit",(f)=>{if(f!==0)o(new p(`DTS worker stopped with exit code ${f}`))})})}if(!qt&&H){let{rootDir:t,entries:n,formats:r,options:e,packageType:s}=Xt,i=performance.now(),o=new Set;global.allFilesUsedToBundleDts=o,c.progress("DTS","Bundling types");try{(async()=>{try{await Promise.all(n.map(async(l)=>{let u=await ht(t,l.path,e);await Promise.all(r.map(async(g)=>{let f=tt(g,s),$=`${e.outDir}/${l.name}${f}`,E=`${t}/${$}`;await Bun.write(E,u),c.progress("DTS",$)}))}));let a=performance.now()-i;H?.postMessage({success:!0,timeMs:a,filesUsed:[...o]})}catch(a){H?.postMessage({success:!1,error:m(a)})}})()}catch(a){H?.postMessage({success:!1,error:m(a)})}}function Yt(t){return t.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function A(t){let n=[],r=new Set;function e(s,i){if(r.has(s)){let o=k();n.push({name:`${s}_${o}`,path:i})}else n.push({name:s,path:i}),r.add(s)}if(Array.isArray(t))for(let s of t){let i=Yt(s);e(i,s)}else Object.entries(t).forEach(([s,i])=>{e(s,i)});return n}function $t(t,n){return`[dir]/${t}${n}`}function wt(t,n){return{name:"bunup:external-plugin",setup(r){r.onResolve({filter:/.*/},(e)=>{let s=e.path;if(t.some((o)=>o.test(s))&&!n.some((o)=>o.test(s)))return{path:s,external:!0};return null})}}}async function _(t,n){if(!t.entry||t.entry.length===0||!t.outDir)throw new w("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let r=performance.now();c.cli("Build started");let e=M(n),s=e?.type,i=I(t,e),o=L(t),a=[wt(i,o)],l=A(t.entry),u=t.format.flatMap((g)=>l.map((f)=>{return Jt(t,n,f,g,s,a)}));try{await Promise.all(u);let g=performance.now()-r,f=j(g);c.cli(`\uD83D\uDCE6 Build success in ${f}`)}catch{throw new w("Build process encountered errors")}if(t.dts){let g=t.format.filter(($)=>{if($==="iife"&&!N(s)&&t.format.includes("cjs"))return!1;return!0}),f=t.dts===!0?l:A(t.dts.entry);try{await yt(n,f,g,t,s)}catch($){throw new p(`DTS build process encountered errors: ${m($)}`)}}}async function Jt(t,n,r,e,s,i){let o=D(e,s),a=it(t,n),l=await Bun.build({...a,entrypoints:[`${n}/${r.path}`],format:e,naming:{entry:$t(r.name,o)},splitting:rt(t.splitting,e),plugins:i,throw:!1});if(!l.success)throw l.logs.forEach((u)=>{if(u.level==="error")c.error(u.message);else if(u.level==="warning")c.warn(u.message);else if(u.level==="info")c.info(u.message)}),new w(`Build failed for ${r} (${e})`);c.progress(z(e,t.name),`${t.outDir}/${r.name}${o}`)}function v(t){return(n,r)=>{r[t]=n===!0?!0:n==="true"}}function T(t){return(n,r)=>{if(typeof n==="string")r[t]=n;else throw new h(`Option --${t} requires a string value`)}}function Et(t){return(n,r)=>{if(typeof n==="string")r[t]=n.split(",");else throw new h(`Option --${t} requires a string value`)}}var Kt={name:{flags:["n","name"],handler:T("name")},format:{flags:["f","format"],handler:(t,n)=>{if(typeof t==="string")n.format=t.split(",");else throw new h("Option --format requires a string value")}},outDir:{flags:["o","out-dir"],handler:T("outDir")},minify:{flags:["m","minify"],handler:v("minify")},watch:{flags:["w","watch"],handler:v("watch")},dts:{flags:["d","dts"],handler:v("dts")},external:{flags:["e","external"],handler:Et("external")},sourcemap:{flags:["sm","sourcemap"],handler:T("sourcemap")},target:{flags:["t","target"],handler:T("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:v("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:v("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:v("minifySyntax")},clean:{flags:["c","clean"],handler:v("clean")},splitting:{flags:["s","splitting"],handler:v("splitting")},noExternal:{flags:["ne","no-external"],handler:Et("noExternal")}},J={};for(let t of Object.values(Kt))if(t)for(let n of t.flags)J[n]=t.handler;function vt(t){return t.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function Ct(t){let n={},r={},e=0;while(e<t.length){let s=t[e];if(s.startsWith("--")){let i,o;if(s.includes("=")){let[a,l]=s.slice(2).split("=",2);i=a,o=l}else{i=s.slice(2);let a=t[e+1];if(o=a&&!a.startsWith("-")?a:!0,typeof o==="string")e++}if(i==="entry")if(typeof o==="string"){let a=vt(o);if(r[a])c.warn(`Duplicate entry name '${a}' derived from '${o}'. Overwriting previous entry.`);r[a]=o}else throw new h("Option --entry requires a string value");else if(i.startsWith("entry.")){let a=i.slice(6);if(typeof o==="string"){if(r[a])c.warn(`Duplicate entry name '${a}' provided via --entry.${a}. Overwriting previous entry.`);r[a]=o}else throw new h(`Option --entry.${a} requires a string value`)}else{let a=J[i];if(a)a(o,n);else throw new h(`Unknown option: --${i}`)}}else if(s.startsWith("-")){let i=s.slice(1),o=t[e+1],a=o&&!o.startsWith("-")?o:!0;if(typeof a==="string")e++;let l=J[i];if(l)l(a,n);else throw new h(`Unknown option: -${i}`)}else{let i=vt(s);if(r[i])c.warn(`Duplicate entry name '${i}' derived from positional argument '${s}'. Overwriting previous entry.`);r[i]=s}e++}if(Object.keys(r).length>0)n.entry=r;return n}(()=>{if(typeof Bun==="undefined")throw new h(`Bunup requires Bun to run.
|
|
10
|
+
To install Bun, visit https://bun.sh/docs/installation`)})();import K from"node:path";import Qt from"chokidar";async function Ot(t,n){let r=new Set,e=A(t.entry);e.forEach((l)=>{let u=K.resolve(n,l.path),g=K.dirname(u);r.add(g)});let s=Qt.watch(Array.from(r),{persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50},atomic:!0,ignorePermissionErrors:!0,ignored:[/[\\/]\.git[\\/]/,/[\\/]node_modules[\\/]/,t.outDir]}),i=null,o=!1,a=async()=>{if(o)return;o=!0;try{await _({...t,entry:e.map((l)=>l.path),clean:!1},n),t.onBuildEnd?.()}catch(l){throw new b(`Build failed: ${m(l)}`)}finally{o=!1}};s.on("change",(l)=>{let u=K.relative(n,l);if(c.cli(`File changed: ${u}`),i)clearTimeout(i);i=setTimeout(()=>a(),300)}),s.on("error",(l)=>{throw new b(`Watcher error: ${m(l)}`)}),await a()}var C=new Set;async function zt(t=Bun.argv.slice(2)){let n=Ct(t),r=await at(process.cwd()),e=process.cwd();if(n.watch)c.cli("Starting watch mode"),c.cli("Watching for file changes");if(r.length===0){let s={...R,...n};if(s.clean)Pt(e,s.outDir);await Rt(s,e)}else{for(let{options:s,rootDir:i}of r)if(s.clean)Pt(i,s.outDir);await Promise.all(r.map(async({options:s,rootDir:i})=>{let o={...R,...s,...n};await Rt(o,i)}))}if(C.size>0)await xt(C),C.clear();if(!n.watch)process.exit(0)}async function Rt(t,n){if(t.watch)await Ot(t,n);else await _(t,n),t.onBuildEnd?.()}function Pt(t,n){let r=Vt.join(t,n);if(Q.existsSync(r))try{Q.rmSync(r,{recursive:!0,force:!0})}catch(e){throw new w(`Failed to clean output directory: ${e}`)}Q.mkdirSync(r,{recursive:!0})}if(Zt)zt().catch((t)=>Z(t));export{zt as main,C as allFilesUsedToBundleDts};
|
package/build/dtsWorker.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var Jt=require("node:module");var Ut=Object.create;var{getPrototypeOf:qt,defineProperty:N,getOwnPropertyNames:et,getOwnPropertyDescriptor:Gt}=Object,st=Object.prototype.hasOwnProperty;var
|
|
1
|
+
var Jt=require("node:module");var Ut=Object.create;var{getPrototypeOf:qt,defineProperty:N,getOwnPropertyNames:et,getOwnPropertyDescriptor:Gt}=Object,st=Object.prototype.hasOwnProperty;var p=(t,n,r)=>{r=t!=null?Ut(qt(t)):{};let e=n||!t||!t.__esModule?N(r,"default",{value:t,enumerable:!0}):r;for(let s of et(t))if(!st.call(e,s))N(e,s,{get:()=>t[s],enumerable:!0});return e},rt=new WeakMap,Xt=(t)=>{var n=rt.get(t),r;if(n)return n;if(n=N({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")et(t).map((e)=>!st.call(n,e)&&N(n,e,{get:()=>t[e],enumerable:!(r=Gt(t,e))||r.enumerable}));return rt.set(t,n),n};var Yt=(t,n)=>{for(var r in n)N(t,r,{get:n[r],enumerable:!0,configurable:!0,set:(e)=>n[r]=()=>e})};var an={};Yt(an,{runDtsInWorker:()=>Z});module.exports=Xt(an);var w=require("node:worker_threads");var J=p(require("node:fs")),St=p(require("node:path")),Bt=require("node:worker_threads");class S extends Error{constructor(t){super(t);this.name="BunupError"}}class v extends S{constructor(t){super(t);this.name="BunupBuildError"}}class d extends S{constructor(t){super(t);this.name="BunupDTSBuildError"}}class y extends S{constructor(t){super(t);this.name="BunupCLIError"}}class j extends S{constructor(t){super(t);this.name="BunupWatchError"}}var m=(t)=>{if(t instanceof Error)return t.message;return String(t)},Kt=(t,n)=>{let r=m(t),e=n?`[${n}] `:"",s="ERROR";if(t instanceof v)s="BUILD ERROR";else if(t instanceof d)s="DTS ERROR";else if(t instanceof y)s="CLI ERROR";else if(t instanceof j)s="WATCH ERROR";else if(t instanceof S)s="BUNUP ERROR";if(console.error(`\x1B[31m[${s}]\x1B[0m ${e}${r}`),t instanceof Error&&t.stack)console.error("\x1B[2m"+t.stack.split(`
|
|
2
2
|
`).slice(1).join(`
|
|
3
|
-
`)+"\x1B[0m")},it=(t,n)=>{Kt(t,n),process.exit(1)};function
|
|
4
|
-
To install Bun, visit https://bun.sh/docs/installation`)})();var
|
|
5
|
-
`);let a=o.labels[0],l=a?
|
|
3
|
+
`)+"\x1B[0m")},it=(t,n)=>{Kt(t,n),process.exit(1)};function Q(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ot(t=8){return Math.random().toString(36).substring(2,2+t)}function at(t,n){switch(t){case"esm":return".mjs";case"cjs":return M(n)?".cjs":".js";case"iife":return".global.js"}}function lt(t,n){switch(t){case"esm":return".d.mts";case"cjs":return M(n)?".d.cts":".d.ts";case"iife":return".d.ts"}}function M(t){return t==="module"}function W(t){return t>=1000?`${(t/1000).toFixed(2)}s`:`${Math.round(t)}ms`}function ct(t){if(!t)return[];return Array.from(new Set([...Object.keys(t.dependencies||{}),...Object.keys(t.peerDependencies||{})]))}function ft(t,n){return t===void 0?n==="esm":t}function Qt(t){return t.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function I(t){let n=[],r=new Set;function e(s,i){if(r.has(s)){let o=ot();n.push({name:`${s}_${o}`,path:i})}else n.push({name:s,path:i}),r.add(s)}if(Array.isArray(t))for(let s of t){let i=Qt(s);e(i,s)}else Object.entries(t).forEach(([s,i])=>{e(s,i)});return n}function ut(t,n){return`[dir]/${t}${n}`}function mt(t){return t.map((n)=>typeof n==="string"?new RegExp(`^${Q(n)}($|\\/|\\\\)`):n)}function H(t,n){return mt(t.external||[]).concat(ct(n).map((r)=>new RegExp(`^${Q(r)}($|\\/|\\\\)`)))}function _(t){return mt(t.noExternal||[])}var L=p(require("node:fs")),V=p(require("node:path"));var c={MAX_LABEL_LENGTH:5,colors:{cli:"183",info:"240",warn:"221",error:"203",progress:{ESM:"214",CJS:"114",IIFE:"105",DTS:"75"},default:"255"},labels:{cli:"BUNUP",info:"INFO",warn:"WARN",error:"ERROR"},formatMessage(t,n,r){let e=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-n.length));return`\x1B[38;5;${t}m[${n}]\x1B[0m ${e}${r}`},cli(t){let n=this.labels.cli;console.log(this.formatMessage(this.colors.cli,n,t))},info(t){console.log(`\x1B[38;5;${this.colors.info}m${t}\x1B[0m`)},warn(t){let n=this.labels.warn;console.warn(this.formatMessage(this.colors.warn,n,t))},error(t){let n=this.labels.error;console.error(this.formatMessage(this.colors.error,n,t))},progress(t,n){let r=String(t),e=this.colors.default;for(let[s,i]of Object.entries(this.colors.progress))if(r.includes(s)){e=i;break}console.log(this.formatMessage(e,r,n))}};function gt(t,n){return`${n?`${n.replace(/-/g,"_")}_`:""}${t}`.toUpperCase()}var B={entry:[],format:["cjs"],outDir:"dist",minify:!1,watch:!1,dts:!1,target:"node",external:[],clean:!0,sourcemap:"none"};function pt(t,n){return{outdir:`${n}/${t.outDir}`,minify:Vt(t),target:t.target,splitting:t.splitting,sourcemap:t.sourcemap}}function Vt(t){let{minify:n,minifyWhitespace:r,minifyIdentifiers:e,minifySyntax:s}=t,i=n===!0;return{whitespace:r??i,identifiers:e??i,syntax:s??i}}async function dt(t){let n=[];for(let r of[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"]){let e=V.default.join(t,`bunup.config${r}`);try{if(!L.default.existsSync(e))continue;let s;if(r===".json"||r===".jsonc"){let i=L.default.readFileSync(e,"utf8");s=JSON.parse(i)}else{let i=await import(`file://${e}`);if(s=i.default||i,!s)c.warn(`No default export found in ${e}`),s={}}if(Array.isArray(s))for(let i of s)n.push({options:{...B,...i},rootDir:t});else n.push({options:{...B,...s},rootDir:t});break}catch(s){throw new v(`Failed to load config from ${e}: ${m(s)}`)}if(n.length>0)break}return n}function T(t){let n=V.default.join(t,"package.json");try{if(!L.default.existsSync(n))return null;let r=L.default.readFileSync(n,"utf8");return JSON.parse(r)}catch(r){return c.warn(`Failed to load package.json at ${n}: ${m(r)}`),null}}function xt(t,n){return{name:"bunup:external-plugin",setup(r){r.onResolve({filter:/.*/},(e)=>{let s=e.path;if(t.some((o)=>o.test(s))&&!n.some((o)=>o.test(s)))return{path:s,external:!0};return null})}}}async function U(t,n){if(!t.entry||t.entry.length===0||!t.outDir)throw new v("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");let r=performance.now();c.cli("Build started");let e=T(n),s=e?.type,i=H(t,e),o=_(t),a=[xt(i,o)],l=I(t.entry),u=t.format.flatMap((g)=>l.map((f)=>{return Zt(t,n,f,g,s,a)}));try{await Promise.all(u);let g=performance.now()-r,f=W(g);c.cli(`\uD83D\uDCE6 Build success in ${f}`)}catch{throw new v("Build process encountered errors")}if(t.dts){let g=t.format.filter((E)=>{if(E==="iife"&&!M(s)&&t.format.includes("cjs"))return!1;return!0}),f=t.dts===!0?l:I(t.dts.entry);try{await Z(n,f,g,t,s)}catch(E){throw new d(`DTS build process encountered errors: ${m(E)}`)}}}async function Zt(t,n,r,e,s,i){let o=at(e,s),a=pt(t,n),l=await Bun.build({...a,entrypoints:[`${n}/${r.path}`],format:e,naming:{entry:ut(r.name,o)},splitting:ft(t.splitting,e),plugins:i,throw:!1});if(!l.success)throw l.logs.forEach((u)=>{if(u.level==="error")c.error(u.message);else if(u.level==="warning")c.warn(u.message);else if(u.level==="info")c.info(u.message)}),new v(`Build failed for ${r} (${e})`);c.progress(gt(e,t.name),`${t.outDir}/${r.name}${o}`)}function O(t){return(n,r)=>{r[t]=n===!0?!0:n==="true"}}function q(t){return(n,r)=>{if(typeof n==="string")r[t]=n;else throw new y(`Option --${t} requires a string value`)}}function ht(t){return(n,r)=>{if(typeof n==="string")r[t]=n.split(",");else throw new y(`Option --${t} requires a string value`)}}var zt={name:{flags:["n","name"],handler:q("name")},format:{flags:["f","format"],handler:(t,n)=>{if(typeof t==="string")n.format=t.split(",");else throw new y("Option --format requires a string value")}},outDir:{flags:["o","out-dir"],handler:q("outDir")},minify:{flags:["m","minify"],handler:O("minify")},watch:{flags:["w","watch"],handler:O("watch")},dts:{flags:["d","dts"],handler:O("dts")},external:{flags:["e","external"],handler:ht("external")},sourcemap:{flags:["sm","sourcemap"],handler:q("sourcemap")},target:{flags:["t","target"],handler:q("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:O("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:O("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:O("minifySyntax")},clean:{flags:["c","clean"],handler:O("clean")},splitting:{flags:["s","splitting"],handler:O("splitting")},noExternal:{flags:["ne","no-external"],handler:ht("noExternal")}},z={};for(let t of Object.values(zt))if(t)for(let n of t.flags)z[n]=t.handler;function yt(t){return t.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function $t(t){let n={},r={},e=0;while(e<t.length){let s=t[e];if(s.startsWith("--")){let i,o;if(s.includes("=")){let[a,l]=s.slice(2).split("=",2);i=a,o=l}else{i=s.slice(2);let a=t[e+1];if(o=a&&!a.startsWith("-")?a:!0,typeof o==="string")e++}if(i==="entry")if(typeof o==="string"){let a=yt(o);if(r[a])c.warn(`Duplicate entry name '${a}' derived from '${o}'. Overwriting previous entry.`);r[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(r[a])c.warn(`Duplicate entry name '${a}' provided via --entry.${a}. Overwriting previous entry.`);r[a]=o}else throw new y(`Option --entry.${a} requires a string value`)}else{let a=z[i];if(a)a(o,n);else throw new y(`Unknown option: --${i}`)}}else if(s.startsWith("-")){let i=s.slice(1),o=t[e+1],a=o&&!o.startsWith("-")?o:!0;if(typeof a==="string")e++;let l=z[i];if(l)l(a,n);else throw new y(`Unknown option: -${i}`)}else{let i=yt(s);if(r[i])c.warn(`Duplicate entry name '${i}' derived from positional argument '${s}'. Overwriting previous entry.`);r[i]=s}e++}if(Object.keys(r).length>0)n.entry=r;return n}(()=>{if(typeof Bun==="undefined")throw new y(`Bunup requires Bun to run.
|
|
4
|
+
To install Bun, visit https://bun.sh/docs/installation`)})();var X=p(require("node:fs")),G=p(require("node:path")),wt=require("oxc-transform");function Et(t,n){let r=G.default.resolve(t),e=G.default.resolve(r,n);if(!X.default.existsSync(r))throw new d(`Root directory does not exist: ${r}`);if(!X.default.existsSync(e))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(G.default.relative(r,e).startsWith(".."))throw new d(`Entry file must be within rootDir: ${e}`);return{absoluteRootDir:r,absoluteEntry:e}}async function vt(t){let n=!1;if(await Promise.all([...t].map(async(r)=>{try{let e=r.replace(/\.d\.ts$/,".ts"),s=await X.default.promises.readFile(e,"utf8"),{errors:i}=wt.isolatedDeclaration(e,s);i.forEach((o)=>{if(!n)console.log(`
|
|
5
|
+
`);let a=o.labels[0],l=a?kt(s,a.start):"",f=`${e.split("/").slice(-3).join("/")}${l}: ${Dt(o.message)}`;c.warn(f),n=!0})}catch{}})),n)c.info(`
|
|
6
6
|
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.
|
|
7
|
-
`)}function
|
|
8
|
-
`),e=r.length,s=r[r.length-1].length+1;return` (${e}:${s})`}function Dt(t){return t.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}var
|
|
7
|
+
`)}function kt(t,n){if(n===void 0)return"";let r=t.slice(0,n).split(`
|
|
8
|
+
`),e=r.length,s=r[r.length-1].length+1;return` (${e}:${s})`}function Dt(t){return t.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}var Y=p(require("node:path")),Ct=p(require("chokidar"));async function Ot(t,n){let r=new Set,e=I(t.entry);e.forEach((l)=>{let u=Y.default.resolve(n,l.path),g=Y.default.dirname(u);r.add(g)});let s=Ct.default.watch(Array.from(r),{persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50},atomic:!0,ignorePermissionErrors:!0,ignored:[/[\\/]\.git[\\/]/,/[\\/]node_modules[\\/]/,t.outDir]}),i=null,o=!1,a=async()=>{if(o)return;o=!0;try{await U({...t,entry:e.map((l)=>l.path),clean:!1},n),t.onBuildEnd?.()}catch(l){throw new j(`Build failed: ${m(l)}`)}finally{o=!1}};s.on("change",(l)=>{let u=Y.default.relative(n,l);if(c.cli(`File changed: ${u}`),i)clearTimeout(i);i=setTimeout(()=>a(),300)}),s.on("error",(l)=>{throw new j(`Watcher error: ${m(l)}`)}),await a()}var R=new Set;async function tn(t=Bun.argv.slice(2)){let n=$t(t),r=await dt(process.cwd()),e=process.cwd();if(n.watch)c.cli("Starting watch mode"),c.cli("Watching for file changes");if(r.length===0){let s={...B,...n};if(s.clean)Pt(e,s.outDir);await Rt(s,e)}else{for(let{options:s,rootDir:i}of r)if(s.clean)Pt(i,s.outDir);await Promise.all(r.map(async({options:s,rootDir:i})=>{let o={...B,...s,...n};await Rt(o,i)}))}if(R.size>0)await vt(R),R.clear();if(!n.watch)process.exit(0)}async function Rt(t,n){if(t.watch)await Ot(t,n);else await U(t,n),t.onBuildEnd?.()}function Pt(t,n){let r=St.default.join(t,n);if(J.default.existsSync(r))try{J.default.rmSync(r,{recursive:!0,force:!0})}catch(e){throw new v(`Failed to clean output directory: ${e}`)}J.default.mkdirSync(r,{recursive:!0})}if(Bt.isMainThread)tn().catch((t)=>it(t));var bt=require("load-tsconfig");function At(t){try{return bt.loadTsConfig(".",t)}catch(n){return c.warn(`Failed to load tsconfig: ${m(n)}`),{path:t,data:{},files:[]}}}var P=p(require("node:path")),Nt=require("rollup"),jt=p(require("rollup-plugin-dts")),K=p(require("typescript"));var nn=()=>{return global.allFilesUsedToBundleDts||R||new Set};async function It(t,n,r,e,s){let a=`\x00virtual:${t.replace(/\.tsx?$/,".d.ts")}`,l=s.data?.compilerOptions,u={name:"bunup:virtual-dts",resolveId(x,$){if(x.startsWith("\x00virtual:"))return x;if(!$?.startsWith("\x00virtual:")||!x.startsWith("."))return null;let h=$.slice(9),b=P.default.resolve(P.default.dirname(h),x);if(x==="."){let A=P.default.join(P.default.dirname(h),"index.d.ts");if(n.has(A))return`\x00virtual:${A}`;b=P.default.dirname(h)}if(n.has(b))return`\x00virtual:${b}`;let nt=`${b}.d.ts`;if(n.has(nt))return`\x00virtual:${nt}`;if(x.startsWith(".")){let A=P.default.join(b,"index.d.ts");if(n.has(A))return`\x00virtual:${A}`}return null},load(x){if(x.startsWith("\x00virtual:")){let $=x.slice(9),h=n.get($);if(h)return nn().add($),h}return null}},g=T(e),f=H(r,g),E=_(r),C;try{C=await Nt.rollup({input:a,onwarn($,h){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes($.code??""))return;h($)},plugins:[u,jt.default({tsconfig:s.path,compilerOptions:{...l?K.default.parseJsonConfigFileContent({compilerOptions:l},K.default.sys,"./").options:{},declaration:!0,noEmit:!1,emitDeclarationOnly:!0,noEmitOnError:!0,checkJs:!1,declarationMap:!1,skipLibCheck:!0,preserveSymlinks:!1,target:K.default.ScriptTarget.ESNext}})],external:($)=>f.some((h)=>h.test($))&&!E.some((h)=>h.test($))});let{output:x}=await C.generate({});if(!x[0]?.code)throw new d("Generated bundle is empty");return x[0].code}catch(x){throw new d(`DTS bundling failed: ${m(x)}`)}finally{if(C)await C.close()}}var tt=p(require("node:fs")),D=p(require("node:path"));var F=p(require("node:path"));function k(t){let n=F.default.dirname(t.path||"");return t.data?.compilerOptions?.baseUrl?F.default.resolve(n,t.data.compilerOptions.baseUrl):n}function Lt(t){let n=new Map,r=t.data?.compilerOptions?.paths;if(!r)return n;let e=k(t);for(let[s,i]of Object.entries(r))if(Array.isArray(i)&&i.length){let o=s.replace(/\*/g,"(.*)"),a=i[0].replace(/\*/g,"$1");n.set(`^${o}$`,F.default.join(e,a))}return n}function Ft(t,n,r){for(let[e,s]of n){let i=new RegExp(e),o=t.match(i);if(o)return s.replace("$1",o[1]||"")}return r?F.default.join(r,t):null}var rn=/(?:import|export)(?:[\s\n]*(?:type[\s\n]+)?(?:\*|\{[^}]*\}|[\w$]+)[\s\n]+from[\s\n]*|[\s\n]+)(["'`])([^'"]+)\1/g,en=/import\s*\(\s*(["'`])([^'"]+)\1\s*\)/g;async function Mt(t,n){let r=new Set([t]),e=[t],s=Lt(n),i=k(n);while(e.length){let o=e.pop();if(!o)continue;try{let a=await tt.default.promises.readFile(o,"utf8"),l=sn(a);for(let u of l){let g=u.startsWith(".")?D.default.resolve(D.default.dirname(o),u):Ft(u,s,i);if(!g)continue;let f=on(g);if(f&&!r.has(f))r.add(f),e.push(f)}}catch(a){c.warn(`Error processing ${o}: ${m(a)}`)}}return r}function sn(t){let n=new Set;for(let r of[rn,en]){let e;while((e=r.exec(t))!==null)n.add(e[2])}return Array.from(n)}function on(t){let n=["",".ts",".tsx","/index.ts","/index.tsx"];for(let r of n){let e=`${t}${r}`;if(tt.default.existsSync(e)&&(e.endsWith(".ts")||e.endsWith(".tsx")))return e}return null}var Wt=p(require("node:fs")),Ht=require("oxc-transform");async function _t(t){let n=new Map;return await Promise.all([...t].map(async(r)=>{try{let e=r.replace(/\.tsx?$/,".d.ts"),s=await Wt.default.promises.readFile(r,"utf8"),{code:i}=Ht.isolatedDeclaration(r,s);if(i)n.set(e,i)}catch(e){c.warn(`Failed to generate declaration for ${r}: ${m(e)}`)}})),n}async function Tt(t,n,r){let{absoluteRootDir:e,absoluteEntry:s}=Et(t,n),i=At(r.preferredTsconfigPath),o=await Mt(s,i),a=await _t(o);return It(s,a,r,e,i)}async function Z(t,n,r,e,s){return new Promise((i,o)=>{let{onBuildEnd:a,...l}=e,u={rootDir:t,entries:n,formats:r,options:l,packageType:s},g=new w.Worker(new URL("./dtsWorker.js",import.meta.url),{workerData:u});g.on("message",async(f)=>{if(f.success){let E=W(f.timeMs);if(c.progress("DTS",`Bundled types in ${E}`),f.filesUsed)f.filesUsed.forEach((C)=>R.add(C));i()}else o(new d(f.error||"Unknown DTS worker error"))}),g.on("error",o),g.on("exit",(f)=>{if(f!==0)o(new d(`DTS worker stopped with exit code ${f}`))})})}if(!w.isMainThread&&w.parentPort){let{rootDir:t,entries:n,formats:r,options:e,packageType:s}=w.workerData,i=performance.now(),o=new Set;global.allFilesUsedToBundleDts=o,c.progress("DTS","Bundling types");try{(async()=>{try{await Promise.all(n.map(async(l)=>{let u=await Tt(t,l.path,e);await Promise.all(r.map(async(g)=>{let f=lt(g,s),E=`${e.outDir}/${l.name}${f}`,C=`${t}/${E}`;await Bun.write(C,u),c.progress("DTS",E)}))}));let a=performance.now()-i;w.parentPort?.postMessage({success:!0,timeMs:a,filesUsed:[...o]})}catch(a){w.parentPort?.postMessage({success:!1,error:m(a)})}})()}catch(a){w.parentPort?.postMessage({success:!1,error:m(a)})}}
|
package/build/index.d.mts
CHANGED
|
@@ -6,6 +6,7 @@ type WithOptional<
|
|
|
6
6
|
type Format = "esm" | "cjs" | "iife";
|
|
7
7
|
type Target = "bun" | "node" | "browser";
|
|
8
8
|
type External = string[];
|
|
9
|
+
type Sourcemap = "none" | "linked" | "external" | "inline";
|
|
9
10
|
type Entry = string[] | Record<string, string>;
|
|
10
11
|
type DtsOptions = {
|
|
11
12
|
/**
|
|
@@ -138,6 +139,26 @@ interface BunupOptions {
|
|
|
138
139
|
* Defaults to true if not specified
|
|
139
140
|
*/
|
|
140
141
|
clean?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Specifies the type of sourcemap to generate
|
|
144
|
+
* Can be 'none', 'linked', 'external', or 'inline'
|
|
145
|
+
*
|
|
146
|
+
* @see https://bun.sh/docs/bundler#sourcemap
|
|
147
|
+
*
|
|
148
|
+
* @default 'none'
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* sourcemap: 'linked'
|
|
152
|
+
*/
|
|
153
|
+
sourcemap?: Sourcemap;
|
|
154
|
+
/**
|
|
155
|
+
* A callback function that runs after the build process completes
|
|
156
|
+
* This can be used for custom post-build operations like copying files,
|
|
157
|
+
* running additional tools, or logging build information
|
|
158
|
+
*
|
|
159
|
+
* If watch mode is enabled, this callback runs after each rebuild
|
|
160
|
+
*/
|
|
161
|
+
onBuildEnd?: () => void | Promise<void>;
|
|
141
162
|
}
|
|
142
163
|
|
|
143
164
|
type DefineConfigOption = WithOptional<BunupOptions, "outDir" | "format">;
|
package/build/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ type WithOptional<
|
|
|
6
6
|
type Format = "esm" | "cjs" | "iife";
|
|
7
7
|
type Target = "bun" | "node" | "browser";
|
|
8
8
|
type External = string[];
|
|
9
|
+
type Sourcemap = "none" | "linked" | "external" | "inline";
|
|
9
10
|
type Entry = string[] | Record<string, string>;
|
|
10
11
|
type DtsOptions = {
|
|
11
12
|
/**
|
|
@@ -138,6 +139,26 @@ interface BunupOptions {
|
|
|
138
139
|
* Defaults to true if not specified
|
|
139
140
|
*/
|
|
140
141
|
clean?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Specifies the type of sourcemap to generate
|
|
144
|
+
* Can be 'none', 'linked', 'external', or 'inline'
|
|
145
|
+
*
|
|
146
|
+
* @see https://bun.sh/docs/bundler#sourcemap
|
|
147
|
+
*
|
|
148
|
+
* @default 'none'
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* sourcemap: 'linked'
|
|
152
|
+
*/
|
|
153
|
+
sourcemap?: Sourcemap;
|
|
154
|
+
/**
|
|
155
|
+
* A callback function that runs after the build process completes
|
|
156
|
+
* This can be used for custom post-build operations like copying files,
|
|
157
|
+
* running additional tools, or logging build information
|
|
158
|
+
*
|
|
159
|
+
* If watch mode is enabled, this callback runs after each rebuild
|
|
160
|
+
*/
|
|
161
|
+
onBuildEnd?: () => void | Promise<void>;
|
|
141
162
|
}
|
|
142
163
|
|
|
143
164
|
type DefineConfigOption = WithOptional<BunupOptions, "outDir" | "format">;
|