-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.mjs
More file actions
49 lines (44 loc) · 1.29 KB
/
Copy pathesbuild.mjs
File metadata and controls
49 lines (44 loc) · 1.29 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
import esbuild from 'esbuild';
const prod = process.argv.includes('--production');
const watch = process.argv.includes('--watch');
// The shipped extension bundle: CommonJS, `vscode` external.
const extensionOpts = {
entryPoints: ['src/extension.ts'],
bundle: true,
outfile: 'dist/extension.js',
platform: 'node',
format: 'cjs',
target: 'node18',
external: ['vscode'],
sourcemap: !prod,
minify: prod,
logLevel: 'info',
};
// Pure-logic ESM builds so `node --test` can import the engines without the
// vscode extension host. Not shipped in the .vsix.
const pure = (entry, out) => ({
entryPoints: [entry],
bundle: true,
outfile: out,
platform: 'node',
format: 'esm',
target: 'node18',
sourcemap: !prod,
minify: false,
logLevel: 'info',
});
const builds = [
extensionOpts,
pure('src/completion.ts', 'dist/completion.mjs'),
pure('src/hover.ts', 'dist/hover.mjs'),
pure('src/diagnostics.ts', 'dist/diagnostics.mjs'),
pure('src/symbols.ts', 'dist/symbols.mjs'),
pure('src/navigation.ts', 'dist/navigation.mjs'),
pure('src/signature.ts', 'dist/signature.mjs'),
];
if (watch) {
const ctxs = await Promise.all(builds.map((b) => esbuild.context(b)));
await Promise.all(ctxs.map((c) => c.watch()));
} else {
await Promise.all(builds.map((b) => esbuild.build(b)));
}