rewrite import.meta

This commit is contained in:
velzie 2024-08-09 17:41:34 -04:00
parent a12e1bb539
commit 066777fe94
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
6 changed files with 43 additions and 24 deletions

View file

@ -1,11 +1,20 @@
import { config, encodeUrl } from "../shared";
export default function (client, self) {
self[config.importfn] = function (base) {
return function (url) {
self[config.importfn] = function (base: string) {
return function (url: string) {
const resolved = new URL(url, base).href;
return Function(`return import("${encodeUrl(resolved)}")`)();
};
};
self[config.metafn] = function (base: string) {
return {
url: base,
resolve: function (url: string) {
return new URL(url, base).href;
},
};
};
}