Skip to content

Commit 78f3533

Browse files
committed
fix: hermes-compiler path for RN 0.82+ in the hermes bytecode plugin
1 parent 396ebbd commit 78f3533

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

packages/repack/src/plugins/HermesBytecodePlugin/utils/getHermesCLIPath.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import fs from 'node:fs';
12
import os from 'node:os';
23
import path from 'node:path';
34

@@ -20,7 +21,7 @@ const getHermesOSBin = (): string | null => {
2021
/**
2122
* Determines the path to the Hermes compiler binary.
2223
*
23-
* Defaults to './node_modules/react-native/sdks/hermesc/{os-bin}/hermesc'
24+
* Defaults to './node_modules/hermes-compiler/hermesc/{os-bin}/hermesc'
2425
*/
2526
export const getHermesCLIPath = (reactNativePath: string): string => {
2627
const osBin = getHermesOSBin();
@@ -32,5 +33,19 @@ export const getHermesCLIPath = (reactNativePath: string): string => {
3233
);
3334
}
3435

36+
const hermesCompilerPath = path.join(
37+
reactNativePath,
38+
'..',
39+
'hermes-compiler',
40+
'hermesc',
41+
osBin,
42+
'hermesc'
43+
);
44+
45+
if (fs.existsSync(hermesCompilerPath)) {
46+
return hermesCompilerPath;
47+
}
48+
49+
// Fallback to the previous hermesc path in older react native versions, <0.82.
3550
return path.join(reactNativePath, 'sdks', 'hermesc', osBin, 'hermesc');
3651
};

0 commit comments

Comments
 (0)