bunup 0.4.78 → 0.4.87
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/dist/cli.js +11 -11
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/plugins.d.ts +5 -5
- package/package.json +12 -8
- package/dist/index.cjs +0 -16
- package/dist/index.d.cts +0 -490
- package/dist/plugins.cjs +0 -2
- package/dist/plugins.d.cts +0 -492
package/dist/cli.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
3
|
+
var Ar=Object.create;var{getPrototypeOf:Er,defineProperty:sn,getOwnPropertyNames:Ur}=Object;var _r=Object.prototype.hasOwnProperty;var v=(n,r,t)=>{t=n!=null?Ar(Er(n)):{};let e=r||!n||!n.__esModule?sn(t,"default",{value:n,enumerable:!0}):t;for(let o of Ur(n))if(!_r.call(e,o))sn(e,o,{get:()=>n[o],enumerable:!0});return e};var Wr=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports);var Hr=(n,r)=>{for(var t in r)sn(n,t,{get:r[t],enumerable:!0,configurable:!0,set:(e)=>r[t]=()=>e})};var p=(n,r)=>()=>(n&&(r=n(n=0)),r);var vr=import.meta.require;var q=Wr((je,an)=>{var Z=process||{},kn=Z.argv||[],Q=Z.env||{},qr=!(!!Q.NO_COLOR||kn.includes("--no-color"))&&(!!Q.FORCE_COLOR||kn.includes("--color")||Z.platform==="win32"||(Z.stdout||{}).isTTY&&Q.TERM!=="dumb"||!!Q.CI),Fr=(n,r,t=n)=>(e)=>{let o=""+e,i=o.indexOf(r,n.length);return~i?n+Yr(o,r,t,i)+r:n+o+r},Yr=(n,r,t,e)=>{let o="",i=0;do o+=n.substring(i,e)+t,i=e+r.length,e=n.indexOf(r,i);while(~e);return o+n.substring(i)},Ln=(n=qr)=>{let r=n?Fr:()=>String;return{isColorSupported:n,reset:r("\x1B[0m","\x1B[0m"),bold:r("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:r("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:r("\x1B[3m","\x1B[23m"),underline:r("\x1B[4m","\x1B[24m"),inverse:r("\x1B[7m","\x1B[27m"),hidden:r("\x1B[8m","\x1B[28m"),strikethrough:r("\x1B[9m","\x1B[29m"),black:r("\x1B[30m","\x1B[39m"),red:r("\x1B[31m","\x1B[39m"),green:r("\x1B[32m","\x1B[39m"),yellow:r("\x1B[33m","\x1B[39m"),blue:r("\x1B[34m","\x1B[39m"),magenta:r("\x1B[35m","\x1B[39m"),cyan:r("\x1B[36m","\x1B[39m"),white:r("\x1B[37m","\x1B[39m"),gray:r("\x1B[90m","\x1B[39m"),bgBlack:r("\x1B[40m","\x1B[49m"),bgRed:r("\x1B[41m","\x1B[49m"),bgGreen:r("\x1B[42m","\x1B[49m"),bgYellow:r("\x1B[43m","\x1B[49m"),bgBlue:r("\x1B[44m","\x1B[49m"),bgMagenta:r("\x1B[45m","\x1B[49m"),bgCyan:r("\x1B[46m","\x1B[49m"),bgWhite:r("\x1B[47m","\x1B[49m"),blackBright:r("\x1B[90m","\x1B[39m"),redBright:r("\x1B[91m","\x1B[39m"),greenBright:r("\x1B[92m","\x1B[39m"),yellowBright:r("\x1B[93m","\x1B[39m"),blueBright:r("\x1B[94m","\x1B[39m"),magentaBright:r("\x1B[95m","\x1B[39m"),cyanBright:r("\x1B[96m","\x1B[39m"),whiteBright:r("\x1B[97m","\x1B[39m"),bgBlackBright:r("\x1B[100m","\x1B[49m"),bgRedBright:r("\x1B[101m","\x1B[49m"),bgGreenBright:r("\x1B[102m","\x1B[49m"),bgYellowBright:r("\x1B[103m","\x1B[49m"),bgBlueBright:r("\x1B[104m","\x1B[49m"),bgMagentaBright:r("\x1B[105m","\x1B[49m"),bgCyanBright:r("\x1B[106m","\x1B[49m"),bgWhiteBright:r("\x1B[107m","\x1B[49m")}};an.exports=Ln();an.exports.createColors=Ln});function V(n){In=n??!1}class E{static instance;loggedOnceMessages=new Set;MAX_LABEL_LENGTH=3;cliColor=d.default.blue;mutedColor=d.default.dim;infoColor=d.default.cyan;warnColor=d.default.yellow;errorColor=d.default.red;defaultColor=d.default.white;progressFgColorMap={ESM:d.default.yellow,CJS:d.default.green,IIFE:d.default.magenta,DTS:d.default.blue};progressBgColorMap={ESM:d.default.bgYellow,CJS:d.default.bgGreen,IIFE:d.default.bgMagenta,DTS:d.default.bgBlue};labels={cli:"CLI",info:"INFO",warn:"WARN",error:"ERROR"};constructor(){}static getInstance(){if(!E.instance)E.instance=new E;return E.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(n){if(!n?.once)return!0;if(this.loggedOnceMessages.has(n.once))return!1;return this.loggedOnceMessages.add(n.once),!0}formatMessage({fgColor:n,bgColor:r,label:t,message:e,identifier:o,muted:i}){let s=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-t.length)),l=i?this.mutedColor(e):e,a=o?` ${r(d.default.black(` ${o} `))}`:"";return`${n(t)} ${s}${l}${a}`}output(n,r={},t=console.log){if(In||!this.shouldLog(r))return;if(r.verticalSpace)t("");if(t(n),r.verticalSpace)t("")}cli(n,r={}){let t=this.formatMessage({fgColor:this.cliColor,bgColor:d.default.bgBlue,label:this.labels.cli,message:n,identifier:r.identifier,muted:r.muted});this.output(t,r)}info(n,r={}){let t=this.formatMessage({fgColor:this.infoColor,bgColor:d.default.bgCyan,label:this.labels.info,message:n,identifier:r.identifier,muted:r.muted});this.output(t,r)}warn(n,r={}){let t=this.formatMessage({fgColor:this.warnColor,bgColor:d.default.bgYellow,label:this.labels.warn,message:n,identifier:r.identifier,muted:r.muted});this.output(t,r,console.warn)}error(n,r={}){let t=this.formatMessage({fgColor:this.errorColor,bgColor:d.default.bgRed,label:this.labels.error,message:n,identifier:r.identifier,muted:r.muted});this.output(t,r,console.error)}getProgressFgColor(n){for(let[r,t]of Object.entries(this.progressFgColorMap))if(n.includes(r))return t;return this.defaultColor}getProgressBgColor(n){for(let[r,t]of Object.entries(this.progressBgColorMap))if(n.includes(r))return t;return d.default.bgWhite}progress(n,r,t={}){let e=this.getProgressFgColor(n),o=this.getProgressBgColor(n),i=this.formatMessage({fgColor:e,bgColor:o,label:n,message:r,identifier:t.identifier,muted:t.muted});this.output(i,t)}}var d,In=!1,m;var L=p(()=>{d=v(q(),1);m=E.getInstance()});function cn(n){return n instanceof N}var b,T,M,C,B,X,N,y=(n)=>{if(n instanceof Error)return n.message;return String(n)},Gr,ln=(n,r)=>{let t=y(n),e=r?`[${r}] `:"",o=cn(n),i="ERROR";if(n instanceof M)i="BUILD ERROR";else if(n instanceof C)i="DTS ERROR";else if(n instanceof B)i="CLI ERROR";else if(n instanceof X)i="WATCH ERROR";else if(o)i="ISOLATED DECL ERROR";else if(n instanceof T)i="BUNUP ERROR";let s=Gr.find((l)=>l.pattern.test(t)&&(l.errorType===i||!l.errorType));if(!s)console.error(`${b.default.red(i)} ${e}${o?b.default.dim(t):t}`);if(s)console.log(`
|
|
4
4
|
`),s.logSolution(t),console.log(`
|
|
5
|
-
`);else if(!o)console.error(b.default.dim(b.default.white("If you think this is a bug, please open an issue at: ")+b.default.cyan("https://github.com/arshad-yaseen/bunup/issues/new")))}
|
|
6
|
-
`)+b.default.white("Example: ")+b.default.green("`bunup --target bun`")+b.default.white(" or in config: ")+b.default.green("{ target: 'bun' }"))}}]});import
|
|
7
|
-
`),e=t.length,o=t[t.length-1].length+1;return` (${e}:${o})`}function
|
|
8
|
-
`);let f=
|
|
9
|
-
`),new
|
|
10
|
-
`);return r===-1?{shebangLine:"",codeContent:n}:{shebangLine:n.slice(0,r+1),codeContent:n.slice(r+1)}}var
|
|
5
|
+
`);else if(!o)console.error(b.default.dim(b.default.white("If you think this is a bug, please open an issue at: ")+b.default.cyan("https://github.com/arshad-yaseen/bunup/issues/new")))},jn=(n,r)=>{ln(n,r),process.exit(1)};var O=p(()=>{b=v(q(),1);L();T=class T extends Error{constructor(n){super(n);this.name="BunupError"}};M=class M extends T{constructor(n){super(n);this.name="BunupBuildError"}};C=class C extends T{constructor(n){super(n);this.name="BunupDTSBuildError"}};B=class B extends T{constructor(n){super(n);this.name="BunupCLIError"}};X=class X extends T{constructor(n){super(n);this.name="BunupWatchError"}};N=class N extends T{constructor(n){super(n);this.name="BunupIsolatedDeclError"}};Gr=[{pattern:/Could not resolve: "bun"/i,errorType:"BUILD ERROR",logSolution:()=>{m.error(b.default.white("You're trying to build a project that uses Bun. ")+b.default.white("Please set the target option to ")+b.default.cyan("`bun`")+b.default.white(`.
|
|
6
|
+
`)+b.default.white("Example: ")+b.default.green("`bunup --target bun`")+b.default.white(" or in config: ")+b.default.green("{ target: 'bun' }"))}}]});import Tn from"fs/promises";import Kr from"path";function Mn(n,r,t){return Array.isArray(n)?n.map((e)=>({...e,[r]:t})):{...n,[r]:t}}function An(n){return Array.isArray(n)?n:[n]}function En(n,r){switch(n){case"esm":return U(r)?".js":".mjs";case"cjs":return U(r)?".cjs":".js";case"iife":return".global.js"}}function Un(n,r){switch(n){case"esm":return U(r)?".d.ts":".d.mts";case"cjs":return U(r)?".d.cts":".d.ts";case"iife":return".d.ts"}}function gn(n){return n==="node"||n==="bun"}function U(n){return n==="module"}function z(n){return n>=1000?`${(n/1000).toFixed(2)}s`:`${Math.round(n)}ms`}function _n(n){if(!n)return[];return Array.from(new Set([...Object.keys(n.dependencies||{}),...Object.keys(n.peerDependencies||{})]))}function A(n,r=3){return n.split("/").slice(-r).join("/")}async function Wn(n,r){let t=Kr.join(n,r);try{await Tn.rm(t,{recursive:!0,force:!0})}catch(e){throw new M(`Failed to clean output directory: ${e}`)}await Tn.mkdir(t,{recursive:!0})}var $=p(()=>{O()});function Qr(n){return _n(n).map((r)=>new RegExp(`^${r}($|\\/|\\\\)`))}function Hn(n,r){return typeof r==="string"?r===n:r.test(n)}function D(n,r,t){let o=Qr(t).some((s)=>s.test(n))||r.external?.some((s)=>Hn(n,s)),i=r.noExternal?.some((s)=>Hn(n,s));return o&&!i}var fn=p(()=>{$()});import{resolveTsImportPath as Zr}from"ts-import-resolver";var Y="\x00dts:",vn=(n,r,t)=>{return{name:"bunup:virtual-dts",async resolveId(e,o){if(mn(e))return e;if(!o||!mn(o))return null;let i=r.tsconfig?Zr({path:e,importer:F(o),tsconfig:r.tsconfig,rootDir:t}):null;if(!i)return null;let s=I(i);if(n.has(s))return J(s);return null},load(e){if(e.startsWith(Y)){let o=F(e),i=n.get(o);if(i)return i}return null}}};var un=p(()=>{j()});function G(n){return n.endsWith(".d.ts")||n.endsWith(".d.mts")||n.endsWith(".d.cts")}function qn(n){return dn.test(n)&&!G(n)}function _(n){return[".ts",".mts",".cts",".tsx"].some((r)=>n.endsWith(r))&&!G(n)}function I(n){if(G(n))return n;if(n.endsWith(".mts"))return`${n.slice(0,-4)}.d.mts`;if(n.endsWith(".cts"))return`${n.slice(0,-4)}.d.cts`;if(dn.test(n))return n.replace(dn,".d.ts");return`${n}.d.ts`}function mn(n){return n.startsWith(Y)}function F(n){return n.replace(Y,"")}function J(n){return`${Y}${n}`}function Fn(n,r){if(r===void 0)return"";let t=n.slice(0,r).split(`
|
|
7
|
+
`),e=t.length,o=t[t.length-1].length+1;return` (${e}:${o})`}function Yn(n,r,t,e){if(typeof e==="boolean"&&e)return!1;if(Array.isArray(e)){for(let o of e)if(typeof o==="string"&&n===o)return!1;else if(o instanceof RegExp&&o.test(n))return!1}return D(n,r,t)}var dn;var j=p(()=>{fn();un();dn=/\.(js|mjs|cjs|ts|mts|cts|tsx|jsx)$/});import{basename as Vr,dirname as Xr,extname as Nr}from"path";function P(n){let r=Vr(n),t=Nr(r);return t?r.slice(0,-t.length):r}function K(n){if(typeof n==="string")return[{fullEntryPath:n,name:P(n)}];if(typeof n==="object"&&!Array.isArray(n))return Object.entries(n).map(([e,o])=>({fullEntryPath:o,name:e}));let r=[],t=new Set;for(let e of n){let o=P(e);if(!t.has(o)){r.push({fullEntryPath:e,name:o}),t.add(o);continue}let s=Xr(e).split("/").filter((a)=>a!=="."&&a!=="");if(s.length===0){let a=1,c;do c=`${o}_${a++}`;while(t.has(c));r.push({fullEntryPath:e,name:c}),t.add(c);continue}let l=!1;for(let a=1;a<=s.length&&!l;a++){let g=`${s.slice(-a).join("/")}/${o}`;if(!t.has(g))r.push({fullEntryPath:e,name:g}),t.add(g),l=!0}if(!l){let a=1,c;do c=`${s.join("/")}/${o}_${a++}`;while(t.has(c));r.push({fullEntryPath:e,name:c}),t.add(c)}}return r}function Gn(n){return n.filter((r)=>_(r.fullEntryPath))}function Kn(n,r){return`[dir]/${n}${r}`}var nn=p(()=>{j()});import{existsSync as Pr,readFileSync as ne,readdirSync as re}from"fs";import{dirname as Nn,join as zn,resolve as ee}from"path";class W{static instance;constructor(){}static getInstance(){if(!W.instance)W.instance=new W;return W.instance}warn(n){console.log(`\x1B[33mWARNING: ${n}\x1B[0m`)}}function Dn(n){try{return Pr(n)}catch{return!1}}async function bn(n){try{if(!Dn(n))return null;if(n.slice(n.lastIndexOf(".")).toLowerCase()===".json"){let e=ne(n,"utf-8");return JSON.parse(e)}let r=await import(n),t=r.default||r;if(typeof t==="function")t=t();if(t instanceof Promise)return t;return t}catch(r){return null}}function oe(n,r){let t=n,e=0;while(e<r){let o=zn(t,"package.json");if(Dn(o))return o;let i=Nn(t);if(i===t)break;t=i,e++}return null}async function Xn(n,r,t,e,o,i){if(i){let a=oe(t,e);if(a){let c=await bn(a);if(c&&typeof c==="object"&&i in c)return{config:c[i],filepath:a}}}if(o){let a=ee(t,o),c=await bn(a);if(c!==null)return{config:c,filepath:a};te.warn(`Preferred path "${o}" not found or invalid, searching for ${n} files instead.`)}let s=t,l=0;while(l<e){try{let c=re(s),g=new Set(c);for(let f of r){let u=`${n}${f}`;if(g.has(u)){let w=zn(s,u),x=await bn(w);if(x!==null)return{config:x,filepath:w}}}}catch(c){}let a=Nn(s);if(a===s)break;s=a,l++}return{config:null,filepath:null}}async function xn(n,r=Vn,t={}){if(typeof n==="string"){let c=n,{cwd:g=process.cwd(),maxDepth:f=10,preferredPath:u,packageJsonProperty:w}=t;return Xn(c,r,g,f,u,w)}let{name:e,extensions:o=Vn,cwd:i=process.cwd(),maxDepth:s=10,preferredPath:l,packageJsonProperty:a}=n;return Xn(e,o,i,s,l,a)}var te,Vn;var Jn=p(()=>{te=W.getInstance(),Vn=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"]});import ie from"path";async function Pn(n,r,t){return Array.isArray(n)&&"root"in n[0]?n.filter((e)=>t?t.includes(e.name):!0).map((e)=>({rootDir:ie.resolve(r,e.root),options:Mn(e.config,"name",e.name)})):[{rootDir:r,options:n}]}async function nr(n){let{config:r,filepath:t}=await xn({name:"package",cwd:n,extensions:[".json"]});return{packageJson:r,path:t}}async function rr(n,r){let{config:t,filepath:e}=await xn({name:"tsconfig",cwd:n,extensions:[".json"],preferredPath:r});return{tsconfig:t,path:e}}var hn=p(()=>{Jn();$()});import er from"path";import{ResolverFactory as se}from"oxc-resolver";function tr(n,r){return{name:"bunup:types-resolve",buildStart(){wn||=new se({mainFields:["types","typings","module","main"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".d.mts",".d.cts",".ts",".mts",".cts"],...n.path&&{tsconfig:{configFile:n.path}},modules:["node_modules","node_modules/@types"]})},async resolveId(t,e){if(r===!1)return;if(t==="bun")return;let o=e?F(e):void 0;if(/\0/.test(t))return;if(Array.isArray(r)){if(!r.some((a)=>typeof a==="string"?a===t:a.test(t)))return}let i=o?er.dirname(o):process.cwd(),{path:s}=await wn.async(i,t);if(!s)return;if(qn(s)){let l=I(s);try{let{path:a}=await wn.async(er.dirname(s),l);if(a)return a}catch(a){}return}return s}}}var wn;var or=p(()=>{j()});import{build as ae}from"rolldown";import{dts as ce}from"rolldown-plugin-dts";async function ir(n,r,t,e,o,i){let s=I(n),l=J(s),a=typeof t.dts==="object"&&"resolve"in t.dts?t.dts.resolve:void 0;try{let{output:c}=await ae({input:l,output:{dir:t.outDir},write:!1,...o.path&&{resolve:{tsconfigFilename:o.path}},onwarn(g,f){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(g.code??""))return;f(g)},plugins:[vn(r,o,i),a&&tr(o,a),ce({dtsInput:!0,emitDtsOnly:!0})],external:(g)=>Yn(g,t,e,a)});if(!c[0]?.code)return m.warn(`Generated empty declaration file for entry "${n}"`,{muted:!0}),"";return c[0].code}catch(c){throw new C(`DTS bundling failed for entry "${n}": ${y(c)}`)}}var sr=p(()=>{O();L();or();j();un()});import{resolveTsImportPath as le}from"ts-import-resolver";function xe(n){let r=new Set,t=[ge,fe,me,ue,de,pe,be];for(let e of t){let o=n.matchAll(e);for(let i of o)if(i[1])r.add(i[1])}return r}async function ar(n,r,t){let e=new Set([n]),o=[n];while(o.length){let i=o.pop();if(!i)continue;try{let s=await Bun.file(i).text(),l=xe(s);for(let a of l){let c=r.tsconfig?le({path:a,importer:i,tsconfig:r.tsconfig,rootDir:t}):null;if(!c||!(_(c)||G(c)))continue;if(!e.has(c))e.add(c),o.push(c)}}catch(s){m.warn(`Error processing ${i}: ${y(s)}`)}}return e}var ge,fe,me,ue,de,pe,be;var cr=p(()=>{O();L();j();ge=/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]/gm,fe=/^\s*export\s+.*from\s+['"]([^'"]+)['"]/gm,me=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,ue=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,de=/import\s+\w+\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,pe=/\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/g,be=/\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/g});import{isolatedDeclaration as he}from"oxc-transform";async function lr(n,r){let t=!1,e=new Map;if(await Promise.all([...n].map(async(o)=>{try{let i=I(o);if(!await Bun.file(o).exists())return;let l=await Bun.file(o).text(),{code:a,errors:c}=he(o,l);if(a)e.set(i,a);for(let g of c){if(!t&&!r)console.log(`
|
|
8
|
+
`);let f=g.labels[0],u=f?Fn(l,f.start):"",x=`${A(o)}${u}: ${we(g.message)}`;m[r?"warn":"error"](x),t=!0}}catch(i){m.warn(`Failed to generate declaration for ${o}: ${y(i)}`)}})),t&&!r)throw console.log(`
|
|
9
|
+
`),new N(`TypeScript is asking for explicit type annotations on your exports. This helps ensure better, more reliable type declarations for your library. Bunup uses TypeScript's ${Cn.default.blue("isolatedDeclarations")} feature to generate these declarations, which requires each export from your library to be fully typed. You can learn more here: ${Cn.default.blue("https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations")}`);return e}function we(n){return n.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}var Cn;var gr=p(()=>{Cn=v(q(),1);O();L();$();j()});import fr from"fs/promises";import yn from"path";async function mr(n,r){let t=yn.resolve(n),e=yn.resolve(t,r);if(!await fr.exists(t))throw new C(`Root directory does not exist: ${t}`);if(!await Bun.file(e).exists())throw new C(`Entry file does not exist: ${e}`);if(!_(e))throw new C(`Entry file must be a TypeScript file: ${e}`);if(yn.relative(t,e).startsWith(".."))throw new C(`Entry file must be within rootDir: ${e}`);return{absoluteRootDir:t,absoluteEntry:e}}var ur=p(()=>{O();j()});async function dr(n,r,t,e,o){let{absoluteEntry:i}=await mr(n,r),s=await ar(i,e,n),l=await lr(s,t.watch);return ir(i,l,t,o,e,n)}var pr=p(()=>{sr();cr();gr();ur()});function tn(n){return{...Ce,...n}}function br(n){let{minify:r,minifyWhitespace:t,minifyIdentifiers:e,minifySyntax:o}=n,i=r===!0;return{whitespace:t??i,identifiers:e??i,syntax:o??i}}function xr(n,r){return r==="cjs"?n:void 0}function hr(n,r,t,e){return{...typeof t==="object"&&Object.keys(t).reduce((o,i)=>{let s=JSON.stringify(t[i]);return o[`process.env.${i}`]=s,o[`import.meta.env.${i}`]=s,o},{}),...n,...e==="cjs"&&(r===!0||typeof r==="object"&&r.importMetaUrl)&&{"import.meta.url":"importMetaUrl"}}}function wr(n,r){return n===void 0?r==="esm":n}function Cr(n){return typeof n==="string"?n:void 0}var Ce;var Bn=p(()=>{Ce={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0}});function yr(n,r){return{name:"bunup:external-plugin",setup(t){t.onResolve({filter:/.*/},(e)=>{let o=e.path;if(D(o,n,r))return{path:o,external:!0};return null})}}}var Br=p(()=>{fn()});function Or({format:n,target:r,shims:t}){let o=Be(t).map((i)=>On[i]).filter((i)=>i.appliesTo(n,r));if(o.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(i){i.onLoad({filter:ye},async({path:s})=>{let l=await Bun.file(s).text(),a=o.filter((u)=>u.isNeededInFile(l));if(a.length===0)return;let{shebangLine:c,codeContent:g}=Oe(l),f=a.map((u)=>u.generateCode()).join("");return{contents:c+f+g}})}}}function Be(n){if(n===!0)return Object.keys(On);if(!n)return[];return Object.entries(n).filter(([r,t])=>t&&(r in On)).map(([r])=>r)}function Oe(n){if(!n.startsWith("#!"))return{shebangLine:"",codeContent:n};let r=n.indexOf(`
|
|
10
|
+
`);return r===-1?{shebangLine:"",codeContent:n}:{shebangLine:n.slice(0,r+1),codeContent:n.slice(r+1)}}var ye,On;var Sr=p(()=>{$();ye=/\.(js|ts|jsx|tsx|mts|cts)$/,On={dirnameFilename:{appliesTo:(n,r)=>n==="esm"&&gn(r),isNeededInFile:(n)=>/\b__dirname\b/.test(n)||/\b__filename\b/.test(n),generateCode:()=>`import { fileURLToPath } from 'url';
|
|
11
11
|
import { dirname } from 'path';
|
|
12
12
|
|
|
13
13
|
const __filename = fileURLToPath(import.meta.url);
|
|
14
14
|
const __dirname = dirname(__filename);
|
|
15
15
|
|
|
16
|
-
`},importMetaUrl:{appliesTo:(n,r)=>n==="cjs"&&
|
|
16
|
+
`},importMetaUrl:{appliesTo:(n,r)=>n==="cjs"&&gn(r),isNeededInFile:(n)=>/\bimport\.meta\.url\b/.test(n),generateCode:()=>`import { pathToFileURL } from 'url';
|
|
17
17
|
|
|
18
18
|
const importMetaUrl = pathToFileURL(__filename).href;
|
|
19
19
|
|
|
20
|
-
`}}});function
|
|
20
|
+
`}}});function Rr(n){if(!n)return[];return n.filter((r)=>r.type==="bun")}function kr(n){if(!n)return[];return n.filter((r)=>r.type==="bunup")}async function Lr(n,r){if(!n)return;for(let t of n)if(t.hooks.onBuildStart)await t.hooks.onBuildStart(r)}async function $r(n,r,t){if(!n)return;for(let e of n)if(e.hooks.onBuildDone)await e.hooks.onBuildDone({options:r,output:t})}var Tr={};Hr(Tr,{build:()=>Sn});async function Sn(n,r=process.cwd()){let t={files:[]},e=tn(n);if(!e.entry||e.entry.length===0||!e.outDir)throw new M("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(e.clean)Wn(r,e.outDir);V(e.silent);let{packageJson:o,path:i}=await nr(r);if(o&&i)m.cli(`Using ${A(i,2)}`,{muted:!0,identifier:e.name,once:`${i}:${e.name}`});let s=kr(e.plugins);await Lr(s,e);let l=K(e.entry),a=o?.type;if(!e.dtsOnly){let c=[yr(e,o),...Rr(e.plugins).map((f)=>f.plugin)],g=e.format.flatMap((f)=>l.map(async(u)=>{let w=e.outputExtension?.({format:f,packageType:a,options:e,entry:u}).js??En(f,a),x=await Bun.build({entrypoints:[`${r}/${u.fullEntryPath}`],format:f,naming:{entry:Kn(u.name,w)},splitting:wr(e.splitting,f),bytecode:xr(e.bytecode,f),define:hr(e.define,e.shims,e.env,f),minify:br(e),outdir:`${r}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:Cr(e.env),plugins:[...c,Or({format:f,target:e.target,shims:e.shims})],throw:!1});if(!x.success)for(let k of x.logs){if(k.level==="error")throw new M(k.message);if(k.level==="warning")m.warn(k.message);else if(k.level==="info")m.info(k.message)}let R=Ir(e.outDir,u.name,w),H=jr(r,R);t.files.push({fullPath:H,relativePathToOutputDir:R}),m.progress(f.toUpperCase(),R,{identifier:e.name})}));await Promise.all(g)}if(e.dts||e.dtsOnly){let c=await rr(r,e.preferredTsconfigPath);if(c.path)m.cli(`Using ${A(c.path,2)}`,{muted:!0,identifier:e.name,once:`${c.path}:${e.name}`});let g=e.format.filter((u)=>{if(u==="iife"&&!U(a)&&e.format.includes("cjs"))return!1;return!0}),f=typeof e.dts==="object"&&e.dts.entry?K(e.dts.entry):Gn(l);try{await Promise.all(f.map(async(u)=>{let w=await dr(r,u.fullEntryPath,e,c,o);await Promise.all(g.map(async(x)=>{let R=e.outputExtension?.({format:x,packageType:a,options:e,entry:u}).dts??Un(x,a),H=Ir(e.outDir,u.name,R),k=jr(r,H);t.files.push({fullPath:k,relativePathToOutputDir:H}),await Bun.write(k,w),m.progress("DTS",H,{identifier:e.name})}))}))}catch(u){if(cn(u))throw u;throw new C(y(u))}}if(await $r(s,e,t),e.onSuccess)await e.onSuccess(e)}function Ir(n,r,t){return`${n}/${r}${t}`}function jr(n,r){return`${n}/${r}`}var Rn=p(()=>{pr();O();nn();hn();L();Bn();Br();Sr();$()});import{exec as Re}from"tinyexec";var pn=v(q(),1);var $n="https://bunup.dev/cli-options";O();nn();L();function h(n){return(r,t)=>{t[n]=r===!0||r==="true"}}function S(n){return(r,t)=>{if(typeof r==="string")t[n]=r;else throw new B(`Option --${n} requires a string value`)}}function rn(n){return(r,t)=>{if(typeof r==="string")t[n]=r.split(",");else throw new B(`Option --${n} requires a string value`)}}function zr(n){return(r,t)=>{if(typeof r==="boolean")t[n]=r;else if(typeof r==="string")if(r.toLowerCase()==="true"||r.toLowerCase()==="false")t[n]=r.toLowerCase()==="true";else t[n]=r;else throw new B(`Option --${n} requires a boolean or string value`)}}function Dr(){console.log(`
|
|
21
21
|
Bunup - \u26A1\uFE0F A blazing-fast build tool for your libraries built with Bun.
|
|
22
|
-
`),console.log("For more information on available options, visit:"),console.log(`${
|
|
23
|
-
`),process.exit(0)}function
|
|
22
|
+
`),console.log("For more information on available options, visit:"),console.log(`${pn.default.cyan(pn.default.underline($n))}
|
|
23
|
+
`),process.exit(0)}function Jr(){console.log("0.4.74"),process.exit(0)}var Qn={name:{flags:["n","name"],handler:S("name")},format:{flags:["f","format"],handler:rn("format")},outDir:{flags:["o","out-dir"],handler:S("outDir")},minify:{flags:["m","minify"],handler:h("minify")},watch:{flags:["w","watch"],handler:h("watch")},dts:{flags:["d","dts"],handler:h("dts")},banner:{flags:["bn","banner"],handler:S("banner")},footer:{flags:["ft","footer"],handler:S("footer")},external:{flags:["e","external"],handler:rn("external")},sourcemap:{flags:["sm","sourcemap"],handler:zr("sourcemap")},target:{flags:["t","target"],handler:S("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:h("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:h("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:h("minifySyntax")},clean:{flags:["c","clean"],handler:h("clean")},splitting:{flags:["s","splitting"],handler:h("splitting")},noExternal:{flags:["ne","no-external"],handler:rn("noExternal")},preferredTsconfigPath:{flags:["tsconfig","preferred-tsconfig-path"],handler:S("preferredTsconfigPath")},bytecode:{flags:["bc","bytecode"],handler:h("bytecode")},dtsOnly:{flags:["do","dts-only"],handler:h("dtsOnly")},silent:{flags:["silent"],handler:h("silent")},config:{flags:["config"],handler:S("config")},publicPath:{flags:["pp","public-path"],handler:S("publicPath")},env:{flags:["env"],handler:S("env")},shims:{flags:["shims"],handler:h("shims")},onSuccess:{flags:["onSuccess"],handler:S("onSuccess")},filter:{flags:["filter"],handler:rn("filter")},entry:{flags:["entry"],handler:(n,r,t)=>{if(typeof n!=="string")throw new B(`Entry${t?` --entry.${t}`:""} requires a string value`);let e=r.entry||{};if(t){if(e[t])m.warn(`Duplicate entry name '${t}' provided via --entry.${t}. Overwriting previous entry.`);e[t]=n}else{let o=P(n);if(e[o])m.warn(`Duplicate entry name '${o}' derived from '${n}'. Overwriting previous entry.`);e[o]=n}r.entry=e}},resolveDts:{flags:["rd","resolve-dts"],handler:(n,r)=>{if(!r.dts)r.dts={};if(typeof r.dts==="boolean")r.dts={};if(typeof n==="string")if(n==="true"||n==="false")r.dts.resolve=n==="true";else r.dts.resolve=n.split(",");else r.dts.resolve=!0}},help:{flags:["h","help"],handler:()=>Dr()},version:{flags:["v","version"],handler:()=>Jr()}},en={};for(let n of Object.values(Qn))for(let r of n.flags)en[r]=n.handler;function Zn(n){let r={};for(let t=0;t<n.length;t++){let e=n[t];if(e.startsWith("--")){let o,i;if(e.includes("=")){let[s,l]=e.slice(2).split("=",2);o=s,i=l}else{o=e.slice(2);let s=n[t+1];if(i=s&&!s.startsWith("-")?s:!0,typeof i==="string")t++}if(o.includes(".")){let[s,l]=o.split(".",2),a=en[s];if(a)a(i,r,l);else throw new B(`Unknown option: --${o}`)}else{let s=en[o];if(s)s(i,r);else throw new B(`Unknown option: --${o}`)}}else if(e.startsWith("-")){let o=e.slice(1),i=n[t+1],s=i&&!i.startsWith("-")?i:!0;if(typeof s==="string")t++;let l=en[o];if(l)l(s,r);else throw new B(`Unknown option: -${o}`)}else Qn.entry.handler(e,r,void 0)}return r}O();L();hn();$();Rn();O();nn();L();Bn();$();import on from"path";async function Mr(n,r){let t=new Set,e=tn(n),o=K(e.entry);for(let c of o){let g=on.resolve(r,c.fullEntryPath),f=on.dirname(g);t.add(f)}let s=(await import("chokidar")).watch(Array.from(t),{persistent:!0,ignoreInitial:!0,atomic:!0,ignorePermissionErrors:!0,ignored:[/[\\/]\.git[\\/]/,/[\\/]node_modules[\\/]/,on.join(r,e.outDir)]}),l=!1,a=async(c=!1)=>{if(l)return;l=!0;try{let g=performance.now();if(await Sn({...e,entry:o.map((f)=>f.fullEntryPath),clean:!1},r),!c)m.cli(`\uD83D\uDCE6 Rebuild finished in ${z(performance.now()-g)}`)}catch(g){ln(g)}finally{l=!1}};s.on("change",(c)=>{let g=on.relative(r,c);m.cli(`File changed: ${g}`,{muted:!0,once:g}),a()}),s.on("error",(c)=>{throw new X(`Watcher error: ${y(c)}`)}),await a(!0)}import{loadConfig as ke}from"unconfig";async function Le(n=Bun.argv.slice(2)){let r=Zn(n);V(r.silent);let t=process.cwd(),{config:e,sources:o}=await ke({sources:[{files:r.config||"bunup.config",extensions:["ts","js","mjs","cjs"]},{files:"package.json",extensions:[],rewrite(f){return f?.bunup}}],merge:!1}),i=o?.[0],s=!e?[{rootDir:t,options:r}]:await Pn(e,t,r.filter);if(m.cli(`Using bunup v0.4.74 and bun v${Bun.version}`,{muted:!0}),i)m.cli(`Using ${A(i,2)}`,{muted:!0});let l=performance.now();m.cli("Build started");let{build:a}=await Promise.resolve().then(() => (Rn(),Tr));await Promise.all(s.flatMap(({options:f,rootDir:u})=>{return An(f).map(async(x)=>{let R={...x,...$e(r)};if(R.watch)await Mr(R,u);else await a(R,u)})}));let c=performance.now()-l,g=z(c);if(m.cli(`\u26A1\uFE0F Build completed in ${g}`),r.watch)m.cli("\uD83D\uDC40 Watching for file changes");if(r.onSuccess)m.cli(`Running command: ${r.onSuccess}`,{muted:!0}),await Re(r.onSuccess,[],{nodeOptions:{shell:!0,stdio:"inherit"}});if(!r.watch)process.exit(process.exitCode??0)}function $e(n){return{...n,onSuccess:void 0,config:void 0}}Le().catch((n)=>jn(n));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import _Bun from "bun";
|
|
2
2
|
|
|
3
|
-
//#region \0dts:/
|
|
3
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/helpers/entry.d.ts
|
|
4
4
|
type ProcessableEntry = {
|
|
5
5
|
fullEntryPath: string
|
|
6
6
|
name: string
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
|
-
//#region \0dts:/
|
|
10
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/plugins/types.d.ts
|
|
11
11
|
/**
|
|
12
12
|
* Represents a Bun plugin that can be used with Bunup
|
|
13
13
|
*/
|
|
@@ -72,7 +72,7 @@ type BunupPlugin = {
|
|
|
72
72
|
type Plugin = BunupBunPlugin | BunupPlugin;
|
|
73
73
|
|
|
74
74
|
//#endregion
|
|
75
|
-
//#region \0dts:/
|
|
75
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/options.d.ts
|
|
76
76
|
type Loader = NonNullable<BunBuildOptions["loader"]>[string];
|
|
77
77
|
type Define = BunBuildOptions["define"];
|
|
78
78
|
type Sourcemap = BunBuildOptions["sourcemap"];
|
|
@@ -460,7 +460,7 @@ interface BuildOptions {
|
|
|
460
460
|
}
|
|
461
461
|
|
|
462
462
|
//#endregion
|
|
463
|
-
//#region \0dts:/
|
|
463
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/types.d.ts
|
|
464
464
|
type MaybePromise<T> = Promise<T> | T;
|
|
465
465
|
type WithOptional<
|
|
466
466
|
T,
|
|
@@ -478,12 +478,12 @@ type DefineWorkspaceItem = {
|
|
|
478
478
|
};
|
|
479
479
|
|
|
480
480
|
//#endregion
|
|
481
|
-
//#region \0dts:/
|
|
481
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/define.d.ts
|
|
482
482
|
declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
|
|
483
483
|
declare function defineWorkspace(options: DefineWorkspaceItem[]): DefineWorkspaceItem[];
|
|
484
484
|
|
|
485
485
|
//#endregion
|
|
486
|
-
//#region \0dts:/
|
|
486
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/build.d.ts
|
|
487
487
|
declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
|
|
488
488
|
|
|
489
489
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
`),e=t.length,o=t[t.length-1].length+1;return` (${e}:${o})`}function
|
|
4
|
-
`);let
|
|
5
|
-
`),new _(`TypeScript is asking for explicit type annotations on your exports. This helps ensure better, more reliable type declarations for your library. Bunup uses TypeScript's ${
|
|
2
|
+
var Zr=Object.create;var{getPrototypeOf:Hr,defineProperty:J,getOwnPropertyNames:Vr}=Object;var zr=Object.prototype.hasOwnProperty;var Y=(r,n,t)=>{t=r!=null?Zr(Hr(r)):{};let e=n||!r||!r.__esModule?J(t,"default",{value:r,enumerable:!0}):t;for(let o of Vr(r))if(!zr.call(e,o))J(e,o,{get:()=>r[o],enumerable:!0});return e};var Xr=(r,n)=>()=>(n||r((n={exports:{}}).exports,n),n.exports);var $=Xr((_n,G)=>{var A=process||{},v=A.argv||[],E=A.env||{},vr=!(!!E.NO_COLOR||v.includes("--no-color"))&&(!!E.FORCE_COLOR||v.includes("--color")||A.platform==="win32"||(A.stdout||{}).isTTY&&E.TERM!=="dumb"||!!E.CI),Pr=(r,n,t=r)=>(e)=>{let o=""+e,i=o.indexOf(n,r.length);return~i?r+rn(o,n,t,i)+n:r+o+n},rn=(r,n,t,e)=>{let o="",i=0;do o+=r.substring(i,e)+t,i=e+n.length,e=r.indexOf(n,i);while(~e);return o+r.substring(i)},P=(r=vr)=>{let n=r?Pr:()=>String;return{isColorSupported:r,reset:n("\x1B[0m","\x1B[0m"),bold:n("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:n("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:n("\x1B[3m","\x1B[23m"),underline:n("\x1B[4m","\x1B[24m"),inverse:n("\x1B[7m","\x1B[27m"),hidden:n("\x1B[8m","\x1B[28m"),strikethrough:n("\x1B[9m","\x1B[29m"),black:n("\x1B[30m","\x1B[39m"),red:n("\x1B[31m","\x1B[39m"),green:n("\x1B[32m","\x1B[39m"),yellow:n("\x1B[33m","\x1B[39m"),blue:n("\x1B[34m","\x1B[39m"),magenta:n("\x1B[35m","\x1B[39m"),cyan:n("\x1B[36m","\x1B[39m"),white:n("\x1B[37m","\x1B[39m"),gray:n("\x1B[90m","\x1B[39m"),bgBlack:n("\x1B[40m","\x1B[49m"),bgRed:n("\x1B[41m","\x1B[49m"),bgGreen:n("\x1B[42m","\x1B[49m"),bgYellow:n("\x1B[43m","\x1B[49m"),bgBlue:n("\x1B[44m","\x1B[49m"),bgMagenta:n("\x1B[45m","\x1B[49m"),bgCyan:n("\x1B[46m","\x1B[49m"),bgWhite:n("\x1B[47m","\x1B[49m"),blackBright:n("\x1B[90m","\x1B[39m"),redBright:n("\x1B[91m","\x1B[39m"),greenBright:n("\x1B[92m","\x1B[39m"),yellowBright:n("\x1B[93m","\x1B[39m"),blueBright:n("\x1B[94m","\x1B[39m"),magentaBright:n("\x1B[95m","\x1B[39m"),cyanBright:n("\x1B[96m","\x1B[39m"),whiteBright:n("\x1B[97m","\x1B[39m"),bgBlackBright:n("\x1B[100m","\x1B[49m"),bgRedBright:n("\x1B[101m","\x1B[49m"),bgGreenBright:n("\x1B[102m","\x1B[49m"),bgYellowBright:n("\x1B[103m","\x1B[49m"),bgBlueBright:n("\x1B[104m","\x1B[49m"),bgMagentaBright:n("\x1B[105m","\x1B[49m"),bgCyanBright:n("\x1B[106m","\x1B[49m"),bgWhiteBright:n("\x1B[107m","\x1B[49m")}};G.exports=P();G.exports.createColors=P});function Nr(r){return r}function Jr(r){return r}import{build as gn}from"rolldown";import{dts as cn}from"rolldown-plugin-dts";var nn=Y($(),1);var l=Y($(),1),rr=!1;function nr(r){rr=r??!1}class h{static instance;loggedOnceMessages=new Set;MAX_LABEL_LENGTH=3;cliColor=l.default.blue;mutedColor=l.default.dim;infoColor=l.default.cyan;warnColor=l.default.yellow;errorColor=l.default.red;defaultColor=l.default.white;progressFgColorMap={ESM:l.default.yellow,CJS:l.default.green,IIFE:l.default.magenta,DTS:l.default.blue};progressBgColorMap={ESM:l.default.bgYellow,CJS:l.default.bgGreen,IIFE:l.default.bgMagenta,DTS:l.default.bgBlue};labels={cli:"CLI",info:"INFO",warn:"WARN",error:"ERROR"};constructor(){}static getInstance(){if(!h.instance)h.instance=new h;return h.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(r){if(!r?.once)return!0;if(this.loggedOnceMessages.has(r.once))return!1;return this.loggedOnceMessages.add(r.once),!0}formatMessage({fgColor:r,bgColor:n,label:t,message:e,identifier:o,muted:i}){let g=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-t.length)),u=i?this.mutedColor(e):e,s=o?` ${n(l.default.black(` ${o} `))}`:"";return`${r(t)} ${g}${u}${s}`}output(r,n={},t=console.log){if(rr||!this.shouldLog(n))return;if(n.verticalSpace)t("");if(t(r),n.verticalSpace)t("")}cli(r,n={}){let t=this.formatMessage({fgColor:this.cliColor,bgColor:l.default.bgBlue,label:this.labels.cli,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n)}info(r,n={}){let t=this.formatMessage({fgColor:this.infoColor,bgColor:l.default.bgCyan,label:this.labels.info,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n)}warn(r,n={}){let t=this.formatMessage({fgColor:this.warnColor,bgColor:l.default.bgYellow,label:this.labels.warn,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n,console.warn)}error(r,n={}){let t=this.formatMessage({fgColor:this.errorColor,bgColor:l.default.bgRed,label:this.labels.error,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n,console.error)}getProgressFgColor(r){for(let[n,t]of Object.entries(this.progressFgColorMap))if(r.includes(n))return t;return this.defaultColor}getProgressBgColor(r){for(let[n,t]of Object.entries(this.progressBgColorMap))if(r.includes(n))return t;return l.default.bgWhite}progress(r,n,t={}){let e=this.getProgressFgColor(r),o=this.getProgressBgColor(r),i=this.formatMessage({fgColor:e,bgColor:o,label:r,message:n,identifier:t.identifier,muted:t.muted});this.output(i,t)}}var p=h.getInstance();class W extends Error{constructor(r){super(r);this.name="BunupError"}}class R extends W{constructor(r){super(r);this.name="BunupBuildError"}}class x extends W{constructor(r){super(r);this.name="BunupDTSBuildError"}}class _ extends W{constructor(r){super(r);this.name="BunupIsolatedDeclError"}}var w=(r)=>{if(r instanceof Error)return r.message;return String(r)};function er(r){return r instanceof _}import lr from"path";import{ResolverFactory as sn}from"oxc-resolver";import tr from"fs/promises";import en from"path";function or(r,n){switch(r){case"esm":return y(n)?".js":".mjs";case"cjs":return y(n)?".cjs":".js";case"iife":return".global.js"}}function ir(r,n){switch(r){case"esm":return y(n)?".d.ts":".d.mts";case"cjs":return y(n)?".d.cts":".d.ts";case"iife":return".d.ts"}}function K(r){return r==="node"||r==="bun"}function y(r){return r==="module"}function sr(r){if(!r)return[];return Array.from(new Set([...Object.keys(r.dependencies||{}),...Object.keys(r.peerDependencies||{})]))}function j(r,n=3){return r.split("/").slice(-n).join("/")}async function gr(r,n){let t=en.join(r,n);try{await tr.rm(t,{recursive:!0,force:!0})}catch(e){throw new R(`Failed to clean output directory: ${e}`)}await tr.mkdir(t,{recursive:!0})}function tn(r){return sr(r).map((n)=>new RegExp(`^${n}($|\\/|\\\\)`))}function cr(r,n){return typeof n==="string"?n===r:n.test(r)}function F(r,n,t){let o=tn(t).some((g)=>g.test(r))||n.external?.some((g)=>cr(r,g)),i=n.noExternal?.some((g)=>cr(r,g));return o&&!i}import{resolveTsImportPath as on}from"ts-import-resolver";var O="\x00dts:",ur=(r,n,t)=>{return{name:"bunup:virtual-dts",async resolveId(e,o){if(q(e))return e;if(!o||!q(o))return null;let i=n.tsconfig?on({path:e,importer:M(o),tsconfig:n.tsconfig,rootDir:t}):null;if(!i)return null;let g=B(i);if(r.has(g))return U(g);return null},load(e){if(e.startsWith(O)){let o=M(e),i=r.get(o);if(i)return i}return null}}};var D=/\.(js|mjs|cjs|ts|mts|cts|tsx|jsx)$/;function T(r){return r.endsWith(".d.ts")||r.endsWith(".d.mts")||r.endsWith(".d.cts")}function ar(r){return D.test(r)&&!T(r)}function S(r){return[".ts",".mts",".cts",".tsx"].some((n)=>r.endsWith(n))&&!T(r)}function B(r){if(T(r))return r;if(r.endsWith(".mts"))return`${r.slice(0,-4)}.d.mts`;if(r.endsWith(".cts"))return`${r.slice(0,-4)}.d.cts`;if(D.test(r))return r.replace(D,".d.ts");return`${r}.d.ts`}function q(r){return r.startsWith(O)}function M(r){return r.replace(O,"")}function U(r){return`${O}${r}`}function mr(r,n){if(n===void 0)return"";let t=r.slice(0,n).split(`
|
|
3
|
+
`),e=t.length,o=t[t.length-1].length+1;return` (${e}:${o})`}function fr(r,n,t,e){if(typeof e==="boolean"&&e)return!1;if(Array.isArray(e)){for(let o of e)if(typeof o==="string"&&r===o)return!1;else if(o instanceof RegExp&&o.test(r))return!1}return F(r,n,t)}var Q;function pr(r,n){return{name:"bunup:types-resolve",buildStart(){Q||=new sn({mainFields:["types","typings","module","main"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".d.mts",".d.cts",".ts",".mts",".cts"],...r.path&&{tsconfig:{configFile:r.path}},modules:["node_modules","node_modules/@types"]})},async resolveId(t,e){if(n===!1)return;if(t==="bun")return;let o=e?M(e):void 0;if(/\0/.test(t))return;if(Array.isArray(n)){if(!n.some((s)=>typeof s==="string"?s===t:s.test(t)))return}let i=o?lr.dirname(o):process.cwd(),{path:g}=await Q.async(i,t);if(!g)return;if(ar(g)){let u=B(g);try{let{path:s}=await Q.async(lr.dirname(g),u);if(s)return s}catch(s){}return}return g}}}async function br(r,n,t,e,o,i){let g=B(r),u=U(g),s=typeof t.dts==="object"&&"resolve"in t.dts?t.dts.resolve:void 0;try{let{output:c}=await gn({input:u,output:{dir:t.outDir},write:!1,...o.path&&{resolve:{tsconfigFilename:o.path}},onwarn(f,m){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(f.code??""))return;m(f)},plugins:[ur(n,o,i),s&&pr(o,s),cn({dtsInput:!0,emitDtsOnly:!0})],external:(f)=>fr(f,t,e,s)});if(!c[0]?.code)return p.warn(`Generated empty declaration file for entry "${r}"`,{muted:!0}),"";return c[0].code}catch(c){throw new x(`DTS bundling failed for entry "${r}": ${w(c)}`)}}import{resolveTsImportPath as un}from"ts-import-resolver";var an=/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]/gm,mn=/^\s*export\s+.*from\s+['"]([^'"]+)['"]/gm,fn=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,ln=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,pn=/import\s+\w+\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,bn=/\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/g,dn=/\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/g;function xn(r){let n=new Set,t=[an,mn,fn,ln,pn,bn,dn];for(let e of t){let o=r.matchAll(e);for(let i of o)if(i[1])n.add(i[1])}return n}async function dr(r,n,t){let e=new Set([r]),o=[r];while(o.length){let i=o.pop();if(!i)continue;try{let g=await Bun.file(i).text(),u=xn(g);for(let s of u){let c=n.tsconfig?un({path:s,importer:i,tsconfig:n.tsconfig,rootDir:t}):null;if(!c||!(S(c)||T(c)))continue;if(!e.has(c))e.add(c),o.push(c)}}catch(g){p.warn(`Error processing ${i}: ${w(g)}`)}}return e}var Z=Y($(),1);import{isolatedDeclaration as Cn}from"oxc-transform";async function xr(r,n){let t=!1,e=new Map;if(await Promise.all([...r].map(async(o)=>{try{let i=B(o);if(!await Bun.file(o).exists())return;let u=await Bun.file(o).text(),{code:s,errors:c}=Cn(o,u);if(s)e.set(i,s);for(let f of c){if(!t&&!n)console.log(`
|
|
4
|
+
`);let m=f.labels[0],a=m?mr(u,m.start):"",d=`${j(o)}${a}: ${wn(f.message)}`;p[n?"warn":"error"](d),t=!0}}catch(i){p.warn(`Failed to generate declaration for ${o}: ${w(i)}`)}})),t&&!n)throw console.log(`
|
|
5
|
+
`),new _(`TypeScript is asking for explicit type annotations on your exports. This helps ensure better, more reliable type declarations for your library. Bunup uses TypeScript's ${Z.default.blue("isolatedDeclarations")} feature to generate these declarations, which requires each export from your library to be fully typed. You can learn more here: ${Z.default.blue("https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations")}`);return e}function wn(r){return r.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}import Cr from"fs/promises";import H from"path";async function wr(r,n){let t=H.resolve(r),e=H.resolve(t,n);if(!await Cr.exists(t))throw new x(`Root directory does not exist: ${t}`);if(!await Bun.file(e).exists())throw new x(`Entry file does not exist: ${e}`);if(!S(e))throw new x(`Entry file must be a TypeScript file: ${e}`);if(H.relative(t,e).startsWith(".."))throw new x(`Entry file must be within rootDir: ${e}`);return{absoluteRootDir:t,absoluteEntry:e}}async function Br(r,n,t,e,o){let{absoluteEntry:i}=await wr(r,n),g=await dr(i,e,r),u=await xr(g,t.watch);return br(i,u,t,o,e,r)}import{basename as Bn,dirname as hn,extname as Rn}from"path";function hr(r){let n=Bn(r),t=Rn(n);return t?n.slice(0,-t.length):n}function V(r){if(typeof r==="string")return[{fullEntryPath:r,name:hr(r)}];if(typeof r==="object"&&!Array.isArray(r))return Object.entries(r).map(([e,o])=>({fullEntryPath:o,name:e}));let n=[],t=new Set;for(let e of r){let o=hr(e);if(!t.has(o)){n.push({fullEntryPath:e,name:o}),t.add(o);continue}let g=hn(e).split("/").filter((s)=>s!=="."&&s!=="");if(g.length===0){let s=1,c;do c=`${o}_${s++}`;while(t.has(c));n.push({fullEntryPath:e,name:c}),t.add(c);continue}let u=!1;for(let s=1;s<=g.length&&!u;s++){let f=`${g.slice(-s).join("/")}/${o}`;if(!t.has(f))n.push({fullEntryPath:e,name:f}),t.add(f),u=!0}if(!u){let s=1,c;do c=`${g.join("/")}/${o}_${s++}`;while(t.has(c));n.push({fullEntryPath:e,name:c}),t.add(c)}}return n}function Rr(r){return r.filter((n)=>S(n.fullEntryPath))}function yr(r,n){return`[dir]/${r}${n}`}import{existsSync as yn,readFileSync as Sn,readdirSync as kn}from"fs";import{dirname as Ir,join as Lr,resolve as In}from"path";class k{static instance;constructor(){}static getInstance(){if(!k.instance)k.instance=new k;return k.instance}warn(r){console.log(`\x1B[33mWARNING: ${r}\x1B[0m`)}}var Ln=k.getInstance(),Sr=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"];function jr(r){try{return yn(r)}catch{return!1}}async function z(r){try{if(!jr(r))return null;if(r.slice(r.lastIndexOf(".")).toLowerCase()===".json"){let e=Sn(r,"utf-8");return JSON.parse(e)}let n=await import(r),t=n.default||n;if(typeof t==="function")t=t();if(t instanceof Promise)return t;return t}catch(n){return null}}function jn(r,n){let t=r,e=0;while(e<n){let o=Lr(t,"package.json");if(jr(o))return o;let i=Ir(t);if(i===t)break;t=i,e++}return null}async function kr(r,n,t,e,o,i){if(i){let s=jn(t,e);if(s){let c=await z(s);if(c&&typeof c==="object"&&i in c)return{config:c[i],filepath:s}}}if(o){let s=In(t,o),c=await z(s);if(c!==null)return{config:c,filepath:s};Ln.warn(`Preferred path "${o}" not found or invalid, searching for ${r} files instead.`)}let g=t,u=0;while(u<e){try{let c=kn(g),f=new Set(c);for(let m of n){let a=`${r}${m}`;if(f.has(a)){let b=Lr(g,a),d=await z(b);if(d!==null)return{config:d,filepath:b}}}}catch(c){}let s=Ir(g);if(s===g)break;g=s,u++}return{config:null,filepath:null}}async function X(r,n=Sr,t={}){if(typeof r==="string"){let c=r,{cwd:f=process.cwd(),maxDepth:m=10,preferredPath:a,packageJsonProperty:b}=t;return kr(c,n,f,m,a,b)}let{name:e,extensions:o=Sr,cwd:i=process.cwd(),maxDepth:g=10,preferredPath:u,packageJsonProperty:s}=r;return kr(e,o,i,g,u,s)}async function Mr(r){let{config:n,filepath:t}=await X({name:"package",cwd:r,extensions:[".json"]});return{packageJson:n,path:t}}async function Or(r,n){let{config:t,filepath:e}=await X({name:"tsconfig",cwd:r,extensions:[".json"],preferredPath:n});return{tsconfig:t,path:e}}var Mn={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function Tr(r){return{...Mn,...r}}function Er(r){let{minify:n,minifyWhitespace:t,minifyIdentifiers:e,minifySyntax:o}=r,i=n===!0;return{whitespace:t??i,identifiers:e??i,syntax:o??i}}function Ar(r,n){return n==="cjs"?r:void 0}function $r(r,n,t,e){return{...typeof t==="object"&&Object.keys(t).reduce((o,i)=>{let g=JSON.stringify(t[i]);return o[`process.env.${i}`]=g,o[`import.meta.env.${i}`]=g,o},{}),...r,...e==="cjs"&&(n===!0||typeof n==="object"&&n.importMetaUrl)&&{"import.meta.url":"importMetaUrl"}}}function Wr(r,n){return r===void 0?n==="esm":r}function _r(r){return typeof r==="string"?r:void 0}function Fr(r,n){return{name:"bunup:external-plugin",setup(t){t.onResolve({filter:/.*/},(e)=>{let o=e.path;if(F(o,r,n))return{path:o,external:!0};return null})}}}var On=/\.(js|ts|jsx|tsx|mts|cts)$/,N={dirnameFilename:{appliesTo:(r,n)=>r==="esm"&&K(n),isNeededInFile:(r)=>/\b__dirname\b/.test(r)||/\b__filename\b/.test(r),generateCode:()=>`import { fileURLToPath } from 'url';
|
|
6
6
|
import { dirname } from 'path';
|
|
7
7
|
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -12,5 +12,5 @@ var Fr=Object.create;var{getPrototypeOf:Yr,defineProperty:V,getOwnPropertyNames:
|
|
|
12
12
|
|
|
13
13
|
const importMetaUrl = pathToFileURL(__filename).href;
|
|
14
14
|
|
|
15
|
-
`}};function
|
|
16
|
-
`);return n===-1?{shebangLine:"",codeContent:r}:{shebangLine:r.slice(0,n+1),codeContent:r.slice(n+1)}}function
|
|
15
|
+
`}};function Ur({format:r,target:n,shims:t}){let o=Tn(t).map((i)=>N[i]).filter((i)=>i.appliesTo(r,n));if(o.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(i){i.onLoad({filter:On},async({path:g})=>{let u=await Bun.file(g).text(),s=o.filter((a)=>a.isNeededInFile(u));if(s.length===0)return;let{shebangLine:c,codeContent:f}=En(u),m=s.map((a)=>a.generateCode()).join("");return{contents:c+m+f}})}}}function Tn(r){if(r===!0)return Object.keys(N);if(!r)return[];return Object.entries(r).filter(([n,t])=>t&&(n in N)).map(([n])=>n)}function En(r){if(!r.startsWith("#!"))return{shebangLine:"",codeContent:r};let n=r.indexOf(`
|
|
16
|
+
`);return n===-1?{shebangLine:"",codeContent:r}:{shebangLine:r.slice(0,n+1),codeContent:r.slice(n+1)}}function Yr(r){if(!r)return[];return r.filter((n)=>n.type==="bun")}function Gr(r){if(!r)return[];return r.filter((n)=>n.type==="bunup")}async function Kr(r,n){if(!r)return;for(let t of r)if(t.hooks.onBuildStart)await t.hooks.onBuildStart(n)}async function qr(r,n,t){if(!r)return;for(let e of r)if(e.hooks.onBuildDone)await e.hooks.onBuildDone({options:n,output:t})}async function An(r,n=process.cwd()){let t={files:[]},e=Tr(r);if(!e.entry||e.entry.length===0||!e.outDir)throw new R("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(e.clean)gr(n,e.outDir);nr(e.silent);let{packageJson:o,path:i}=await Mr(n);if(o&&i)p.cli(`Using ${j(i,2)}`,{muted:!0,identifier:e.name,once:`${i}:${e.name}`});let g=Gr(e.plugins);await Kr(g,e);let u=V(e.entry),s=o?.type;if(!e.dtsOnly){let c=[Fr(e,o),...Yr(e.plugins).map((m)=>m.plugin)],f=e.format.flatMap((m)=>u.map(async(a)=>{let b=e.outputExtension?.({format:m,packageType:s,options:e,entry:a}).js??or(m,s),d=await Bun.build({entrypoints:[`${n}/${a.fullEntryPath}`],format:m,naming:{entry:yr(a.name,b)},splitting:Wr(e.splitting,m),bytecode:Ar(e.bytecode,m),define:$r(e.define,e.shims,e.env,m),minify:Er(e),outdir:`${n}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:_r(e.env),plugins:[...c,Ur({format:m,target:e.target,shims:e.shims})],throw:!1});if(!d.success)for(let C of d.logs){if(C.level==="error")throw new R(C.message);if(C.level==="warning")p.warn(C.message);else if(C.level==="info")p.info(C.message)}let I=Dr(e.outDir,a.name,b),L=Qr(n,I);t.files.push({fullPath:L,relativePathToOutputDir:I}),p.progress(m.toUpperCase(),I,{identifier:e.name})}));await Promise.all(f)}if(e.dts||e.dtsOnly){let c=await Or(n,e.preferredTsconfigPath);if(c.path)p.cli(`Using ${j(c.path,2)}`,{muted:!0,identifier:e.name,once:`${c.path}:${e.name}`});let f=e.format.filter((a)=>{if(a==="iife"&&!y(s)&&e.format.includes("cjs"))return!1;return!0}),m=typeof e.dts==="object"&&e.dts.entry?V(e.dts.entry):Rr(u);try{await Promise.all(m.map(async(a)=>{let b=await Br(n,a.fullEntryPath,e,c,o);await Promise.all(f.map(async(d)=>{let I=e.outputExtension?.({format:d,packageType:s,options:e,entry:a}).dts??ir(d,s),L=Dr(e.outDir,a.name,I),C=Qr(n,L);t.files.push({fullPath:C,relativePathToOutputDir:L}),await Bun.write(C,b),p.progress("DTS",L,{identifier:e.name})}))}))}catch(a){if(er(a))throw a;throw new x(w(a))}}if(await qr(g,e,t),e.onSuccess)await e.onSuccess(e)}function Dr(r,n,t){return`${r}/${n}${t}`}function Qr(r,n){return`${r}/${n}`}export{Jr as defineWorkspace,Nr as defineConfig,An as build};
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import _Bun from "bun";
|
|
2
2
|
|
|
3
|
-
//#region \0dts:/
|
|
3
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/helpers/entry.d.ts
|
|
4
4
|
type ProcessableEntry = {
|
|
5
5
|
fullEntryPath: string
|
|
6
6
|
name: string
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
|
-
//#region \0dts:/
|
|
10
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/types.d.ts
|
|
11
11
|
type MaybePromise<T> = Promise<T> | T;
|
|
12
12
|
type Arrayable<T> = T | T[];
|
|
13
13
|
type Bun = typeof _Bun;
|
|
@@ -15,7 +15,7 @@ type BunBuildOptions = Parameters<Bun["build"]>[0];
|
|
|
15
15
|
type BunPlugin = Exclude<BunBuildOptions["plugins"], undefined>[number];
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
|
-
//#region \0dts:/
|
|
18
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/options.d.ts
|
|
19
19
|
type Loader = NonNullable<BunBuildOptions["loader"]>[string];
|
|
20
20
|
type Define = BunBuildOptions["define"];
|
|
21
21
|
type Sourcemap = BunBuildOptions["sourcemap"];
|
|
@@ -403,7 +403,7 @@ interface BuildOptions {
|
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
//#endregion
|
|
406
|
-
//#region \0dts:/
|
|
406
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/plugins/types.d.ts
|
|
407
407
|
/**
|
|
408
408
|
* Represents a Bun plugin that can be used with Bunup
|
|
409
409
|
*/
|
|
@@ -468,7 +468,7 @@ type BunupPlugin = {
|
|
|
468
468
|
type Plugin = BunupBunPlugin | BunupPlugin;
|
|
469
469
|
|
|
470
470
|
//#endregion
|
|
471
|
-
//#region \0dts:/
|
|
471
|
+
//#region \0dts:/Users/admin/Desktop/Projects/bunup/src/plugins/built-in/report.d.ts
|
|
472
472
|
type ReportPluginOptions = {
|
|
473
473
|
/**
|
|
474
474
|
* The maximum bundle size in bytes.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunup",
|
|
3
3
|
"description": "⚡ A blazing-fast build tool for your libraries built with Bun.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.87",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Arshad Yaseen <m@arshadyaseen.com> (https://arshadyaseen.com)",
|
|
7
7
|
"type": "module",
|
|
@@ -19,13 +19,17 @@
|
|
|
19
19
|
"homepage": "https://bunup.dev",
|
|
20
20
|
"funding": "https://github.com/sponsors/arshad-yaseen",
|
|
21
21
|
"keywords": ["bun", "bunup", "bun-bundler"],
|
|
22
|
-
"types": "./dist/index.d.ts",
|
|
23
|
-
"main": "./dist/index.cjs",
|
|
24
|
-
"module": "./dist/index.js",
|
|
25
22
|
"files": ["dist"],
|
|
26
23
|
"bin": {
|
|
27
24
|
"bunup": "./dist/cli.js"
|
|
28
25
|
},
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"module": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": "./dist/index.js",
|
|
31
|
+
"./plugins": "./dist/plugins.js"
|
|
32
|
+
},
|
|
29
33
|
"scripts": {
|
|
30
34
|
"build": "bunup",
|
|
31
35
|
"dev": "bunup --watch",
|
|
@@ -55,13 +59,13 @@
|
|
|
55
59
|
"workspaces": ["tests", "docs", "benchmarks", "create-bunup"],
|
|
56
60
|
"dependencies": {
|
|
57
61
|
"chokidar": "^4.0.3",
|
|
58
|
-
"coffi": "^0.1.23",
|
|
59
62
|
"oxc-resolver": "^5.0.1",
|
|
60
63
|
"oxc-transform": "^0.58.1",
|
|
61
64
|
"rolldown": "1.0.0-beta.7",
|
|
62
65
|
"rolldown-plugin-dts": "^0.7.0",
|
|
63
66
|
"tinyexec": "^1.0.1",
|
|
64
|
-
"ts-import-resolver": "^0.1.10"
|
|
67
|
+
"ts-import-resolver": "^0.1.10",
|
|
68
|
+
"unconfig": "^7.3.2"
|
|
65
69
|
},
|
|
66
70
|
"peerDependencies": {
|
|
67
71
|
"typescript": ">=4.5.0"
|
|
@@ -75,8 +79,8 @@
|
|
|
75
79
|
"@biomejs/biome": "^1.9.4",
|
|
76
80
|
"@types/bun": "^1.2.5",
|
|
77
81
|
"bumpp": "^10.1.0",
|
|
78
|
-
"bunup": "^0.4.
|
|
79
|
-
"create-bunup": "create-bunup",
|
|
82
|
+
"bunup": "^0.4.78",
|
|
83
|
+
"create-bunup": "workspace:create-bunup",
|
|
80
84
|
"husky": "^9.1.7",
|
|
81
85
|
"lint-staged": "^15.5.1",
|
|
82
86
|
"typescript": "^5.8.3"
|
package/dist/index.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// @bun @bun-cjs
|
|
2
|
-
(function(exports, require, module, __filename, __dirname) {var vr=Object.create;var{getPrototypeOf:Pr,defineProperty:O,getOwnPropertyNames:nr,getOwnPropertyDescriptor:rn}=Object,er=Object.prototype.hasOwnProperty;var l=(r,n,t)=>{t=r!=null?vr(Pr(r)):{};let e=n||!r||!r.__esModule?O(t,"default",{value:r,enumerable:!0}):t;for(let o of nr(r))if(!er.call(e,o))O(e,o,{get:()=>r[o],enumerable:!0});return e},rr=new WeakMap,nn=(r)=>{var n=rr.get(r),t;if(n)return n;if(n=O({},"__esModule",{value:!0}),r&&typeof r==="object"||typeof r==="function")nr(r).map((e)=>!er.call(n,e)&&O(n,e,{get:()=>r[e],enumerable:!(t=rn(r,e))||t.enumerable}));return rr.set(r,n),n},en=(r,n)=>()=>(n||r((n={exports:{}}).exports,n),n.exports);var tn=(r,n)=>{for(var t in n)O(r,t,{get:n[t],enumerable:!0,configurable:!0,set:(e)=>n[t]=()=>e})};var W=en((yn,G)=>{var _=process||{},ir=_.argv||[],A=_.env||{},on=!(!!A.NO_COLOR||ir.includes("--no-color"))&&(!!A.FORCE_COLOR||ir.includes("--color")||_.platform==="win32"||(_.stdout||{}).isTTY&&A.TERM!=="dumb"||!!A.CI),sn=(r,n,t=r)=>(e)=>{let o=""+e,i=o.indexOf(n,r.length);return~i?r+gn(o,n,t,i)+n:r+o+n},gn=(r,n,t,e)=>{let o="",i=0;do o+=r.substring(i,e)+t,i=e+n.length,e=r.indexOf(n,i);while(~e);return o+r.substring(i)},sr=(r=on)=>{let n=r?sn:()=>String;return{isColorSupported:r,reset:n("\x1B[0m","\x1B[0m"),bold:n("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:n("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:n("\x1B[3m","\x1B[23m"),underline:n("\x1B[4m","\x1B[24m"),inverse:n("\x1B[7m","\x1B[27m"),hidden:n("\x1B[8m","\x1B[28m"),strikethrough:n("\x1B[9m","\x1B[29m"),black:n("\x1B[30m","\x1B[39m"),red:n("\x1B[31m","\x1B[39m"),green:n("\x1B[32m","\x1B[39m"),yellow:n("\x1B[33m","\x1B[39m"),blue:n("\x1B[34m","\x1B[39m"),magenta:n("\x1B[35m","\x1B[39m"),cyan:n("\x1B[36m","\x1B[39m"),white:n("\x1B[37m","\x1B[39m"),gray:n("\x1B[90m","\x1B[39m"),bgBlack:n("\x1B[40m","\x1B[49m"),bgRed:n("\x1B[41m","\x1B[49m"),bgGreen:n("\x1B[42m","\x1B[49m"),bgYellow:n("\x1B[43m","\x1B[49m"),bgBlue:n("\x1B[44m","\x1B[49m"),bgMagenta:n("\x1B[45m","\x1B[49m"),bgCyan:n("\x1B[46m","\x1B[49m"),bgWhite:n("\x1B[47m","\x1B[49m"),blackBright:n("\x1B[90m","\x1B[39m"),redBright:n("\x1B[91m","\x1B[39m"),greenBright:n("\x1B[92m","\x1B[39m"),yellowBright:n("\x1B[93m","\x1B[39m"),blueBright:n("\x1B[94m","\x1B[39m"),magentaBright:n("\x1B[95m","\x1B[39m"),cyanBright:n("\x1B[96m","\x1B[39m"),whiteBright:n("\x1B[97m","\x1B[39m"),bgBlackBright:n("\x1B[100m","\x1B[49m"),bgRedBright:n("\x1B[101m","\x1B[49m"),bgGreenBright:n("\x1B[102m","\x1B[49m"),bgYellowBright:n("\x1B[103m","\x1B[49m"),bgBlueBright:n("\x1B[104m","\x1B[49m"),bgMagentaBright:n("\x1B[105m","\x1B[49m"),bgCyanBright:n("\x1B[106m","\x1B[49m"),bgWhiteBright:n("\x1B[107m","\x1B[49m")}};G.exports=sr();G.exports.createColors=sr});var Sn={};tn(Sn,{defineWorkspace:()=>or,defineConfig:()=>tr,build:()=>Nr});module.exports=nn(Sn);function tr(r){return r}function or(r){return r}var Sr=require("rolldown"),kr=require("rolldown-plugin-dts");var mn=l(W());var c=l(W()),gr=!1;function mr(r){gr=r??!1}class h{static instance;loggedOnceMessages=new Set;MAX_LABEL_LENGTH=3;cliColor=c.default.blue;mutedColor=c.default.dim;infoColor=c.default.cyan;warnColor=c.default.yellow;errorColor=c.default.red;defaultColor=c.default.white;progressFgColorMap={ESM:c.default.yellow,CJS:c.default.green,IIFE:c.default.magenta,DTS:c.default.blue};progressBgColorMap={ESM:c.default.bgYellow,CJS:c.default.bgGreen,IIFE:c.default.bgMagenta,DTS:c.default.bgBlue};labels={cli:"CLI",info:"INFO",warn:"WARN",error:"ERROR"};constructor(){}static getInstance(){if(!h.instance)h.instance=new h;return h.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(r){if(!r?.once)return!0;if(this.loggedOnceMessages.has(r.once))return!1;return this.loggedOnceMessages.add(r.once),!0}formatMessage({fgColor:r,bgColor:n,label:t,message:e,identifier:o,muted:i}){let s=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-t.length)),u=i?this.mutedColor(e):e,g=o?` ${n(c.default.black(` ${o} `))}`:"";return`${r(t)} ${s}${u}${g}`}output(r,n={},t=console.log){if(gr||!this.shouldLog(n))return;if(n.verticalSpace)t("");if(t(r),n.verticalSpace)t("")}cli(r,n={}){let t=this.formatMessage({fgColor:this.cliColor,bgColor:c.default.bgBlue,label:this.labels.cli,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n)}info(r,n={}){let t=this.formatMessage({fgColor:this.infoColor,bgColor:c.default.bgCyan,label:this.labels.info,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n)}warn(r,n={}){let t=this.formatMessage({fgColor:this.warnColor,bgColor:c.default.bgYellow,label:this.labels.warn,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n,console.warn)}error(r,n={}){let t=this.formatMessage({fgColor:this.errorColor,bgColor:c.default.bgRed,label:this.labels.error,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n,console.error)}getProgressFgColor(r){for(let[n,t]of Object.entries(this.progressFgColorMap))if(r.includes(n))return t;return this.defaultColor}getProgressBgColor(r){for(let[n,t]of Object.entries(this.progressBgColorMap))if(r.includes(n))return t;return c.default.bgWhite}progress(r,n,t={}){let e=this.getProgressFgColor(r),o=this.getProgressBgColor(r),i=this.formatMessage({fgColor:e,bgColor:o,label:r,message:n,identifier:t.identifier,muted:t.muted});this.output(i,t)}}var x=h.getInstance();class U extends Error{constructor(r){super(r);this.name="BunupError"}}class R extends U{constructor(r){super(r);this.name="BunupBuildError"}}class f extends U{constructor(r){super(r);this.name="BunupDTSBuildError"}}class F extends U{constructor(r){super(r);this.name="BunupIsolatedDeclError"}}var C=(r)=>{if(r instanceof Error)return r.message;return String(r)};function ur(r){return r instanceof F}var V=l(require("path")),hr=require("oxc-resolver");var H=l(require("fs/promises")),cr=l(require("path"));function ar(r,n){switch(r){case"esm":return S(n)?".js":".mjs";case"cjs":return S(n)?".cjs":".js";case"iife":return".global.js"}}function br(r,n){switch(r){case"esm":return S(n)?".d.ts":".d.mts";case"cjs":return S(n)?".d.cts":".d.ts";case"iife":return".d.ts"}}function D(r){return r==="node"||r==="bun"}function S(r){return r==="module"}function pr(r){if(!r)return[];return Array.from(new Set([...Object.keys(r.dependencies||{}),...Object.keys(r.peerDependencies||{})]))}function T(r,n=3){return r.split("/").slice(-n).join("/")}async function xr(r,n){let t=cr.default.join(r,n);try{await H.default.rm(t,{recursive:!0,force:!0})}catch(e){throw new R(`Failed to clean output directory: ${e}`)}await H.default.mkdir(t,{recursive:!0})}function un(r){return pr(r).map((n)=>new RegExp(`^${n}($|\\/|\\\\)`))}function fr(r,n){return typeof n==="string"?n===r:n.test(r)}function Y(r,n,t){let o=un(t).some((s)=>s.test(r))||n.external?.some((s)=>fr(r,s)),i=n.noExternal?.some((s)=>fr(r,s));return o&&!i}var dr=require("ts-import-resolver");var $="\x00dts:",lr=(r,n,t)=>{return{name:"bunup:virtual-dts",async resolveId(e,o){if(Q(e))return e;if(!o||!Q(o))return null;let i=n.tsconfig?dr.resolveTsImportPath({path:e,importer:E(o),tsconfig:n.tsconfig,rootDir:t}):null;if(!i)return null;let s=B(i);if(r.has(s))return K(s);return null},load(e){if(e.startsWith($)){let o=E(e),i=r.get(o);if(i)return i}return null}}};var Z=/\.(js|mjs|cjs|ts|mts|cts|tsx|jsx)$/;function j(r){return r.endsWith(".d.ts")||r.endsWith(".d.mts")||r.endsWith(".d.cts")}function Cr(r){return Z.test(r)&&!j(r)}function k(r){return[".ts",".mts",".cts",".tsx"].some((n)=>r.endsWith(n))&&!j(r)}function B(r){if(j(r))return r;if(r.endsWith(".mts"))return`${r.slice(0,-4)}.d.mts`;if(r.endsWith(".cts"))return`${r.slice(0,-4)}.d.cts`;if(Z.test(r))return r.replace(Z,".d.ts");return`${r}.d.ts`}function Q(r){return r.startsWith($)}function E(r){return r.replace($,"")}function K(r){return`${$}${r}`}function Br(r,n){if(n===void 0)return"";let t=r.slice(0,n).split(`
|
|
3
|
-
`),e=t.length,o=t[t.length-1].length+1;return` (${e}:${o})`}function wr(r,n,t,e){if(typeof e==="boolean"&&e)return!1;if(Array.isArray(e)){for(let o of e)if(typeof o==="string"&&r===o)return!1;else if(o instanceof RegExp&&o.test(r))return!1}return Y(r,n,t)}var z;function Rr(r,n){return{name:"bunup:types-resolve",buildStart(){z||=new hr.ResolverFactory({mainFields:["types","typings","module","main"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".d.mts",".d.cts",".ts",".mts",".cts"],...r.path&&{tsconfig:{configFile:r.path}},modules:["node_modules","node_modules/@types"]})},async resolveId(t,e){if(n===!1)return;if(t==="bun")return;let o=e?E(e):void 0;if(/\0/.test(t))return;if(Array.isArray(n)){if(!n.some((g)=>typeof g==="string"?g===t:g.test(t)))return}let i=o?V.default.dirname(o):process.cwd(),{path:s}=await z.async(i,t);if(!s)return;if(Cr(s)){let u=B(s);try{let{path:g}=await z.async(V.default.dirname(s),u);if(g)return g}catch(g){}return}return s}}}async function Lr(r,n,t,e,o,i){let s=B(r),u=K(s),g=typeof t.dts==="object"&&"resolve"in t.dts?t.dts.resolve:void 0;try{let{output:m}=await Sr.build({input:u,output:{dir:t.outDir},write:!1,...o.path&&{resolve:{tsconfigFilename:o.path}},onwarn(p,b){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(p.code??""))return;b(p)},plugins:[lr(n,o,i),g&&Rr(o,g),kr.dts({dtsInput:!0,emitDtsOnly:!0})],external:(p)=>wr(p,t,e,g)});if(!m[0]?.code)return x.warn(`Generated empty declaration file for entry "${r}"`,{muted:!0}),"";return m[0].code}catch(m){throw new f(`DTS bundling failed for entry "${r}": ${C(m)}`)}}var yr=require("ts-import-resolver");var cn=/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]/gm,an=/^\s*export\s+.*from\s+['"]([^'"]+)['"]/gm,bn=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,pn=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,xn=/import\s+\w+\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,fn=/\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/g,dn=/\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/g;function ln(r){let n=new Set,t=[cn,an,bn,pn,xn,fn,dn];for(let e of t){let o=r.matchAll(e);for(let i of o)if(i[1])n.add(i[1])}return n}async function Ir(r,n,t){let e=new Set([r]),o=[r];while(o.length){let i=o.pop();if(!i)continue;try{let s=await Bun.file(i).text(),u=ln(s);for(let g of u){let m=n.tsconfig?yr.resolveTsImportPath({path:g,importer:i,tsconfig:n.tsconfig,rootDir:t}):null;if(!m||!(k(m)||j(m)))continue;if(!e.has(m))e.add(m),o.push(m)}}catch(s){x.warn(`Error processing ${i}: ${C(s)}`)}}return e}var Mr=require("oxc-transform"),X=l(W());async function Or(r,n){let t=!1,e=new Map;if(await Promise.all([...r].map(async(o)=>{try{let i=B(o);if(!await Bun.file(o).exists())return;let u=await Bun.file(o).text(),{code:g,errors:m}=Mr.isolatedDeclaration(o,u);if(g)e.set(i,g);for(let p of m){if(!t&&!n)console.log(`
|
|
4
|
-
`);let b=p.labels[0],a=b?Br(u,b.start):"",w=`${T(o)}${a}: ${Cn(p.message)}`;x[n?"warn":"error"](w),t=!0}}catch(i){x.warn(`Failed to generate declaration for ${o}: ${C(i)}`)}})),t&&!n)throw console.log(`
|
|
5
|
-
`),new F(`TypeScript is asking for explicit type annotations on your exports. This helps ensure better, more reliable type declarations for your library. Bunup uses TypeScript's ${X.default.blue("isolatedDeclarations")} feature to generate these declarations, which requires each export from your library to be fully typed. You can learn more here: ${X.default.blue("https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations")}`);return e}function Cn(r){return r.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}var J=l(require("fs/promises")),q=l(require("path"));async function Tr(r,n){let t=q.default.resolve(r),e=q.default.resolve(t,n);if(!await J.default.exists(t))throw new f(`Root directory does not exist: ${t}`);if(!await Bun.file(e).exists())throw new f(`Entry file does not exist: ${e}`);if(!k(e))throw new f(`Entry file must be a TypeScript file: ${e}`);if(q.default.relative(t,e).startsWith(".."))throw new f(`Entry file must be within rootDir: ${e}`);return{absoluteRootDir:t,absoluteEntry:e}}async function Er(r,n,t,e,o){let{absoluteEntry:i}=await Tr(r,n),s=await Ir(i,e,r),u=await Or(s,t.watch);return Lr(i,u,t,o,e,r)}var L=require("path");function $r(r){let n=L.basename(r),t=L.extname(n);return t?n.slice(0,-t.length):n}function N(r){if(typeof r==="string")return[{fullEntryPath:r,name:$r(r)}];if(typeof r==="object"&&!Array.isArray(r))return Object.entries(r).map(([e,o])=>({fullEntryPath:o,name:e}));let n=[],t=new Set;for(let e of r){let o=$r(e);if(!t.has(o)){n.push({fullEntryPath:e,name:o}),t.add(o);continue}let s=L.dirname(e).split("/").filter((g)=>g!=="."&&g!=="");if(s.length===0){let g=1,m;do m=`${o}_${g++}`;while(t.has(m));n.push({fullEntryPath:e,name:m}),t.add(m);continue}let u=!1;for(let g=1;g<=s.length&&!u;g++){let p=`${s.slice(-g).join("/")}/${o}`;if(!t.has(p))n.push({fullEntryPath:e,name:p}),t.add(p),u=!0}if(!u){let g=1,m;do m=`${s.join("/")}/${o}_${g++}`;while(t.has(m));n.push({fullEntryPath:e,name:m}),t.add(m)}}return n}function jr(r){return r.filter((n)=>k(n.fullEntryPath))}function Ar(r,n){return`[dir]/${r}${n}`}var v=require("coffi");async function _r(r){let{config:n,filepath:t}=await v.loadConfig({name:"package",cwd:r,extensions:[".json"]});return{packageJson:n,path:t}}async function Wr(r,n){let{config:t,filepath:e}=await v.loadConfig({name:"tsconfig",cwd:r,extensions:[".json"],preferredPath:n});return{tsconfig:t,path:e}}var Bn={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function Ur(r){return{...Bn,...r}}function Fr(r){let{minify:n,minifyWhitespace:t,minifyIdentifiers:e,minifySyntax:o}=r,i=n===!0;return{whitespace:t??i,identifiers:e??i,syntax:o??i}}function Yr(r,n){return n==="cjs"?r:void 0}function Kr(r,n,t,e){return{...typeof t==="object"&&Object.keys(t).reduce((o,i)=>{let s=JSON.stringify(t[i]);return o[`process.env.${i}`]=s,o[`import.meta.env.${i}`]=s,o},{}),...r,...e==="cjs"&&(n===!0||typeof n==="object"&&n.importMetaUrl)&&{"import.meta.url":"importMetaUrl"}}}function qr(r,n){return r===void 0?n==="esm":r}function Gr(r){return typeof r==="string"?r:void 0}function Hr(r,n){return{name:"bunup:external-plugin",setup(t){t.onResolve({filter:/.*/},(e)=>{let o=e.path;if(Y(o,r,n))return{path:o,external:!0};return null})}}}var wn=/\.(js|ts|jsx|tsx|mts|cts)$/,P={dirnameFilename:{appliesTo:(r,n)=>r==="esm"&&D(n),isNeededInFile:(r)=>/\b__dirname\b/.test(r)||/\b__filename\b/.test(r),generateCode:()=>`import { fileURLToPath } from 'url';
|
|
6
|
-
import { dirname } from 'path';
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = dirname(__filename);
|
|
10
|
-
|
|
11
|
-
`},importMetaUrl:{appliesTo:(r,n)=>r==="cjs"&&D(n),isNeededInFile:(r)=>/\bimport\.meta\.url\b/.test(r),generateCode:()=>`import { pathToFileURL } from 'url';
|
|
12
|
-
|
|
13
|
-
const importMetaUrl = pathToFileURL(__filename).href;
|
|
14
|
-
|
|
15
|
-
`}};function Dr({format:r,target:n,shims:t}){let o=hn(t).map((i)=>P[i]).filter((i)=>i.appliesTo(r,n));if(o.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(i){i.onLoad({filter:wn},async({path:s})=>{let u=await Bun.file(s).text(),g=o.filter((a)=>a.isNeededInFile(u));if(g.length===0)return;let{shebangLine:m,codeContent:p}=Rn(u),b=g.map((a)=>a.generateCode()).join("");return{contents:m+b+p}})}}}function hn(r){if(r===!0)return Object.keys(P);if(!r)return[];return Object.entries(r).filter(([n,t])=>t&&(n in P)).map(([n])=>n)}function Rn(r){if(!r.startsWith("#!"))return{shebangLine:"",codeContent:r};let n=r.indexOf(`
|
|
16
|
-
`);return n===-1?{shebangLine:"",codeContent:r}:{shebangLine:r.slice(0,n+1),codeContent:r.slice(n+1)}}function Qr(r){if(!r)return[];return r.filter((n)=>n.type==="bun")}function Zr(r){if(!r)return[];return r.filter((n)=>n.type==="bunup")}async function zr(r,n){if(!r)return;for(let t of r)if(t.hooks.onBuildStart)await t.hooks.onBuildStart(n)}async function Vr(r,n,t){if(!r)return;for(let e of r)if(e.hooks.onBuildDone)await e.hooks.onBuildDone({options:n,output:t})}async function Nr(r,n=process.cwd()){let t={files:[]},e=Ur(r);if(!e.entry||e.entry.length===0||!e.outDir)throw new R("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(e.clean)xr(n,e.outDir);mr(e.silent);let{packageJson:o,path:i}=await _r(n);if(o&&i)x.cli(`Using ${T(i,2)}`,{muted:!0,identifier:e.name,once:`${i}:${e.name}`});let s=Zr(e.plugins);await zr(s,e);let u=N(e.entry),g=o?.type;if(!e.dtsOnly){let m=[Hr(e,o),...Qr(e.plugins).map((b)=>b.plugin)],p=e.format.flatMap((b)=>u.map(async(a)=>{let y=e.outputExtension?.({format:b,packageType:g,options:e,entry:a}).js??ar(b,g),w=await Bun.build({entrypoints:[`${n}/${a.fullEntryPath}`],format:b,naming:{entry:Ar(a.name,y)},splitting:qr(e.splitting,b),bytecode:Yr(e.bytecode,b),define:Kr(e.define,e.shims,e.env,b),minify:Fr(e),outdir:`${n}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:Gr(e.env),plugins:[...m,Dr({format:b,target:e.target,shims:e.shims})],throw:!1});if(!w.success)for(let d of w.logs){if(d.level==="error")throw new R(d.message);if(d.level==="warning")x.warn(d.message);else if(d.level==="info")x.info(d.message)}let I=Xr(e.outDir,a.name,y),M=Jr(n,I);t.files.push({fullPath:M,relativePathToOutputDir:I}),x.progress(b.toUpperCase(),I,{identifier:e.name})}));await Promise.all(p)}if(e.dts||e.dtsOnly){let m=await Wr(n,e.preferredTsconfigPath);if(m.path)x.cli(`Using ${T(m.path,2)}`,{muted:!0,identifier:e.name,once:`${m.path}:${e.name}`});let p=e.format.filter((a)=>{if(a==="iife"&&!S(g)&&e.format.includes("cjs"))return!1;return!0}),b=typeof e.dts==="object"&&e.dts.entry?N(e.dts.entry):jr(u);try{await Promise.all(b.map(async(a)=>{let y=await Er(n,a.fullEntryPath,e,m,o);await Promise.all(p.map(async(w)=>{let I=e.outputExtension?.({format:w,packageType:g,options:e,entry:a}).dts??br(w,g),M=Xr(e.outDir,a.name,I),d=Jr(n,M);t.files.push({fullPath:d,relativePathToOutputDir:M}),await Bun.write(d,y),x.progress("DTS",M,{identifier:e.name})}))}))}catch(a){if(ur(a))throw a;throw new f(C(a))}}if(await Vr(s,e,t),e.onSuccess)await e.onSuccess(e)}function Xr(r,n,t){return`${r}/${n}${t}`}function Jr(r,n){return`${r}/${n}`}})
|