diff --git a/artifacts/api-server/build.ts b/artifacts/api-server/build.ts index 3a66ebe..30043d2 100644 --- a/artifacts/api-server/build.ts +++ b/artifacts/api-server/build.ts @@ -1,7 +1,7 @@ import path from "path"; import { fileURLToPath } from "url"; import { build as esbuild } from "esbuild"; -import { rm, readFile } from "fs/promises"; +import { rm, readFile, writeFile } from "fs/promises"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -70,6 +70,15 @@ async function buildAll() { external: externals, logLevel: "info", }); + + // Write a thin CJS shim so both dist/index.cjs (legacy .replit deployment + // config) and dist/index.js (artifact.toml run command) resolve to the same bundle. + await writeFile( + path.resolve(distDir, "index.cjs"), + `// shim: delegates to dist/index.js\nrequire('./index.js');\n`, + "utf-8", + ); + console.log(" dist/index.cjs (shim → index.js)"); } buildAll().catch((err) => {