Created
April 25, 2025 00:00
-
-
Save sawaYch/8f13c655de9d58e6ea03cc0ae8635c5c to your computer and use it in GitHub Desktop.
upload react native ios & android source map (Hermes) to sentry.io manually
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# generate sourcemap | |
# | |
# (android) | |
echo "π Generating sourcemap for android..." | |
npx react-native bundle \ | |
--dev false \ | |
--minify false \ | |
--platform android \ | |
--entry-file index.js \ | |
--reset-cache \ | |
--bundle-output index.android.bundle \ | |
--sourcemap-output index.android.bundle.map | |
# (ios) | |
echo "π Done generating sourcemap for android" | |
echo "π Generating sourcemap for ios..." | |
npx react-native bundle \ | |
--dev false \ | |
--minify false \ | |
--platform ios \ | |
--entry-file index.js \ | |
--reset-cache \ | |
--bundle-output main.jsbundle \ | |
--sourcemap-output main.jsbundle.map | |
echo "π Done generating sourcemap for ios" | |
# | |
# compile hermes bytecode bundle and sourcemap | |
# | |
# (android) | |
echo "π Compiling hermes bytecode bundle and sourcemap for android..." | |
node_modules/hermes-engine/osx-bin/hermesc \ | |
-O -emit-binary \ | |
-output-source-map \ | |
-out=index.android.bundle.hbc \ | |
index.android.bundle | |
rm -f index.android.bundle | |
mv index.android.bundle.hbc index.android.bundle | |
echo "π Done compiling hermes bytecode bundle and sourcemap for android" | |
# (ios) | |
echo "π Compiling hermes bytecode bundle and sourcemap for ios..." | |
node_modules/hermes-engine/osx-bin/hermesc \ | |
-O -emit-binary \ | |
-output-source-map \ | |
-out=main.jsbundle.hbc \ | |
main.jsbundle | |
rm -f main.jsbundle | |
mv main.jsbundle.hbc main.jsbundle | |
echo "π Done compiling hermes bytecode bundle and sourcemap for ios" | |
# | |
# compose hermes bytecode and metro sourcemap | |
# | |
# (android) | |
echo "π Composing hermes bytecode and metro sourcemap for android..." | |
mv index.android.bundle.map index.android.bundle.packager.map | |
node \ | |
node_modules/react-native/scripts/compose-source-maps.js \ | |
index.android.bundle.packager.map \ | |
index.android.bundle.hbc.map \ | |
-o index.android.bundle.map | |
echo "π Done composing hermes bytecode and metro sourcemap for android" | |
echo "π Copying debugid for android..." | |
node \ | |
node_modules/@sentry/react-native/scripts/copy-debugid.js \ | |
index.android.bundle.packager.map index.android.bundle.map | |
rm -f index.android.bundle.packager.map | |
echo "π Done copying debugid for android" | |
# (ios) | |
echo "π Composing hermes bytecode and metro sourcemap for ios..." | |
mv main.jsbundle.map main.jsbundle.packager.map | |
node \ | |
node_modules/react-native/scripts/compose-source-maps.js \ | |
main.jsbundle.packager.map \ | |
main.jsbundle.hbc.map \ | |
-o main.jsbundle.map | |
echo "π Done composing hermes bytecode and metro sourcemap for ios" | |
echo "π Copying debugid for ios..." | |
node \ | |
node_modules/@sentry/react-native/scripts/copy-debugid.js \ | |
main.jsbundle.packager.map main.jsbundle.map | |
rm -f main.jsbundle.packager.map | |
echo "π Done copying debugid for ios" | |
echo "π Uploading sourcemap for android..." | |
SENTRY_ORG=siemens-fj | |
SENTRY_PROJECT=smart-cs-shl-prod | |
SENTRY_AUTH_TOKEN=your-sentry-auth-token | |
# sentry-cli require node >=18 | |
nvm use 18 | |
echo "π Uploading sourcemap for android..." | |
node_modules/@sentry/cli/bin/sentry-cli sourcemaps upload \ | |
--org siemens-fj \ | |
--project smart-cs-shl-prod \ | |
--auth-token $SENTRY_AUTH_TOKEN \ | |
--debug-id-reference \ | |
index.android.bundle index.android.bundle.map | |
echo "π Done uploading sourcemap for android" | |
echo "π Uploading sourcemap for ios..." | |
node_modules/@sentry/cli/bin/sentry-cli sourcemaps upload \ | |
--org siemens-fj \ | |
--project smart-cs-shl-prod \ | |
--auth-token $SENTRY_AUTH_TOKEN \ | |
--debug-id-reference \ | |
main.jsbundle main.jsbundle.map | |
echo "π Done uploading sourcemap for ios" | |
echo "π Cleanup" | |
rm index.android.bundle index.android.bundle.hbc.map index.android.bundle.map main.jsbundle.hbc.map main.jsbundle.map | |
echo "π Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment