fix(build): make oRPC/tRPC dist runnable under node ESM (deploy crashloop)

flake.nix only rewrote @/ aliases but left extensionless relative imports
(./router) in compiled dist/. node dist/index.js (how prod runs) cannot
resolve extensionless ESM specifiers -> ERR_MODULE_NOT_FOUND -> backend
crashlooped (444 restarts, port 4001 dead). Extract the fixer into a shared
scripts/fix-imports.mjs that appends .js to extensionless relative imports and
rewrites @/ aliases, and wire it into backend + discord-gateway build phases.

Verified: fresh tsc + fixer -> node dist/index.js boots; oRPC over /trpc
serves both HTTP POST and WebSocket (config/dashboard/voice/moderation/
media/chatbot/analysis) end-to-end against Postgres + Redis. next build
passes with the oRPC client + partysocket.
This commit is contained in:
asepharyana
2026-08-16 14:45:02 +07:00
parent 2fa1827f17
commit 726a8e116b
27 changed files with 646 additions and 417 deletions
+2 -1
View File
@@ -10,12 +10,13 @@
"format": "biome format --write"
},
"dependencies": {
"@trpc/client": "^11.18.0",
"@orpc/client": "1.15.0",
"clsx": "^2.1.1",
"lucide-react": "^1.27.0",
"motion": "^12.0.0",
"next": "16.2.12",
"next-themes": "^0.4.6",
"partysocket": "1.3.0",
"react": "19.2.4",
"react-dom": "19.2.4",
"swr": "^2.4.2",