or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli-commands.mddependency-management.mdindex.mdmodule-discovery.mdplatform-support.mdreact-native-integration.md
tile.json

tessl/npm-expo-modules-autolinking

Scripts that autolink Expo modules.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/expo-modules-autolinking@3.0.x

To install, run

npx @tessl/cli install tessl/npm-expo-modules-autolinking@3.0.0

index.mddocs/

Expo Modules Autolinking

Expo Modules Autolinking provides automated native dependency configuration for React Native and Expo projects through a comprehensive autolinking system. It eliminates manual native module configuration by automatically discovering, resolving, and linking native dependencies across multiple platforms (iOS, Android, macOS, tvOS, devtools), supporting both individual projects and monorepo structures.

Package Information

  • Package Name: expo-modules-autolinking
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install expo-modules-autolinking

Core Imports

import { 
  queryAutolinkingModulesFromProjectAsync,
  makeCachedDependenciesLinker,
  ModuleDescriptor, 
  SupportedPlatform,
  ResolutionResult
} from "expo-modules-autolinking";

For CommonJS:

const { 
  queryAutolinkingModulesFromProjectAsync,
  makeCachedDependenciesLinker
} = require("expo-modules-autolinking");

Basic Usage

import { 
  queryAutolinkingModulesFromProjectAsync,
  SupportedPlatform 
} from "expo-modules-autolinking";

// Query modules for a specific platform
const modules = await queryAutolinkingModulesFromProjectAsync(
  "/path/to/project",
  { platform: "ios" }
);

console.log("Found modules:", modules.map(m => m.packageName));

Architecture

Expo Modules Autolinking is built around several key components:

  • CLI Tool: Standalone binary with commands for searching, resolving, and configuring modules
  • Module Discovery: Automatic scanning and identification of Expo modules in project dependencies
  • Platform Support: Cross-platform linking for iOS, Android, macOS, tvOS, and devtools
  • Dependency Resolution: Advanced dependency resolution with duplicate detection and caching
  • React Native Integration: Seamless integration with React Native CLI and build systems

Capabilities

CLI Tool Interface

Command-line interface with comprehensive commands for module discovery, resolution, package list generation, and configuration verification.

// CLI main function
function main(args: string[]): Promise<void>;

CLI Commands

Module Discovery and Resolution

Core functionality for finding and resolving Expo modules with support for custom search paths and platform-specific configuration.

/**
 * Find modules in specified search paths and app root
 * @param params - Find modules parameters
 * @returns Promise resolving to search results
 */
function findModulesAsync(params: FindModulesParams): Promise<SearchResults>;

interface FindModulesParams {
  appRoot: string;
  autolinkingOptions: AutolinkingOptions & { platform: SupportedPlatform };
}

/**
 * Resolve found modules into platform-specific descriptors
 * @param searchResults - Results from findModulesAsync
 * @param options - Autolinking options
 * @returns Promise resolving to module descriptors
 */
function resolveModulesAsync(
  searchResults: SearchResults,
  options: AutolinkingOptions
): Promise<ModuleDescriptor[]>;

/** @deprecated Use the newer autolinking options loader system instead */
interface QueryAutolinkingModulesFromProjectParams extends Partial<AutolinkingCommonArguments> {
  platform: SupportedPlatform;
  [extra: string]: unknown;
}

/** @deprecated Use the newer autolinking options loader system instead */
function queryAutolinkingModulesFromProjectAsync(
  projectRoot: string,
  options: QueryAutolinkingModulesFromProjectParams
): Promise<ModuleDescriptor[]>;

Module Discovery

Configuration Management

Autolinking options loading and configuration management system.

/**
 * Create an autolinking options loader for project configuration
 * @param argumentsOptions - Optional common arguments
 * @returns Options loader instance
 */
function createAutolinkingOptionsLoader(
  argumentsOptions?: AutolinkingCommonArguments
): LinkingOptionsLoader;

interface LinkingOptionsLoader {
  getCommandRoot(): string;
  getAppRoot(): Promise<string>;
  getPlatformOptions<T extends SupportedPlatform | undefined>(
    platform: T
  ): Promise<AutolinkingOptions & { platform: T }>;
  getPlatformOptions(): Promise<AutolinkingOptions>;
}

interface AutolinkingOptions {
  legacy_shallowReactNativeLinking: boolean;
  searchPaths: string[];
  nativeModulesDir: string | null;
  exclude: string[];
  buildFromSource?: string[];
  flags?: Record<string, any>;
}

Dependency Management

Advanced dependency resolution system with caching, workspace support, and duplicate detection for efficient module management.

interface CachedDependenciesLinker {
  getOptionsForPlatform(platform: SupportedPlatform): Promise<CachedDependenciesSearchOptions>;
  loadReactNativeProjectConfig(): Promise<RNConfigReactNativeProjectConfig | null>;
  scanDependenciesFromRNProjectConfig(): Promise<ResolutionResult>;
  scanDependenciesRecursively(): Promise<ResolutionResult>;
  scanDependenciesInSearchPath(searchPath: string): Promise<ResolutionResult>;
}

function makeCachedDependenciesLinker(params: {
  projectRoot: string;
}): CachedDependenciesLinker;

function scanDependencyResolutionsForPlatform(
  linker: CachedDependenciesLinker,
  platform: SupportedPlatform,
  include?: string[]
): Promise<ResolutionResult>;

