openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
22 lines (21 loc) • 640 B
JavaScript
import fs from "node:fs";
import path from "node:path";
//#region src/infra/native-module-format.ts
/** Read the nearest package type for native ESM retention decisions. */
function isNativeEsmPackage(e) {
let t = path.dirname(e);
while (true) {
const e = path.join(t, "package.json");
if (fs.existsSync(e)) try {
const t = JSON.parse(fs.readFileSync(e, "utf8"));
return typeof t === "object" && t !== null && Object.getOwnPropertyDescriptor(t, "type")?.value === "module";
} catch {
return false;
}
const n = path.dirname(t);
if (n === t) return false;
t = n;
}
}
//#endregion
export { isNativeEsmPackage as t };