bunup 0.4.35 → 0.4.37
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 +4 -4
- package/bin/bunup.js +2 -0
- package/build/cli.mjs +11 -11
- package/build/index.d.mts +2 -1
- package/build/index.d.ts +2 -1
- package/build/index.js +7 -7
- package/build/index.mjs +7 -7
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -7,10 +7,10 @@ Bunup is the **high-performance build tool** for TypeScript and JavaScript libra
|
|
|
7
7
|
|
|
8
8
|
| Bundler | Format | Build Time | Build Time (with dts) |
|
|
9
9
|
| ------- | -------- | -------------- | --------------------- |
|
|
10
|
-
| bunup | esm, cjs | **3.
|
|
11
|
-
| tsdown | esm, cjs | 5.
|
|
12
|
-
| unbuild | esm, cjs |
|
|
13
|
-
| tsup | esm, cjs |
|
|
10
|
+
| bunup | esm, cjs | **3.52ms ⚡️** | **20.84ms ⚡️** |
|
|
11
|
+
| tsdown | esm, cjs | 5.65ms | 434.67ms |
|
|
12
|
+
| unbuild | esm, cjs | 43.13ms | 275.80ms |
|
|
13
|
+
| tsup | esm, cjs | 63.39ms | 904.67ms |
|
|
14
14
|
|
|
15
15
|
_Lower is better. Benchmarks run on identical code and output formats._
|
|
16
16
|
|
package/bin/bunup.js
ADDED
package/build/cli.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{exec as
|
|
3
|
+
import{exec as wt}from"tinyexec";import{build as Je}from"rolldown";import{dts as Xe}from"rolldown-plugin-dts";var te=!1;function M(e){te=e??!1}class O{static instance;loggedOnceMessages=new Set;MAX_LABEL_LENGTH=3;MAX_MESSAGE_LENGTH=25;colors={cli:"147",info:"245",warn:"179",error:"174",progress:{ESM:"172",CJS:"108",IIFE:"146",DTS:"110"},default:"252",size:"65"};labels={cli:"CLI",info:"INFO",warn:"WARN",error:"ERROR"};constructor(){}static getInstance(){if(!O.instance)O.instance=new O;return O.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(e){if(!e?.once)return!0;if(this.loggedOnceMessages.has(e.once))return!1;return this.loggedOnceMessages.add(e.once),!0}formatMessage({colorCode:e,label:t,message:n,size:r,identifier:s,muted:o}){let i=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-t.length)),a=o?`\x1B[38;5;${this.colors.info}m${n}\x1B[0m`:n;if(r){let[c,...f]=a.split(" "),p=" ".repeat(Math.max(0,this.MAX_MESSAGE_LENGTH-c.length)),m=s?` \x1B[48;5;${e};38;5;0m ${s} \x1B[0m`:"";return`\x1B[38;5;${e}m${t}\x1B[0m ${i}${c}${p} \x1B[38;5;${this.colors.size}m${r}\x1B[0m ${f.join(" ")}${m}`}let l=s?` \x1B[48;5;${e};38;5;0m ${s} \x1B[0m`:"";return`\x1B[38;5;${e}m${t}\x1B[0m ${i}${a}${l}`}output(e,t={},n=console.log){if(te)return;if(!this.shouldLog(t))return;if(t.verticalSpace)console.log("");if(n(e),t.verticalSpace)console.log("")}cli(e,t={}){let n=this.formatMessage({colorCode:this.colors.cli,label:this.labels.cli,message:e,identifier:t.identifier,muted:t.muted});this.output(n,t)}info(e,t={}){let n=this.formatMessage({colorCode:this.colors.info,label:this.labels.info,message:e,identifier:t.identifier,muted:t.muted});this.output(n,t)}warn(e,t={}){let n=this.formatMessage({colorCode:this.colors.warn,label:this.labels.warn,message:e,identifier:t.identifier,muted:t.muted});this.output(n,t,console.warn)}error(e,t={}){let n=this.formatMessage({colorCode:this.colors.error,label:this.labels.error,message:e,identifier:t.identifier,muted:t.muted});this.output(n,t,console.error)}progress(e,t,n,r){let s=String(e),o=this.colors.default,i,a,l={};if(typeof n==="string")i=n,a=r;else if(n)i=n.size,a=n.identifier,l=n;for(let[f,p]of Object.entries(this.colors.progress))if(s.includes(f)){o=p;break}let c=this.formatMessage({colorCode:o,label:s,message:t,size:i,identifier:a,muted:l.muted});this.output(c,l)}}var u=O.getInstance();class E extends Error{constructor(e){super(e);this.name="BunupError"}}class C extends E{constructor(e){super(e);this.name="BunupBuildError"}}class g extends E{constructor(e){super(e);this.name="BunupDTSBuildError"}}class b extends E{constructor(e){super(e);this.name="BunupCLIError"}}class A extends E{constructor(e){super(e);this.name="BunupWatchError"}}var h=(e)=>{if(e instanceof Error)return e.message;return String(e)},Ge=[{pattern:/Could not resolve: "bun"/i,errorType:"BUILD ERROR",logSolution:()=>{u.error("\x1B[0mYou're trying to build a project that uses Bun. Please set the target option to \x1B[36m`bun`\x1B[0m.\nExample: \x1B[32m`bunup --target bun`\x1B[0m or in config: \x1B[32m{ target: 'bun' }\x1B[0m")}}],q=(e,t)=>{let n=h(e),r=t?`[${t}] `:"",s="ERROR";if(e instanceof C)s="BUILD ERROR";else if(e instanceof g)s="DTS ERROR";else if(e instanceof b)s="CLI ERROR";else if(e instanceof A)s="WATCH ERROR";else if(e instanceof E)s="BUNUP ERROR";let o=Ge.find((i)=>i.pattern.test(n)&&(i.errorType===s||!i.errorType));if(!o)console.error(`\x1B[31m${s}\x1B[0m ${r}${n}`);if(o)console.log(`
|
|
4
4
|
`),o.logSolution(n),console.log(`
|
|
5
|
-
`);else console.error("\x1B[90mIf you think this is a bug, please open an issue at: \x1B[36mhttps://github.com/arshad-yaseen/bunup/issues/new\x1B[0m")},ne=(e,t)=>{q(e,t),process.exit(1)};import re from"node:fs/promises";import
|
|
6
|
-
`);let a=i.labels[0],l=a?
|
|
5
|
+
`);else console.error("\x1B[90mIf you think this is a bug, please open an issue at: \x1B[36mhttps://github.com/arshad-yaseen/bunup/issues/new\x1B[0m")},ne=(e,t)=>{q(e,t),process.exit(1)};import re from"node:fs/promises";import Ye from"node:path";function G(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function se(e=8){let t="";while(t.length<e)t+=Math.random().toString(36).substring(2);return t.substring(0,e)}function ie(e,t,n){return Array.isArray(e)?e.map((r)=>({...r,[t]:n})):{...e,[t]:n}}function oe(e){return Array.isArray(e)?e:[e]}function ae(e,t){switch(e){case"esm":return S(t)?".js":".mjs";case"cjs":return S(t)?".cjs":".js";case"iife":return".global.js"}}function le(e,t){switch(e){case"esm":return S(t)?".d.ts":".d.mts";case"cjs":return S(t)?".d.cts":".d.ts";case"iife":return".d.ts"}}function Y(e){return e==="node"||e==="bun"}function S(e){return e==="module"}function P(e){return e>=1000?`${(e/1000).toFixed(2)}s`:`${Math.round(e)}ms`}function ce(e){if(!e)return[];return Array.from(new Set([...Object.keys(e.dependencies||{}),...Object.keys(e.peerDependencies||{})]))}function K(e){if(e===0)return"0 B";let t=["B","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(1024));if(n===0)return`${e} ${t[n]}`;return`${(e/1024**n).toFixed(2)} ${t[n]}`}function x(e,t=3){return e.split("/").slice(-t).join("/")}async function ue(e,t){let n=Ye.join(e,t);try{await re.rm(n,{recursive:!0,force:!0})}catch(r){throw new C(`Failed to clean output directory: ${r}`)}await re.mkdir(n,{recursive:!0})}function D(e){return[".ts",".mts",".cts",".tsx"].some((t)=>e.endsWith(t))}function fe(e){return e.map((t)=>typeof t==="string"?new RegExp(`^${G(t)}($|\\/|\\\\)`):t)}function k(e,t){return fe(e.external||[]).concat(ce(t).map((n)=>new RegExp(`^${G(n)}($|\\/|\\\\)`)))}function j(e){return fe(e.noExternal||[])}import be from"node:path";import{ResolverFactory as Ve}from"oxc-resolver";import{resolveTsImportPath as Ke}from"ts-import-resolver";var R="\x00dts:",me=(e,t,n)=>{return{name:"bunup:virtual-dts",async resolveId(r,s){if(V(r))return r;if(!s||!V(s))return null;let o=t.tsconfig?Ke({path:r,importer:B(s),tsconfig:t.tsconfig,rootDir:n}):null;if(!o)return null;let i=w(o);if(e.has(i))return I(i);return null},load(r){if(r.startsWith(R)){let s=B(r),o=e.get(s);if(o)return $.add(s),o}return null}}};function pe(e){return e.tsconfig.compilerOptions??{}}function de(e){return e.endsWith(".d.ts")||e.endsWith(".d.mts")||e.endsWith(".d.cts")}function ge(e){return/\.(js|mjs|cjs|ts|mts|cts|tsx|jsx)$/.test(e)&&!de(e)}function w(e){if(de(e))return e;return e.replace(/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/,".d.ts")}function V(e){return e.startsWith(R)}function B(e){return e.replace(R,"")}function I(e){return`${R}${e}`}function he(e,t,n,r){if(typeof r==="boolean"&&r)return!1;if(Array.isArray(r)){for(let s of r)if(typeof s==="string"&&e===s)return!1;else if(s instanceof RegExp&&s.test(e))return!1}return t.some((s)=>s.test(e))&&!n.some((s)=>s.test(e))}var J;function ye(e,t){return{name:"bunup:types-resolve",buildStart(){J||=new Ve({mainFields:["types","typings","module","main"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".d.mts",".d.cts",".ts",".mts",".cts"],...e.path&&{tsconfig:{configFile:e.path}},modules:["node_modules","node_modules/@types"]})},async resolveId(n,r){if(t===!1)return;if(n==="bun")return;let s=r?B(r):void 0;if(/\0/.test(n))return;if(Array.isArray(t)){if(!t.some((l)=>typeof l==="string"?l===n:l.test(n)))return}let o=s?be.dirname(s):process.cwd(),{path:i}=await J.async(o,n);if(!i)return;if(ge(i)){let a=w(i);try{let{path:l}=await J.async(be.dirname(i),a);if(l)return l}catch(l){}return}return i}}}async function xe(e,t,n,r,s,o){let i=w(e),a=I(i),l=k(n,r),c=j(n),f=typeof n.dts==="object"&&"resolve"in n.dts?n.dts.resolve:void 0;try{let{output:p}=await Je({input:a,output:{dir:n.outDir},write:!1,onwarn(m,T){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(m.code??""))return;T(m)},plugins:[me(t,s,o),f&&ye(s,f),Xe({dtsInput:!0,emitDtsOnly:!0,compilerOptions:{...pe(s),declaration:!0,noEmit:!1,emitDeclarationOnly:!0,noEmitOnError:!0,checkJs:!1,declarationMap:!1,skipLibCheck:!0,preserveSymlinks:!1,target:99}})],external:(m)=>he(m,l,c,f)});if(!p[0]?.code)return u.warn(`Generated empty declaration file for entry "${e}"`,{muted:!0}),"";return p[0].code}catch(p){throw new g(`DTS bundling failed for entry "${e}": ${h(p)}`)}}import{resolveTsImportPath as ze}from"ts-import-resolver";var Qe=/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]/gm,Ze=/^\s*export\s+.*from\s+['"]([^'"]+)['"]/gm,et=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,tt=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,nt=/import\s+\w+\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,rt=/\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/g,st=/\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/g;function it(e){let t=new Set,n=[Qe,Ze,et,tt,nt,rt,st];for(let r of n){let s=e.matchAll(r);for(let o of s)if(o[1])t.add(o[1])}return t}async function we(e,t,n){let r=new Set([e]),s=[e];while(s.length){let o=s.pop();if(!o)continue;try{let i=await Bun.file(o).text(),a=it(i);for(let l of a){let c=t.tsconfig?ze({path:l,importer:o,tsconfig:t.tsconfig,rootDir:n}):null;if(!c)continue;if(!r.has(c))r.add(c),s.push(c)}}catch(i){u.warn(`Error processing ${o}: ${h(i)}`)}}return r}import{isolatedDeclaration as ot}from"oxc-transform";async function Ce(e){let t=new Map;return await Promise.all([...e].map(async(n)=>{try{let r=w(n);if(!await Bun.file(n).exists())return;let o=await Bun.file(n).text(),{code:i}=ot(n,o);if(i)t.set(r,i)}catch(r){u.warn(`Failed to generate declaration for ${n}: ${h(r)}`)}})),t}import Oe from"node:fs/promises";import X from"node:path";import{isolatedDeclaration as at}from"oxc-transform";async function Ee(e,t){let n=X.resolve(e),r=X.resolve(n,t);if(!await Oe.exists(n))throw new g(`Root directory does not exist: ${n}`);if(!await Bun.file(r).exists())throw new g(`Entry file does not exist: ${r}`);if(!D(r))throw new g(`Entry file must be a TypeScript file: ${r}`);if(X.relative(n,r).startsWith(".."))throw new g(`Entry file must be within rootDir: ${r}`);return{absoluteRootDir:n,absoluteEntry:r}}async function Se(e){let t=!1;if(await Promise.all([...e].map(async(n)=>{try{let r=n.replace(/\.d\.ts$/,".ts"),s=await Bun.file(r).text(),{errors:o}=at(r,s);for(let i of o){if(!t)console.log(`
|
|
6
|
+
`);let a=i.labels[0],l=a?lt(s,a.start):"",f=`${x(r)}${l}: ${ct(i.message)}`;u.warn(f),t=!0}}catch{}})),t)u.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
|
-
`),r=n.length,s=n[n.length-1].length+1;return` (${r}:${s})`}function
|
|
8
|
+
`)}function lt(e,t){if(t===void 0)return"";let n=e.slice(0,t).split(`
|
|
9
|
+
`),r=n.length,s=n[n.length-1].length+1;return` (${r}:${s})`}function ct(e){return e.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}async function $e(e,t,n,r,s){let{absoluteEntry:o}=await Ee(e,t),i=await we(o,r,e),a=await Ce(i);return xe(o,a,n,s,r,e)}function _(e){return e.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function L(e,{warnOnConflict:t=!0}={}){let n=[],r=new Set,s={};function o(i,a){if(r.has(i)){let l=se(),c=`${i}_${l}`;if(t)u.warn(`Output name conflict: "${i}" is used by multiple files.
|
|
10
10
|
Bunup uses filenames without extensions as output names by default.
|
|
11
11
|
|
|
12
12
|
${s[i]} -> ${i}.js
|
|
@@ -20,18 +20,18 @@ To fix this, use named entries in your configuration:
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
See: https://bunup.arshadyaseen.com/documentation/#named-entries`,{muted:!0,verticalSpace:!0});n.push({name:c,path:a})}else n.push({name:i,path:a}),r.add(i),s[i]=a}if(Array.isArray(e))for(let i of e){let a=_(i);o(a,i)}else if(typeof e==="object")for(let[i,a]of Object.entries(e))o(i,a);else{let i=_(e);o(i,e)}return n}function
|
|
23
|
+
See: https://bunup.arshadyaseen.com/documentation/#named-entries`,{muted:!0,verticalSpace:!0});n.push({name:c,path:a})}else n.push({name:i,path:a}),r.add(i),s[i]=a}if(Array.isArray(e))for(let i of e){let a=_(i);o(a,i)}else if(typeof e==="object")for(let[i,a]of Object.entries(e))o(i,a);else{let i=_(e);o(i,e)}return n}function Te(e){return e.filter((t)=>D(t.path))}function Be(e,t){return`[dir]/${e}${t}`}import{loadConfig as Re}from"coffi";async function Le(e,t){return Array.isArray(e)&&"root"in e[0]?e.map((n)=>({rootDir:n.root,options:ie(n.config,"name",n.name)})):[{rootDir:t,options:e}]}async function Me(e){let{config:t,filepath:n}=await Re({name:"package",cwd:e,extensions:[".json"],maxDepth:3});return{packageJson:t,path:n}}async function Ae(e,t){let{config:n,filepath:r}=await Re({name:"tsconfig",cwd:e,extensions:[".json"],preferredPath:t,maxDepth:3});return{tsconfig:n,path:r}}var ut={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function N(e){return{...ut,...e}}function Pe(e){let{minify:t,minifyWhitespace:n,minifyIdentifiers:r,minifySyntax:s}=e,o=t===!0;return{whitespace:n??o,identifiers:r??o,syntax:s??o}}function De(e,t){return t==="cjs"?e:void 0}function ke(e,t,n,r){return{...typeof n==="object"&&Object.keys(n).reduce((s,o)=>{let i=JSON.stringify(n[o]);return s[`process.env.${o}`]=i,s[`import.meta.env.${o}`]=i,s},{}),...e,...r==="cjs"&&(t===!0||typeof t==="object"&&t.importMetaUrl)&&{"import.meta.url":"importMetaUrl"}}}function je(e,t){return e===void 0?t==="esm":e}function Ie(e){return typeof e==="string"?e:void 0}function _e(e,t){return{name:"bunup:external-plugin",setup(n){n.onResolve({filter:/.*/},(r)=>{let s=r.path;if(e.some((i)=>i.test(s))&&!t.some((i)=>i.test(s)))return{path:s,external:!0};return null})}}}var ft=/\.(js|ts|jsx|tsx|mts|cts)$/,z={dirnameFilename:{appliesTo:(e,t)=>e==="esm"&&Y(t),isNeededInFile:(e)=>/\b__dirname\b/.test(e)||/\b__filename\b/.test(e),generateCode:()=>`import { fileURLToPath } from 'url';
|
|
24
24
|
import { dirname } from 'path';
|
|
25
25
|
|
|
26
26
|
const __filename = fileURLToPath(import.meta.url);
|
|
27
27
|
const __dirname = dirname(__filename);
|
|
28
28
|
|
|
29
|
-
`},importMetaUrl:{appliesTo:(e,t)=>e==="cjs"&&
|
|
29
|
+
`},importMetaUrl:{appliesTo:(e,t)=>e==="cjs"&&Y(t),isNeededInFile:(e)=>/\bimport\.meta\.url\b/.test(e),generateCode:()=>`import { pathToFileURL } from 'url';
|
|
30
30
|
|
|
31
31
|
const importMetaUrl = pathToFileURL(__filename).href;
|
|
32
32
|
|
|
33
|
-
`}};function
|
|
34
|
-
`);return t===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,t+1),codeContent:e.slice(t+1)}}var $=new Set;async function
|
|
33
|
+
`}};function Ne({format:e,target:t,shims:n}){let s=mt(n).map((o)=>z[o]).filter((o)=>o.appliesTo(e,t));if(s.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(o){o.onLoad({filter:ft},async({path:i})=>{let a=await Bun.file(i).text(),l=s.filter((m)=>m.isNeededInFile(a));if(l.length===0)return;let{shebangLine:c,codeContent:f}=pt(a),p=l.map((m)=>m.generateCode()).join("");return{contents:c+p+f}})}}}function mt(e){if(e===!0)return Object.keys(z);if(!e)return[];return Object.entries(e).filter(([t,n])=>n&&(t in z)).map(([t])=>t)}function pt(e){if(!e.startsWith("#!"))return{shebangLine:"",codeContent:e};let t=e.indexOf(`
|
|
34
|
+
`);return t===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,t+1),codeContent:e.slice(t+1)}}var $=new Set;async function U(e,t){let n=N(e);if(!n.entry||n.entry.length===0||!n.outDir)throw new C("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(n.clean)ue(t,n.outDir);M(n.silent);let{packageJson:r,path:s}=await Me(t);if(r&&s)u.cli(`Using package.json: ${x(s,2)}`,{muted:!0,identifier:n.name,once:`${s}:${n.name}`});let o=L(n.entry),i=r?.type,a=k(n,r),l=j(n);if(!n.dtsOnly){let c=[_e(a,l)],f=n.format.flatMap((p)=>o.map((m)=>{return dt(n,t,m,p,i,c)}));await Promise.all(f)}if(n.dts||n.dtsOnly){let c=await Ae(t,n.preferredTsconfigPath);if(c.path)u.cli(`Using tsconfig: ${x(c.path,2)}`,{muted:!0,identifier:n.name,once:`${c.path}:${n.name}`});let f=n.format.filter((m)=>{if(m==="iife"&&!S(i)&&n.format.includes("cjs"))return!1;return!0}),p=typeof n.dts==="object"&&n.dts.entry?L(n.dts.entry):Te(o);try{await Promise.all(p.map(async(m)=>{let T=await $e(t,m.path,n,c,r);await Promise.all(f.map(async(ee)=>{let Fe=n.outputExtension?.({format:ee,packageType:i,options:n,entry:m}).dts??le(ee,i),F=`${t}/${n.outDir}/${m.name}${Fe}`;await Bun.write(F,T);let qe=Bun.file(F).size||0;u.progress("DTS",x(F),K(qe),n.name)}))}))}catch(m){throw new g(h(m))}}if(n.onBuildSuccess)await n.onBuildSuccess(n)}async function dt(e,t,n,r,s,o){let i=e.outputExtension?.({format:r,packageType:s,options:e,entry:n}).js??ae(r,s),a=await Bun.build({entrypoints:[`${t}/${n.path}`],format:r,naming:{entry:Be(n.name,i)},splitting:je(e.splitting,r),bytecode:De(e.bytecode,r),define:ke(e.define,e.shims,e.env,r),minify:Pe(e),outdir:`${t}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:Ie(e.env),plugins:[...o,Ne({format:r,target:e.target,shims:e.shims}),...e.bunBuildPlugins??[]],throw:!1});if(!a.success)for(let f of a.logs){if(f.level==="error")throw new C(f.message);if(f.level==="warning")u.warn(f.message);else if(f.level==="info")u.info(f.message)}let l=`${t}/${e.outDir}/${n.name}${i}`,c=Bun.file(l).size||0;u.progress(r.toUpperCase(),x(l),K(c),e.name)}var v="0.4.37";var Ue="https://bunup.arshadyaseen.com/documentation/#cli-options";function d(e){return(t,n)=>{n[e]=t===!0||t==="true"}}function y(e){return(t,n)=>{if(typeof t==="string")n[e]=t;else throw new b(`Option --${e} requires a string value`)}}function Q(e){return(t,n)=>{if(typeof t==="string")n[e]=t.split(",");else throw new b(`Option --${e} requires a string value`)}}function ht(e){return(t,n)=>{if(typeof t==="boolean")n[e]=t;else if(typeof t==="string")if(t.toLowerCase()==="true"||t.toLowerCase()==="false")n[e]=t.toLowerCase()==="true";else n[e]=t;else throw new b(`Option --${e} requires a boolean or string value`)}}function bt(){console.log(`
|
|
35
35
|
Bunup - An extremely fast, zero-config bundler for JavaScript and TypeScript, powered by Bun.
|
|
36
|
-
`),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${
|
|
37
|
-
`),process.exit(0)}function
|
|
36
|
+
`),console.log("For more information on available options, visit:"),console.log(`\x1B[36m\x1B[4m${Ue}\x1B[0m
|
|
37
|
+
`),process.exit(0)}function yt(){console.log(v),process.exit(0)}var ve={name:{flags:["n","name"],handler:y("name")},format:{flags:["f","format"],handler:Q("format")},outDir:{flags:["o","out-dir"],handler:y("outDir")},minify:{flags:["m","minify"],handler:d("minify")},watch:{flags:["w","watch"],handler:d("watch")},dts:{flags:["d","dts"],handler:d("dts")},banner:{flags:["bn","banner"],handler:y("banner")},footer:{flags:["ft","footer"],handler:y("footer")},external:{flags:["e","external"],handler:Q("external")},sourcemap:{flags:["sm","sourcemap"],handler:ht("sourcemap")},target:{flags:["t","target"],handler:y("target")},minifyWhitespace:{flags:["mw","minify-whitespace"],handler:d("minifyWhitespace")},minifyIdentifiers:{flags:["mi","minify-identifiers"],handler:d("minifyIdentifiers")},minifySyntax:{flags:["ms","minify-syntax"],handler:d("minifySyntax")},clean:{flags:["c","clean"],handler:d("clean")},splitting:{flags:["s","splitting"],handler:d("splitting")},noExternal:{flags:["ne","no-external"],handler:Q("noExternal")},preferredTsconfigPath:{flags:["tsconfig","preferred-tsconfig-path"],handler:y("preferredTsconfigPath")},bytecode:{flags:["bc","bytecode"],handler:d("bytecode")},dtsOnly:{flags:["do","dts-only"],handler:d("dtsOnly")},silent:{flags:["silent"],handler:d("silent")},config:{flags:["config"],handler:y("config")},publicPath:{flags:["pp","public-path"],handler:y("publicPath")},env:{flags:["env"],handler:y("env")},shims:{flags:["shims"],handler:d("shims")},onSuccess:{flags:["onSuccess"],handler:y("onSuccess")},entry:{flags:["entry"],handler:(e,t,n)=>{if(typeof e!=="string")throw new b(`Entry${n?` --entry.${n}`:""} requires a string value`);let r=t.entry||{};if(n){if(r[n])u.warn(`Duplicate entry name '${n}' provided via --entry.${n}. Overwriting previous entry.`);r[n]=e}else{let s=_(e);if(r[s])u.warn(`Duplicate entry name '${s}' derived from '${e}'. Overwriting previous entry.`);r[s]=e}t.entry=r}},resolveDts:{flags:["rd","resolve-dts"],handler:(e,t)=>{if(!t.dts)t.dts={};if(typeof t.dts==="boolean")t.dts={};if(typeof e==="string")if(e==="true"||e==="false")t.dts.resolve=e==="true";else t.dts.resolve=e.split(",");else t.dts.resolve=!0}},help:{flags:["h","help"],handler:()=>bt()},version:{flags:["v","version"],handler:()=>yt()}},H={};for(let e of Object.values(ve))for(let t of e.flags)H[t]=e.handler;function He(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r.startsWith("--")){let s,o;if(r.includes("=")){let[i,a]=r.slice(2).split("=",2);s=i,o=a}else{s=r.slice(2);let i=e[n+1];if(o=i&&!i.startsWith("-")?i:!0,typeof o==="string")n++}if(s.includes(".")){let[i,a]=s.split(".",2),l=H[i];if(l)l(o,t,a);else throw new b(`Unknown option: --${s}`)}else{let i=H[s];if(i)i(o,t);else throw new b(`Unknown option: --${s}`)}}else if(r.startsWith("-")){let s=r.slice(1),o=e[n+1],i=o&&!o.startsWith("-")?o:!0;if(typeof i==="string")n++;let a=H[s];if(a)a(i,t);else throw new b(`Unknown option: -${s}`)}else ve.entry.handler(r,t,void 0)}return t}import{loadConfig as Ct}from"coffi";import W from"node:path";import xt from"chokidar";async function We(e,t){let n=new Set,r=N(e),s=L(r.entry);for(let l of s){let c=W.resolve(t,l.path),f=W.dirname(c);n.add(f)}let o=xt.watch(Array.from(n),{persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50},ignoreInitial:!0,atomic:!0,ignorePermissionErrors:!0,ignored:[/[\\/]\.git[\\/]/,/[\\/]node_modules[\\/]/,W.join(t,r.outDir)]}),i=!1,a=async(l=!1)=>{if(i)return;i=!0;try{let c=performance.now();if(await U({...r,entry:s.map((f)=>f.path),clean:!1},t),!l)u.cli(`\uD83D\uDCE6 Rebuild finished in ${P(performance.now()-c)}`);await Z()}catch(c){q(c)}finally{i=!1}};o.on("change",(l)=>{let c=W.relative(t,l);u.cli(`File changed: ${c}`,{muted:!0,once:c}),a()}),o.on("error",(l)=>{throw new A(`Watcher error: ${h(l)}`)}),await a(!0)}async function Ot(e=Bun.argv.slice(2)){let t=He(e);M(t.silent);let n=process.cwd(),{config:r,filepath:s}=await Ct({name:"bunup.config",extensions:[".ts",".js",".mjs",".cjs"],maxDepth:1,preferredPath:t.config}),o=!r?[{rootDir:n,options:t}]:await Le(r,n);if(u.cli(`Using bunup v${v} and bun v${Bun.version}`,{muted:!0}),s)u.cli(`Using config file: ${x(s,2)}`,{muted:!0});let i=performance.now();u.cli("Build started"),await Promise.all(o.flatMap(({options:c,rootDir:f})=>{return oe(c).map(async(m)=>{let T={...m,...Et(t)};return St(T,f)})}));let a=performance.now()-i,l=P(a);if(u.cli(`\u26A1\uFE0F Build completed in ${l}`),await Z(),t.watch)u.cli("\uD83D\uDC40 Watching for file changes");if(t.onSuccess)u.cli(`Running command: ${t.onSuccess}`,{muted:!0}),wt(t.onSuccess,[],{nodeOptions:{shell:!0,stdio:"inherit"}});if(!t.watch)process.exit(0)}function Et(e){return{...e,onSuccess:void 0,config:void 0}}async function Z(){if($.size>0)await Se($),$.clear()}async function St(e,t){if(e.watch)await We(e,t);else await U(e,t)}Ot().catch((e)=>ne(e));export{Z as validateDtsFiles};
|
package/build/index.d.mts
CHANGED
|
@@ -27,6 +27,7 @@ type ShimOptions = {
|
|
|
27
27
|
importMetaUrl?: boolean
|
|
28
28
|
};
|
|
29
29
|
type Shims = boolean | ShimOptions;
|
|
30
|
+
type DtsResolve = boolean | (string | RegExp)[];
|
|
30
31
|
type DtsOptions = {
|
|
31
32
|
/**
|
|
32
33
|
* Entry point files for TypeScript declaration file generation
|
|
@@ -58,7 +59,7 @@ type DtsOptions = {
|
|
|
58
59
|
/**
|
|
59
60
|
* Resolve external types used in dts files from node_modules
|
|
60
61
|
*/
|
|
61
|
-
resolve?:
|
|
62
|
+
resolve?: DtsResolve
|
|
62
63
|
};
|
|
63
64
|
interface BuildOptions {
|
|
64
65
|
/**
|
package/build/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ type ShimOptions = {
|
|
|
27
27
|
importMetaUrl?: boolean
|
|
28
28
|
};
|
|
29
29
|
type Shims = boolean | ShimOptions;
|
|
30
|
+
type DtsResolve = boolean | (string | RegExp)[];
|
|
30
31
|
type DtsOptions = {
|
|
31
32
|
/**
|
|
32
33
|
* Entry point files for TypeScript declaration file generation
|
|
@@ -58,7 +59,7 @@ type DtsOptions = {
|
|
|
58
59
|
/**
|
|
59
60
|
* Resolve external types used in dts files from node_modules
|
|
60
61
|
*/
|
|
61
|
-
resolve?:
|
|
62
|
+
resolve?: DtsResolve
|
|
62
63
|
};
|
|
63
64
|
interface BuildOptions {
|
|
64
65
|
/**
|
package/build/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
var
|
|
1
|
+
var He=require("node:module");var We=Object.create;var{getPrototypeOf:Fe,defineProperty:E,getOwnPropertyNames:Y,getOwnPropertyDescriptor:Ue}=Object,V=Object.prototype.hasOwnProperty;var C=(e,t,r)=>{r=e!=null?We(Fe(e)):{};let n=t||!e||!e.__esModule?E(r,"default",{value:e,enumerable:!0}):r;for(let s of Y(e))if(!V.call(n,s))E(n,s,{get:()=>e[s],enumerable:!0});return n},K=new WeakMap,Ge=(e)=>{var t=K.get(e),r;if(t)return t;if(t=E({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")Y(e).map((n)=>!V.call(t,n)&&E(t,n,{get:()=>e[n],enumerable:!(r=Ue(e,n))||r.enumerable}));return K.set(e,t),t};var qe=(e,t)=>{for(var r in t)E(e,r,{get:t[r],enumerable:!0,configurable:!0,set:(n)=>t[r]=()=>n})};var it={};qe(it,{defineWorkspace:()=>J,defineConfig:()=>X,build:()=>Pe});module.exports=Ge(it);function X(e){return e}function J(e){return e}var pe=require("rolldown"),de=require("rolldown-plugin-dts");var Q=!1;function Z(e){Q=e??!1}class b{static instance;loggedOnceMessages=new Set;MAX_LABEL_LENGTH=3;MAX_MESSAGE_LENGTH=25;colors={cli:"147",info:"245",warn:"179",error:"174",progress:{ESM:"172",CJS:"108",IIFE:"146",DTS:"110"},default:"252",size:"65"};labels={cli:"CLI",info:"INFO",warn:"WARN",error:"ERROR"};constructor(){}static getInstance(){if(!b.instance)b.instance=new b;return b.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(e){if(!e?.once)return!0;if(this.loggedOnceMessages.has(e.once))return!1;return this.loggedOnceMessages.add(e.once),!0}formatMessage({colorCode:e,label:t,message:r,size:n,identifier:s,muted:o}){let i=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-t.length)),a=o?`\x1B[38;5;${this.colors.info}m${r}\x1B[0m`:r;if(n){let[c,...l]=a.split(" "),g=" ".repeat(Math.max(0,this.MAX_MESSAGE_LENGTH-c.length)),m=s?` \x1B[48;5;${e};38;5;0m ${s} \x1B[0m`:"";return`\x1B[38;5;${e}m${t}\x1B[0m ${i}${c}${g} \x1B[38;5;${this.colors.size}m${n}\x1B[0m ${l.join(" ")}${m}`}let u=s?` \x1B[48;5;${e};38;5;0m ${s} \x1B[0m`:"";return`\x1B[38;5;${e}m${t}\x1B[0m ${i}${a}${u}`}output(e,t={},r=console.log){if(Q)return;if(!this.shouldLog(t))return;if(t.verticalSpace)console.log("");if(r(e),t.verticalSpace)console.log("")}cli(e,t={}){let r=this.formatMessage({colorCode:this.colors.cli,label:this.labels.cli,message:e,identifier:t.identifier,muted:t.muted});this.output(r,t)}info(e,t={}){let r=this.formatMessage({colorCode:this.colors.info,label:this.labels.info,message:e,identifier:t.identifier,muted:t.muted});this.output(r,t)}warn(e,t={}){let r=this.formatMessage({colorCode:this.colors.warn,label:this.labels.warn,message:e,identifier:t.identifier,muted:t.muted});this.output(r,t,console.warn)}error(e,t={}){let r=this.formatMessage({colorCode:this.colors.error,label:this.labels.error,message:e,identifier:t.identifier,muted:t.muted});this.output(r,t,console.error)}progress(e,t,r,n){let s=String(e),o=this.colors.default,i,a,u={};if(typeof r==="string")i=r,a=n;else if(r)i=r.size,a=r.identifier,u=r;for(let[l,g]of Object.entries(this.colors.progress))if(s.includes(l)){o=g;break}let c=this.formatMessage({colorCode:o,label:s,message:t,size:i,identifier:a,muted:u.muted});this.output(c,u)}}var f=b.getInstance();class A extends Error{constructor(e){super(e);this.name="BunupError"}}class h extends A{constructor(e){super(e);this.name="BunupBuildError"}}class p extends A{constructor(e){super(e);this.name="BunupDTSBuildError"}}var d=(e)=>{if(e instanceof Error)return e.message;return String(e)};var I=C(require("node:fs/promises")),z=C(require("node:path"));function j(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function v(e=8){let t="";while(t.length<e)t+=Math.random().toString(36).substring(2);return t.substring(0,e)}function ee(e,t){switch(e){case"esm":return y(t)?".js":".mjs";case"cjs":return y(t)?".cjs":".js";case"iife":return".global.js"}}function te(e,t){switch(e){case"esm":return y(t)?".d.ts":".d.mts";case"cjs":return y(t)?".d.cts":".d.ts";case"iife":return".d.ts"}}function N(e){return e==="node"||e==="bun"}function y(e){return e==="module"}function re(e){if(!e)return[];return Array.from(new Set([...Object.keys(e.dependencies||{}),...Object.keys(e.peerDependencies||{})]))}function P(e){if(e===0)return"0 B";let t=["B","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(1024));if(r===0)return`${e} ${t[r]}`;return`${(e/1024**r).toFixed(2)} ${t[r]}`}function w(e,t=3){return e.split("/").slice(-t).join("/")}async function ne(e,t){let r=z.default.join(e,t);try{await I.default.rm(r,{recursive:!0,force:!0})}catch(n){throw new h(`Failed to clean output directory: ${n}`)}await I.default.mkdir(r,{recursive:!0})}function T(e){return[".ts",".mts",".cts",".tsx"].some((t)=>e.endsWith(t))}function se(e){return e.map((t)=>typeof t==="string"?new RegExp(`^${j(t)}($|\\/|\\\\)`):t)}function B(e,t){return se(e.external||[]).concat(re(t).map((r)=>new RegExp(`^${j(r)}($|\\/|\\\\)`)))}function R(e){return se(e.noExternal||[])}var W=C(require("node:path")),fe=require("oxc-resolver");var ie=require("ts-import-resolver");var S="\x00dts:",oe=(e,t,r)=>{return{name:"bunup:virtual-dts",async resolveId(n,s){if(_(n))return n;if(!s||!_(s))return null;let o=t.tsconfig?ie.resolveTsImportPath({path:n,importer:$(s),tsconfig:t.tsconfig,rootDir:r}):null;if(!o)return null;let i=x(o);if(e.has(i))return O(i);return null},load(n){if(n.startsWith(S)){let s=$(n),o=e.get(s);if(o)return ae.add(s),o}return null}}};function ue(e){return e.tsconfig.compilerOptions??{}}function ce(e){return e.endsWith(".d.ts")||e.endsWith(".d.mts")||e.endsWith(".d.cts")}function le(e){return/\.(js|mjs|cjs|ts|mts|cts|tsx|jsx)$/.test(e)&&!ce(e)}function x(e){if(ce(e))return e;return e.replace(/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/,".d.ts")}function _(e){return e.startsWith(S)}function $(e){return e.replace(S,"")}function O(e){return`${S}${e}`}function me(e,t,r,n){if(typeof n==="boolean"&&n)return!1;if(Array.isArray(n)){for(let s of n)if(typeof s==="string"&&e===s)return!1;else if(s instanceof RegExp&&s.test(e))return!1}return t.some((s)=>s.test(e))&&!r.some((s)=>s.test(e))}var k;function ge(e,t){return{name:"bunup:types-resolve",buildStart(){k||=new fe.ResolverFactory({mainFields:["types","typings","module","main"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".d.mts",".d.cts",".ts",".mts",".cts"],...e.path&&{tsconfig:{configFile:e.path}},modules:["node_modules","node_modules/@types"]})},async resolveId(r,n){if(t===!1)return;if(r==="bun")return;let s=n?$(n):void 0;if(/\0/.test(r))return;if(Array.isArray(t)){if(!t.some((u)=>typeof u==="string"?u===r:u.test(r)))return}let o=s?W.default.dirname(s):process.cwd(),{path:i}=await k.async(o,r);if(!i)return;if(le(i)){let a=x(i);try{let{path:u}=await k.async(W.default.dirname(i),a);if(u)return u}catch(u){}return}return i}}}async function xe(e,t,r,n,s,o){let i=x(e),a=O(i),u=B(r,n),c=R(r),l=typeof r.dts==="object"&&"resolve"in r.dts?r.dts.resolve:void 0;try{let{output:g}=await pe.build({input:a,output:{dir:r.outDir},write:!1,onwarn(m,D){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(m.code??""))return;D(m)},plugins:[oe(t,s,o),l&&ge(s,l),de.dts({dtsInput:!0,emitDtsOnly:!0,compilerOptions:{...ue(s),declaration:!0,noEmit:!1,emitDeclarationOnly:!0,noEmitOnError:!0,checkJs:!1,declarationMap:!1,skipLibCheck:!0,preserveSymlinks:!1,target:99}})],external:(m)=>me(m,u,c,l)});if(!g[0]?.code)return f.warn(`Generated empty declaration file for entry "${e}"`,{muted:!0}),"";return g[0].code}catch(g){throw new p(`DTS bundling failed for entry "${e}": ${d(g)}`)}}var be=require("ts-import-resolver");var Ke=/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]/gm,Ye=/^\s*export\s+.*from\s+['"]([^'"]+)['"]/gm,Ve=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,Xe=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,Je=/import\s+\w+\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,Qe=/\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/g,Ze=/\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/g;function ze(e){let t=new Set,r=[Ke,Ye,Ve,Xe,Je,Qe,Ze];for(let n of r){let s=e.matchAll(n);for(let o of s)if(o[1])t.add(o[1])}return t}async function he(e,t,r){let n=new Set([e]),s=[e];while(s.length){let o=s.pop();if(!o)continue;try{let i=await Bun.file(o).text(),a=ze(i);for(let u of a){let c=t.tsconfig?be.resolveTsImportPath({path:u,importer:o,tsconfig:t.tsconfig,rootDir:r}):null;if(!c)continue;if(!n.has(c))n.add(c),s.push(c)}}catch(i){f.warn(`Error processing ${o}: ${d(i)}`)}}return n}var ye=require("oxc-transform");async function we(e){let t=new Map;return await Promise.all([...e].map(async(r)=>{try{let n=x(r);if(!await Bun.file(r).exists())return;let o=await Bun.file(r).text(),{code:i}=ye.isolatedDeclaration(r,o);if(i)t.set(n,i)}catch(n){f.warn(`Failed to generate declaration for ${r}: ${d(n)}`)}})),t}var F=C(require("node:fs/promises")),M=C(require("node:path")),ve=require("oxc-transform");async function Ee(e,t){let r=M.default.resolve(e),n=M.default.resolve(r,t);if(!await F.default.exists(r))throw new p(`Root directory does not exist: ${r}`);if(!await Bun.file(n).exists())throw new p(`Entry file does not exist: ${n}`);if(!T(n))throw new p(`Entry file must be a TypeScript file: ${n}`);if(M.default.relative(r,n).startsWith(".."))throw new p(`Entry file must be within rootDir: ${n}`);return{absoluteRootDir:r,absoluteEntry:n}}async function Ce(e,t,r,n,s){let{absoluteEntry:o}=await Ee(e,t),i=await he(o,n,e),a=await we(i);return xe(o,a,r,s,n,e)}function $e(e){return e.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function U(e,{warnOnConflict:t=!0}={}){let r=[],n=new Set,s={};function o(i,a){if(n.has(i)){let u=v(),c=`${i}_${u}`;if(t)f.warn(`Output name conflict: "${i}" is used by multiple files.
|
|
2
2
|
Bunup uses filenames without extensions as output names by default.
|
|
3
3
|
|
|
4
|
-
${i
|
|
4
|
+
${s[i]} -> ${i}.js
|
|
5
5
|
${a} -> ${c}.js (auto-renamed to avoid conflict)
|
|
6
6
|
|
|
7
7
|
To fix this, use named entries in your configuration:
|
|
8
8
|
{
|
|
9
9
|
entry: {
|
|
10
|
-
custom_name: "${i
|
|
10
|
+
custom_name: "${s[i]}",
|
|
11
11
|
another_name: "${a}"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
See: https://bunup.arshadyaseen.com/documentation/#named-entries`,{muted:!0,verticalSpace:!0});
|
|
15
|
+
See: https://bunup.arshadyaseen.com/documentation/#named-entries`,{muted:!0,verticalSpace:!0});r.push({name:c,path:a})}else r.push({name:i,path:a}),n.add(i),s[i]=a}if(Array.isArray(e))for(let i of e){let a=$e(i);o(a,i)}else if(typeof e==="object")for(let[i,a]of Object.entries(e))o(i,a);else{let i=$e(e);o(i,e)}return r}function Se(e){return e.filter((t)=>T(t.path))}function Te(e,t){return`[dir]/${e}${t}`}var G=require("coffi");async function Be(e){let{config:t,filepath:r}=await G.loadConfig({name:"package",cwd:e,extensions:[".json"],maxDepth:3});return{packageJson:t,path:r}}async function Re(e,t){let{config:r,filepath:n}=await G.loadConfig({name:"tsconfig",cwd:e,extensions:[".json"],preferredPath:t,maxDepth:3});return{tsconfig:r,path:n}}var et={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function Oe(e){return{...et,...e}}function Me(e){let{minify:t,minifyWhitespace:r,minifyIdentifiers:n,minifySyntax:s}=e,o=t===!0;return{whitespace:r??o,identifiers:n??o,syntax:s??o}}function De(e,t){return t==="cjs"?e:void 0}function Le(e,t,r,n){return{...typeof r==="object"&&Object.keys(r).reduce((s,o)=>{let i=JSON.stringify(r[o]);return s[`process.env.${o}`]=i,s[`import.meta.env.${o}`]=i,s},{}),...e,...n==="cjs"&&(t===!0||typeof t==="object"&&t.importMetaUrl)&&{"import.meta.url":"importMetaUrl"}}}function Ae(e,t){return e===void 0?t==="esm":e}function Ie(e){return typeof e==="string"?e:void 0}function je(e,t){return{name:"bunup:external-plugin",setup(r){r.onResolve({filter:/.*/},(n)=>{let s=n.path;if(e.some((i)=>i.test(s))&&!t.some((i)=>i.test(s)))return{path:s,external:!0};return null})}}}var tt=/\.(js|ts|jsx|tsx|mts|cts)$/,q={dirnameFilename:{appliesTo:(e,t)=>e==="esm"&&N(t),isNeededInFile:(e)=>/\b__dirname\b/.test(e)||/\b__filename\b/.test(e),generateCode:()=>`import { fileURLToPath } from 'url';
|
|
16
16
|
import { dirname } from 'path';
|
|
17
17
|
|
|
18
18
|
const __filename = fileURLToPath(import.meta.url);
|
|
19
19
|
const __dirname = dirname(__filename);
|
|
20
20
|
|
|
21
|
-
`},importMetaUrl:{appliesTo:(e,
|
|
21
|
+
`},importMetaUrl:{appliesTo:(e,t)=>e==="cjs"&&N(t),isNeededInFile:(e)=>/\bimport\.meta\.url\b/.test(e),generateCode:()=>`import { pathToFileURL } from 'url';
|
|
22
22
|
|
|
23
23
|
const importMetaUrl = pathToFileURL(__filename).href;
|
|
24
24
|
|
|
25
|
-
`}};function
|
|
26
|
-
`);return
|
|
25
|
+
`}};function Ne({format:e,target:t,shims:r}){let s=rt(r).map((o)=>q[o]).filter((o)=>o.appliesTo(e,t));if(s.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(o){o.onLoad({filter:tt},async({path:i})=>{let a=await Bun.file(i).text(),u=s.filter((m)=>m.isNeededInFile(a));if(u.length===0)return;let{shebangLine:c,codeContent:l}=nt(a),g=u.map((m)=>m.generateCode()).join("");return{contents:c+g+l}})}}}function rt(e){if(e===!0)return Object.keys(q);if(!e)return[];return Object.entries(e).filter(([t,r])=>r&&(t in q)).map(([t])=>t)}function nt(e){if(!e.startsWith("#!"))return{shebangLine:"",codeContent:e};let t=e.indexOf(`
|
|
26
|
+
`);return t===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,t+1),codeContent:e.slice(t+1)}}var ae=new Set;async function Pe(e,t){let r=Oe(e);if(!r.entry||r.entry.length===0||!r.outDir)throw new h("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(r.clean)ne(t,r.outDir);Z(r.silent);let{packageJson:n,path:s}=await Be(t);if(n&&s)f.cli(`Using package.json: ${w(s,2)}`,{muted:!0,identifier:r.name,once:`${s}:${r.name}`});let o=U(r.entry),i=n?.type,a=B(r,n),u=R(r);if(!r.dtsOnly){let c=[je(a,u)],l=r.format.flatMap((g)=>o.map((m)=>{return st(r,t,m,g,i,c)}));await Promise.all(l)}if(r.dts||r.dtsOnly){let c=await Re(t,r.preferredTsconfigPath);if(c.path)f.cli(`Using tsconfig: ${w(c.path,2)}`,{muted:!0,identifier:r.name,once:`${c.path}:${r.name}`});let l=r.format.filter((m)=>{if(m==="iife"&&!y(i)&&r.format.includes("cjs"))return!1;return!0}),g=typeof r.dts==="object"&&r.dts.entry?U(r.dts.entry):Se(o);try{await Promise.all(g.map(async(m)=>{let D=await Ce(t,m.path,r,c,n);await Promise.all(l.map(async(H)=>{let _e=r.outputExtension?.({format:H,packageType:i,options:r,entry:m}).dts??te(H,i),L=`${t}/${r.outDir}/${m.name}${_e}`;await Bun.write(L,D);let ke=Bun.file(L).size||0;f.progress("DTS",w(L),P(ke),r.name)}))}))}catch(m){throw new p(d(m))}}if(r.onBuildSuccess)await r.onBuildSuccess(r)}async function st(e,t,r,n,s,o){let i=e.outputExtension?.({format:n,packageType:s,options:e,entry:r}).js??ee(n,s),a=await Bun.build({entrypoints:[`${t}/${r.path}`],format:n,naming:{entry:Te(r.name,i)},splitting:Ae(e.splitting,n),bytecode:De(e.bytecode,n),define:Le(e.define,e.shims,e.env,n),minify:Me(e),outdir:`${t}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:Ie(e.env),plugins:[...o,Ne({format:n,target:e.target,shims:e.shims}),...e.bunBuildPlugins??[]],throw:!1});if(!a.success)for(let l of a.logs){if(l.level==="error")throw new h(l.message);if(l.level==="warning")f.warn(l.message);else if(l.level==="info")f.info(l.message)}let u=`${t}/${e.outDir}/${r.name}${i}`,c=Bun.file(u).size||0;f.progress(n.toUpperCase(),w(u),P(c),e.name)}
|
package/build/index.mjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Se(e){return e}function Te(e){return e}import{build as Me}from"rolldown";import{dts as De}from"rolldown-plugin-dts";var W=!1;function F(e){W=e??!1}class b{static instance;loggedOnceMessages=new Set;MAX_LABEL_LENGTH=3;MAX_MESSAGE_LENGTH=25;colors={cli:"147",info:"245",warn:"179",error:"174",progress:{ESM:"172",CJS:"108",IIFE:"146",DTS:"110"},default:"252",size:"65"};labels={cli:"CLI",info:"INFO",warn:"WARN",error:"ERROR"};constructor(){}static getInstance(){if(!b.instance)b.instance=new b;return b.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(e){if(!e?.once)return!0;if(this.loggedOnceMessages.has(e.once))return!1;return this.loggedOnceMessages.add(e.once),!0}formatMessage({colorCode:e,label:r,message:t,size:n,identifier:s,muted:o}){let i=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-r.length)),a=o?`\x1B[38;5;${this.colors.info}m${t}\x1B[0m`:t;if(n){let[c,...l]=a.split(" "),g=" ".repeat(Math.max(0,this.MAX_MESSAGE_LENGTH-c.length)),m=s?` \x1B[48;5;${e};38;5;0m ${s} \x1B[0m`:"";return`\x1B[38;5;${e}m${r}\x1B[0m ${i}${c}${g} \x1B[38;5;${this.colors.size}m${n}\x1B[0m ${l.join(" ")}${m}`}let u=s?` \x1B[48;5;${e};38;5;0m ${s} \x1B[0m`:"";return`\x1B[38;5;${e}m${r}\x1B[0m ${i}${a}${u}`}output(e,r={},t=console.log){if(W)return;if(!this.shouldLog(r))return;if(r.verticalSpace)console.log("");if(t(e),r.verticalSpace)console.log("")}cli(e,r={}){let t=this.formatMessage({colorCode:this.colors.cli,label:this.labels.cli,message:e,identifier:r.identifier,muted:r.muted});this.output(t,r)}info(e,r={}){let t=this.formatMessage({colorCode:this.colors.info,label:this.labels.info,message:e,identifier:r.identifier,muted:r.muted});this.output(t,r)}warn(e,r={}){let t=this.formatMessage({colorCode:this.colors.warn,label:this.labels.warn,message:e,identifier:r.identifier,muted:r.muted});this.output(t,r,console.warn)}error(e,r={}){let t=this.formatMessage({colorCode:this.colors.error,label:this.labels.error,message:e,identifier:r.identifier,muted:r.muted});this.output(t,r,console.error)}progress(e,r,t,n){let s=String(e),o=this.colors.default,i,a,u={};if(typeof t==="string")i=t,a=n;else if(t)i=t.size,a=t.identifier,u=t;for(let[l,g]of Object.entries(this.colors.progress))if(s.includes(l)){o=g;break}let c=this.formatMessage({colorCode:o,label:s,message:r,size:i,identifier:a,muted:u.muted});this.output(c,u)}}var f=b.getInstance();class M extends Error{constructor(e){super(e);this.name="BunupError"}}class h extends M{constructor(e){super(e);this.name="BunupBuildError"}}class p extends M{constructor(e){super(e);this.name="BunupDTSBuildError"}}var d=(e)=>{if(e instanceof Error)return e.message;return String(e)};import U from"node:fs/promises";import Be from"node:path";function D(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function G(e=8){let r="";while(r.length<e)r+=Math.random().toString(36).substring(2);return r.substring(0,e)}function q(e,r){switch(e){case"esm":return y(r)?".js":".mjs";case"cjs":return y(r)?".cjs":".js";case"iife":return".global.js"}}function H(e,r){switch(e){case"esm":return y(r)?".d.ts":".d.mts";case"cjs":return y(r)?".d.cts":".d.ts";case"iife":return".d.ts"}}function L(e){return e==="node"||e==="bun"}function y(e){return e==="module"}function K(e){if(!e)return[];return Array.from(new Set([...Object.keys(e.dependencies||{}),...Object.keys(e.peerDependencies||{})]))}function A(e){if(e===0)return"0 B";let r=["B","KB","MB","GB"],t=Math.floor(Math.log(e)/Math.log(1024));if(t===0)return`${e} ${r[t]}`;return`${(e/1024**t).toFixed(2)} ${r[t]}`}function w(e,r=3){return e.split("/").slice(-r).join("/")}async function Y(e,r){let t=Be.join(e,r);try{await U.rm(t,{recursive:!0,force:!0})}catch(n){throw new h(`Failed to clean output directory: ${n}`)}await U.mkdir(t,{recursive:!0})}function $(e){return[".ts",".mts",".cts",".tsx"].some((r)=>e.endsWith(r))}function V(e){return e.map((r)=>typeof r==="string"?new RegExp(`^${D(r)}($|\\/|\\\\)`):r)}function S(e,r){return V(e.external||[]).concat(K(r).map((t)=>new RegExp(`^${D(t)}($|\\/|\\\\)`)))}function T(e){return V(e.noExternal||[])}import ee from"node:path";import{ResolverFactory as Oe}from"oxc-resolver";import{resolveTsImportPath as Re}from"ts-import-resolver";var C="\x00dts:",X=(e,r,t)=>{return{name:"bunup:virtual-dts",async resolveId(n,s){if(I(n))return n;if(!s||!I(s))return null;let o=r.tsconfig?Re({path:n,importer:E(s),tsconfig:r.tsconfig,rootDir:t}):null;if(!o)return null;let i=x(o);if(e.has(i))return B(i);return null},load(n){if(n.startsWith(C)){let s=E(n),o=e.get(s);if(o)return J.add(s),o}return null}}};function Q(e){return e.tsconfig.compilerOptions??{}}function Z(e){return e.endsWith(".d.ts")||e.endsWith(".d.mts")||e.endsWith(".d.cts")}function z(e){return/\.(js|mjs|cjs|ts|mts|cts|tsx|jsx)$/.test(e)&&!Z(e)}function x(e){if(Z(e))return e;return e.replace(/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/,".d.ts")}function I(e){return e.startsWith(C)}function E(e){return e.replace(C,"")}function B(e){return`${C}${e}`}function v(e,r,t,n){if(typeof n==="boolean"&&n)return!1;if(Array.isArray(n)){for(let s of n)if(typeof s==="string"&&e===s)return!1;else if(s instanceof RegExp&&s.test(e))return!1}return r.some((s)=>s.test(e))&&!t.some((s)=>s.test(e))}var j;function te(e,r){return{name:"bunup:types-resolve",buildStart(){j||=new Oe({mainFields:["types","typings","module","main"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".d.mts",".d.cts",".ts",".mts",".cts"],...e.path&&{tsconfig:{configFile:e.path}},modules:["node_modules","node_modules/@types"]})},async resolveId(t,n){if(r===!1)return;if(t==="bun")return;let s=n?E(n):void 0;if(/\0/.test(t))return;if(Array.isArray(r)){if(!r.some((u)=>typeof u==="string"?u===t:u.test(t)))return}let o=s?ee.dirname(s):process.cwd(),{path:i}=await j.async(o,t);if(!i)return;if(z(i)){let a=x(i);try{let{path:u}=await j.async(ee.dirname(i),a);if(u)return u}catch(u){}return}return i}}}async function re(e,r,t,n,s,o){let i=x(e),a=B(i),u=S(t,n),c=T(t),l=typeof t.dts==="object"&&"resolve"in t.dts?t.dts.resolve:void 0;try{let{output:g}=await Me({input:a,output:{dir:t.outDir},write:!1,onwarn(m,R){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(m.code??""))return;R(m)},plugins:[X(r,s,o),l&&te(s,l),De({dtsInput:!0,emitDtsOnly:!0,compilerOptions:{...Q(s),declaration:!0,noEmit:!1,emitDeclarationOnly:!0,noEmitOnError:!0,checkJs:!1,declarationMap:!1,skipLibCheck:!0,preserveSymlinks:!1,target:99}})],external:(m)=>v(m,u,c,l)});if(!g[0]?.code)return f.warn(`Generated empty declaration file for entry "${e}"`,{muted:!0}),"";return g[0].code}catch(g){throw new p(`DTS bundling failed for entry "${e}": ${d(g)}`)}}import{resolveTsImportPath as Le}from"ts-import-resolver";var Ae=/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]/gm,Ie=/^\s*export\s+.*from\s+['"]([^'"]+)['"]/gm,je=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,Ne=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,Pe=/import\s+\w+\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,_e=/\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/g,ke=/\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/g;function We(e){let r=new Set,t=[Ae,Ie,je,Ne,Pe,_e,ke];for(let n of t){let s=e.matchAll(n);for(let o of s)if(o[1])r.add(o[1])}return r}async function ne(e,r,t){let n=new Set([e]),s=[e];while(s.length){let o=s.pop();if(!o)continue;try{let i=await Bun.file(o).text(),a=We(i);for(let u of a){let c=r.tsconfig?Le({path:u,importer:o,tsconfig:r.tsconfig,rootDir:t}):null;if(!c)continue;if(!n.has(c))n.add(c),s.push(c)}}catch(i){f.warn(`Error processing ${o}: ${d(i)}`)}}return n}import{isolatedDeclaration as Fe}from"oxc-transform";async function se(e){let r=new Map;return await Promise.all([...e].map(async(t)=>{try{let n=x(t);if(!await Bun.file(t).exists())return;let o=await Bun.file(t).text(),{code:i}=Fe(t,o);if(i)r.set(n,i)}catch(n){f.warn(`Failed to generate declaration for ${t}: ${d(n)}`)}})),r}import ie from"node:fs/promises";import N from"node:path";import{isolatedDeclaration as jt}from"oxc-transform";async function oe(e,r){let t=N.resolve(e),n=N.resolve(t,r);if(!await ie.exists(t))throw new p(`Root directory does not exist: ${t}`);if(!await Bun.file(n).exists())throw new p(`Entry file does not exist: ${n}`);if(!$(n))throw new p(`Entry file must be a TypeScript file: ${n}`);if(N.relative(t,n).startsWith(".."))throw new p(`Entry file must be within rootDir: ${n}`);return{absoluteRootDir:t,absoluteEntry:n}}async function ae(e,r,t,n,s){let{absoluteEntry:o}=await oe(e,r),i=await ne(o,n,e),a=await se(i);return re(o,a,t,s,n,e)}function ue(e){return e.split("/").pop()?.split(".").slice(0,-1).join(".")||""}function P(e,{warnOnConflict:r=!0}={}){let t=[],n=new Set,s={};function o(i,a){if(n.has(i)){let u=G(),c=`${i}_${u}`;if(r)f.warn(`Output name conflict: "${i}" is used by multiple files.
|
|
2
2
|
Bunup uses filenames without extensions as output names by default.
|
|
3
3
|
|
|
4
|
-
${i
|
|
4
|
+
${s[i]} -> ${i}.js
|
|
5
5
|
${a} -> ${c}.js (auto-renamed to avoid conflict)
|
|
6
6
|
|
|
7
7
|
To fix this, use named entries in your configuration:
|
|
8
8
|
{
|
|
9
9
|
entry: {
|
|
10
|
-
custom_name: "${i
|
|
10
|
+
custom_name: "${s[i]}",
|
|
11
11
|
another_name: "${a}"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
See: https://bunup.arshadyaseen.com/documentation/#named-entries`,{muted:!0,verticalSpace:!0});t.push({name:c,path:a})}else t.push({name:
|
|
15
|
+
See: https://bunup.arshadyaseen.com/documentation/#named-entries`,{muted:!0,verticalSpace:!0});t.push({name:c,path:a})}else t.push({name:i,path:a}),n.add(i),s[i]=a}if(Array.isArray(e))for(let i of e){let a=ue(i);o(a,i)}else if(typeof e==="object")for(let[i,a]of Object.entries(e))o(i,a);else{let i=ue(e);o(i,e)}return t}function ce(e){return e.filter((r)=>$(r.path))}function le(e,r){return`[dir]/${e}${r}`}import{loadConfig as me}from"coffi";async function fe(e){let{config:r,filepath:t}=await me({name:"package",cwd:e,extensions:[".json"],maxDepth:3});return{packageJson:r,path:t}}async function ge(e,r){let{config:t,filepath:n}=await me({name:"tsconfig",cwd:e,extensions:[".json"],preferredPath:r,maxDepth:3});return{tsconfig:t,path:n}}var Ue={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function pe(e){return{...Ue,...e}}function de(e){let{minify:r,minifyWhitespace:t,minifyIdentifiers:n,minifySyntax:s}=e,o=r===!0;return{whitespace:t??o,identifiers:n??o,syntax:s??o}}function xe(e,r){return r==="cjs"?e:void 0}function be(e,r,t,n){return{...typeof t==="object"&&Object.keys(t).reduce((s,o)=>{let i=JSON.stringify(t[o]);return s[`process.env.${o}`]=i,s[`import.meta.env.${o}`]=i,s},{}),...e,...n==="cjs"&&(r===!0||typeof r==="object"&&r.importMetaUrl)&&{"import.meta.url":"importMetaUrl"}}}function he(e,r){return e===void 0?r==="esm":e}function ye(e){return typeof e==="string"?e:void 0}function we(e,r){return{name:"bunup:external-plugin",setup(t){t.onResolve({filter:/.*/},(n)=>{let s=n.path;if(e.some((i)=>i.test(s))&&!r.some((i)=>i.test(s)))return{path:s,external:!0};return null})}}}var Ge=/\.(js|ts|jsx|tsx|mts|cts)$/,_={dirnameFilename:{appliesTo:(e,r)=>e==="esm"&&L(r),isNeededInFile:(e)=>/\b__dirname\b/.test(e)||/\b__filename\b/.test(e),generateCode:()=>`import { fileURLToPath } from 'url';
|
|
16
16
|
import { dirname } from 'path';
|
|
17
17
|
|
|
18
18
|
const __filename = fileURLToPath(import.meta.url);
|
|
19
19
|
const __dirname = dirname(__filename);
|
|
20
20
|
|
|
21
|
-
`},importMetaUrl:{appliesTo:(e,r)=>e==="cjs"&&
|
|
21
|
+
`},importMetaUrl:{appliesTo:(e,r)=>e==="cjs"&&L(r),isNeededInFile:(e)=>/\bimport\.meta\.url\b/.test(e),generateCode:()=>`import { pathToFileURL } from 'url';
|
|
22
22
|
|
|
23
23
|
const importMetaUrl = pathToFileURL(__filename).href;
|
|
24
24
|
|
|
25
|
-
`}};function
|
|
26
|
-
`);return r===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,r+1),codeContent:e.slice(r+1)}}var
|
|
25
|
+
`}};function Ee({format:e,target:r,shims:t}){let s=qe(t).map((o)=>_[o]).filter((o)=>o.appliesTo(e,r));if(s.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(o){o.onLoad({filter:Ge},async({path:i})=>{let a=await Bun.file(i).text(),u=s.filter((m)=>m.isNeededInFile(a));if(u.length===0)return;let{shebangLine:c,codeContent:l}=He(a),g=u.map((m)=>m.generateCode()).join("");return{contents:c+g+l}})}}}function qe(e){if(e===!0)return Object.keys(_);if(!e)return[];return Object.entries(e).filter(([r,t])=>t&&(r in _)).map(([r])=>r)}function He(e){if(!e.startsWith("#!"))return{shebangLine:"",codeContent:e};let r=e.indexOf(`
|
|
26
|
+
`);return r===-1?{shebangLine:"",codeContent:e}:{shebangLine:e.slice(0,r+1),codeContent:e.slice(r+1)}}var J=new Set;async function Ke(e,r){let t=pe(e);if(!t.entry||t.entry.length===0||!t.outDir)throw new h("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(t.clean)Y(r,t.outDir);F(t.silent);let{packageJson:n,path:s}=await fe(r);if(n&&s)f.cli(`Using package.json: ${w(s,2)}`,{muted:!0,identifier:t.name,once:`${s}:${t.name}`});let o=P(t.entry),i=n?.type,a=S(t,n),u=T(t);if(!t.dtsOnly){let c=[we(a,u)],l=t.format.flatMap((g)=>o.map((m)=>{return Ye(t,r,m,g,i,c)}));await Promise.all(l)}if(t.dts||t.dtsOnly){let c=await ge(r,t.preferredTsconfigPath);if(c.path)f.cli(`Using tsconfig: ${w(c.path,2)}`,{muted:!0,identifier:t.name,once:`${c.path}:${t.name}`});let l=t.format.filter((m)=>{if(m==="iife"&&!y(i)&&t.format.includes("cjs"))return!1;return!0}),g=typeof t.dts==="object"&&t.dts.entry?P(t.dts.entry):ce(o);try{await Promise.all(g.map(async(m)=>{let R=await ae(r,m.path,t,c,n);await Promise.all(l.map(async(k)=>{let Ce=t.outputExtension?.({format:k,packageType:i,options:t,entry:m}).dts??H(k,i),O=`${r}/${t.outDir}/${m.name}${Ce}`;await Bun.write(O,R);let $e=Bun.file(O).size||0;f.progress("DTS",w(O),A($e),t.name)}))}))}catch(m){throw new p(d(m))}}if(t.onBuildSuccess)await t.onBuildSuccess(t)}async function Ye(e,r,t,n,s,o){let i=e.outputExtension?.({format:n,packageType:s,options:e,entry:t}).js??q(n,s),a=await Bun.build({entrypoints:[`${r}/${t.path}`],format:n,naming:{entry:le(t.name,i)},splitting:he(e.splitting,n),bytecode:xe(e.bytecode,n),define:be(e.define,e.shims,e.env,n),minify:de(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:ye(e.env),plugins:[...o,Ee({format:n,target:e.target,shims:e.shims}),...e.bunBuildPlugins??[]],throw:!1});if(!a.success)for(let l of a.logs){if(l.level==="error")throw new h(l.message);if(l.level==="warning")f.warn(l.message);else if(l.level==="info")f.info(l.message)}let u=`${r}/${e.outDir}/${t.name}${i}`,c=Bun.file(u).size||0;f.progress(n.toUpperCase(),w(u),A(c),e.name)}export{Te as defineWorkspace,Se as defineConfig,Ke as build};
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunup",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.37",
|
|
4
4
|
"description": "An extremely fast, zero-config bundler for TypeScript & JavaScript, powered by Bun.",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
7
7
|
"module": "./build/index.mjs",
|
|
8
8
|
"files": [
|
|
9
|
-
"build"
|
|
9
|
+
"build",
|
|
10
|
+
"bin"
|
|
10
11
|
],
|
|
11
12
|
"bin": {
|
|
12
|
-
"bunup": "
|
|
13
|
+
"bunup": "./bin/bunup.js"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
15
16
|
"@biomejs/biome": "^1.9.4",
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
"bunup": "^0.4.23",
|
|
21
22
|
"husky": "^9.1.7",
|
|
22
23
|
"typescript": "^5.8.3",
|
|
23
|
-
"create-bunup": "0.4.
|
|
24
|
+
"create-bunup": "0.4.37"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {
|
|
26
27
|
"typescript": ">=4.5.0"
|