-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.config.js
More file actions
35 lines (32 loc) · 1.04 KB
/
esbuild.config.js
File metadata and controls
35 lines (32 loc) · 1.04 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
import esbuild from "esbuild";
import fs from "fs";
import { execSync } from "child_process";
const pkg = JSON.parse(fs.readFileSync("package.json", "utf-8"));
let commit = "unknown";
try {
commit = execSync("git rev-parse --short HEAD", { encoding: "utf-8" }).trim();
} catch {}
await esbuild.build({
entryPoints: ["linter.js"],
bundle: true,
platform: "node",
target: "node18",
format: "esm",
outfile: "dist/linter.mjs",
define: {
__LINTER_VERSION__: JSON.stringify(pkg.version),
__LINTER_COMMIT__: JSON.stringify(commit),
},
banner: {
// Shebang for global installs + restore __filename / __dirname and
// a CJS-compatible require() so bundled CJS deps work at runtime.
js: [
'#!/usr/bin/env node',
'import { createRequire as __createRequire } from "module";',
'import { fileURLToPath as __fileURLToPath } from "url";',
'import { dirname as __dirname_ } from "path";',
"const require = __createRequire(import.meta.url);",
].join("\n"),
},
});
console.log("Built dist/linter.mjs");