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,CAAC;KACtB;IACD,MAAM,IAAI,oBAAW,CAAC,6BAA6B,UAAU,EAAE,EAAE,gBAAgB,CAAC,CAAC;AACrF,CAAC;AAND,0CAMC","sourcesContent":["import JsonFile from '@expo/json-file';\n\nimport { AppJSONConfig, ConfigContext, ExpoConfig } from './Config.types';\nimport { ConfigError } from './Errors';\nimport { DynamicConfigResults, evalConfig } from './evalConfig';\n\nfunction isMissingFileCode(code: string): boolean {\n return ['ENOENT', 'MODULE_NOT_FOUND', 'ENOTDIR'].includes(code);\n}\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 try {\n return evalConfig(configFile, context);\n } catch (error) {\n // If the file doesn't exist then we should skip it and continue searching.\n if (!isMissingFileCode(error.code)) {\n // @ts-ignore\n error.isConfigError = true;\n // @ts-ignore: Replace the babel stack with a more relevant stack.\n error.stack = new Error().stack;\n throw error;\n }\n }\n return null;\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"]} |