From 6ed11341d1305993c00127ab5ae15afbd9cbcf67 Mon Sep 17 00:00:00 2001 From: MrPiglr <31398225+MrPiglr@users.noreply.github.com> Date: Tue, 23 Dec 2025 04:56:10 +0000 Subject: [PATCH] Fix ESM module compatibility: convert build to ESM format with proper require/dirname shims for Supabase --- package.json | 2 +- script/build.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 98fb3bf..baea0a6 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dev:client": "vite dev --port 5000", "dev": "NODE_ENV=development tsx server/index.ts", "build": "tsx script/build.ts", - "start": "NODE_ENV=production node dist/index.cjs", + "start": "NODE_ENV=production node dist/index.js", "check": "tsc", "db:push": "drizzle-kit push" }, diff --git a/script/build.ts b/script/build.ts index 8279abb..2e92784 100644 --- a/script/build.ts +++ b/script/build.ts @@ -50,14 +50,17 @@ async function buildAll() { entryPoints: ["server/index.ts"], platform: "node", bundle: true, - format: "cjs", - outfile: "dist/index.cjs", + format: "esm", + outfile: "dist/index.js", define: { "process.env.NODE_ENV": '"production"', }, minify: true, external: externals, logLevel: "info", + banner: { + js: "import { createRequire } from 'module'; import { fileURLToPath } from 'url'; import { dirname } from 'path'; const require = createRequire(import.meta.url); const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename);", + }, }); }