async module.import.
Closed this issue · 3 comments
jdalton commented
The basic idea for async module.import
is
Module.prototype.import = function (path) {
return Promise.resolve().then(() => {
const ns = Object.create(null);
module.importSync(path, {
"*": (value, name) => {
ns[name] = value;
}
});
return ns;
});
};
Except that the file needs to retrievable from remote, so http
and https
, and that the promise won't resolve until all of the module's deps and deps of deps are loaded too. That means keeping queue of requests that need to complete.
jdalton commented
Update:
Turns out remote module loading with http
and https
won't likely be supported by Node out of the box so our mockup is pretty close.
Update:
Ok, I got clarification, so we don't have to wait for deps of deps to be loaded either so the mockup is reeaaally close.
benjamn commented
This is fixed now, right?
jdalton commented
Yep! 🎉