Files
bitgate/packages/standalone/build.mjs
Cursor AgentandthePR0M3TH3AN 9e6f6c659e Add --bitgate-* theme tokens and a build-injected VERSION.
Widget styles now prefer --bitgate-* custom properties, falling back to the
deprecated --gov-* names and then the existing defaults so current pages and
overrides keep working. Browser bundles and ESM entry points expose VERSION
(and window.bitgate.version) from package.json. Document allowlist on the
widget policy preset list. Sync the lockfile so npm ci sees @bitgate/standalone.

Co-authored-by: thePR0M3TH3AN <[email protected]>
2026-10-08 19:14:44 +00:00

52 lines
1.6 KiB
JavaScript

#!/usr/bin/env node
/**
* Bundle the headless engine + Nostr codecs into a single self-contained ESM
* file for no-build static sites.
*
* The output (`dist/bitgate.js`) is the same canonical code the npm packages
* ship — not a second implementation — with the bare `@bitgate/*` specifiers
* resolved and inlined. Consumers copy it onto their own origin and import it
* with a single relative path; they never fetch it from someone else's
* deployment.
*
* Usage: node packages/standalone/build.mjs [--watch]
*/
import { build, context } from "esbuild";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { bitgateVersionPlugin } from "../../scripts/esbuild-bitgate-version.mjs";
const HERE = dirname(fileURLToPath(import.meta.url));
/** @type {import("esbuild").BuildOptions} */
const options = {
entryPoints: [join(HERE, "src", "index.js")],
outfile: join(HERE, "dist", "bitgate.js"),
bundle: true,
format: "esm",
platform: "browser",
target: ["es2022"],
sourcemap: true,
minify: true,
legalComments: "inline",
banner: {
js: "/*! BitGate (headless standalone) — GPL-3.0-or-later — https://github.com/PR0M3TH3AN/Nostr-Governance */",
},
plugins: [bitgateVersionPlugin()],
};
const watch = process.argv.includes("--watch");
if (watch) {
const ctx = await context(options);
await ctx.watch();
console.log("bitgate standalone: watching…");
} else {
const result = await build(options);
if (result.errors.length) {
process.exit(1);
}
console.log(`✓ Built ${options.outfile}`);
}