File size: 672 Bytes
bee6636 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import { ScramjetClient } from "../client";
import { config } from "../../shared";
import { rewriteUrl } from "../../shared/rewriters/url";
export default function (client: ScramjetClient, self: Self) {
const Function = client.natives.store["Function"];
self[config.globals.importfn] = function (base: string, url: string) {
const resolved = new URL(url, base).href;
return Function(
`return import("${rewriteUrl(resolved, client.meta)}?type=module")`
)();
};
self[config.globals.metafn] = function (base: string) {
return {
url: base,
resolve: function (url: string) {
return new URL(url, base).href;
},
};
};
}
|