MCPcopy Create free account
hub / github.com/stenciljs/core / resolveModuleManually

Method resolveModuleManually

src/sys/node/node-resolve-module.ts:82–102  ·  view source on GitHub ↗
(fromDir: string, moduleId: string, cacheKey: string)

Source from the content-addressed store, hash-verified

80 }
81
82 resolveModuleManually(fromDir: string, moduleId: string, cacheKey: string) {
83 const root = normalizePath(path.parse(fromDir).root);
84
85 let dir = normalizePath(path.join(fromDir, 'noop.js'));
86 let packageJsonFilePath: string;
87
88 while (dir !== root) {
89 dir = normalizePath(path.dirname(dir));
90 packageJsonFilePath = path.join(dir, 'node_modules', moduleId, 'package.json');
91
92 if (!fs.existsSync(packageJsonFilePath)) {
93 continue;
94 }
95
96 this.resolveModuleCache.set(cacheKey, packageJsonFilePath);
97
98 return packageJsonFilePath;
99 }
100
101 throw new Error(`error loading "${moduleId}" from "${fromDir}"`);
102 }
103}

Callers 1

resolveModuleMethod · 0.95

Calls 5

normalizePathFunction · 0.85
parseMethod · 0.80
joinMethod · 0.80
dirnameMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected