eight04 / rollup-plugin-iife

Convert ES modules into IIFEs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support import() and import.meta

eight04 opened this issue · comments

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.

commented

Dynamic import is deferred to #20.