1"use strict"; 2 3Object.defineProperty(exports, "__esModule", { 4 value: true 5}); 6exports.getDynamicConfig = getDynamicConfig; 7exports.getStaticConfig = getStaticConfig; 8 9function _jsonFile() { 10 const data = _interopRequireDefault(require("@expo/json-file")); 11 12 _jsonFile = function () { 13 return data; 14 }; 15 16 return data; 17} 18 19function _fs() { 20 const data = require("fs"); 21 22 _fs = function () { 23 return data; 24 }; 25 26 return data; 27} 28 29function _Errors() { 30 const data = require("./Errors"); 31 32 _Errors = function () { 33 return data; 34 }; 35 36 return data; 37} 38 39function _evalConfig() { 40 const data = require("./evalConfig"); 41 42 _evalConfig = function () { 43 return data; 44 }; 45 46 return data; 47} 48 49function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 50 51// We cannot use async config resolution right now because Next.js doesn't support async configs. 52// If they don't add support for async Webpack configs then we may need to pull support for Next.js. 53function readConfigFile(configFile, context) { 54 // If the file doesn't exist then we should skip it and continue searching. 55 if (!(0, _fs().existsSync)(configFile)) { 56 return null; 57 } 58 59 try { 60 return (0, _evalConfig().evalConfig)(configFile, context); 61 } catch (error) { 62 // @ts-ignore 63 error.isConfigError = true; 64 error.message = `Error reading Expo config at ${configFile}:\n\n${error.message}`; 65 throw error; 66 } 67} 68 69function getDynamicConfig(configPath, request) { 70 const config = readConfigFile(configPath, request); 71 72 if (config) { 73 // The config must be serialized and evaluated ahead of time so the spawned process can send it over. 74 return config; 75 } // TODO: It seems this is only thrown if the file cannot be found (which may never happen). 76 // If so we should throw a more helpful error. 77 78 79 throw new (_Errors().ConfigError)(`Failed to read config at: ${configPath}`, 'INVALID_CONFIG'); 80} 81 82function getStaticConfig(configPath) { 83 const config = _jsonFile().default.read(configPath, { 84 json5: true 85 }); 86 87 if (config) { 88 return config; 89 } 90 91 throw new (_Errors().ConfigError)(`Failed to read config at: ${configPath}`, 'INVALID_CONFIG'); 92} 93//# sourceMappingURL=getConfig.js.map