forked from AsPulse/TypedHttpAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ts
More file actions
61 lines (50 loc) · 1.33 KB
/
build.ts
File metadata and controls
61 lines (50 loc) · 1.33 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { build } from 'esbuild';
import { rm, writeFile } from 'fs/promises';
import { generateDtsBundle } from 'dts-bundle-generator';
import { resolve } from 'path';
import pkg from './package.json';
const { dependencies, devDependencies } = pkg;
const buildOptions = {
bundle: true,
external: [
...Object.keys(dependencies ?? []),
...Object.keys(devDependencies ?? []),
],
minify: true,
sourcemap: false,
};
(async () => {
await rm('./lib', { recursive: true, force: true });
await rm('./server', { recursive: true, force: true });
await rm('./client', { recursive: true, force: true });
await build({
...buildOptions,
entryPoints: ['./src/entry/server.ts'],
format: 'cjs',
outfile: './server/index.js',
});
await build({
...buildOptions,
entryPoints: ['./src/entry/client.ts'],
format: 'cjs',
outfile: './client/index.js',
});
const serverDts = generateDtsBundle([
{
filePath: './src/entry/server.ts',
output: {
exportReferencedTypes: false,
},
},
]);
const clientDts = generateDtsBundle([
{
filePath: './src/entry/client.ts',
output: {
exportReferencedTypes: false,
},
},
]);
await writeFile(resolve('./server/index.d.ts'), serverDts);
await writeFile(resolve('./client/index.d.ts'), clientDts);
})();