-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ts
42 lines (37 loc) · 993 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
/// <reference types='bun-types' />
// Script made by @aquapi - https://github.com/bit-js/library/blob/main/build.ts
// Modified by @benjamint08 for ProBun
import {existsSync, rmSync} from 'fs';
import pkg from './package.json';
import {$} from 'bun';
import {parseArgs} from "util";
// Generating types
const dir = './lib';
if (existsSync(dir)) rmSync(dir, { recursive: true });
const { values, positionals } = parseArgs({
args: Bun.argv,
options: {
version: {
type: 'string',
},
},
strict: true,
allowPositionals: true,
});
if(values.version) {
pkg.version = values.version;
Bun.write('package.json', JSON.stringify(pkg, null, 2));
console.log(`Updated version to ${values.version}`);
}
// Build source files
Bun.build({
format: 'esm',
target: 'bun',
outdir: './lib',
entrypoints: ['./src/main'],
minify: {
whitespace: true
},
external: Object.keys(pkg.dependencies)
});
await $`bun x tsc`;