MCPcopy
hub / github.com/meteor/meteor / resolve

Method resolve

tools/isobuild/compiler-plugin.js:365–398  ·  view source on GitHub ↗
(id, parentPath)

Source from the content-addressed store, hash-verified

363 }
364
365 resolve(id, parentPath) {
366 parentPath = parentPath || files.pathJoin(
367 this.getSourceRoot(),
368 this.getPathInPackage()
369 );
370
371 const resId = this._resolveCacheLookup(id, parentPath);
372 if (resId) {
373 return resId;
374 }
375
376 const parentStat = optimisticStatOrNull(parentPath);
377 if (! parentStat ||
378 ! parentStat.isFile()) {
379 throw new Error("Not a file: " + parentPath);
380 }
381
382 const batch = this._resourceSlot.packageSourceBatch;
383 const resolver = batch.getResolver({
384 // Make sure we use a server architecture when resolving, so that we
385 // don't accidentally use package.json "browser" fields.
386 // https://github.com/meteor/meteor/issues/9870
387 targetArch: archinfo.host(),
388 });
389 const resolved = resolver.resolve(id, parentPath);
390
391 if (resolved === "missing") {
392 const error = new Error("Cannot find module '" + id + "'");
393 error.code = "MODULE_NOT_FOUND";
394 throw error;
395 }
396
397 return this._resolveCacheStore(id, parentPath, resolved.id);
398 }
399
400 require(id, parentPath) {
401 return this._require(id, parentPath);

Callers 3

_requireMethod · 0.95
finalizeMethod · 0.45
_linkJSMethod · 0.45

Calls 5

getSourceRootMethod · 0.95
getPathInPackageMethod · 0.95
_resolveCacheLookupMethod · 0.95
_resolveCacheStoreMethod · 0.95
getResolverMethod · 0.80

Tested by

no test coverage detected