module: add path to the module object
This adds the `path` property to the module object. It contains the current directory as path. That is necessary to add an extra caching layer. It also makes sure the `id` uses a default in case it's not set. Otherwise the `path.dirname(id)` command could fail. PR-URL: https://github.com/nodejs/node/pull/26970 Refs: https://github.com/nodejs/node/pull/25362 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
be577615c8
commit
d0043136e5
@ -98,8 +98,9 @@ function updateChildren(parent, child, scan) {
|
||||
children.push(child);
|
||||
}
|
||||
|
||||
function Module(id, parent) {
|
||||
function Module(id = '', parent) {
|
||||
this.id = id;
|
||||
this.path = path.dirname(id);
|
||||
this.exports = {};
|
||||
this.parent = parent;
|
||||
updateChildren(parent, this, false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user