1{"version":3,"file":"getModulesPaths.js","names":["getWorkspaceRoot","projectRoot","findWorkspaceRoot","error","message","includes","getModulesPaths","paths","workspaceRoot","path","resolve","push"],"sources":["../src/getModulesPaths.ts"],"sourcesContent":["import findWorkspaceRoot from 'find-yarn-workspace-root';\nimport path from 'path';\n\n/** Wraps `findWorkspaceRoot` and guards against having an empty `package.json` file in an upper directory. */\nexport function getWorkspaceRoot(projectRoot: string): string | null {\n  try {\n    return findWorkspaceRoot(projectRoot);\n  } catch (error: any) {\n    if (error.message.includes('Unexpected end of JSON input')) {\n      return null;\n    }\n    throw error;\n  }\n}\n\nexport function getModulesPaths(projectRoot: string): string[] {\n  const paths: string[] = [];\n\n  // Only add the project root if it's not the current working directory\n  // this minimizes the chance of Metro resolver breaking on new Node.js versions.\n  const workspaceRoot = getWorkspaceRoot(path.resolve(projectRoot)); // Absolute path or null\n  if (workspaceRoot) {\n    paths.push(path.resolve(projectRoot));\n    paths.push(path.resolve(workspaceRoot, 'node_modules'));\n  }\n\n  return paths;\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;AAEA;AACO,SAASA,gBAAT,CAA0BC,WAA1B,EAA8D;EACnE,IAAI;IACF,OAAO,IAAAC,gCAAA,EAAkBD,WAAlB,CAAP;EACD,CAFD,CAEE,OAAOE,KAAP,EAAmB;IACnB,IAAIA,KAAK,CAACC,OAAN,CAAcC,QAAd,CAAuB,8BAAvB,CAAJ,EAA4D;MAC1D,OAAO,IAAP;IACD;;IACD,MAAMF,KAAN;EACD;AACF;;AAEM,SAASG,eAAT,CAAyBL,WAAzB,EAAwD;EAC7D,MAAMM,KAAe,GAAG,EAAxB,CAD6D,CAG7D;EACA;;EACA,MAAMC,aAAa,GAAGR,gBAAgB,CAACS,eAAA,CAAKC,OAAL,CAAaT,WAAb,CAAD,CAAtC,CAL6D,CAKM;;EACnE,IAAIO,aAAJ,EAAmB;IACjBD,KAAK,CAACI,IAAN,CAAWF,eAAA,CAAKC,OAAL,CAAaT,WAAb,CAAX;IACAM,KAAK,CAACI,IAAN,CAAWF,eAAA,CAAKC,OAAL,CAAaF,aAAb,EAA4B,cAA5B,CAAX;EACD;;EAED,OAAOD,KAAP;AACD"}