UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

20 lines (17 loc) • 656 B
import { fileURLToPath, pathToFileURL } from "node:url"; import { dirname, resolve } from "node:path"; const cache = /* @__PURE__ */ new Map(); async function workerImport(relativePath, callerUrl) { const callerDir = dirname(fileURLToPath(callerUrl)); const absolutePath = resolve(callerDir, relativePath); const cacheKey = absolutePath; if (cache.has(cacheKey)) { return cache.get(cacheKey); } const mjsPath = absolutePath.endsWith(".mjs") ? absolutePath : `${absolutePath}.mjs`; const mod = await import(pathToFileURL(mjsPath).href); cache.set(cacheKey, mod); return mod; } export { workerImport }; //# sourceMappingURL=workerImport.mjs.map