-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ts
49 lines (44 loc) · 1.3 KB
/
build.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import path from "node:path";
import { execSync } from "node:child_process";
import { rimraf } from "rimraf";
import { build } from "esbuild";
import { bundle } from "dts-bundle";
import { t } from "./src";
const finishedBuild = (dir: string) => console.log(`${t("✔︎").green._} build: ${t(dir).black._}`);
export const buildChainsi = async () => {
execSync("tsc -p tsconfig.build.json");
const res = await build({
entryPoints: [path.resolve(`src/index`)],
bundle: true,
minify: true,
target: "es2018",
outdir: `dist`,
format: "esm",
plugins: [
{
name: "TypeScriptDeclarationsPlugin",
setup(build) {
build.onEnd(() => {
bundle({
name: `chainsi`,
main: `temp/src/index.d.ts`,
out: path.resolve(`dist/index.d.ts`),
});
});
},
},
],
});
execSync("rm -rf temp");
finishedBuild(`dist`);
return res;
};
export const clearChainsiSync = () => [rimraf("dist")];
await (async function main() {
console.log("clear dist...");
await Promise.allSettled(clearChainsiSync());
console.log(`${t("✔︎").green._} finished clearing dist`);
console.log("building chainsi...");
const buildingChainsi = buildChainsi();
await Promise.all([buildingChainsi]);
})();