Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cuddly-months-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@callstack/repack": patch
---

Fix hermes-compiler path for RN 0.82+ in the hermes bytecode plugin
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';

Expand All @@ -20,7 +21,7 @@ const getHermesOSBin = (): string | null => {
/**
* Determines the path to the Hermes compiler binary.
*
* Defaults to './node_modules/react-native/sdks/hermesc/{os-bin}/hermesc'
* Defaults to './node_modules/hermes-compiler/hermesc/{os-bin}/hermesc'
*/
export const getHermesCLIPath = (reactNativePath: string): string => {
const osBin = getHermesOSBin();
Expand All @@ -32,5 +33,19 @@ export const getHermesCLIPath = (reactNativePath: string): string => {
);
}

const hermesCompilerPath = path.join(
reactNativePath,
'..',
'hermes-compiler',
'hermesc',
osBin,
'hermesc'
);

if (fs.existsSync(hermesCompilerPath)) {
return hermesCompilerPath;
}

// Fallback to the previous hermesc path in older react native versions, <0.82.
return path.join(reactNativePath, 'sdks', 'hermesc', osBin, 'hermesc');
};