fix: use ssrLoadModule to load Express server in Vite dev plugin
Some checks are pending
Build / build (push) Waiting to run
Deploy / deploy (push) Waiting to run
Lint & Type Check / lint (push) Waiting to run
Security Scan / semgrep (push) Waiting to run
Security Scan / dependency-check (push) Waiting to run
Test / test (18.x) (push) Waiting to run
Test / test (20.x) (push) Waiting to run

Dynamic import("./server") resolves relative to Vite's .vite-temp/
compilation dir, not the project root. ssrLoadModule resolves from
/app root and processes TypeScript correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
AeThex 2026-04-15 00:28:32 +00:00
parent a57cdb029a
commit 885ea76d12

View file

@ -42,7 +42,7 @@ function expressPlugin(): Plugin {
async configureServer(server) {
try {
console.log("[Vite] Loading Express server...");
const { createServer } = await import("./server");
const { createServer } = await server.ssrLoadModule("/server/index.ts");
const app = createServer();
console.log("[Vite] Express server created, mounting...");