Fix ESM module compatibility: convert build to ESM format with proper require/dirname shims for Supabase

This commit is contained in:
MrPiglr 2025-12-23 04:56:10 +00:00
parent e3e894ca61
commit 6ed11341d1
2 changed files with 6 additions and 3 deletions

View file

@ -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"
},

View file

@ -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);",
},
});
}