forked from quarylabs/sqruff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.js
69 lines (62 loc) · 1.45 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
const esbuild = require("esbuild");
const production = process.argv.includes("--production");
const wasmPlugin = {
name: "wasm",
setup(build) {
const path = require("path");
const fs = require("fs");
build.onResolve({ filter: /\.wasm$/ }, (args) => {
return {
path: path.isAbsolute(args.path)
? args.path
: path.join(args.resolveDir, args.path),
namespace: "wasm-binary",
};
});
build.onLoad({ filter: /.*/, namespace: "wasm-binary" }, async (args) => {
return {
contents: await fs.promises.readFile(args.path),
loader: "binary",
};
});
},
};
esbuild
.build({
entryPoints: ["src/browser.ts"],
bundle: true,
external: ["vscode"],
outfile: "dist/browser.js",
format: "cjs",
platform: "browser",
minify: production,
})
.catch(() => process.exit(1));
esbuild
.build({
entryPoints: ["src/lsp-worker.ts"],
bundle: true,
outfile: "dist/browserServerMain.js",
format: "iife",
platform: "browser",
plugins: [wasmPlugin],
minify: production,
})
.catch(() => process.exit(1));
esbuild
.build({
entryPoints: ["src/native.ts"],
bundle: true,
external: [
"vscode",
"vscode-languageclient",
"vscode-languageclient/node",
"path",
"fs",
],
outfile: "dist/native.cjs",
platform: "node",
format: "cjs",
minify: production,
})
.catch(() => process.exit(1));