-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.mts
More file actions
executable file
·41 lines (36 loc) · 1 KB
/
build.mts
File metadata and controls
executable file
·41 lines (36 loc) · 1 KB
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
#!/usr/bin/env npx kubik
import esbuild from 'esbuild';
import fs from 'fs';
import { Task } from 'kubik';
import path from 'path';
import pkg from './package.json' assert { type: 'json' };
const { __dirname, $ } = Task.init(import.meta, {
name: 'sdk',
watch: [ './src' ],
});
const outDir = path.join(__dirname, 'lib');
const typesDir = path.join(__dirname, 'types');
const srcDir = path.join(__dirname, 'src');
await fs.promises.rm(outDir, { recursive: true, force: true });
await fs.promises.rm(typesDir, { recursive: true, force: true });
const { errors } = await esbuild.build({
color: true,
entryPoints: [
path.join(srcDir, 'index.ts'),
path.join(srcDir, 'browser.ts'),
],
outdir: outDir,
format: 'esm',
platform: 'node',
target: ['node20'],
sourcemap: true,
bundle: true,
// Bundle, but keep un-bundled all public dependencies.
external: Object.keys({
...pkg.dependencies,
...pkg.peerDependencies,
}),
minify: false,
});
if (!errors.length)
await $`tsc --pretty -p .`;