1{"version":3,"file":"getConfig.js","names":["readConfigFile","configFile","context","existsSync","evalConfig","error","isConfigError","message","getDynamicConfig","configPath","request","config","ConfigError","getStaticConfig","JsonFile","read","json5"],"sources":["../src/getConfig.ts"],"sourcesContent":["import JsonFile from '@expo/json-file';\nimport { existsSync } from 'fs';\n\nimport { AppJSONConfig, ConfigContext, ExpoConfig } from './Config.types';\nimport { ConfigError } from './Errors';\nimport { DynamicConfigResults, evalConfig } from './evalConfig';\n\n// We cannot use async config resolution right now because Next.js doesn't support async configs.\n// If they don't add support for async Webpack configs then we may need to pull support for Next.js.\nfunction readConfigFile(configFile: string, context: ConfigContext): null | DynamicConfigResults {\n  // If the file doesn't exist then we should skip it and continue searching.\n  if (!existsSync(configFile)) {\n    return null;\n  }\n  try {\n    return evalConfig(configFile, context);\n  } catch (error: any) {\n    // @ts-ignore\n    error.isConfigError = true;\n    error.message = `Error reading Expo config at ${configFile}:\\n\\n${error.message}`;\n    throw error;\n  }\n}\n\nexport function getDynamicConfig(configPath: string, request: ConfigContext): DynamicConfigResults {\n  const config = readConfigFile(configPath, request);\n  if (config) {\n    // The config must be serialized and evaluated ahead of time so the spawned process can send it over.\n    return config;\n  }\n  // TODO: It seems this is only thrown if the file cannot be found (which may never happen).\n  // If so we should throw a more helpful error.\n  throw new ConfigError(`Failed to read config at: ${configPath}`, 'INVALID_CONFIG');\n}\n\nexport function getStaticConfig(configPath: string): AppJSONConfig | ExpoConfig {\n  const config = JsonFile.read(configPath, { json5: true });\n  if (config) {\n    return config as any;\n  }\n  throw new ConfigError(`Failed to read config at: ${configPath}`, 'INVALID_CONFIG');\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;AAEA;AACA;AACA,SAASA,cAAT,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