-
Couldn't load subscription status.
- Fork 4
Description
Currently, we look up the appropriate version of hermes from react-native like so:
react-native-node-api/packages/host/src/node/cli/hermes.ts
Lines 31 to 38 in 0419678
| const appPackageRoot = packageDirectorySync({ cwd: from }); | |
| assert(appPackageRoot, "Failed to find package root"); | |
| const reactNativePath = path.dirname( | |
| require.resolve("react-native/package.json", { | |
| // Ensures we'll be patching the React Native package actually used by the app | |
| paths: [appPackageRoot], | |
| }), | |
| ); |
For out-of-tree platforms like react-native-macos, though, I had to apply the following patch before it'd resolve the correct root during pod install:
let reactNativePath;
if(from.endsWith("ios") || from.endsWith("android")){
reactNativePath = node_path_1.default.dirname(require.resolve("react-native/package.json", {
// Ensures we'll be patching the React Native package actually used by the app
paths: [appPackageRoot],
}));
} else if(from.endsWith("macos")){
reactNativePath = node_path_1.default.dirname(require.resolve("react-native-macos/package.json", {
// Ensures we'll be patching the React Native package actually used by the app
paths: [appPackageRoot],
}));
} else if(from.endsWith("windows")){
reactNativePath = node_path_1.default.dirname(require.resolve("react-native-windows/package.json", {
// Ensures we'll be patching the React Native package actually used by the app
paths: [appPackageRoot],
}));
} else {
throw new Error("Unsupported platform.");
}There is surely a more elegant way to do it (it would be nicest to know the platform for certain, rather than just guessing based on the presence of an ios/android/macos folder in the path), but just to illustrate the point.
kraenhansen
Metadata
Metadata
Assignees
Labels
No labels