From 9f749e7d81b63c7e9f1f83925db06bb2fa76c69b Mon Sep 17 00:00:00 2001 From: Amirhossein Khalili Date: Tue, 15 Sep 2026 23:51:11 +0330 Subject: [PATCH] fix: bundle maintenance CLI JavaScript dependencies Include Drizzle, validation, and password hashing dependencies in the CLI instead of relying on Next standalone tracing. Keep native SQLite and Sharp external and provide CommonJS require compatibility within the ESM bundle. Verification skipped as requested. --- scripts/build-maintenance.mjs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/build-maintenance.mjs b/scripts/build-maintenance.mjs index fc76846..abe5a3c 100644 --- a/scripts/build-maintenance.mjs +++ b/scripts/build-maintenance.mjs @@ -1,2 +1,16 @@ import { build } from 'esbuild'; -await build({ entryPoints: ['scripts/maintenance.ts'], outfile: '.next/standalone/maintenance.mjs', bundle: true, platform: 'node', target: 'node22', format: 'esm', packages: 'external' }); + +await build({ + entryPoints: ['scripts/maintenance.ts'], + outfile: '.next/standalone/maintenance.mjs', + bundle: true, + platform: 'node', + target: 'node22', + format: 'esm', + // Next traces the web application, not this separate maintenance entry point. + // Bundle its JS dependencies; only native packages stay external. + external: ['better-sqlite3', 'sharp'], + banner: { + js: "import { createRequire as createMaintenanceRequire } from 'node:module'; const require = createMaintenanceRequire(import.meta.url);", + }, +});