1"use strict"; 2 3Object.defineProperty(exports, "__esModule", { 4 value: true 5}); 6exports.getModulesPaths = getModulesPaths; 7exports.getServerRoot = getServerRoot; 8exports.getWorkspaceRoot = getWorkspaceRoot; 9function _findYarnWorkspaceRoot() { 10 const data = _interopRequireDefault(require("find-yarn-workspace-root")); 11 _findYarnWorkspaceRoot = function () { 12 return data; 13 }; 14 return data; 15} 16function _path() { 17 const data = _interopRequireDefault(require("path")); 18 _path = function () { 19 return data; 20 }; 21 return data; 22} 23function _env() { 24 const data = require("./env"); 25 _env = function () { 26 return data; 27 }; 28 return data; 29} 30function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 31/** Wraps `findWorkspaceRoot` and guards against having an empty `package.json` file in an upper directory. */ 32function getWorkspaceRoot(projectRoot) { 33 try { 34 return (0, _findYarnWorkspaceRoot().default)(projectRoot); 35 } catch (error) { 36 if (error.message.includes('Unexpected end of JSON input')) { 37 return null; 38 } 39 throw error; 40 } 41} 42function getModulesPaths(projectRoot) { 43 const paths = []; 44 45 // Only add the project root if it's not the current working directory 46 // this minimizes the chance of Metro resolver breaking on new Node.js versions. 47 const workspaceRoot = getWorkspaceRoot(_path().default.resolve(projectRoot)); // Absolute path or null 48 if (workspaceRoot) { 49 paths.push(_path().default.resolve(projectRoot)); 50 paths.push(_path().default.resolve(workspaceRoot, 'node_modules')); 51 } 52 return paths; 53} 54function getServerRoot(projectRoot) { 55 var _getWorkspaceRoot; 56 return _env().env.EXPO_USE_METRO_WORKSPACE_ROOT ? (_getWorkspaceRoot = getWorkspaceRoot(projectRoot)) !== null && _getWorkspaceRoot !== void 0 ? _getWorkspaceRoot : projectRoot : projectRoot; 57} 58//# sourceMappingURL=getModulesPaths.js.map