-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Generate source maps for iOS and Android #9596
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| #!/bin/bash | ||
| set -e | ||
| # Source map generating script for android and ios js bundles | ||
|
|
||
| PLATFORM=$1 | ||
|
|
||
| if [[ ! $PLATFORM =~ ^(ios|android)$ ]]; then | ||
| error "Unsupported platform '$PLATFORM', possible options are: 'android' or 'ios'" | ||
| exit 1 | ||
| fi | ||
|
|
||
| SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") | ||
| LOCAL_PACKAGES=$(npm bin) | ||
| NODE_MODULES="$SCRIPTS_DIR/../node_modules" | ||
| source "$SCRIPTS_DIR/shellUtils.sh"; | ||
|
|
||
| title "Generating $PLATFORM Source Map File" | ||
|
|
||
| info "" | ||
| info "1. Generating packager map" | ||
| info "" | ||
|
|
||
| "$LOCAL_PACKAGES/react-native" bundle \ | ||
| --platform $PLATFORM \ | ||
| --dev false \ | ||
| --entry-file index.js \ | ||
| --bundle-output index.$PLATFORM.bundle \ | ||
| --sourcemap-output index.$PLATFORM.bundle.packager.map \ | ||
| --reset-cache \ | ||
| --minify false | ||
|
|
||
| OS_BIN="" | ||
|
|
||
| case "$OSTYPE" in | ||
| darwin*) OS_BIN=osx-bin ;; | ||
| linux*) OS_BIN=linux64-bin ;; | ||
| msys*) OS_BIN=win64-bin ;; | ||
| cygwin*) OS_BIN=win64-bin ;; | ||
| *) error "unknown: $OSTYPE" ;; | ||
| esac | ||
|
|
||
| if [ -z "$OS_BIN" ]; then | ||
| error "Failed to match hermes OS-BIN" | ||
| exit 1; | ||
| fi | ||
|
|
||
| info "" | ||
| info "2. Generating hermes map" | ||
| info "" | ||
| info "Using hermes OS-BIN: '$OS_BIN'" | ||
| info "" | ||
|
|
||
| # In react native 0.69 this path needs to change to NODE_MODULES/react-native/sdks/hermesc/$OS_BIN/hermesc | ||
| "$NODE_MODULES/hermes-engine/$OS_BIN/hermesc" -O -emit-binary -output-source-map -out=index.$PLATFORM.bundle.hbc index.$PLATFORM.bundle | ||
|
Comment on lines
+32
to
+54
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This script was created following
It's easier to locate a Hermes cli bin from The OSTYPE check is necessary because I suspect this script would be run by both linux and mac users |
||
|
|
||
| info "" | ||
|
roryabraham marked this conversation as resolved.
|
||
| info "3. Merging source maps" | ||
| info "" | ||
|
|
||
| node "$NODE_MODULES/react-native/scripts/compose-source-maps.js" \ | ||
| index.$PLATFORM.bundle.packager.map \ | ||
| index.$PLATFORM.bundle.hbc.map \ | ||
| -o index.$PLATFORM.bundle.map | ||
|
|
||
|
Comment on lines
+60
to
+64
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This combines the regular source map (package) file together with the bite code source map file For some reason we only need the combined source map for Android stack traces while for ios the packager source map is enough I'm still confirming and finding out why |
||
| success "" | ||
| success "Result ready: 'index.$PLATFORM.bundle.map'" | ||
| success "" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason iOS only works with the
.package.mapfile - it does not work with the combined map file from the packager and the hermes (hbc) map files (producesnull:null:nullresults)It could be the stacktrace samples are already decoded partially from crashlytics