-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New: Sourcemap Page #3293
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
Merged
Merged
New: Sourcemap Page #3293
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
94b0238
feat: add sourcemap page
iBotPeaches 9a41d84
feat: remove dated sourcemap from hermes profile page
iBotPeaches 419daaf
refactor: drop section of debug for hint as hermesFlagsDebug
iBotPeaches 098ae1d
refactor: adjusting grammar and removing ToC
iBotPeaches 9363198
style: add missing period
iBotPeaches 4f5e072
refactor: reword sourcemap line
iBotPeaches File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
id: sourcemaps | ||
title: Source Maps | ||
--- | ||
|
||
Source maps allows to map a transformed file back to the original source file. The main purpose of source maps is to aid debugging and help investigating issues from release builds. | ||
|
||
Without the source maps, when running into an error in the release build you will see a stacktrace like: | ||
|
||
```text | ||
TypeError: Cannot read property 'data' of undefined | ||
at anonymous(app:///index.android.bundle:1:4277021) | ||
at call(native) | ||
at p(app:///index.android.bundle:1:227785) | ||
``` | ||
|
||
With source maps generated, a stacktrace will include path, file name, and line number of the original source file: | ||
|
||
```text | ||
TypeError: Cannot read property 'data' of undefined | ||
at anonymous(src/modules/notifications/Permission.js:15:requestNotificationPermission) | ||
at call(native) | ||
at p(node_modules/regenerator-runtime/runtime.js:64:Generator) | ||
``` | ||
|
||
This allows to triage release issues given a more accurate stacktrace. | ||
|
||
Follow the instructions below to get started with source maps. | ||
|
||
## Enable source maps on Android | ||
|
||
### Hermes | ||
|
||
:::info | ||
Source maps are built in Release mode by default. However, if `hermesFlagsRelease` is set - source maps will have to be enabled. | ||
::: | ||
|
||
If so, ensure the following is set in your app's `android/app/build.gradle` file. | ||
|
||
```groovy | ||
project.ext.react = [ | ||
enableHermes: true, | ||
hermesFlagsRelease: ["-O", "-output-source-map"], // plus whichever flag was required to set this away from default | ||
] | ||
``` | ||
|
||
If done correctly - you may see the output location of the source map during Metro build output. | ||
|
||
```text | ||
Writing bundle output to:, android/app/build/generated/assets/react/release/index.android.bundle | ||
Writing sourcemap output to:, android/app/build/intermediates/sourcemaps/react/release/index.android.bundle.packager.map | ||
``` | ||
|
||
Development builds do not produce a bundle and thus already have symbols, but if the development build is bundled you may use `hermesFlagsDebug` like above to enable source maps. | ||
|
||
## Enable source maps on iOS | ||
|
||
Source maps are disabled by default. To enable them one has to define `SOURCEMAP_FILE` environment variable. | ||
|
||
In order to do so, within Xcode head to the build phase - "Bundle React Native code and images". | ||
|
||
At the top of the file near the other export's, add an entry for `SOURCEMAP_FILE` to the preferred location and name. Like below: | ||
|
||
``` | ||
export SOURCEMAP_FILE="$(pwd)/../main.jsbundle.map"; | ||
|
||
export NODE_BINARY=node | ||
../node_modules/react-native/scripts/react-native-xcode.sh | ||
``` | ||
|
||
If done correctly - you may see the output location of the source map during Metro build output. | ||
|
||
```text | ||
Writing bundle output to:, Build/Intermediates.noindex/ArchiveIntermediates/application/BuildProductsPath/Release-iphoneos/main.jsbundle | ||
Writing sourcemap output to:, Build/Intermediates.noindex/ArchiveIntermediates/application/BuildProductsPath/Release-iphoneos/main.jsbundle.map | ||
``` | ||
|
||
## Manual Symbolication | ||
|
||
:::info | ||
You may read about manual symbolication of a stack trace on the [symbolication](symbolication.md) page. | ||
::: |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.