param platformImplementations import { resolve } from 'metro-resolver' ; export function reactNativePlatformResolver ( platformImplementations ) { return ( context , _realModuleName , platform , moduleName ) => { let backupResolveRequest = context . resolveRequest ; delete context . resolveRequest ; try { let modifiedModuleName = moduleName ; if ( platformImplementations [ platform ] ) { if ( moduleName === 'react-native' ) { modifiedModuleName = platformImplementations [ platform ] ; } else if ( moduleName . startsWith ( 'react-native/' ) ) { modifiedModuleName = `${ platformImplementations [ platform ] }/${ modifiedModuleName . slice ( 'react-native/' . length ) }` ; } } let result = resolve ( context , modifiedModuleName , platform ) ; return result ; } catch ( e ) { throw e ; } finally { context . resolveRequest = backupResolveRequest ; } } ; }