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

fix(cli): implement Node 22 mjs entrypoint to bypass type stripping limit

diegosouzapw8d52a6cc7ab8
diff --git a/.gitignore b/.gitignore
index c4abb01ea6..2be9ea05a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -170,3 +170,4 @@ docs/superpowers/
# GitNexus local index
.gitnexus
.worktrees
+bin/omniroute.mjs
diff --git a/package.json b/package.json
index 4be879cbc7..24b5b99963 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
"description": "Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",
"type": "module",
"bin": {
- "omniroute": "bin/omniroute.ts",
+ "omniroute": "bin/omniroute.mjs",
"omniroute-reset-password": "bin/reset-password.mjs"
},
"files": [
diff --git a/scripts/prepublish.ts b/scripts/prepublish.ts
index cc5c627212..b278a1a81a 100644
--- a/scripts/prepublish.ts
+++ b/scripts/prepublish.ts
@@ -372,6 +372,24 @@ if (existsSync(mcpSrcFile)) {
}
}
+// ── Step 8.7: Bundle CLI Entrypoint ──────────────────────────
+const cliSrcFile = join(ROOT, "bin", "omniroute.ts");
+const cliDestFile = join(ROOT, "bin", "omniroute.mjs");
+
+if (existsSync(cliSrcFile)) {
+ console.log(" 🔨 Bundling CLI Entrypoint (TypeScript → JavaScript)...");
+ try {
+ execSync(
+ `npx esbuild bin/omniroute.ts --bundle --platform=node --packages=external --format=esm --outfile=bin/omniroute.mjs`,
+ { cwd: ROOT, stdio: "inherit" }
+ );
+ execSync(`chmod +x bin/omniroute.mjs`, { cwd: ROOT });
+ console.log(" ✅ CLI Entrypoint bundled to bin/omniroute.mjs");
+ } catch (err: any) {
+ console.warn(" ⚠️ CLI bundle error:", err.message);
+ }
+}
+
// ── Step 9: Copy shared utilities needed at runtime ────────
const sharedApiKey = join(ROOT, "src", "shared", "utils", "apiKey.js");
const sharedApiKeyDest = join(APP_DIR, "src", "shared", "utils");