diff --git a/Source/Fn/Build.ts b/Source/Fn/Build.ts index e5071ba6..d0fdff31 100644 --- a/Source/Fn/Build.ts +++ b/Source/Fn/Build.ts @@ -4,10 +4,10 @@ import type { Pattern } from "fast-glob"; import File from "../Fn/File.js"; import Default from "../Object/Option.js"; -import Glob from "fast-glob"; import { exec as Exec } from "child_process"; import { deepmerge as Merge } from "deepmerge-ts"; -import { build as Build } from "esbuild"; +import { build as Build, analyzeMetafile } from "esbuild"; +import Glob from "fast-glob"; /** * The `Build` function compiles and builds TypeScript files using esbuild and TypeScript compiler. @@ -40,12 +40,20 @@ export default async ( ), } satisfies Option) as Option; - await Build( + const Result = await Build( Option?.ESBuild ? Merge(_Configuration, await File(Option?.ESBuild)) : _Configuration ); + console.log( + Result.metafile + ? await analyzeMetafile(Result.metafile, { + verbose: true, + }) + : {} + ); + if (Option?.TypeScript) { Exec(`tsc -p ${Option?.TypeScript}`); } else { diff --git a/Source/Object/Option.ts b/Source/Object/Option.ts index 68892a1e..d52ef4f9 100644 --- a/Source/Object/Option.ts +++ b/Source/Object/Option.ts @@ -8,13 +8,15 @@ import _JSON from "../Fn/JSON.js"; const Out = "Target"; export default { + color: true, format: "esm", + metafile: true, minify: true, outdir: Out, platform: "node", target: "esnext", write: true, - metafile: true, + logLevel: "debug", plugins: [ { name: "Target", diff --git a/Target/Fn/Build.js b/Target/Fn/Build.js index 852ca897..e3e0b5eb 100644 --- a/Target/Fn/Build.js +++ b/Target/Fn/Build.js @@ -1 +1 @@ -import l from"../Fn/File.js";import f from"../Object/Option.js";import m from"fast-glob";import{exec as o}from"child_process";import{deepmerge as s}from"deepmerge-ts";import{build as c}from"esbuild";var b=async(p,t)=>{const r=[];for(const e of p)for(const a of await m(e.replaceAll("'","").replaceAll('"',"")))r.push(a);r.reverse();const i=s(f,{entryPoints:Object.fromEntries(r.map(e=>[e.replace("Source/","").split(".").slice(0,-1).join("."),e]))});await c(t?.ESBuild?s(i,await l(t?.ESBuild)):i),t?.TypeScript?o(`tsc -p ${t?.TypeScript}`):o("tsc")};export{b as default}; +import f from"../Fn/File.js";import m from"../Object/Option.js";import{exec as s}from"child_process";import{deepmerge as a}from"deepmerge-ts";import{build as c,analyzeMetafile as n}from"esbuild";import u from"fast-glob";var E=async(l,e)=>{const i=[];for(const t of l)for(const p of await u(t.replaceAll("'","").replaceAll('"',"")))i.push(p);const r=a(m,{entryPoints:Object.fromEntries(i.map(t=>[t.replace("Source/","").split(".").slice(0,-1).join("."),t]))}),o=await c(e?.ESBuild?a(r,await f(e?.ESBuild)):r);console.log(o.metafile?await n(o.metafile,{verbose:!0}):{}),e?.TypeScript?s(`tsc -p ${e?.TypeScript}`):s("tsc")};export{E as default}; diff --git a/Target/Object/Option.js b/Target/Object/Option.js index 887d2a2a..0ac5e4e7 100644 --- a/Target/Object/Option.js +++ b/Target/Object/Option.js @@ -1 +1 @@ -import{copy as r}from"esbuild-plugin-copy";import{rm as e}from"fs/promises";import i from"../Fn/JSON.js";const t="Target";var m={format:"esm",minify:!0,outdir:t,platform:"node",target:"esnext",write:!0,plugins:[{name:"Target",setup(o){o.onStart(async()=>{try{await e(t,{recursive:!0})}catch{}})}},r({resolveFrom:"out",assets:[{from:"./Source/Notation/TypeScript.json",to:"./Notation/"}]})],define:{"process.env.VERSION_PACKAGE":`'${(await i("package.json"))?.version}'`}};export{m as default}; +import{copy as o}from"esbuild-plugin-copy";import{rm as r}from"fs/promises";import i from"../Fn/JSON.js";const t="Target";var p={color:!0,format:"esm",metafile:!0,minify:!0,outdir:t,platform:"node",target:"esnext",write:!0,logLevel:"debug",plugins:[{name:"Target",setup(e){e.onStart(async()=>{try{await r(t,{recursive:!0})}catch{}})}},o({resolveFrom:"out",assets:[{from:"./Source/Notation/TypeScript.json",to:"./Notation/"}]})],define:{"process.env.VERSION_PACKAGE":`'${(await i("package.json"))?.version}'`}};export{p as default};