-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathesbuild.js
More file actions
57 lines (49 loc) · 1.35 KB
/
Copy pathesbuild.js
File metadata and controls
57 lines (49 loc) · 1.35 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
const esbuild = require('esbuild');
const watch = process.argv.includes('--watch');
const minify = process.argv.includes('--minify');
/** Settings shared by every bundle. */
const common = {
bundle: true,
platform: 'node',
target: 'node22',
format: 'cjs',
sourcemap: !minify,
minify,
logLevel: 'info',
};
/** @type {import('esbuild').BuildOptions} */
const extension = {
...common,
entryPoints: ['src/extension.ts'],
outfile: 'dist/extension.js',
// `vscode` is provided by the extension host at runtime and must not be bundled.
external: ['vscode'],
};
/** @type {import('esbuild').BuildOptions} */
const dapServer = {
...common,
entryPoints: ['src/server/main.ts'],
outfile: 'dist/dap-server.js',
banner: { js: '#!/usr/bin/env node' },
};
/** @type {import('esbuild').BuildOptions} */
const trace = {
...common,
entryPoints: ['src/trace/main.ts'],
outfile: 'dist/trace.js',
banner: { js: '#!/usr/bin/env node' },
};
const allOptions = [extension, dapServer, trace];
async function main() {
if (watch) {
const contexts = await Promise.all(allOptions.map((o) => esbuild.context(o)));
await Promise.all(contexts.map((c) => c.watch()));
console.log('esbuild: watching...');
} else {
await Promise.all(allOptions.map((o) => esbuild.build(o)));
}
}
main().catch((err) => {
console.error(err);
process.exit(1);
});