26382a7ac6
CI / Clippy (push) Failing after 15m13s
CI / Test (ubuntu-latest) (push) Failing after 16m1s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Build (no embeddings / no ORT) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Cookbook (Node) (push) Has been cancelled
CI / Pi Extension (Node) (push) Has been cancelled
CI / Rust SDK (lean-ctx-client) (push) Has been cancelled
CI / Embed SDK (lean-ctx-sdk) (push) Has been cancelled
CI / Python SDK (leanctx) (push) Has been cancelled
CI / Hermes Plugin (Python) (push) Has been cancelled
CI / SDK Conformance Matrix (push) Has been cancelled
CI / Coverage (push) Has been cancelled
CI / cargo-deny (push) Has been cancelled
CI / Adversarial Safety (push) Has been cancelled
CI / Benchmarks (push) Has been cancelled
CI / Output-Quality Gate (eval A/B) (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CI / CI Green (push) Has been cancelled
JetBrains Plugin / Actionlint (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (rust) (push) Has been cancelled
JetBrains Plugin / Validation (push) Has been cancelled
JetBrains Plugin / Build (push) Has been cancelled
JetBrains Plugin / Test (push) Has been cancelled
Security Check / Security Scan (push) Has been cancelled
45 lines
1.9 KiB
JavaScript
45 lines
1.9 KiB
JavaScript
// Builds extensions/vendor/mcp-sdk.js — a self-contained bundle of the MCP
|
|
// SDK client (incl. zod) so the published package needs ZERO runtime npm
|
|
// dependencies.
|
|
//
|
|
// Why (GH #670): pi installs every package into one shared npm prefix
|
|
// (~/.pi/agent/npm). Each `pi install`/`remove` re-reifies the whole tree and
|
|
// physically rewrites unrelated packages; an interrupted extraction (Windows
|
|
// AV/file locks) strands files like zod/v3/locales/en.js, and npm never
|
|
// repairs a package whose package.json version matches. Bundling removes the
|
|
// failure class: there is no zod left on disk to corrupt.
|
|
//
|
|
// The bundle is generated at publish time (`prepack`) and before tests; it is
|
|
// NOT committed. Node built-ins stay external (platform: node).
|
|
import { build } from "esbuild";
|
|
import { mkdirSync } from "node:fs";
|
|
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
const outfile = resolve(here, "..", "extensions", "vendor", "mcp-sdk.cjs");
|
|
mkdirSync(dirname(outfile), { recursive: true });
|
|
|
|
const result = await build({
|
|
entryPoints: [resolve(here, "vendor-entry.mjs")],
|
|
outfile,
|
|
bundle: true,
|
|
platform: "node",
|
|
target: "node18",
|
|
// CJS on purpose: pi loads extensions through jiti, which transpiles every
|
|
// module to CJS — an ESM bundle would need a createRequire banner that
|
|
// collides with the CJS wrapper's own `require` binding. As CJS the bundle
|
|
// requires node built-ins natively under jiti, and native ESM importers
|
|
// (vitest, plain `node`) still get named exports via esbuild's
|
|
// cjs-module-lexer annotation.
|
|
format: "cjs",
|
|
sourcemap: false,
|
|
minify: false,
|
|
legalComments: "inline",
|
|
logLevel: "warning",
|
|
metafile: true,
|
|
});
|
|
|
|
const bytes = Object.values(result.metafile.outputs)[0]?.bytes ?? 0;
|
|
console.log(`vendor bundle: ${outfile} (${(bytes / 1024).toFixed(0)} KB)`);
|