Skip to content

Commit 81e91c1

Browse files
committed
fix: add undici to ESM builtins, last-resort host require.resolve fallback
1 parent d71ed4e commit 81e91c1

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/nodejs/src/bridge-handlers.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3086,7 +3086,6 @@ export function buildModuleResolutionBridgeHandlers(
30863086
}
30873087

30883088
// Try require.resolve first
3089-
if (req === "undici") console.error(`[DEBUG resolve undici] hostDir=${hostDir} sandboxDir=${sandboxDir} referrer=${referrer}`);
30903089
try {
30913090
const resolved = hostRequire.resolve(req, { paths: [hostDir] });
30923091
return deps.hostToSandboxPath(resolved);
@@ -3109,6 +3108,13 @@ export function buildModuleResolutionBridgeHandlers(
31093108
const resolved = resolveFromExports(realDir);
31103109
if (resolved) return resolved;
31113110
} catch { /* fallback failed */ }
3111+
3112+
// Last resort: try resolving from the host process itself (no path restrictions).
3113+
// This handles Node.js-bundled packages like undici that aren't in node: namespace.
3114+
try {
3115+
const resolved = hostRequire.resolve(req);
3116+
return deps.hostToSandboxPath(resolved);
3117+
} catch { /* truly not found */ }
31123118
return null;
31133119
};
31143120

0 commit comments

Comments
 (0)