code: function resolveModulePath(
    context: ModulePathContext,
    toModuleName: string,
    platform: string | null,
  ): Resolution {
    const modulePath = isAbsolutePath(toModuleName)
      ? resolveWindowsPath(toModuleName)
      : path.join(path.dirname(context.originModulePath), toModuleName);
    const redirectedPath = context.redirectModulePath(modulePath);
    if (redirectedPath === false) {
      return {type: 'empty'};
    }
    const result = resolveFileOrDir(context, redirectedPath, platform);
    if (result.type === 'resolved') {
      return result.resolution;
    }
    throw new FailedToResolvePathError(result.candidates);
  }
docs: Resolve any kind of module path, whether it's a file or a directory.
  For example we may want to resolve './foobar'. The closest
  `package.json` may define a redirection for this path, for example
  `/smth/lib/foobar`, that may be further resolved to
  `/smth/lib/foobar/index.ios.js`.