MCPcopy Index your code
hub / github.com/nodejs/node / resolve

Method resolve

lib/internal/modules/package_map.js:173–195  ·  view source on GitHub ↗

* Main resolution method. * Returns the package path and subpath for the specifier, or undefined if * the specifier is not in the parent package's dependencies. * Throws ERR_PACKAGE_MAP_EXTERNAL_FILE if parentPath is not within any * mapped package. * @param {string} specifier * @p

(specifier, parentPath)

Source from the content-addressed store, hash-verified

171 * @returns {{packagePath: string, subpath: string}|undefined}
172 */
173 resolve(specifier, parentPath) {
174 const parentKey = this.#getKeyForPath(parentPath);
175
176 if (parentKey === null) {
177 throw new ERR_PACKAGE_MAP_EXTERNAL_FILE(specifier, parentPath, this.#configPath);
178 }
179
180 const { packageName, subpath } = parsePackageName(specifier);
181 const parentEntry = this.#packages.get(parentKey);
182
183 const targetKey = parentEntry.dependencies.get(packageName);
184 if (targetKey === undefined) {
185 // Package not in parent's dependencies - let the caller throw the appropriate error
186 return undefined;
187 }
188
189 const targetEntry = this.#packages.get(targetKey);
190 if (!targetEntry) {
191 throw new ERR_PACKAGE_MAP_KEY_NOT_FOUND(targetKey, this.#configPath);
192 }
193
194 return { packagePath: targetEntry.path, subpath };
195 }
196}
197
198/**

Callers 15

pathToFileURLFunction · 0.45
readNextFunction · 0.45
constructorMethod · 0.45
getRelativePathFunction · 0.45
saveMethod · 0.45
takeHeapSnapshotFunction · 0.45
resolveMainPathFunction · 0.45
packageMapResolveFunction · 0.45
addReadySubtestMethod · 0.45
waitForBuildPhaseFunction · 0.45
constructorMethod · 0.45

Calls 3

#getKeyForPathMethod · 0.95
parsePackageNameFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected