Closed patgoley closed 7 years ago
Standard node require behavior will look for somePath and also somePath/index.js, so NodeKit should probably do the same.
somePath
somePath/index.js
I'm thinking the js implementation of require should be updated to the following:
BootstrapModule.prototype.require = function(id) { if (id == 'native_module') { return BootstrapModule; } if (id[0] == ".") { id = _absolutePath(this.__dirname + '/', id); } var cached; var isPossibleDirectoryRequire = id.indexOf('index.js') == -1; var directoryIndexId = id + '/index.js'; if (isPossibleDirectoryRequire) { cached = BootstrapModule.getCached(directoryIndexId); if (cached) { return cached.exports } } var cached = BootstrapModule.getCached(id); if (cached) { return cached.exports; } process.moduleLoadList.push('BootstrapModule ' + id); var bootstrapModule = new BootstrapModule(id); bootstrapModule.cache(); bootstrapModule.load(); if (Object.keys(bootstrapModule.exports).length == 0 && isPossibleDirectoryRequire { return BootstrapModule.require(directoryIndexId) } return bootstrapModule.exports; };
Standard node require behavior will look for
somePath
and alsosomePath/index.js
, so NodeKit should probably do the same.I'm thinking the js implementation of require should be updated to the following: