-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathesbuild.mjs
More file actions
66 lines (62 loc) · 2.44 KB
/
esbuild.mjs
File metadata and controls
66 lines (62 loc) · 2.44 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
58
59
60
61
62
63
64
65
66
import * as esbuild from "esbuild";
import copyStaticFiles from "esbuild-copy-static-files";
import process from "node:process";
import path from "node:path";
import { problemMatcher, removeStrict, nodeTpl } from "@hpcc-js/esbuild-plugins";
import tsconfigNode from "./tsconfig.json" with {"type": "json"};
import tsconfigBrowser from "./tsconfig.webview.json" with {"type": "json"};
const outputDirectory = "dist";
const watch = process.argv.includes("--watch");
const production = !watch && process.argv.includes("--production");
console.log(`Build: watch: ${watch}, production: ${production}`);
async function bundle(tsconfigRaw, entryPoint, platform, format, plugins = []) {
const ctx = await esbuild.context({
tsconfigRaw,
entryPoints: [entryPoint],
outdir: outputDirectory,
bundle: true,
format,
minify: production,
sourcemap: !production ? "linked" : false,
platform,
target: platform === "node" ? "node20" : "es2022",
external: ["child_process", "crypto", "fs", "https", "node:*", "os", "http", "vscode"],
logLevel: production ? "silent" : "info",
plugins: [
...plugins,
problemMatcher(),
]
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
}
(async () => {
await Promise.all([
bundle(tsconfigNode, "./src/extension.ts", "node", "cjs", [
// copyStaticFiles({
// src: "./node_modules/@hpcc-js/ddl-shim/schema/v2.json",
// dest: path.join(outputDirectory, "v2.json"),
// }),
copyStaticFiles({
src: "./util/docs.vecdb",
dest: path.join(outputDirectory, "docs.vecdb"),
}),
copyStaticFiles({
src: "./node_modules/@hpcc-js/dgrid-shim/dist/index.min.js",
dest: path.join(outputDirectory, "dgrid-shim.min.js"),
})
]),
bundle(tsconfigBrowser, "./src/notebook/renderers/wuRenderer.tsx", "browser", "esm"),
bundle(tsconfigBrowser, "./src/notebook/renderers/ojsRenderer.ts", "browser", "esm"),
bundle(tsconfigBrowser, "./src/eclwatch.tsx", "browser", "iife"),
bundle(tsconfigBrowser, "./src/web-extension.ts", "browser", "iife"),
nodeTpl("./util/index-docs.ts", "./dist-util/index-docs")
]);
})().catch(e => {
console.error(e);
process.exit(1);
});