import chalk from 'chalk' ; import { watchFile } from 'fs' ; import path from 'path' ; import resolveFrom from 'resolve-from' ; import { ProjectUtils } from '../internal' ; const watchingFiles = [ ] ; /**
 * Get the babel configuration file for the project.
 */ export function getProjectBabelConfigFile ( projectRoot ) { return ( resolveFrom . silent ( projectRoot , './babel.config.js' ) || resolveFrom . silent ( projectRoot , './.babelrc' ) || resolveFrom . silent ( projectRoot , './.babelrc.js' ) ) ; } export function watchBabelConfigForProject ( projectRoot ) { const configPath = getProjectBabelConfigFile ( projectRoot ) ; if ( configPath ) { return watchBabelConfig ( projectRoot , configPath ) ; } return configPath ; } /**
 * Watch the babel configuration file and warn to reload the CLI if it changes.
 */ export function watchBabelConfig ( projectRoot , configPath ) { if ( watchingFiles . includes ( configPath ) ) { return ; } watchingFiles . push ( configPath ) ; const configName = path . relative ( projectRoot , configPath ) ; watchFile ( configPath , ( cur , prev ) => { if ( prev . size || cur . size ) { ProjectUtils . logInfo ( projectRoot , 'expo' , `\u203A Detected a change in ${ chalk . bold ( configName ) }. Restart the server to see the new results.` ) ; } } ) ; }