rnx-kit/packages/tools-react-native
React Native SDK Bot dcd48a377d
RELEASING: Releasing 2 package(s) (#3426)
Releases:
  @rnx-kit/tools-react-native@2.0.2
  @rnx-kit/config@0.7.1

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-11-21 17:09:00 +01:00
..
src fix(tools-react-native): support loading ESM config files (#3422) 2024-11-19 20:00:19 +01:00
test feat(tools-react-native): add caching layer on top of `loadConfig` (#3261) 2024-08-06 18:48:48 +02:00
CHANGELOG.md RELEASING: Releasing 2 package(s) (#3426) 2024-11-21 17:09:00 +01:00
README.md fix(tools-react-native): support loading ESM config files (#3422) 2024-11-19 20:00:19 +01:00
cache.d.ts feat(tools-react-native): add caching layer on top of `loadConfig` (#3261) 2024-08-06 18:48:48 +02:00
cache.js feat(tools-react-native): add caching layer on top of `loadConfig` (#3261) 2024-08-06 18:48:48 +02:00
context.d.ts fix(tools-react-native): add `loadContextAsync` to exported types (#3424) 2024-11-20 18:58:01 +01:00
context.js feat(tools-react-native): add caching layer on top of `loadConfig` (#3261) 2024-08-06 18:48:48 +02:00
eslint.config.js
metro.d.ts
metro.js
package.json RELEASING: Releasing 2 package(s) (#3426) 2024-11-21 17:09:00 +01:00
platform.d.ts
platform.js
tsconfig.json

README.md

@rnx-kit/tools-react-native

Build npm version

@rnx-kit/tools-react-native is a collection of supplemental react-native functions and types.

You can import the entire package, or, to save space, import individual categories:

import * as tools from "@rnx-kit/tools-react-native";

// Alternatively...
import * as metroTools from "@rnx-kit/tools-react-native/metro";
import * as platformTools from "@rnx-kit/tools-react-native/platform";
Category Type Name Description
platform AllPlatforms List of supported react-native platforms.
Category Function Description
context loadContext(projectRoot) Equivalent to calling loadConfig() from @react-native-community/cli, but the result is cached for faster subsequent accesses.
context loadContextAsync(projectRoot) Equivalent to calling loadConfigAsync() (with fallback to loadConfig()) from @react-native-community/cli, but the result is cached for faster subsequent accesses.
context resolveCommunityCLI(root, reactNativePath) Finds path to @react-native-community/cli.
metro findMetroPath(projectRoot) Finds the installation path of Metro.
metro getMetroVersion(projectRoot) Returns Metro version number.
metro requireModuleFromMetro(moduleName, fromDir) Imports specified module starting from the installation directory of the currently used metro version.
platform expandPlatformExtensions(platform, extensions) Returns a list of extensions that should be tried for the target platform in prioritized order.
platform getAvailablePlatforms(startDir) Returns a map of available React Native platforms. The result is cached.
platform getAvailablePlatformsUncached(startDir, platformMap) Returns a map of available React Native platforms. The result is NOT cached.
platform parsePlatform(val) Parse a string to ensure it maps to a valid react-native platform.
platform platformExtensions(platform) Returns file extensions that can be mapped to the target platform.