function* interpretExports(name, exports, conditions) {
  if (isArray(exports)) {
    for (const section of exports) {
      const results = [...interpretExports(name, section, conditions)];
      if (results.length > 0) {
        yield* results;
        break;
      }
    }
  }
  if (typeof exports === 'string') {
    yield [name, relativize(exports)];
    return;
  }
  if (Object(exports) !== exports) {
    throw Error(
      `Cannot interpret package.json exports property for package ${name}, must be string or object, got ${exports}`,
    );
  }
  for (const [key, value] of entries(exports)) {
    // "./" is explicitly an invalid key, but that doesn't
    // stop people from trying to use it.
    if (key === './') {
      // eslint-disable-next-line no-continue
      continue; // or no-op
    } else if (key.startsWith('./') || key === '.') {
      if (name === '.') {
        yield* interpretExports(key, value, conditions);
      } else {
        yield* interpretExports(join(name, key), value, conditions);
      }
    } else if (conditions.has(key)) {
      yield* interpretExports(name, value, conditions);
      // Take only the first matching tag.
      break;
    }
  }
}
@param {string} name - the name of the referrer package.
@param {object} exports - the `exports` field from a package.json.
@param {Set<string>} conditions - build conditions about the target environment
for selecting relevant exports, e.g., "browser" or "node".
@yields {[string, string]}
@returns {Generator<[string, string]>}