Repository Public
1// Bundles the server, the TypeScript SDK (../sdk-ts) and the MCP SDK into ONE file: dist/index.js runs standalone with `node`.2import { build } from "esbuild"3import fs from "node:fs"4import path from "node:path"5import { fileURLToPath } from "node:url"67const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")8const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"))9await build({10 entryPoints: [path.join(root, "src/index.ts")],11 outfile: path.join(root, "dist/index.js"),12 bundle: true,13 platform: "node",14 format: "esm",15 target: "node20",16 alias: { "@spboucher/spmail": path.resolve(root, "../sdk-ts/src/index.ts") },17 define: { __SPMAIL_MCP_VERSION__: JSON.stringify(pkg.version) },18 banner: { js: "#!/usr/bin/env node\nimport { createRequire as __spmailCreateRequire } from 'node:module'; const require = __spmailCreateRequire(import.meta.url);" },19 legalComments: "none",20 logLevel: "warning",21})22fs.chmodSync(path.join(root, "dist/index.js"), 0o755)23console.log(`dist/index.js built (${(fs.statSync(path.join(root, "dist/index.js")).size / 1024).toFixed(0)} kB)`)24