UNPKG

@basmilius/tools

Version:

Commonly used tools for building.

5 lines (3 loc) 1.42 kB
import{build as f}from"bun";async function n(t){try{t.root??="src",t.outdir??="dist",t.minify??=!0,t.sourcemap??="linked",t.splitting??=!1,t.format??="esm",t.target??="node",await f(t),console.log("✔ Build complete!")}catch(o){console.error("✘ Build failed!"),console.error(o),process.exit(1)}}import{exists as c,rm as d}from"node:fs/promises";import{resolve as h}from"node:path";function i(t){return{name:"clean",async setup(){let o=h(t);if(!await c(o))return;await d(t,{recursive:!0})}}}import{pathToFileURL as a}from"bun";import{copyFile as y}from"node:fs/promises";function p(t,o){return{name:"copy",setup(e){e.onEnd(async()=>{await y(a(t),a(o))})}}}import{file as w,pathToFileURL as u,write as x}from"bun";import{isolatedDeclaration as B}from"oxc-transform";function s(){let t=new Set;return{name:"oxc-transform-dts",setup(o){if(!o.config.root||!o.config.outdir){console.warn("✘ No types generated, osx-transform-dts requires both a root and outdir.");return}let e=u(o.config.root).pathname,m=u(o.config.outdir).pathname;o.onStart(()=>{t.clear()}),o.onLoad({filter:/\.ts$/},async(r)=>{if(r.path.startsWith(e)&&!t.has(r.path)){t.add(r.path);let{code:l}=await B(r.path,await w(r.path).text());await x(r.path.replace(new RegExp(`^${e}`),m).replace(/\.ts$/,".d.ts"),l)}return})}}}export{s as dts,p as copy,i as clean,n as build}; //# debugId=DE7B20A4BA861EE664756E2164756E21 //# sourceMappingURL=index.js.map