From 8983781202a417adba3233ff2d82120bac783a5b Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Mon, 9 Sep 2024 10:59:38 +0300 Subject: [PATCH] --- CHANGELOG.md | 2 ++ Source/Function/Build.ts | 40 +++++++++++++++++++----------------- Source/Variable/ESBuild.ts | 8 +++++--- Target/Function/Build.d.ts | 1 + Target/Function/Build.js | 2 +- Target/Variable/ESBuild.d.ts | 2 +- package.json | 6 +++--- 7 files changed, 34 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00f25ba9..ae08e44d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.1.5 + ## 0.1.4 ### Changed diff --git a/Source/Function/Build.ts b/Source/Function/Build.ts index 81295941..05825aad 100644 --- a/Source/Function/Build.ts +++ b/Source/Function/Build.ts @@ -19,35 +19,34 @@ export default (async (...[File, Option]: Parameters) => { Pipe.reverse(); - console.log(Pipe); - let Configuration: BuildOptions = Merge( (await import("../Variable/ESBuild.js")).default, { entryPoints: Object.fromEntries( Pipe.map((File) => [ - File.replace("Source/", "") - .replace("src/", "") - .split(".") - .slice(0, -1.0) - .join("."), + `${dirname(File)}/${basename(File, extname(File))}`.replace( + normalize(File).split(sep).at(0) ?? "", + "", + ), File, ]), ), }, ); - - Configuration = Merge(Option?.ESBuild - ? Merge( - Configuration, - await ( - await import("@Function/File.js") - ).default(Option.ESBuild), - ) - : Configuration, { - tsconfig: Option?.TypeScript ?? "tsconfig.json", - }); + Configuration = Merge( + Option?.ESBuild + ? Merge( + Configuration, + await ( + await import("@Function/File.js") + ).default(Option.ESBuild), + ) + : Configuration, + { + tsconfig: Option?.TypeScript ?? "tsconfig.json", + }, + ); Configuration.plugins?.push({ name: "TypeScript", @@ -82,6 +81,9 @@ export const { default: Merge } = await import("../Function/Merge.js"); export const Pipe: string[] = []; +export const { extname, basename, relative, dirname, normalize, sep } = + await import("path"); + export const Current = (await import("url")).fileURLToPath( - (await import("path")).dirname(import.meta.url), + dirname(import.meta.url), ); diff --git a/Source/Variable/ESBuild.ts b/Source/Variable/ESBuild.ts index ed62997a..bef07f18 100644 --- a/Source/Variable/ESBuild.ts +++ b/Source/Variable/ESBuild.ts @@ -1,3 +1,5 @@ +import type { BuildOptions } from "esbuild"; + /** * @module ESBuild * @@ -20,7 +22,9 @@ export default { onStart(async () => { try { outdir - ? await (await import("fs/promises")).rm(outdir, { + ? await ( + await import("fs/promises") + ).rm(outdir, { recursive: true, }) : {}; @@ -41,5 +45,3 @@ export default { }'`, }, } satisfies BuildOptions as BuildOptions; - -import type { BuildOptions } from "esbuild"; diff --git a/Target/Function/Build.d.ts b/Target/Function/Build.d.ts index 6708a1ee..f919c313 100644 --- a/Target/Function/Build.d.ts +++ b/Target/Function/Build.d.ts @@ -18,4 +18,5 @@ export declare const Merge: (...objects: Ts) => i parents: ReadonlyArray>>; }>>; export declare const Pipe: string[]; +export declare const extname: (path: string) => string, basename: (path: string, suffix?: string) => string, relative: (from: string, to: string) => string, dirname: (path: string) => string, normalize: (path: string) => string, sep: "\\" | "/"; export declare const Current: string; diff --git a/Target/Function/Build.js b/Target/Function/Build.js index 00684bef..90627e94 100644 --- a/Target/Function/Build.js +++ b/Target/Function/Build.js @@ -1 +1 @@ -var c=async(...[s,a])=>{for(const e of s)for(const l of await(await import("fast-glob")).default(e.replaceAll("'","").replaceAll('"',""),{ignore:a?.Exclude??[]}))i.push(l);i.reverse(),console.log(i);let t=r((await import("../Variable/ESBuild.js")).default,{entryPoints:Object.fromEntries(i.map(e=>[e.replace("Source/","").replace("src/","").split(".").slice(0,-1).join("."),e]))});t=r(a?.ESBuild?r(t,await(await import("./File.js")).default(a.ESBuild)):t,{tsconfig:a?.TypeScript??"tsconfig.json"}),t.plugins?.push({name:"TypeScript",setup({onEnd:e}){e(async()=>{await o(`tsc -p ${t.tsconfig}`),await o(`tsc-alias -f -p ${t.tsconfig}`)})}}),a?.Watch?await(await(await import("esbuild")).context(t)).watch():console.log(await(await import("esbuild")).analyzeMetafile((await(await import("esbuild")).build(t))?.metafile??"",{verbose:!0}))};const{default:o}=await import("../Function/Exec.js"),{default:r}=await import("../Function/Merge.js"),i=[],p=(await import("url")).fileURLToPath((await import("path")).dirname(import.meta.url));export{p as Current,o as Exec,r as Merge,i as Pipe,c as default}; +var u=async(...[p,e])=>{for(const t of p)for(const n of await(await import("fast-glob")).default(t.replaceAll("'","").replaceAll('"',""),{ignore:e?.Exclude??[]}))r.push(n);r.reverse();let a=i((await import("../Variable/ESBuild.js")).default,{entryPoints:Object.fromEntries(r.map(t=>[`${s(t)}/${c(t,l(t))}`.replace(f(t).split(m).at(0)??"",""),t]))});a=i(e?.ESBuild?i(a,await(await import("./File.js")).default(e.ESBuild)):a,{tsconfig:e?.TypeScript??"tsconfig.json"}),a.plugins?.push({name:"TypeScript",setup({onEnd:t}){t(async()=>{await o(`tsc -p ${a.tsconfig}`),await o(`tsc-alias -f -p ${a.tsconfig}`)})}}),e?.Watch?await(await(await import("esbuild")).context(a)).watch():console.log(await(await import("esbuild")).analyzeMetafile((await(await import("esbuild")).build(a))?.metafile??"",{verbose:!0}))};const{default:o}=await import("../Function/Exec.js"),{default:i}=await import("../Function/Merge.js"),r=[],{extname:l,basename:c,relative:w,dirname:s,normalize:f,sep:m}=await import("path"),d=(await import("url")).fileURLToPath(s(import.meta.url));export{d as Current,o as Exec,i as Merge,r as Pipe,c as basename,u as default,s as dirname,l as extname,f as normalize,w as relative,m as sep}; diff --git a/Target/Variable/ESBuild.d.ts b/Target/Variable/ESBuild.d.ts index e47c3943..d9224aba 100644 --- a/Target/Variable/ESBuild.d.ts +++ b/Target/Variable/ESBuild.d.ts @@ -1,7 +1,7 @@ +import type { BuildOptions } from "esbuild"; /** * @module ESBuild * */ declare const _default: BuildOptions; export default _default; -import type { BuildOptions } from "esbuild"; diff --git a/package.json b/package.json index fae10797..ece5bbcd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@playform/build", - "version": "0.1.4", + "version": "0.1.5", "private": false, "description": "🌀 Build —", "keywords": [ @@ -30,8 +30,8 @@ "Build": "Target/Class/Build.js" }, "scripts": { - "Run": "node --no-warnings --loader ts-node/esm Source/Class/Build.ts 'Source/**/*.ts' --Watch", - "prepublishOnly": "node --no-warnings --loader ts-node/esm Source/Class/Build.ts 'Source/**/*.ts'" + "Run": "node --no-warnings --loader ts-node/esm Source/Class/Build.ts 'Source/**/*.{ts,css}' --Watch", + "prepublishOnly": "node --no-warnings --loader ts-node/esm Source/Class/Build.ts 'Source/**/*.{ts,css}'" }, "dependencies": { "@types/node": "22.5.4",