Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function preloadImports(parsedModule, parent){
for (var i = 0, l = parsedModule.imports.length; i < l; i++){
var path = parsedModule.imports[i];
if (!(path in aliases)){
if (path in testObject)
path = path + '.js'; // Resolve Node cache bug
parsedModule.imports[i] = path = Module._resolveFilename(path, parent);
}
if (Path.extname(aliases[path] || path) == '.js' && !Object.prototype.hasOwnProperty.call(require.cache, path)){
var mod = new Module(path, parent);
mod.filename = path;
preload(path, mod);
}
}
}
function resolve(moduleName) {
let resolved = NodeModule._resolveFilename(moduleName, _parentModule);
return (resolved instanceof Array) ? resolved[1] : resolved;
}
function resolve(mainModule) {
if (!mainModule.startsWith('/'))
throw new Error('Invalid relative module path');
if (require.resolve)
return require.resolve(mainModule);
else
return Module._resolveFilename(mainModule, module, false);
}