fix(production): preserve emitted plugin runtimes

This commit is contained in:
2026-08-13 18:00:30 +05:30
parent 94a6b436f5
commit 5106256401
6 changed files with 110 additions and 4 deletions
+5 -1
View File
@@ -188,6 +188,7 @@ export function generateQueriesFile(
): string {
const byTable = new Map(models.map((m) => [m.model.name, m]));
const usedModels = new Set<string>();
let usesExecResult = false;
const blocks: string[] = [];
for (const q of queries) {
@@ -202,6 +203,7 @@ export function generateQueriesFile(
const sig = argFields.length ? `db: Db, args: { ${argFields.join("; ")} }` : "db: Db";
if (q.kind === "exec") {
usesExecResult = true;
blocks.push(
`export async function ${q.name}(${sig}): Promise<ExecResult> {\n return db.exec(${sqlLit}, ${positional});\n}`,
);
@@ -224,7 +226,9 @@ export function generateQueriesFile(
);
}
const imports = [`import type { Db, ExecResult } from "@wrnexus/db";`];
const imports = [
`import type { Db${usesExecResult ? ", ExecResult" : ""} } from "@wrnexus/db";`,
];
if (usedModels.size > 0) {
imports.push(`import { ${[...usedModels].sort().join(", ")} } from "./schema.ts";`);
}