From f0684fda32cd3f7813d4eff8f66638e3f2cb6a20 Mon Sep 17 00:00:00 2001 From: van3hardy Date: Mon, 10 Aug 2026 23:56:33 -0400 Subject: [PATCH] test(opencode): assert built entry exports only the plugin function --- tests/scripts/build-opencode.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/scripts/build-opencode.test.js b/tests/scripts/build-opencode.test.js index f3f973ca9..abc55a275 100644 --- a/tests/scripts/build-opencode.test.js +++ b/tests/scripts/build-opencode.test.js @@ -46,6 +46,25 @@ function main() { assert.strictEqual(result.status, 0, result.stderr) assert.ok(fs.existsSync(distEntry), ".opencode/dist/index.js should exist after build") }], + ["built OpenCode entry exports only the plugin function", () => { + const check = ` + const assert = require("assert") + const { pathToFileURL } = require("url") + const file = process.argv[1] + import(pathToFileURL(file).href).then((mod) => { + assert.deepStrictEqual(Object.keys(mod).sort(), ["default"]) + assert.strictEqual(typeof mod.default, "function") + }).catch((error) => { + console.error(error) + process.exit(1) + }) + ` + const result = spawnSync(process.execPath, ["-e", check, distEntry], { + cwd: repoRoot, + encoding: "utf8", + }) + assert.strictEqual(result.status, 0, result.stderr) + }], ["npm pack includes the compiled OpenCode dist payload", () => { const result = spawnSync("npm", ["pack", "--dry-run", "--json"], { cwd: repoRoot,