The registry smoke caught 0.1.1 broken at import time from jsr.io: createRequire(import.meta.url) throws for non-file URLs. Now lazy and anchored to pathToFileURL(cwd) — the anchor is irrelevant since only absolute staged .node paths are ever required.
- commit
- 83cb0f43dbb4dcaa9c7f19328ecbaf4a06098426
- parent
- f022775fde8d185ee823eea4aeb637b7c933db92
- author
- Dami <dami.etoile@gmail.com>
| M | deno.json | 2 | +- |
| M | src/ | 12 | ++++++++++-- |
| M | src/ | 4 | ++-- |
@@ -1,6 +1,6 @@
11 {22 "name": "@nzip/lofi-node",3- "version": "0.1.1",3+ "version": "0.1.2",44 "license": "MIT",55 "description": "Self-hostable sync node for lofi apps: an embedded Jazz sync server with iroh peer-to-peer transport and ticket-gated access. Pair homes by ticket — no static IPs, no cloud — issue revocable app tickets, and choose where your data lives.",66 "exports": {@@ -6,6 +6,7 @@
66 // panic outside a tokio context and ABORT the process under Deno.77 88 import { createRequire } from "node:module";9+import { pathToFileURL } from "node:url";910 import { MeshUnavailableError } from "../errors.ts";1011 import { resolveIrohLib } from "./loader.ts";1112 import { RELEASE_ARTIFACTS } from "./artifacts.ts";@@ -101,7 +102,14 @@ export interface IrohAddon {
101102 maxFrame(): number;102103 }103104 104-const require = createRequire(import.meta.url);105+// Lazy + cwd-anchored: import.meta.url is an https: URL when this module is106+// served from the JSR registry, and createRequire refuses non-file URLs. The107+// anchor is irrelevant anyway — we only ever require absolute staged paths.108+let lazyRequire: ReturnType<typeof createRequire> | null = null;109+function nodeRequire(path: string): unknown {110+ lazyRequire ??= createRequire(pathToFileURL(`${Deno.cwd()}/`).href);111+ return lazyRequire(path);112+}105113 106114 /** Cache key for extracted artifacts — bump when the vendored tag or107115 * lofi_ext surface changes (see native/iroh-js/UPSTREAM.md). */@@ -236,7 +244,7 @@ export async function loadIrohAddon(explicitPath?: string): Promise<IrohAddon> {
236244 }237245 let addon: IrohAddon;238246 try {239- addon = require(loadPath) as IrohAddon;247+ addon = nodeRequire(loadPath) as IrohAddon;240248 } catch (e) {241249 throw new MeshUnavailableError(`addon load failed for ${loadPath}: ${(e as Error).message}`);242250 }@@ -1,10 +1,10 @@
11 // GENERATED by tools/release_artifacts.ts — do not edit by hand.22 // Release-asset names + sha256 digests for the native addon; the loader3-// downloads these from the GitHub release for version 0.1.1 and refuses3+// downloads these from the GitHub release for version 0.1.2 and refuses44 // anything that does not match. Regenerate: deno task release:artifacts55 66 export const RELEASE_ARTIFACTS = {7- "version": "0.1.1",7+ "version": "0.1.2",88 "assets": {99 "darwin-aarch64": {1010 "file": "libnumber0_iroh-aarch64-apple-darwin.dylib",