or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

build-cache.mdconfiguration.mdindex.mdpaths.mdsdk-version.md
tile.json

build-cache.mddocs/

Build Cache Integration

Type definitions and interfaces for build caching systems used in Expo development workflows. Provides standardized interfaces for implementing custom build cache providers.

Capabilities

Build Cache Provider Interface

Core interface for implementing build cache providers that can store and retrieve build artifacts.

/**
 * Build cache provider configuration
 */
interface BuildCacheProvider<T = any> {
  /** Build cache provider plugin implementation */
  plugin: BuildCacheProviderPlugin<T>;
  /** Configuration options for the provider */
  options: T;
}

/**
 * Build cache provider plugin interface
 * Providers must implement either the new or legacy interface
 */
type BuildCacheProviderPlugin<T = any> = {
  /** Optional fingerprint hash calculation */
  calculateFingerprintHash?: (
    props: CalculateFingerprintHashProps,
    options: T
  ) => Promise<string | null>;
} & (
  | {
      /** Resolve cached build artifacts */
      resolveBuildCache(props: ResolveBuildCacheProps, options: T): Promise<string | null>;
      /** Upload build artifacts to cache */
      uploadBuildCache(props: UploadBuildCacheProps, options: T): Promise<string | null>;
    }
  | {
      /** @deprecated Use resolveBuildCache instead */
      resolveRemoteBuildCache: (
        props: ResolveRemoteBuildCacheProps,
        options: T
      ) => Promise<string | null>;
      /** @deprecated Use uploadBuildCache instead */
      uploadRemoteBuildCache: (
        props: UploadRemoteBuildCacheProps,
        options: T
      ) => Promise<string | null>;
    }
);

Cache Resolution Properties

Properties used for resolving cached build artifacts.

/**
 * Properties for resolving build cache artifacts
 */
interface ResolveBuildCacheProps {
  /** Project root directory */
  projectRoot: string;
  /** Target platform ('android' | 'ios') */
  platform: 'android' | 'ios';
  /** Runtime options used for the build */
  runOptions: RunOptions;
  /** Unique fingerprint hash identifying the build configuration */
  fingerprintHash: string;
}

/**
 * @deprecated Use ResolveBuildCacheProps instead
 */
type ResolveRemoteBuildCacheProps = ResolveBuildCacheProps;

Cache Upload Properties

Properties used for uploading build artifacts to cache.

/**
 * Properties for uploading build artifacts to cache
 */
interface UploadBuildCacheProps {
  /** Project root directory */
  projectRoot: string;
  /** Path to the build artifact to upload */
  buildPath: string;
  /** Runtime options used for the build */
  runOptions: RunOptions;
  /** Unique fingerprint hash identifying the build configuration */
  fingerprintHash: string;
  /** Target platform ('android' | 'ios') */
  platform: 'android' | 'ios';
}

/**
 * @deprecated Use UploadBuildCacheProps instead
 */
type UploadRemoteBuildCacheProps = UploadBuildCacheProps;

Fingerprint Calculation

Properties for calculating build fingerprint hashes.

/**
 * Properties for calculating fingerprint hash
 */
interface CalculateFingerprintHashProps {
  /** Project root directory */
  projectRoot: string;
  /** Target platform ('android' | 'ios') */
  platform: 'android' | 'ios';
  /** Runtime options that affect the build */
  runOptions: RunOptions;
}

Run Options

Platform-specific runtime configuration options that affect build caching.

Android Run Options

/**
 * Android-specific runtime options
 */
interface AndroidRunOptions {
  /** Android build variant (debug, release, etc.) */
  variant?: string;
  /** Target device (true for physical device, string for specific device, false for emulator) */
  device?: boolean | string;
  /** Development server port */
  port?: number;
  /** Whether to start the bundler dev server */
  bundler?: boolean;
  /** Whether to install the app after building */
  install?: boolean;
  /** Whether to use build cache */
  buildCache?: boolean;
  /** Whether to build for all architectures */
  allArch?: boolean;
  /** Path to existing binary to install */
  binary?: string;
  /** Application ID override */
  appId?: string;
}

