function buildRegExps(
  basePath /*: string */,
  dirPaths /*: $ReadOnlyArray<RegExp | string> */,
) /*: $ReadOnlyArray<RegExp> */ {
  return dirPaths.map(folderPath =>
    // Babel cares about Windows/Unix paths since v7b44
    // https://github.com/babel/babel/issues/8184
    // basePath + path.sep + dirPath/dirRegex
    // /home/name/webroot/js + / + relative/path/to/exclude
    // c:\home\name\webroot\js + \ + relative\path\to\exclude
    folderPath instanceof RegExp
      ? new RegExp(
          `^${escapeRegExp(path.resolve(basePath, '.') + path.sep)}${
            folderPath.source // This is an actual regex value, don't escape it.
          }`,
          folderPath.flags,
        )
      : new RegExp('^' + escapeRegExp(path.resolve(basePath, folderPath))),
  );
}
We use absolute paths for matching only the top-level folders reliably. For
example, we would not want to match some deeply nested folder that happens to
have the same name as one of `BABEL_ENABLED_PATHS`.