import { getAvailablePlatforms } from "@rnx-kit/tools-react-native" ; import type { ResolverLog } from "./log" ; const DEFAULT_PACKAGE_NAME = "react-native" ; param currentDirectory param platform param disableReactNativePackageSubstitution param log returns export function createReactNativePackageNameReplacer ( currentDirectory , platform , disableReactNativePackageSubstitution , log ) { const platformPackageName = getAvailablePlatforms ( currentDirectory ) [ platform ] ; if ( ! platformPackageName || disableReactNativePackageSubstitution ) { return ( m ) => m ; } return ( m ) : string => { if ( ! m . startsWith ( DEFAULT_PACKAGE_NAME ) ) { return m ; } const replaced = platformPackageName + m . substring ( DEFAULT_PACKAGE_NAME . length ) ; log . log ( "Substituting module '%s' with '%s'." , m , replaced ) ; return replaced ; } ; }