-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ts
45 lines (39 loc) · 926 Bytes
/
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
import fs from "fs";
import config from "./package.json";
const path = import.meta.dir + "/lib";
const modules = ["clone", "merge", "omit", "pick", "type-guards"];
const build = await Bun.build({
entrypoints: [
"./src/index.ts",
...modules.map((module) => `./src/${module}/index.ts`),
],
outdir: "./lib",
root: "./src",
splitting: true,
sourcemap: "none",
minify: true,
});
if (!build.success) {
throw new Error(`Build failed: ${build.logs}`);
}
const buildPackage = {
author: config.author,
description: config.description,
keywords: config.keywords,
license: config.license,
main: "./index.js",
name: config.name,
release: config.release,
repository: config.repository,
type: "module",
types: "./index.d.ts",
version: config.version,
};
fs.writeFileSync(
path + "/package.json",
JSON.stringify(buildPackage, null, 2),
{
encoding: "utf-8",
flag: "w+",
}
);