Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

test(opencode-plugin): ESM default-export test (#3967)

Diego Rodrigues de Sa e Souzaca1e17f74082
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");
});