function scanExpoModuleResolutionsForPlatform(
  linker: CachedDependenciesLinker,
  platform: SupportedPlatform
): Promise<Record<string, PackageRevision>>;

Dependency Management

Platform Support

Platform-specific implementations for iOS, Android, macOS, tvOS, and devtools with native build system integration.

function getLinkingImplementationForPlatform(
  platform: SupportedPlatform
): PlatformImplementation;

Platform Support

Module Configuration

Expo module configuration loading and management.

/**
 * Expo module configuration class for loading and accessing module metadata
 */
class ExpoModuleConfig {
  constructor(readonly rawConfig: RawExpoModuleConfig);
  
  /** Check if module supports the specified platform */
  supportsPlatform(platform: SupportedPlatform): boolean;
  
  /** Get Apple/iOS specific configuration */
  getAppleConfig(): RawModuleConfigApple | null;
  
  /** Get list of Apple modules */
  appleModules(): string[];
  
  /** Get Apple app delegate subscribers */
  appleAppDelegateSubscribers(): string[];
  
  /** Get Apple React delegate handlers */
  appleReactDelegateHandlers(): string[];
  
  /** Get Apple podspec paths */
  applePodspecPaths(): string[];
  
  /** Get Apple Swift module names */
  appleSwiftModuleNames(): string[];
  
  /** Check if module is debug-only for Apple platforms */
  appleDebugOnly(): boolean;
  
  /** Get Android project configurations */
  androidProjects(defaultProjectName: string): ExpoAndroidProjectConfig[];
  
  /** Get Android Gradle plugins */
  androidGradlePlugins(): AndroidGradlePluginDescriptor[];
  
  /** Get Android AAR project configurations */
  androidGradleAarProjects(): AndroidGradleAarProjectDescriptor[];
  
  /** Get Android publication configuration */
  androidPublication(): AndroidPublication | undefined;
  
  /** Get core features provided by module */
  coreFeatures(): string[];
  
  /** Convert to JSON representation */
  toJSON(): RawExpoModuleConfig;
}

/**
 * Discover and load Expo module configuration from directory
 * @param directoryPath - Path to search for module configuration
 * @returns Promise resolving to module config or null if not found
 */
function discoverExpoModuleConfigAsync(
  directoryPath: string
): Promise<ExpoModuleConfig | null>;

React Native Configuration

React Native CLI configuration generation for seamless integration with existing React Native projects and build workflows.

interface RNConfigReactNativeProjectConfig {
  dependencies: { [packageName: string]: any };
  commands: any[];
  platforms: any;
  project: any;
}

/**
 * Create React Native configuration for autolinking
 * @param params - Configuration parameters
 * @returns Promise resolving to React Native config
 */
function createReactNativeConfigAsync(
  params: ReactNativeConfigParams
): Promise<ReactNativeConfig>;

/**
 * Resolve React Native module from dependency resolution
 * @param resolution - Dependency resolution result
 * @param config - Configuration options
 * @param platform - Target platform
 * @param excludeNames - Set of package names to exclude
 * @returns Promise resolving to resolved module
 */
function resolveReactNativeModule(
  resolution: DependencyResolution,
  config: any,
  platform: SupportedPlatform,
  excludeNames: Set<string>
): Promise<any>;

React Native Integration

Core Types

type SupportedPlatform = 
  | 'apple'
  | 'ios' 
  | 'android'
  | 'web'
  | 'macos'
  | 'tvos'
  | 'devtools'
  | (string & {});

interface PackageRevision {
  name: string;
  path: string;
  version: string;
  config?: ExpoModuleConfig;
  duplicates?: PackageRevision[];
}

type SearchResults = {
  [moduleName: string]: PackageRevision;
};

interface AutolinkingCommonArguments {
  projectRoot?: string | null;
  searchPaths?: string[] | null;
  exclude?: string[] | null;
  platform?: SupportedPlatform | null;
}

type ModuleDescriptor =
  | ModuleDescriptorAndroid
  | ModuleDescriptorIos
  | ModuleDescriptorDevTools;

interface CommonNativeModuleDescriptor {
  packageName: string;
  coreFeatures?: string[];
}

interface ModuleDescriptorAndroid extends CommonNativeModuleDescriptor {
  projects?: ModuleAndroidProjectInfo[];
  plugins?: ModuleAndroidPluginInfo[];
}

interface ModuleDescriptorIos extends CommonNativeModuleDescriptor {
  modules: string[];
  pods: ModuleIosPodspecInfo[];
  flags: Record<string, any> | undefined;
  swiftModuleNames: string[];
  appDelegateSubscribers: string[];
  reactDelegateHandlers: string[];
  debugOnly: boolean;
}

interface ModuleDescriptorDevTools {
  packageName: string;
  packageRoot: string;
  webpageRoot: string;
}

interface BaseDependencyResolution {
  name: string;
  version: string;
  path: string;
  originPath: string;
}

interface DependencyResolution extends BaseDependencyResolution {
  source: DependencyResolutionSource;
  duplicates: BaseDependencyResolution[] | null;
  depth: number;
  [prop: string]: unknown;
}

enum DependencyResolutionSource {
  RECURSIVE_RESOLUTION,
  SEARCH_PATH,
  RN_CLI_LOCAL,
}

type ResolutionResult = Record<string, DependencyResolution | undefined>;

interface CachedDependenciesSearchOptions {
  searchPaths: string[];
  exclude: string[];
}