Compare commits

...

1 Commits

Author SHA1 Message Date
diegosouzapw
943a9374b4 fix: permanent @swc/helpers MODULE_NOT_FOUND fix (#crash)
prepublish.mjs: explicitly copy @swc/helpers into standalone app/node_modules
before packaging. npm tarball will always include it.

postinstall.mjs: fallback copy of @swc/helpers from root node_modules into
app/node_modules/@swc/ when missing after npm install -g.

Fixes server crash after npm install -g omniroute.
2026-03-12 10:42:59 -03:00
5 changed files with 50 additions and 3 deletions

View File

@@ -11,7 +11,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
---
## [2.3.4] — 2026-03-12
## [2.3.5] — 2026-03-12
> ### Hotfix: Permanent @swc/helpers MODULE_NOT_FOUND Fix
### 🐛 Bug Fixes
- **`@swc/helpers` MODULE_NOT_FOUND crash on `npm install -g`** — Next.js standalone tracer does not always include `@swc/helpers` in `app/node_modules/`, causing an immediate server crash after install. Fixed in two layers:
- `scripts/prepublish.mjs` — now explicitly copies `@swc/helpers` from root `node_modules/` into the standalone `app/node_modules/` before packaging. The npm tarball will always include it from now on.
- `scripts/postinstall.mjs` — added a fallback that copies `@swc/helpers` from root into `app/node_modules/@swc/` if it's missing after install. Handles older versions and edge cases.
---
> ### UI Polish — Endpoint Music Section, Always-Visible Buttons & Provider Logos

View File

@@ -1,7 +1,7 @@
openapi: 3.1.0
info:
title: OmniRoute API
version: 2.3.4
version: 2.3.5
description: |
OmniRoute is a local-first AI API proxy router. It provides an OpenAI-compatible
endpoint that routes requests to multiple AI providers with load balancing,

View File

@@ -1,6 +1,6 @@
{
"name": "omniroute",
"version": "2.3.4",
"version": "2.3.5",
"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": {

View File

@@ -113,3 +113,28 @@ if (process.platform === "darwin") {
console.warn(" If build tools are missing: xcode-select --install");
}
console.warn("");
// ── @swc/helpers fix ────────────────────────────────────────────────────────
// Next.js standalone tracer doesn't always include @swc/helpers in app/node_modules/,
// causing a MODULE_NOT_FOUND crash at runtime. Copy it from root node_modules if needed.
const swcHelpersApp = join(ROOT, "app", "node_modules", "@swc", "helpers");
const swcHelpersRoot = join(ROOT, "node_modules", "@swc", "helpers");
if (!existsSync(swcHelpersApp)) {
if (existsSync(swcHelpersRoot)) {
try {
const { cpSync } = await import("node:fs");
mkdirSync(join(ROOT, "app", "node_modules", "@swc"), { recursive: true });
cpSync(swcHelpersRoot, swcHelpersApp, { recursive: true });
console.log(" ✅ @swc/helpers copied to standalone app/node_modules.\n");
} catch (err) {
console.warn(` ⚠️ Could not copy @swc/helpers: ${err.message}`);
console.warn(
" Try manually: cp -r node_modules/@swc/helpers app/node_modules/@swc/helpers\n"
);
}
} else {
console.warn(" ⚠️ @swc/helpers not found in root node_modules either.");
console.warn(" Try: npm install --save-exact @swc/helpers@0.5.19\n");
}
}

View File

@@ -122,6 +122,18 @@ if (existsSync(sharedApiKey)) {
// ── Step 10: Ensure data/ directory exists ──────────────────
mkdirSync(join(APP_DIR, "data"), { recursive: true });
// ── Step 10.5: Copy @swc/helpers into standalone ───────────
// Next.js standalone tracer sometimes omits @swc/helpers from app/node_modules/,
// causing MODULE_NOT_FOUND at runtime. Always copy it explicitly.
const swcHelpersSrc = join(ROOT, "node_modules", "@swc", "helpers");
const swcHelpersDst = join(APP_DIR, "node_modules", "@swc", "helpers");
if (existsSync(swcHelpersSrc) && !existsSync(swcHelpersDst)) {
console.log(" 📋 Copying @swc/helpers to standalone app/node_modules...");
mkdirSync(join(APP_DIR, "node_modules", "@swc"), { recursive: true });
cpSync(swcHelpersSrc, swcHelpersDst, { recursive: true });
console.log(" ✅ @swc/helpers included in standalone build.");
}
// ── Done ───────────────────────────────────────────────────
const appPkg = join(APP_DIR, "package.json");
if (existsSync(appPkg)) {