You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
It's almost possible to build lookup of other resources (like browser-side javascript resources) on top of the node.js require system. The only thing missing is the ability to resolve lookups relative to a module.
Adding the following to module.js exposes that functionality cleanly:
This is something I just needed myself as well, so I'm definitely for adding the resolve method to Module.prototype.require. The current work-around of using Module._resolveFilename directly with, for example, the given module.parent is obviously risky.
We won't be adding any API or functionality to the module system any time soon. The algorithm is pretty simple, and easy to implement in userland modules (as browserify does).
It's almost possible to build lookup of other resources (like browser-side javascript resources) on top of the node.js require system. The only thing missing is the ability to resolve lookups relative to a module.
Adding the following to module.js exposes that functionality cleanly:
Module.prototype.resolve = function(path) {
return Module._resolveFilename(path, this);
};
Alternatively, changing require.resolve to take a path from which to start would be an even more flexible solution.
The text was updated successfully, but these errors were encountered: