-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.mjs
30 lines (28 loc) · 892 Bytes
/
build.mjs
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
import esbuild from "esbuild";
import fs from "fs";
const nodeVersion = fs.readFileSync(".nvmrc", "utf-8").trim();
console.log("Building for Node.js version:", nodeVersion);
await esbuild.build({
entryPoints: ["./src/probot.ts", "./src/authorizer.ts"],
bundle: true,
outdir: "dist",
platform: "node",
format: "esm",
outExtension: { ".js": ".mjs" },
target: `node${nodeVersion}`,
minifyWhitespace: true,
minifySyntax: true,
// `banner` is needed due to:
// - https://github.com/evanw/esbuild/issues/1921#issuecomment-1575636282
banner: {
js: `\
import path from 'path';
import { fileURLToPath } from 'url';
import { createRequire as topLevelCreateRequire } from 'module';
const require = topLevelCreateRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);\
`,
},
sourcemap: "external",
});