我有一个UMD库,并且在commonjs中有以下作品...
global.window = global;
var DoSomething = require("../dist/sce-umd.js").DoSomething;
(function(){
var instance = new DoSomething();
instance.doSomethingElse();
})()
我正在尝试对ESM做同样的事情,例如...
(()=>{
// Needed for UMD
global.window = global;
import("../dist/sce-umd.js").then((OtherThing)=>{
console.log("This is the next level");
const other = new OtherThing();
other.doSomethingElse();
});
})();
但是我得到...
TypeError:OtherThing不是构造函数
我也尝试过new OtherThing.DoSomething()
,但我得到了...
TypeError:OtherThing.DoSomething不是构造函数