gatherDependency = async (
  readDescriptor,
  canonical,
  graph,
  dependencyLocations,
  packageLocation,
  name,
  conditions,
  preferredPackageLogicalPathMap,
  languageOptions,
  strict,
  {
    childLogicalPath = [],
    optional = false,
    commonDependencyDescriptors = {},
    log = noop,
  } = {},
) => {
  const dependency = await findPackage(
    readDescriptor,
    canonical,
    packageLocation,
    name,
  );
  if (dependency === undefined) {
    // allow the dependency to be missing if optional
    if (optional || !strict) {
      return;
    }
    throw Error(`Cannot find dependency ${name} for ${packageLocation}`);
  }
  dependencyLocations[name] = dependency.packageLocation;

  const bestLogicalPath = currentBestLogicalPath(
    childLogicalPath,
    dependency.packageLocation,
    preferredPackageLogicalPathMap,
  );

  if (bestLogicalPath === childLogicalPath) {
    preferredPackageLogicalPathMap.set(
      dependency.packageLocation,
      bestLogicalPath,
    );
  }

  await graphPackage(
    name,
    readDescriptor,
    canonical,
    graph,
    dependency,
    conditions,
    false,
    languageOptions,
    strict,
    {
      commonDependencyDescriptors,
      preferredPackageLogicalPathMap,
      logicalPath: childLogicalPath,
      log,
    },
  );
}
Adds information for the dependency of the package at `packageLocation` to the `graph` object.

@param {ReadDescriptorFn} readDescriptor
@param {CanonicalFn} canonical
@param {Graph} graph - the partially build graph.
@param {Record<string, string>} dependencyLocations
@param {string} packageLocation - location of the package of interest.
@param {string} name - name of the package of interest.
@param {Set<string>} conditions
@param {Map<string, Array<string>>} preferredPackageLogicalPathMap
@param {LanguageOptions} languageOptions
@param {boolean} strict - If `true`, a missing dependency will throw an exception
@param {GatherDependencyOptions} options
@returns {Promise<void>}