diff --git a/Dockerfile b/Dockerfile index 0c5d6e6..46d79b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,18 +22,21 @@ RUN npx prisma generate # Build the Next.js app RUN npm run build -# Pre-compile the seed to a self-contained CJS bundle. Runtime then runs -# plain `node prisma/seed-dow.cjs` and avoids the whole tsx+module-resolution -# nightmare: Next.js's standalone node_modules was aggressively reshuffling -# the tree after install, leaving packages like postgres-array with a -# manifest but no index.js. Bundling sidesteps that entirely. +# Pre-compile the seed to a self-contained ESM bundle. Runtime then runs +# plain `node prisma/seed-dow.mjs` and avoids the whole tsx+module- +# resolution nightmare: Next.js's standalone node_modules was aggressively +# reshuffling the tree after install, leaving packages like postgres-array +# with a manifest but no index.js. Bundling sidesteps that entirely. # -# `--packages=external` keeps NPM packages (e.g. bcryptjs, @prisma/*) as -# runtime require() calls so the bundle stays small and native .node files +# ESM (not CJS) because Prisma's generated client uses `import.meta.url` +# for engine detection — that's `undefined` in CJS and crashes on load. +# +# `--packages=external` keeps NPM packages (bcryptjs, @prisma/*) as +# runtime import() calls so the bundle stays small and native .node files # in @prisma/client work normally. RUN npx -y esbuild@0.24 prisma/seed-dow.ts \ - --bundle --platform=node --format=cjs --target=node22 \ - --outfile=prisma/seed-dow.cjs \ + --bundle --platform=node --format=esm --target=node22 \ + --outfile=prisma/seed-dow.mjs \ --packages=external # Production image