Files
Netcatty/scripts/build-preload.mjs
T
陈大猫 e2b3004d4b perf(memory): Phase 3 deep business-code memory optimization (main, renderer & active terminals) (#4488)
Includes all Phase 3 rounds (1-5), Node unit test mock compatibility fixes,
and Codex review fixes (pinyin readiness subscribers & KnownHostsManager
mount retention).
2026-11-27 23:24:40 +08:00

27 lines
890 B
JavaScript

import path from "node:path";
import { fileURLToPath } from "node:url";
import { build } from "esbuild";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootDir = path.resolve(__dirname, "..");
const entryPoint = path.join(rootDir, "electron", "preload.cjs");
const outfile = path.join(rootDir, "electron", "preload.bundle.cjs");
await build({
entryPoints: [entryPoint],
outfile,
bundle: true,
format: "cjs",
// Browser platform enforces zero Node.js builtin requires (only `electron` is
// external), guaranteeing sandbox: true compatibility at build time while
// preserving Electron's injected `process` global.
platform: "browser",
target: "chrome140",
external: ["electron"],
minify: true,
legalComments: "none",
banner: {
js: "// Generated by scripts/build-preload.mjs for Electron sandbox: true. Do not edit directly.",
},
});