Skip to content

Commit 5105f11

Browse files
authored
Merge pull request #100 from rickyvetter/patch-1
Calculate fetchBase once at toplevel
2 parents 090b7b2 + c3cf34b commit 5105f11

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

runtime/wasm/runtime.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,9 @@
471471
const f = path.join(path.dirname(require.main.filename), src);
472472
return require("node:fs/promises").readFile(f);
473473
}
474+
const fetchBase = globalThis?.document?.currentScript?.src;
474475
function fetchRelative(src) {
475-
const base = globalThis?.document?.currentScript?.src;
476-
const url = base ? new URL(src, base) : src;
476+
const url = fetchBase ? new URL(src, fetchBase) : src;
477477
return fetch(url);
478478
}
479479
const loadCode = isNode ? loadRelative : fetchRelative;

0 commit comments

Comments
 (0)