Files
oh-my-claudecode/scripts/build-bridge-entry.mjs
Bellman 09817cbb3b fix: ship complete plugin runtime closure (#3479)
* fix: ship complete plugin runtime closure

* fix: refresh plugin runtime closure after dev merge

* test: combine package closure regressions after dev merge

* test: extract full package for runtime closure parity

* fix(ci): fail closed on generated PR artifacts

* test(workflow): accept fail-closed transcript race

* fix(session-end): bound deferred recovery

* fix(session-end): close recovery edge cases

* fix(session-end): terminalize exhausted recovery

* fix(session-end): release detached action handles

* fix(plugin): verify complete package closure

* fix(session-end): recover sealed wiki interleaving

* fix(plugin): ship complete declaration closure

* test(session-end): tolerate detached teardown lag

* test(session-end): wait for detached shutdown

* fix(session-end): preserve OpenClaw routing context

* fix(shipping): bind generated trust and recovery routing

* chore(shipping): remove unreachable generated extras

* fix(shipping): support exact generated deletions
2026-07-19 01:01:02 +09:00

63 lines
1.9 KiB
JavaScript

#!/usr/bin/env node
/**
* Build script for standalone Team Bridge entry point bundle
* Bundles the bridge entry into a standalone JS file for plugin distribution
*/
import * as esbuild from 'esbuild';
import { mkdir } from 'fs/promises';
// Output to bridge/ directory (not gitignored) for plugin distribution
const outfile = 'bridge/team-bridge.cjs';
// Ensure output directory exists
await mkdir('bridge', { recursive: true });
// Preamble: resolve global npm modules so externalized native packages
// (like @ast-grep/napi) can be found when running from plugin cache
const banner = `
// Resolve global npm modules for native package imports
try {
var _cp = require('child_process');
var _Module = require('module');
var _globalRoot = _cp.execSync('npm root -g', { encoding: 'utf8', timeout: 5000 }).trim();
if (_globalRoot) {
var _sep = process.platform === 'win32' ? ';' : ':';
process.env.NODE_PATH = _globalRoot + (process.env.NODE_PATH ? _sep + process.env.NODE_PATH : '');
_Module._initPaths();
}
} catch (_e) { /* npm not available - native modules will gracefully degrade */ }
`;
const watchMode = process.argv.includes('--watch');
const buildConfig = {
entryPoints: ['src/team/bridge-entry.ts'],
bundle: true,
preserveSymlinks: true,
platform: 'node',
target: 'node18',
format: 'cjs',
outfile,
banner: { js: banner },
// Externalize Node.js built-ins and native modules
external: [
'fs', 'path', 'os', 'util', 'stream', 'events',
'buffer', 'crypto', 'http', 'https', 'url',
'child_process', 'assert', 'module', 'net', 'tls',
'dns', 'readline', 'tty', 'worker_threads',
// Native modules that can't be bundled
'@ast-grep/napi',
'better-sqlite3',
],
};
if (watchMode) {
const ctx = await esbuild.context(buildConfig);
await ctx.watch();
console.error(`Watching ${outfile}...`);
} else {
await esbuild.build(buildConfig);
console.error(`Built ${outfile}`);
}