import path from "node:path"; import { fileURLToPath } from "node:url"; import { build } from "esbuild"; const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../.."); const prismaRuntimeExternals = ["@prisma/client", "@prisma/adapter-pg", "pg", "pino", "bcryptjs"]; const sharedBuildOptions = { absWorkingDir: repoRoot, bundle: true, format: "esm", logLevel: "warning", platform: "node", }; const artifactBuilds = [ { entryPoints: ["packages/db/src/permissions-seed.server.ts"], outfile: "packages/db/dist/permissions-seed.server.js", packages: "external", }, { alias: { "@hivegrid/logger": "./packages/logger/src/index.ts" }, entryPoints: ["packages/db/src/deploy-permission-catalog-sync.server.ts"], outfile: "packages/db/dist/deploy-permission-catalog-sync.server.js", packages: "external", }, { alias: { "~": "./apps/web/app" }, banner: { js: "import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);", }, entryPoints: ["prisma/seed.ts"], external: prismaRuntimeExternals, outfile: "packages/db/dist/production-seed.server.js", }, { alias: { "~": "./apps/web/app" }, entryPoints: ["scripts/seed-e2e-readiness.ts"], external: prismaRuntimeExternals, outfile: "packages/db/dist/e2e-readiness-seed.server.js", }, ]; await Promise.all(artifactBuilds.map((artifact) => build({ ...sharedBuildOptions, ...artifact })));