Skip to content

Instantly share code, notes, and snippets.

@sawaYch
Created April 25, 2025 00:00
Show Gist options
  • Save sawaYch/8f13c655de9d58e6ea03cc0ae8635c5c to your computer and use it in GitHub Desktop.
Save sawaYch/8f13c655de9d58e6ea03cc0ae8635c5c to your computer and use it in GitHub Desktop.
upload react native ios & android source map (Hermes) to sentry.io manually
#!/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