mirror of
https://github.com/earendil-works/pi.git
synced 2026-09-28 05:54:43 +08:00
fix: verify durable browser-safe exports
This commit is contained in:
@@ -4,6 +4,7 @@ import { dirname, join, resolve } from "node:path";
|
||||
import { build } from "esbuild";
|
||||
|
||||
const outputPath = join(tmpdir(), "pi-browser-smoke.js");
|
||||
const durableOutputPath = join(tmpdir(), "pi-durable-browser-smoke.js");
|
||||
const agentTreeshakeOutputPath = join(tmpdir(), "pi-agent-treeshake-smoke.js");
|
||||
const errorLogPath = join(tmpdir(), "pi-browser-smoke-errors.log");
|
||||
const generatedCatalogDataDir = join(process.cwd(), "packages/ai/src/providers/data");
|
||||
@@ -51,6 +52,30 @@ try {
|
||||
plugins: [generatedCatalogDataPlugin],
|
||||
});
|
||||
|
||||
const durableBuild = await build({
|
||||
entryPoints: ["scripts/durable-browser-smoke-entry.ts"],
|
||||
bundle: true,
|
||||
platform: "browser",
|
||||
format: "esm",
|
||||
logLevel: "silent",
|
||||
metafile: true,
|
||||
outfile: durableOutputPath,
|
||||
write: false,
|
||||
});
|
||||
const durableInputs = durableBuild.metafile.inputs;
|
||||
for (const expectedInput of [
|
||||
"packages/durable/src/index.ts",
|
||||
"packages/durable/src/storage/memory.ts",
|
||||
"packages/durable/src/storage/sqlite/index.ts",
|
||||
"packages/durable/src/storage/sqlite/storage.ts",
|
||||
]) {
|
||||
if (!findInput(durableInputs, expectedInput)) {
|
||||
throw new Error(`Durable browser bundle does not include ${expectedInput}`);
|
||||
}
|
||||
}
|
||||
const nodeAdapter = findInput(durableInputs, "packages/durable/src/storage/sqlite/node.ts");
|
||||
if (nodeAdapter) throw new Error(`Durable browser bundle unexpectedly includes ${nodeAdapter}`);
|
||||
|
||||
const agentTreeshakeBuild = await build({
|
||||
entryPoints: ["scripts/agent-treeshake-smoke-entry.ts"],
|
||||
bundle: true,
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import * as durable from "@earendil-works/pi-durable";
|
||||
import * as sqlite from "@earendil-works/pi-durable/storage/sqlite";
|
||||
|
||||
// Keep both runtime-neutral public entry points live so the browser smoke build
|
||||
// catches accidental imports of Node-only adapters or built-ins.
|
||||
console.log(Object.keys(durable), Object.keys(sqlite));
|
||||
Reference in New Issue
Block a user