How to use the metro-core.AmbiguousModuleResolutionError function in metro-core

To help you get started, we’ve selected a few metro-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook / metro / packages / metro / src / node-haste / DependencyGraph / ResolutionRequest.js View on Github external
const platform = this._options.platform;

    const allowHaste = !this._options.helpers.isNodeModulesDir(fromModule.path);

    try {
      return cacheResult(
        resolver.resolveDependency(
          fromModule,
          toModuleName,
          allowHaste,
          platform,
        ),
      );
    } catch (error) {
      if (error instanceof DuplicateHasteCandidatesError) {
        throw new AmbiguousModuleResolutionError(fromModule.path, error);
      }
      if (error instanceof InvalidPackageError) {
        throw new PackageResolutionError({
          packageError: error,
          originModulePath: fromModule.path,
          targetModuleName: toModuleName,
        });
      }
      throw error;
    }
  }