loadConfig = async ({ configPath, cwd }, logger) => {
  try {
    let result

    if (configPath) {
      debugLog('Loading configuration from `%s`...', configPath)
      result = await loadConfigByExt(resolveConfig(configPath))
    } else {
      debugLog('Searching for configuration from `%s`...', cwd)
      const { lilconfig } = await import('lilconfig')
      const explorer = lilconfig(CONFIG_NAME, { searchPlaces: CONFIG_FILE_NAMES, loaders })
      result = await explorer.search(cwd)
    }

    if (!result) return {}

    // config is a promise when using the `dynamicImport` loader
    const config = (await result.config) ?? null
    const filepath = result.filepath

    debugLog('Successfully loaded config from `%s`:\n%O', filepath, config)

    return { config, filepath }
  } catch (error) {
    debugLog('Failed to load configuration from `%s` with error:\n', configPath, error)
    logger.error(failedToLoadConfig(configPath))
    return {}
  }
}
@param {object} options
@param {string} [options.configPath] - Explicit path to a config file
@param {string} [options.cwd] - Current working directory