-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.lib.js
62 lines (58 loc) · 1.75 KB
/
build.lib.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const ts = require("typescript");
const esbuild = require("esbuild");
const path = require("path");
const { dependencies, peerDependencies } = require('./package.json');
const { serverDeps = dependencies, serverPeers = peerDependencies } = require('./server/package.json');
const external = Object.keys(dependencies)
.concat(Object.keys(peerDependencies || []))
.concat(Object.keys(serverDeps || []))
.concat(Object.keys(serverPeers || []));
// LIB - CJS
esbuild.build({
entryPoints: ['server/src/lpc/lpc.ts'],
bundle: true,
banner: { js: "// Copyright 2024 John L Chmura\n" },
outfile: 'out/lib/lpc.js',
target: ["es2020"],
external: Object.keys(dependencies).concat(Object.keys(peerDependencies || [])),
packages: "external",
sourcesContent: false,
platform: 'node',
format: 'cjs',
sourcemap: 'linked',
mainFields: ['module','main'],
logLevel: 'warning',
})
// CLI
esbuild.build({
entryPoints: ['server/src/cli/lpc.ts'],
bundle: true,
banner: { js: "// Copyright 2024 John L Chmura\n" },
outfile: 'out/lib/cli.js',
// outdir: 'out/lib',
target: ["es2020"],
external: Object.keys(dependencies).concat(Object.keys(peerDependencies || [])),
platform: 'node',
format: 'cjs',
sourcemap: 'linked',
mainFields: ['module','main'],
logLevel: 'warning',
treeShaking: true,
minify: true
})
// SERVER
esbuild.build({
entryPoints: ['server/src/server.ts'],
bundle: true,
banner: { js: "// Copyright 2024 John L Chmura\n" },
outfile: 'out/lib/server.js',
target: ["es2020"],
external: Object.keys(dependencies).concat(Object.keys(peerDependencies || [])),
platform: 'node',
format: 'cjs',
sourcemap: 'linked',
mainFields: ['module','main'],
logLevel: 'warning',
treeShaking: true,
minify: true
})