From ca1e17f740820c743c057183cdccae57603ac113 Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza <8016841+diegosouzapw@users.noreply.github.com> Date: Tue, 16 Jun 2026 02:50:40 -0300 Subject: [PATCH] test(opencode-plugin): ESM default-export test (#3967) The plugin became ESM-only when the CJS bundle was dropped to fix the OpenCode loader (#3883), so tests/scaffold.test.ts's 'CJS default export resolves via require()' test fails at publish time with 'Cannot find module ../dist/index.cjs' (it only runs in the npm-publish opencode-plugin job, so the cycle never caught it). Replaced with an ESM import of the built dist/index.js asserting the same v1 { id, server } shape; dropped the now-unused createRequire import. omniroute@3.8.26 itself already published fine. --- .../opencode-plugin/tests/scaffold.test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/@omniroute/opencode-plugin/tests/scaffold.test.ts b/@omniroute/opencode-plugin/tests/scaffold.test.ts index 36aa4c7e46..42e1f09404 100644 --- a/@omniroute/opencode-plugin/tests/scaffold.test.ts +++ b/@omniroute/opencode-plugin/tests/scaffold.test.ts @@ -1,6 +1,5 @@ import test from "node:test"; import assert from "node:assert/strict"; -import { createRequire } from "node:module"; import { OmniRoutePlugin, OMNIROUTE_PROVIDER_KEY, @@ -63,11 +62,12 @@ test("OmniRoutePlugin: returns an empty hooks object (scaffold)", async () => { assert.notEqual(hooks, null); }); -test("scaffold: CJS default export resolves via require() with v1 shape", () => { - const require_ = createRequire(import.meta.url); - const cjs = require_("../dist/index.cjs"); - // after cjsInterop:true, default export is on cjs.default - assert.strictEqual(typeof cjs.default, "object"); - assert.strictEqual(cjs.default.id, "@omniroute/opencode-plugin"); - assert.strictEqual(typeof cjs.default.server, "function"); +test("scaffold: built ESM default export resolves with the v1 plugin shape", async () => { + // The plugin is ESM-only now — the CJS bundle was dropped to fix the OpenCode + // loader (#3883), so there is no more ../dist/index.cjs. Validate that the built + // distributable's default export still carries the OpenCode v1 { id, server } shape. + const mod = await import("../dist/index.js"); + assert.strictEqual(typeof mod.default, "object"); + assert.strictEqual(mod.default.id, "@omniroute/opencode-plugin"); + assert.strictEqual(typeof mod.default.server, "function"); });