(mod, id, direct)
| 84 | const cacheBuiltins = {__proto__: null}; |
| 85 | |
| 86 | function requireImpl(mod, id, direct) { |
| 87 | if (direct && mod.require !== originalRequire) { |
| 88 | return mod.require(id); |
| 89 | } |
| 90 | const filename = resolve0(mod, id, undefined, Module._extensions, direct); |
| 91 | if (localStringPrototypeStartsWith(filename, 'node:')) { |
| 92 | id = localStringPrototypeSlice(filename, 5); |
| 93 | let nmod = cacheBuiltins[id]; |
| 94 | if (!nmod) { |
| 95 | nmod = loadBuiltinModule(id); |
| 96 | if (!nmod) throw new VMError(`Cannot find module '${filename}'`, 'ENOTFOUND'); |
| 97 | cacheBuiltins[id] = nmod; |
| 98 | } |
| 99 | return nmod; |
| 100 | } |
| 101 | |
| 102 | const cachedModule = Module._cache[filename]; |
| 103 | if (cachedModule !== undefined) { |
| 104 | mod._updateChildren(cachedModule, false); |
| 105 | return cachedModule.exports; |
| 106 | } |
| 107 | |
| 108 | let nmod = cacheBuiltins[id]; |
| 109 | if (nmod) return nmod; |
| 110 | nmod = loadBuiltinModule(id); |
| 111 | if (nmod) { |
| 112 | cacheBuiltins[id] = nmod; |
| 113 | return nmod; |
| 114 | } |
| 115 | |
| 116 | const path = dirname(filename); |
| 117 | const module = new Module(filename, path, mod); |
| 118 | registerModule(module, filename, path, mod, direct); |
| 119 | mod._updateChildren(module, true); |
| 120 | try { |
| 121 | Module._cache[filename] = module; |
| 122 | const handler = findBestExtensionHandler(filename); |
| 123 | handler(module, filename); |
| 124 | module.loaded = true; |
| 125 | } catch (e) { |
| 126 | delete Module._cache[filename]; |
| 127 | const children = mod.children; |
| 128 | if (localArrayIsArray(children)) { |
| 129 | const index = localArrayPrototypeIndexOf(children, module); |
| 130 | if (index !== -1) { |
| 131 | localArrayPrototypeSplice(children, index, 1); |
| 132 | } |
| 133 | } |
| 134 | throw e; |
| 135 | } |
| 136 | |
| 137 | return module.exports; |
| 138 | } |
| 139 | |
| 140 | Module.builtinModules = ensureSandboxArray(builtinModules); |
| 141 | Module.globalPaths = ensureSandboxArray(globalPaths); |
no test coverage detected
searching dependent graphs…