@stacksjs/build 0.75.329 → 0.75.334
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/index.d.ts +2 -2
- package/dist/index.js +4 -3
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -18,8 +18,8 @@ export declare function validateDeclarations(dir: string): Promise<void>;
|
|
|
18
18
|
*
|
|
19
19
|
* Loading happens in a subprocess because it EXECUTES module top-level code;
|
|
20
20
|
* a package that needs env or a database at import must not fail its build
|
|
21
|
-
* for that reason.
|
|
22
|
-
* left alone deliberately.
|
|
21
|
+
* for that reason. Syntax and link errors are fatal. Runtime requirements
|
|
22
|
+
* such as a browser DOM are left alone deliberately.
|
|
23
23
|
*/
|
|
24
24
|
export declare function validateRuntimeExports(dir: string): Promise<void>;
|
|
25
25
|
export declare function outro(options: {
|
package/dist/index.js
CHANGED
|
@@ -249,7 +249,8 @@ Errors:`);for(let S of s.errors){let M=` - ${S.file}`;if(S.location)M+=`:${S.lo
|
|
|
249
249
|
`+(e.exclude?.length?` exclude: ${e.exclude.map((o)=>JSON.stringify(o)).join(", ")}
|
|
250
250
|
`:"")+"Entrypoints are resolved relative to --root. Pass several by repeating --entrypoints or separating them with commas.";if(t.length===0){if(e.entrypoints.filter((o)=>Rr(o)&&ac(o)&&!Pr(o,r)).length===e.entrypoints.length)return;throw Error(`No source files matched. Nothing was generated.
|
|
251
251
|
${n}`)}let i=e.entrypoints.filter((o)=>{if(Pm.test(o))return!1;return!ac(Rr(o)?o:et(r,o))});if(i.length>0)throw Error(`Entrypoint${i.length>1?"s":""} not found: ${i.map((o)=>JSON.stringify(o)).join(", ")}
|
|
252
|
-
${n}`)}async function km(e){let t=[],r=et(e.cwd,e.root),n=e.exclude||[],i=[...e.entrypoints,...e.include??[]];for(let o of i)if(Rr(o)&&xo(o)){if(!o.includes("node_modules")){if(!Pr(o,r)&&e.outputStructure!=="flat")q.warn(`Skipping entrypoint outside root: ${je(e.cwd,o)}`);else if(!Ao(o,n,r))t.push(o)}}else{let s=new fc(o);for await(let a of s.scan({cwd:r,absolute:!0,onlyFiles:!0}))if(xo(a)&&!a.includes("node_modules")){if(!Ao(a,n,r))t.push(a)}}return[...new Set(t.map((o)=>et(o)))].sort()}function Pr(e,t){let r=je(t,e);return r!==".."&&!r.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!Rr(r)}function Mm(e,t){let r=new Map;for(let n of e){let i=Or(n,t),o=r.get(i);if(o&&o!==n)throw Error(`Output path collision: ${je(t.cwd,o)} and ${je(t.cwd,n)} both emit ${je(t.cwd,i)}`);r.set(i,n)}}function xo(e){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(e)&&!/\.d\.(?:ts|mts|cts)$/.test(e)}function Or(e,t){let r=et(t.cwd,t.root),n=je(r,e).replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(i)=>{if(i===".mts"||i===".mjs")return".d.mts";if(i===".cts"||i===".cjs")return".d.cts";return".d.ts"});if(t.outputStructure==="mirror")return et(t.cwd,t.outdir,n);else{let i=To(n);return et(t.cwd,t.outdir,i)}}function Dm(e,t,r=""){let n=je(Tr(e),t).replace(/\\/g,"/");if(n=n.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),r)n+=r;if(!n.startsWith("."))n=`./${n}`;return n}function Im(e,t,r){let n=Or(t,r),i=(o)=>{let s=zt(o,t);if(!s.isRelative||!s.resolved)return o;if(/\.d\.(?:ts|mts|cts)$/.test(s.resolved))return o;let a=o.match(/[?#].*$/)?.[0]??"",c=a?o.slice(0,-a.length):o,f=Sm(c),u=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(f)?f:"";return Dm(n,Or(s.resolved,r),u)+a};return e.replace(/\b(from\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(o,s,a,c)=>`${s}${a}${i(c)}${a}`).replace(/\b(import\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(o,s,a,c)=>`${s}${a}${i(c)}${a}`).replace(/\b(import\s*\(\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(o,s,a,c)=>`${s}${a}${i(c)}${a}`)}async function Fm(e,t,r,n,i){let o=t;if(n)o=await n.runOnBeforeFile(e,t);let s=El(o,e,r.keepComments,r.isolatedDeclarations??!1);if(n)s=await n.runOnDeclarations(e,o,s);let a=0,c=0;for(let u=0;u<s.length;u++){let l=s[u];if(l.kind==="import")a++;if(l.kind==="export"||l.isExported)c++}let f=oc(s,{filePath:e,sourceCode:o,declarations:s},r.keepComments,r.importOrder);if(f=Im(f,e,r),i)f=kl(f,i,{filePath:e});if(r.normalizeOutput===!0||r.declarationOrder)f=Tl(f,{lineEnding:"lf",declarationOrder:r.declarationOrder,indent:{style:r.indentStyle??"spaces",size:r.indentSize??2}});if(n)f=await n.runOnAfterFile(e,o,f);return{content:f,declarationCount:s.length,importCount:a,exportCount:c}}var fc,Am=50,xr,Pm;var uc=ge(()=>{Lr();tn();Xo();ns();ss();Fa();fs();Wa();vl();Sl();$l();Rl();Ml();Zl();sc();({Glob:fc}=globalThis.Bun);xr=new Map;Pm=/[*?[\]{}!]/});var hc=ge(()=>{uc()});import{createHash as Lm}from"crypto";import{existsSync as Wm,readFileSync as Bm,writeFileSync as Gm}from"fs";import{dirname as jm,join as _m,relative as dc,resolve as kr,sep as Vi}from"path";import pc from"process";class gc{listeners=new Map;on(e,t){let r=this.listeners.get(e)||[];r.push(t),this.listeners.set(e,r)}async emit(e,t){let r={type:e,timestamp:Date.now(),data:t},n=this.listeners.get(e)||[];for(let i of n)await i(r)}}class yc{manifest;cacheDir;manifestPath;constructor(e,t){this.cacheDir=e,this.manifestPath=_m(e,"manifest.json"),this.manifest=this.loadManifest(t)}loadManifest(e){try{if(Wm(this.manifestPath)){let t=JSON.parse(Bm(this.manifestPath,"utf-8"));if(t.configHash===e&&t.version==="1.0")return t}}catch{}return{version:"1.0",configHash:e,entries:{}}}save(){try{let{mkdirSync:e}=Nm("fs");e(this.cacheDir,{recursive:!0}),Gm(this.manifestPath,JSON.stringify(this.manifest,null,2))}catch{}}getEntry(e){return this.manifest.entries[e]}setEntry(e,t){this.manifest.entries[e]=t}isValid(e,t){return this.getEntry(e)?.hash===t}clear(){this.manifest.entries={},this.save()}}function Vm(e){let t={root:e.root,outdir:e.outdir,entrypoints:e.entrypoints,clean:e.clean,tsconfigPath:e.tsconfigPath};return Lm("md5").update(JSON.stringify(t)).digest("hex")}function Cc(e={}){let{onSuccess:t,onError:r,failOnError:n=!0,incremental:i=!1,cacheDir:o=".dtsx-cache",on:s,timeout:a=60000,continueOnError:c=!1,verbose:f=!1,...u}=e,l=new gc;if(s){for(let[p,C]of Object.entries(s))if(C)l.on(p,C)}return{name:"bun-plugin-dtsx",async setup(p){let C=Date.now(),E=null,y=0;try{let x=zm(u,p),S=Vm(x);if(x.clean){let H=kr(x.cwd??pc.cwd(),x.outdir??"./dist");if(mc.has(H))x.clean=!1;else mc.add(H)}if(i)E=new yc(kr(o),S);if(await l.emit("start",{type:"start",files:x.entrypoints||[],config:x}),f){if(console.log("[bun-plugin-dtsx] Starting declaration generation..."),i)console.log("[bun-plugin-dtsx] Incremental mode enabled")}let D=await(async()=>new Promise((H,K)=>{let me=setTimeout(()=>{K(new Mr(`Generation timed out after ${a}ms`,"TIMEOUT_ERROR",{timeout:a}))},a);Ro(x).then((I)=>{clearTimeout(me),H(I)}).catch((I)=>{clearTimeout(me),K(I)})}))(),O=Date.now()-C;if(E)E.save();if(await l.emit("complete",{type:"complete",stats:D,duration:O,fromCache:y}),f){if(console.log(`[bun-plugin-dtsx] Generation complete in ${O}ms`),y>0)console.log(`[bun-plugin-dtsx] ${y} files served from cache`)}if(t)await t(D)}catch(x){let S=Um(x);if(await l.emit("error",{type:"error",error:S}),r)await r(S);else{if(console.error("[bun-plugin-dtsx] Error generating declarations:"),console.error(` Code: ${S.code}`),console.error(` Message: ${S.message}`),S.context)console.error(` Context: ${JSON.stringify(S.context)}`);if(f&&S.stack)console.error(` Stack: ${S.stack}`)}if(n&&!c)throw S}}}}function Um(e){if(e instanceof Mr)return e;if(e instanceof Error){let t="GENERATION_ERROR";if(e.message.includes("config")||e.message.includes("Config"))t="CONFIG_ERROR";else if(e.message.includes("file")||e.message.includes("File")||e.message.includes("ENOENT"))t="FILE_ERROR";return new Mr(e.message,t,{originalError:e.name},e)}return new Mr(String(e),"GENERATION_ERROR")}function Km(e){let t=e.map((n)=>jm(n).split(Vi)),r=t[0];for(let n of t.slice(1)){let i=0;while(i<r.length&&i<n.length&&r[i]===n[i])i++;r=r.slice(0,i)}return r.join(Vi)||Vi}function zm(e,t){let r=e.cwd||pc.cwd(),n=t?.config?.entrypoints,i=e.outdir||e.build?.config.outdir||t?.config.outdir||"./dist",o=e.root||e.build?.config.root||t?.config.root;if(!o&&n?.length){let a=Km(n.map((c)=>kr(r,c)));o=dc(r,a)||"."}o=o||"./src";let s=e.entrypoints;if(!s)if(n?.length){let a=kr(r,o),c=[];for(let f of n){let u=kr(r,f);if(u===a||u.startsWith(a+Vi))c.push(dc(a,u));else console.warn(`[bun-plugin-dtsx] Skipping entrypoint outside root "${o}": ${f}`)}s=c.length?c:["index.ts"]}else s=["index.ts"];return{...e,cwd:r,root:o,entrypoints:s,outdir:i,clean:e.clean??!0,tsconfigPath:e.tsconfigPath}}var Nm,Mr,mc;var wc=ge(()=>{hc();Nm=import.meta.require;Mr=class Mr extends Error{code;context;cause;constructor(e,t,r,n){super(e);if(this.name="DtsxPluginError",this.code=t,this.context=r,this.cause=n,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}};mc=new Set});import{mkdir as Hm,stat as Jm}from"fs/promises";import{bold as Po,dim as Oo,green as qm,italic as Ec,log as Ym}from"@stacksjs/cli";import{path as ot}from"@stacksjs/path";import{glob as vc}from"@stacksjs/storage";async function Zm(e){let t=await vc([ot.resolve(e,"dist","**/*.d.ts")],{absolute:!0}),r=new Bun.Transpiler({loader:"ts",target:"bun"});for(let n of t){let i=await Bun.file(n).text();try{r.transformSync(i)}catch(o){throw Error(`Invalid declaration generated at ${n}: ${o instanceof Error?o.message:String(o)}`)}}}async function Xm(e){let t=ot.resolve(e,"dist","index.js");if(!await Bun.file(t).exists())return;let r=Bun.spawnSync({cmd:[process.execPath,"-e",`await import(${JSON.stringify(t)})`],stdout:"ignore",stderr:"pipe",env:{...process.env,NODE_ENV:"test"}});if(r.exitCode===0)return;let n=new TextDecoder().decode(r.stderr??new Uint8Array)
|
|
253
|
-
`)
|
|
254
|
-
|
|
252
|
+
${n}`)}async function km(e){let t=[],r=et(e.cwd,e.root),n=e.exclude||[],i=[...e.entrypoints,...e.include??[]];for(let o of i)if(Rr(o)&&xo(o)){if(!o.includes("node_modules")){if(!Pr(o,r)&&e.outputStructure!=="flat")q.warn(`Skipping entrypoint outside root: ${je(e.cwd,o)}`);else if(!Ao(o,n,r))t.push(o)}}else{let s=new fc(o);for await(let a of s.scan({cwd:r,absolute:!0,onlyFiles:!0}))if(xo(a)&&!a.includes("node_modules")){if(!Ao(a,n,r))t.push(a)}}return[...new Set(t.map((o)=>et(o)))].sort()}function Pr(e,t){let r=je(t,e);return r!==".."&&!r.startsWith(`..${process.platform==="win32"?"\\":"/"}`)&&!Rr(r)}function Mm(e,t){let r=new Map;for(let n of e){let i=Or(n,t),o=r.get(i);if(o&&o!==n)throw Error(`Output path collision: ${je(t.cwd,o)} and ${je(t.cwd,n)} both emit ${je(t.cwd,i)}`);r.set(i,n)}}function xo(e){return/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/.test(e)&&!/\.d\.(?:ts|mts|cts)$/.test(e)}function Or(e,t){let r=et(t.cwd,t.root),n=je(r,e).replace(/\.(m?tsx?|cts|jsx?|mjs|cjs|vue|stx)$/,(i)=>{if(i===".mts"||i===".mjs")return".d.mts";if(i===".cts"||i===".cjs")return".d.cts";return".d.ts"});if(t.outputStructure==="mirror")return et(t.cwd,t.outdir,n);else{let i=To(n);return et(t.cwd,t.outdir,i)}}function Dm(e,t,r=""){let n=je(Tr(e),t).replace(/\\/g,"/");if(n=n.replace(/\.d\.mts$/,"").replace(/\.d\.cts$/,"").replace(/\.d\.ts$/,""),r)n+=r;if(!n.startsWith("."))n=`./${n}`;return n}function Im(e,t,r){let n=Or(t,r),i=(o)=>{let s=zt(o,t);if(!s.isRelative||!s.resolved)return o;if(/\.d\.(?:ts|mts|cts)$/.test(s.resolved))return o;let a=o.match(/[?#].*$/)?.[0]??"",c=a?o.slice(0,-a.length):o,f=Sm(c),u=/^(?:\.js|\.jsx|\.mjs|\.cjs)$/.test(f)?f:"";return Dm(n,Or(s.resolved,r),u)+a};return e.replace(/\b(from\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(o,s,a,c)=>`${s}${a}${i(c)}${a}`).replace(/\b(import\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(o,s,a,c)=>`${s}${a}${i(c)}${a}`).replace(/\b(import\s*\(\s*)(['"])(\.{1,2}\/[^'"]+)\2/g,(o,s,a,c)=>`${s}${a}${i(c)}${a}`)}async function Fm(e,t,r,n,i){let o=t;if(n)o=await n.runOnBeforeFile(e,t);let s=El(o,e,r.keepComments,r.isolatedDeclarations??!1);if(n)s=await n.runOnDeclarations(e,o,s);let a=0,c=0;for(let u=0;u<s.length;u++){let l=s[u];if(l.kind==="import")a++;if(l.kind==="export"||l.isExported)c++}let f=oc(s,{filePath:e,sourceCode:o,declarations:s},r.keepComments,r.importOrder);if(f=Im(f,e,r),i)f=kl(f,i,{filePath:e});if(r.normalizeOutput===!0||r.declarationOrder)f=Tl(f,{lineEnding:"lf",declarationOrder:r.declarationOrder,indent:{style:r.indentStyle??"spaces",size:r.indentSize??2}});if(n)f=await n.runOnAfterFile(e,o,f);return{content:f,declarationCount:s.length,importCount:a,exportCount:c}}var fc,Am=50,xr,Pm;var uc=ge(()=>{Lr();tn();Xo();ns();ss();Fa();fs();Wa();vl();Sl();$l();Rl();Ml();Zl();sc();({Glob:fc}=globalThis.Bun);xr=new Map;Pm=/[*?[\]{}!]/});var hc=ge(()=>{uc()});import{createHash as Lm}from"crypto";import{existsSync as Wm,readFileSync as Bm,writeFileSync as Gm}from"fs";import{dirname as jm,join as _m,relative as dc,resolve as kr,sep as Vi}from"path";import pc from"process";class gc{listeners=new Map;on(e,t){let r=this.listeners.get(e)||[];r.push(t),this.listeners.set(e,r)}async emit(e,t){let r={type:e,timestamp:Date.now(),data:t},n=this.listeners.get(e)||[];for(let i of n)await i(r)}}class yc{manifest;cacheDir;manifestPath;constructor(e,t){this.cacheDir=e,this.manifestPath=_m(e,"manifest.json"),this.manifest=this.loadManifest(t)}loadManifest(e){try{if(Wm(this.manifestPath)){let t=JSON.parse(Bm(this.manifestPath,"utf-8"));if(t.configHash===e&&t.version==="1.0")return t}}catch{}return{version:"1.0",configHash:e,entries:{}}}save(){try{let{mkdirSync:e}=Nm("fs");e(this.cacheDir,{recursive:!0}),Gm(this.manifestPath,JSON.stringify(this.manifest,null,2))}catch{}}getEntry(e){return this.manifest.entries[e]}setEntry(e,t){this.manifest.entries[e]=t}isValid(e,t){return this.getEntry(e)?.hash===t}clear(){this.manifest.entries={},this.save()}}function Vm(e){let t={root:e.root,outdir:e.outdir,entrypoints:e.entrypoints,clean:e.clean,tsconfigPath:e.tsconfigPath};return Lm("md5").update(JSON.stringify(t)).digest("hex")}function Cc(e={}){let{onSuccess:t,onError:r,failOnError:n=!0,incremental:i=!1,cacheDir:o=".dtsx-cache",on:s,timeout:a=60000,continueOnError:c=!1,verbose:f=!1,...u}=e,l=new gc;if(s){for(let[p,C]of Object.entries(s))if(C)l.on(p,C)}return{name:"bun-plugin-dtsx",async setup(p){let C=Date.now(),E=null,y=0;try{let x=zm(u,p),S=Vm(x);if(x.clean){let H=kr(x.cwd??pc.cwd(),x.outdir??"./dist");if(mc.has(H))x.clean=!1;else mc.add(H)}if(i)E=new yc(kr(o),S);if(await l.emit("start",{type:"start",files:x.entrypoints||[],config:x}),f){if(console.log("[bun-plugin-dtsx] Starting declaration generation..."),i)console.log("[bun-plugin-dtsx] Incremental mode enabled")}let D=await(async()=>new Promise((H,K)=>{let me=setTimeout(()=>{K(new Mr(`Generation timed out after ${a}ms`,"TIMEOUT_ERROR",{timeout:a}))},a);Ro(x).then((I)=>{clearTimeout(me),H(I)}).catch((I)=>{clearTimeout(me),K(I)})}))(),O=Date.now()-C;if(E)E.save();if(await l.emit("complete",{type:"complete",stats:D,duration:O,fromCache:y}),f){if(console.log(`[bun-plugin-dtsx] Generation complete in ${O}ms`),y>0)console.log(`[bun-plugin-dtsx] ${y} files served from cache`)}if(t)await t(D)}catch(x){let S=Um(x);if(await l.emit("error",{type:"error",error:S}),r)await r(S);else{if(console.error("[bun-plugin-dtsx] Error generating declarations:"),console.error(` Code: ${S.code}`),console.error(` Message: ${S.message}`),S.context)console.error(` Context: ${JSON.stringify(S.context)}`);if(f&&S.stack)console.error(` Stack: ${S.stack}`)}if(n&&!c)throw S}}}}function Um(e){if(e instanceof Mr)return e;if(e instanceof Error){let t="GENERATION_ERROR";if(e.message.includes("config")||e.message.includes("Config"))t="CONFIG_ERROR";else if(e.message.includes("file")||e.message.includes("File")||e.message.includes("ENOENT"))t="FILE_ERROR";return new Mr(e.message,t,{originalError:e.name},e)}return new Mr(String(e),"GENERATION_ERROR")}function Km(e){let t=e.map((n)=>jm(n).split(Vi)),r=t[0];for(let n of t.slice(1)){let i=0;while(i<r.length&&i<n.length&&r[i]===n[i])i++;r=r.slice(0,i)}return r.join(Vi)||Vi}function zm(e,t){let r=e.cwd||pc.cwd(),n=t?.config?.entrypoints,i=e.outdir||e.build?.config.outdir||t?.config.outdir||"./dist",o=e.root||e.build?.config.root||t?.config.root;if(!o&&n?.length){let a=Km(n.map((c)=>kr(r,c)));o=dc(r,a)||"."}o=o||"./src";let s=e.entrypoints;if(!s)if(n?.length){let a=kr(r,o),c=[];for(let f of n){let u=kr(r,f);if(u===a||u.startsWith(a+Vi))c.push(dc(a,u));else console.warn(`[bun-plugin-dtsx] Skipping entrypoint outside root "${o}": ${f}`)}s=c.length?c:["index.ts"]}else s=["index.ts"];return{...e,cwd:r,root:o,entrypoints:s,outdir:i,clean:e.clean??!0,tsconfigPath:e.tsconfigPath}}var Nm,Mr,mc;var wc=ge(()=>{hc();Nm=import.meta.require;Mr=class Mr extends Error{code;context;cause;constructor(e,t,r,n){super(e);if(this.name="DtsxPluginError",this.code=t,this.context=r,this.cause=n,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}};mc=new Set});import{mkdir as Hm,stat as Jm}from"fs/promises";import{bold as Po,dim as Oo,green as qm,italic as Ec,log as Ym}from"@stacksjs/cli";import{path as ot}from"@stacksjs/path";import{glob as vc}from"@stacksjs/storage";async function Zm(e){let t=await vc([ot.resolve(e,"dist","**/*.d.ts")],{absolute:!0}),r=new Bun.Transpiler({loader:"ts",target:"bun"});for(let n of t){let i=await Bun.file(n).text();try{r.transformSync(i)}catch(o){throw Error(`Invalid declaration generated at ${n}: ${o instanceof Error?o.message:String(o)}`)}}}async function Xm(e){let t=ot.resolve(e,"dist","index.js");if(!await Bun.file(t).exists())return;let r=Bun.spawnSync({cmd:[process.execPath,"-e",`try { await import(${JSON.stringify(t)}) } catch (error) { console.error(error); process.exit(1) }`],stdout:"ignore",stderr:"pipe",env:{...process.env,NODE_ENV:"test"}});if(r.exitCode===0)return;let n=new TextDecoder().decode(r.stderr??new Uint8Array),i=/SyntaxError|needs to refer to a top-level declared variable|does not provide an export named|Export named .* not found/i;if(i.test(n)){let o=n.split(`
|
|
253
|
+
`).find((s)=>i.test(s))??n.trim().split(`
|
|
254
|
+
`)[0];throw Error(`Built package at ${t} cannot be imported: ${o}
|
|
255
|
+
Fix the generated module at its source before publishing.`)}}async function U0(e){let r=Date.now()-e.startTime,n=e.pkgName??`@stacksjs/${ot.basename(e.dir)}`;if(e.result.errors&&e.result.errors.length>0)throw console.error("Build errors:",e.result.errors),Error(`Build failed with errors: ${JSON.stringify(e.result.errors)}`);else if(e.result.success!==void 0&&!e.result.success){let o=e.result.logs?.[0]||"Unknown build error";throw console.log(o),Error(`Build failed: ${o}`)}await Bun.write(ot.resolve(e.dir,"dist","tsconfig.json"),`${JSON.stringify({compilerOptions:{paths:{}}},null,2)}
|
|
255
256
|
`),await Zm(e.dir),await Xm(e.dir);let i=await vc([ot.resolve(e.dir,"dist","**/*")],{absolute:!0});for(let o of i){let s=await Jm(o),a;if(s.size<1048576)a=`${(s.size/1024).toFixed(2)}kb`;else a=`${(s.size/1024/1024).toFixed(2)}mb`;let c=ot.relative(e.dir,o).replace("dist/","");console.log(`${Po(Oo(`[${a}]`))} ${Oo("dist/")}${c}`)}console.log(`${Po(Oo(`[${r}ms]`))} Built ${Ec(Po(qm(n)))}`)}async function K0(e){let t=e.pkgName??`@stacksjs/${ot.basename(e.dir)}`;if(e.styled===!1)console.log(`Building ${t}...`);else Ym.info(`Building ${Ec(t)}...`);return{startTime:Date.now()}}async function z0(e){await Promise.resolve().then(() => wc());let r=ot.resolve(e.dir,"src"),n=ot.resolve(e.dir,"dist"),i=(await Array.fromAsync(new Bun.Glob("**/*.ts").scan({cwd:r}))).filter((s)=>!s.endsWith(".d.ts")).filter((s)=>!s.endsWith(".test.ts")&&!s.endsWith(".spec.ts"));await Bun.build({entrypoints:i.map((s)=>ot.resolve(r,s)),outdir:n,root:r,target:"bun",format:"esm",splitting:!1,external:e.external??Qm(),plugins:[Cc({root:r,outdir:n})]});let o=new Bun.Transpiler({loader:"ts",target:"bun",minifyWhitespace:!0,define:{"process.env.NODE_ENV":"process.env.NODE_ENV"}});for(let s of i){let a=o.transformSync(await Bun.file(ot.resolve(r,s)).text());a=a.replace(/(['"])(\.\.?\/[^'"]+?)\.tsx?\1/g,"$1$2.js$1");let c=ot.resolve(n,s.replace(/\.ts$/,".js"));await Hm(ot.dirname(c),{recursive:!0}),await Bun.write(c,a)}}function Qm(e=[]){let t=[];try{let r=Mc("fs"),n=JSON.parse(r.readFileSync(`${process.cwd()}/package.json`,"utf8"));t=[...Object.keys(n.dependencies??{}),...Object.keys(n.peerDependencies??{}),...Object.keys(n.optionalDependencies??{})]}catch{}return["@stacksjs/*",...t,...t.map((r)=>`${r}/*`),"bun-queue","ioredis","localtunnels","localtunnels/*","@craft-native/ts","ts-md","meilisearch","algoliasearch","@opensearch-project/opensearch","*.yaml","*.yml",...e]}export{Qm as frameworkExternal,K0 as intro,U0 as outro,z0 as transpilePackage,Zm as validateDeclarations,Xm as validateRuntimeExports};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/build",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.334",
|
|
6
6
|
"description": "The Stacks framework build tools and configurations.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"prepublishOnly": "bun run build"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@stacksjs/cli": "0.75.
|
|
62
|
-
"@stacksjs/path": "0.75.
|
|
63
|
-
"@stacksjs/storage": "0.75.
|
|
61
|
+
"@stacksjs/cli": "0.75.334",
|
|
62
|
+
"@stacksjs/path": "0.75.334",
|
|
63
|
+
"@stacksjs/storage": "0.75.334",
|
|
64
64
|
"bun-plugin-dtsx": "^0.11.21"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|