mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
26 lines
710 B
JavaScript
26 lines
710 B
JavaScript
const Module = module.constructor;
|
|
const Mp = Module.prototype;
|
|
|
|
Mp.resolve = function (id) {
|
|
return Module._resolveFilename(id, this);
|
|
};
|
|
|
|
// Enable the module.{watch,export,...} runtime API needed by Reify.
|
|
require("reify/lib/runtime").enable(Mp);
|
|
|
|
const moduleLoad = Mp.load;
|
|
Mp.load = function (filename) {
|
|
const result = moduleLoad.apply(this, arguments);
|
|
if (typeof this.runSetters === "function") {
|
|
// Make sure we call module.runSetters (or module.runModuleSetters, a
|
|
// legacy synonym) whenever a module finishes loading.
|
|
this.runSetters();
|
|
}
|
|
return result;
|
|
};
|
|
|
|
const resolved = Promise.resolve();
|
|
Mp.dynamicImport = function (id) {
|
|
return resolved.then(() => require(id));
|
|
};
|