Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react-native): fix sourcemaps for iOS builds with hermes #1197

Merged
merged 1 commit into from
Oct 5, 2023
Merged
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
51 changes: 25 additions & 26 deletions packages/react-native/scripts/honeybadger-upload-sourcemaps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ if $USE_HERMES; then
# react native <= 0.68
HERMES_PATH_2="$NODE_MODULES/hermes-engine/$OS_BIN/hermesc"


if [ -f "$HERMES_PATH_1" ]; then
HERMES_EXECUTABLE="$HERMES_PATH_1"
elif [ -f "$HERMES_PATH_2" ]; then
Expand All @@ -184,9 +183,6 @@ if $USE_HERMES; then
exit 1
fi


echo "Generating Hermes Android source map ..."

#
# compile the Android code to bytecode and generate the Hermes sourcemap
#
Expand All @@ -209,39 +205,42 @@ if $USE_HERMES; then


#
# Need to find the Hermes compiler executable for iOS.
# For iOS, we're no longer using the hermes output concatenation,
# even for hermes builds, as it produces incorrect sourcemaps.
#

HERMES_EXECUTABLE="$PROJECT_ROOT_DIR/ios/Pods/hermes-engine/destroot/bin/hermesc"
# HERMES_EXECUTABLE="$PROJECT_ROOT_DIR/ios/Pods/hermes-engine/destroot/bin/hermesc"

if [ ! -f "$HERMES_EXECUTABLE" ]; then
echo "Error: The Hermes compiler executable for iOS was not found in the expected location: $HERMES_EXECUTABLE . Did you run pod install in the ios/ directory?"
exit 1
fi
# if [ ! -f "$HERMES_EXECUTABLE" ]; then
# echo "Error: The Hermes compiler executable for iOS was not found in the expected location: $HERMES_EXECUTABLE . Did you run pod install in the ios/ directory?"
# exit 1
# fi


echo "Generating Hermes iOS source map ..."
# echo "Generating Hermes iOS source map ..."

#
# Compile the iOS code to bytecode and generate the Hermes sourcemap.
#

"$HERMES_EXECUTABLE" \
-O \
-emit-binary \
-output-source-map \
-out="$IOS_COMPILER_BUNDLE" \
"$IOS_PACKAGER_BUNDLE" > /dev/null 2>&1
# "$HERMES_EXECUTABLE" \
# -O \
# -emit-binary \
# -output-source-map \
# -out="$IOS_COMPILER_BUNDLE" \
# "$IOS_PACKAGER_BUNDLE" > /dev/null 2>&1

#
# merge the two iOS sourcemaps
#

node "$NODE_MODULES/react-native/scripts/compose-source-maps.js" \
"$IOS_PACKAGER_SOURCE_MAP" \
"$IOS_COMPILER_SOURCE_MAP" \
-o "$IOS_FINAL_SOURCE_MAP" > /dev/null 2>&1
# node "$NODE_MODULES/react-native/scripts/compose-source-maps.js" \
# "$IOS_PACKAGER_SOURCE_MAP" \
# "$IOS_COMPILER_SOURCE_MAP" \
# -o "$IOS_FINAL_SOURCE_MAP" > /dev/null 2>&1


# Same operation for hermes builds on iOS as with --no-hermes; see note above.
mv "$IOS_PACKAGER_SOURCE_MAP" "$IOS_FINAL_SOURCE_MAP"

#
# cleanup
Expand All @@ -253,9 +252,9 @@ if $USE_HERMES; then
"$ANDROID_COMPILER_BUNDLE" \
"$ANDROID_COMPILER_SOURCE_MAP" \
"$IOS_PACKAGER_BUNDLE" \
"$IOS_PACKAGER_SOURCE_MAP" \
"$IOS_COMPILER_BUNDLE" \
"$IOS_COMPILER_SOURCE_MAP"
"$IOS_PACKAGER_SOURCE_MAP" # \
# "$IOS_COMPILER_BUNDLE" \
# "$IOS_COMPILER_SOURCE_MAP"

else

Expand Down Expand Up @@ -304,7 +303,7 @@ curl https://api.honeybadger.io/v1/source_maps \
curl https://api.honeybadger.io/v1/source_maps \
-F api_key="$API_KEY" \
-F revision="$REVISION" \
-F minified_url=main.jsbundle \
-F minified_url="*/main.jsbundle" \
-F source_map=@"$IOS_FINAL_SOURCE_MAP" \
-F minified_file=@"$EMPTY_FILE" > /dev/null 2>&1

Expand Down