Support import() and import.meta
eight04 opened this issue · comments
eight commented
import()
import("./foo.js").then(console.log);
to
myImport("./foo.js", document.currentScript.src).then(console.log);
import.meta
console.log(import.meta.url);
to
console.log(document.currentScript.src);
Throw other import.meta.*
Sometimes document.currentScript.src
may not work e.g. in worker. We may need something like:
typeof document !== "undefined" && document.currentScript && document.currentScript.src || typeof location !== "undefined" && location.href || ""
We can use resolveImportMeta
and renderDynamicImport
.