import { readFileSync } from "node:fs"; import { fileURLToPath } from "node:url"; import path from "node:path"; /** * Vite `define` entries every host needs to run numbl in the browser: * numbl reads `process` in a few guarded places, and the lab reports numbl's * package version (its `exports` map does not expose package.json to imports). */ export function numblDefine(): Record { const entry = fileURLToPath(import.meta.resolve("numbl")); const pkgPath = path.join(path.dirname(entry), "..", "package.json"); const version = (JSON.parse(readFileSync(pkgPath, "utf8")) as { version: string }).version; return { "process.platform": JSON.stringify("browser"), "process.env": "{}", __NUMBL_VERSION__: JSON.stringify(version), }; }