iOS Run Options

/**
 * iOS-specific runtime options
 */
interface IosRunOptions {
  /** iOS device to target (true for physical device, string for specific device, false for simulator) */
  device?: string | boolean;
  /** Development server port (ignored if bundler is false) */
  port?: number;
  /** Xcode scheme to build */
  scheme?: string | boolean;
  /** Xcode configuration to build (Debug or Release) */
  configuration?: 'Debug' | 'Release';
  /** Whether to start the bundler dev server */
  bundler?: boolean;
  /** Whether to install missing dependencies before building */
  install?: boolean;
  /** Whether to use derived data for builds */
  buildCache?: boolean;
  /** Path to existing binary to install on device */
  binary?: string;
  /** Re-bundle JS and assets, embed in existing app, and install again */
  rebundle?: boolean;
}

Combined Run Options

/**
 * Union type for all platform run options
 */
type RunOptions = AndroidRunOptions | IosRunOptions;

Implementation Examples

Basic Build Cache Provider

import { BuildCacheProvider, BuildCacheProviderPlugin } from "@expo/config";

// Custom cache provider plugin
const myPlugin: BuildCacheProviderPlugin<{ apiKey: string }> = {
  async calculateFingerprintHash(props, options) {
    // Calculate hash based on project state
    return "abc123def456";
  },
  
  async resolveBuildCache(props, options) {
    // Check if cached build exists
    const cacheKey = `${props.platform}-${props.fingerprintHash}`;
    const cachedPath = await fetchFromCache(cacheKey, options.apiKey);
    return cachedPath;
  },
  
  async uploadBuildCache(props, options) {
    // Upload build to cache
    const cacheKey = `${props.platform}-${props.fingerprintHash}`;
    await uploadToCache(cacheKey, props.buildPath, options.apiKey);
    return cacheKey;
  }
};

// Provider configuration
const provider: BuildCacheProvider<{ apiKey: string }> = {
  plugin: myPlugin,
  options: {
    apiKey: "your-api-key"
  }
};

Fingerprint Hash Calculation

import { CalculateFingerprintHashProps } from "@expo/config";

async function calculateHash(props: CalculateFingerprintHashProps): Promise<string> {
  const { projectRoot, platform, runOptions } = props;
  
  // Include relevant build configuration in hash
  const hashInputs = {
    platform,
    configuration: runOptions.configuration || 'Debug',
    scheme: runOptions.scheme,
    variant: runOptions.variant,
    // Add other relevant options
  };
  
  return generateHash(hashInputs);
}

Cache Resolution Logic

import { ResolveBuildCacheProps } from "@expo/config";

async function resolveCache(props: ResolveBuildCacheProps): Promise<string | null> {
  const { platform, fingerprintHash, runOptions } = props;
  
  // Build cache key from fingerprint and options
  const cacheKey = `${platform}-${fingerprintHash}-${runOptions.configuration}`;
  
  // Check if cached build exists and is valid
  const cachedBuild = await checkCache(cacheKey);
  if (cachedBuild && await validateCache(cachedBuild)) {
    return cachedBuild.path;
  }
  
  return null; // No valid cache found
}

Legacy Support

The interface maintains backward compatibility with deprecated method names:

// Legacy interface (deprecated)
interface LegacyBuildCacheProvider {
  resolveRemoteBuildCache(props: ResolveRemoteBuildCacheProps, options: any): Promise<string | null>;
  uploadRemoteBuildCache(props: UploadRemoteBuildCacheProps, options: any): Promise<string | null>;
}

// Migration to new interface
interface ModernBuildCacheProvider {
  resolveBuildCache(props: ResolveBuildCacheProps, options: any): Promise<string | null>;
  uploadBuildCache(props: UploadBuildCacheProps, options: any): Promise<string | null>;
}

New implementations should use the non-deprecated method names (resolveBuildCache and uploadBuildCache) for future compatibility.