@@ -7,8 +7,9 @@ import { spawn, SpawnFailure } from "bufout";
77import { oraPromise } from "ora" ;
88import { packageDirectorySync } from "pkg-dir" ;
99
10- import { prettyPath } from "../path-utils" ;
10+ import { getLatestMtime , prettyPath } from "../path-utils" ;
1111
12+ const HOST_PACKAGE_ROOT = path . resolve ( __dirname , "../../.." ) ;
1213const HERMES_GIT_URL = "https://github.com/kraenhansen/hermes.git" ;
1314const HERMES_GIT_TAG = "node-api-for-react-native-0.79.0" ;
1415const REACT_NATIVE_DIR = path . dirname (
@@ -65,14 +66,28 @@ export const command = new Command("vendor-hermes")
6566 isEnabled : ! silent ,
6667 }
6768 ) ;
69+ }
70+ const hermesJsiPath = path . join ( hermesPath , "API/jsi/jsi" ) ;
71+ const reactNativePath = path . dirname (
72+ require . resolve ( "react-native/package.json" , {
73+ // Ensures we'll be patching the React Native package actually used by the app
74+ paths : [ appPackageRoot ] ,
75+ } )
76+ ) ;
77+ const reactNativeJsiPath = path . join (
78+ reactNativePath ,
79+ "ReactCommon/jsi/jsi/"
80+ ) ;
81+
82+ if (
83+ fs . existsSync ( reactNativeJsiPath ) &&
84+ ( force ||
85+ getLatestMtime ( hermesJsiPath ) > getLatestMtime ( reactNativeJsiPath ) )
86+ ) {
6887 await oraPromise (
69- fs . promises . cp (
70- path . join ( hermesPath , "API/jsi/jsi" ) ,
71- path . join ( REACT_NATIVE_DIR , "ReactCommon/jsi/jsi/" ) ,
72- {
73- recursive : true ,
74- }
75- ) ,
88+ fs . promises . cp ( hermesJsiPath , reactNativeJsiPath , {
89+ recursive : true ,
90+ } ) ,
7691 {
7792 text : `Copying JSI from Hermes to React Native` ,
7893 successText : "Copied JSI from Hermes to React Native" ,
0 commit comments