forked from angular/vscode-ng-language-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.js
72 lines (66 loc) · 1.71 KB
/
esbuild.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
63
64
65
66
67
68
69
70
71
72
const esbuild = require('esbuild');
const fs = require('fs');
/** @type esbuild.BuildOptions */
const defaultOptions = {
bundle: true,
platform: 'node',
logLevel: 'info',
format: 'cjs',
};
/** @type esbuild.BuildOptions */
const clientConfig = {
...defaultOptions,
entryPoints: ['dist/client/extension.js'],
outfile: 'dist/npm/index.js',
external: [
'fs',
'path',
'vscode',
'vscode-languageclient/node',
'vscode-languageserver-protocol',
'vscode-jsonrpc',
],
// Do not enable minification. It seems to break the extension on Windows (with WSL). See #1198.
minify: false,
};
/** @type esbuild.BuildOptions */
const bannerConfig = {
...defaultOptions,
entryPoints: ['dist/banner/banner.js'],
outfile: 'dist/banner/banner.esbuild.js',
external: [
'path',
],
// This is described in more detail in the `server/banner.ts` but this line actually overrides
// the built-in `require` function by adding a line at the bottom of the generated banner code
// to assign the override function to the `require` name.
footer: {js: 'require = requireOverride;'}
};
/** @type esbuild.BuildOptions */
const serverConfig = {
...defaultOptions,
entryPoints: ['dist/server/server.js'],
outfile: 'dist/npm/server/index.js',
external: [
'fs',
'path',
'typescript/lib/tsserverlibrary',
'vscode-languageserver',
'vscode-uri',
'vscode-jsonrpc',
],
};
async function build() {
try {
await esbuild.build(clientConfig);
await esbuild.build(bannerConfig);
await esbuild.build({
...serverConfig,
banner: {js: fs.readFileSync('dist/banner/banner.esbuild.js', 'utf8')},
});
} catch (e) {
console.error(e);
process.exit(1);
}
}
build();