Skip to content

fix: support Expo 55 in ORT RN Expo config plugin#28658

Open
artus9033 wants to merge 1 commit into
microsoft:mainfrom
artus9033:fix/expo-plugin-support-55
Open

fix: support Expo 55 in ORT RN Expo config plugin#28658
artus9033 wants to merge 1 commit into
microsoft:mainfrom
artus9033:fix/expo-plugin-support-55

Conversation

@artus9033
Copy link
Copy Markdown

@artus9033 artus9033 commented May 25, 2026

Description

This PR adds a conditionally-switched logic for establishing the insertion point registering the ORT RN native module for Expo < 55 (ReactNativeHostWrapper) and Expo >= 55 (ExpoReactHostFactory.getDefaultReactHost) in the Expo config plugin's main application code manipulation logic.

Below are example artifacts after modifications by the ORT RN Expo config plugin for:

Expo 54
package com.anonymous.myapp

// @generated begin onnxruntime-react-native-import - expo prebuild (DO NOT MODIFY) sync-4543d7f2625243dfdef886002e5bf12df91957f2
import ai.onnxruntime.reactnative.OnnxruntimePackage
// @generated end onnxruntime-react-native-import
import android.app.Application
import android.content.res.Configuration

import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.ReactHost
import com.facebook.react.common.ReleaseLevel
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint
import com.facebook.react.defaults.DefaultReactNativeHost

import expo.modules.ApplicationLifecycleDispatcher
import expo.modules.ReactNativeHostWrapper

class MainApplication : Application(), ReactApplication {

  override val reactNativeHost: ReactNativeHost = ReactNativeHostWrapper(
      this,
      object : DefaultReactNativeHost(this) {
        override fun getPackages(): List<ReactPackage> =
            PackageList(this).packages.apply {
// @generated begin onnxruntime-react-native-package - expo prebuild (DO NOT MODIFY) sync-25da176d9e9c766ec723838ae4be361b632bb7b3
              add(OnnxruntimePackage())
// @generated end onnxruntime-react-native-package
              // Packages that cannot be autolinked yet can be added manually here, for example:
              // add(MyReactNativePackage())
            }

          override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"

          override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG

          override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
      }
  )
Expo 55
package com.anonymous.expoapp

// @generated begin onnxruntime-react-native-import - expo prebuild (DO NOT MODIFY) sync-4543d7f2625243dfdef886002e5bf12df91957f2
import ai.onnxruntime.reactnative.OnnxruntimePackage
// @generated end onnxruntime-react-native-import
import android.app.Application
import android.content.res.Configuration

import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
import com.facebook.react.ReactPackage
import com.facebook.react.ReactHost
import com.facebook.react.common.ReleaseLevel
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint

import expo.modules.ApplicationLifecycleDispatcher
import expo.modules.ExpoReactHostFactory

class MainApplication : Application(), ReactApplication {

  override val reactHost: ReactHost by lazy {
    ExpoReactHostFactory.getDefaultReactHost(
      context = applicationContext,
      packageList =
        PackageList(this).packages.apply {
// @generated begin onnxruntime-react-native-package - expo prebuild (DO NOT MODIFY) sync-a88c2d7d7f009e4e421e13cf3649dd1245afdb53
          add(OnnxruntimePackage())
// @generated end onnxruntime-react-native-package
          // Packages that cannot be autolinked yet can be added manually here, for example:
          // add(MyReactNativePackage())
        }
    )
  }

Motivation and Context

Fixes #28657 by adding an insertion point path for Expo 55+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] ORT RN Expo config plugin incompatible with Expo 55+

1 participant