-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.js
37 lines (31 loc) · 854 Bytes
/
build.js
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
import { build } from 'esbuild';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import ts from 'typescript';
build({
entryPoints: ['lib/cli.ts', 'lib/main.ts', 'lib/worker.ts'],
outdir: 'dist',
bundle: true,
external: ['chalk', 'cac', 'typescript'],
target: 'node18',
platform: 'node',
format: 'esm',
tsconfig: 'tsconfig.lib.json',
});
const projectRoot = dirname(fileURLToPath(import.meta.url));
const { config } = ts.readConfigFile(
resolve(projectRoot, 'tsconfig.lib.json'),
ts.sys.readFile,
);
const { options, fileNames } = ts.parseJsonConfigFileContent(
config,
ts.sys,
projectRoot,
);
const program = ts.createProgram(fileNames, {
...options,
emitDeclarationOnly: true,
outDir: resolve(projectRoot, 'dist'),
rootDir: resolve(projectRoot, 'lib'),
});
program.emit();