-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
38 lines (33 loc) · 1.09 KB
/
build.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
import { promises as fsp } from "fs";
import { dirname, resolve as resolvePath } from "path";
import { fileURLToPath } from "url";
import esbuild from "esbuild";
async function loadPackageJson() {
const filePath = fileURLToPath(import.meta.url);
const dirPath = dirname(filePath);
const packageJsonPath = resolvePath(dirPath, "package.json");
const packageJsonContent = await fsp.readFile(packageJsonPath, "utf-8");
const packageJson = JSON.parse(packageJsonContent);
return packageJson;
}
async function loadDependenciesNames() {
const { dependencies } = await loadPackageJson();
const depNames = Object.keys(dependencies);
return depNames;
}
(async () => {
console.log("👷🔨 build started");
const buildTimerLabel = "👷✅ build completed";
console.time(buildTimerLabel);
const depNames = await loadDependenciesNames();
await esbuild.build({
entryPoints: ["src/server.ts"],
outfile: "dist/ssh-connect.js",
platform: "node",
external: depNames,
bundle: true,
sourcemap: true,
format: "esm",
});
console.timeEnd(buildTimerLabel);
})();