Hi, I would like to share a better way to build source-maps for your App, without having to modify or copy any react-native scripts in the node_modules folder.
For android, add this to your android/app/build.gradle file.
project.ext.react = [
...
extraPackagerArgs: [
"--sourcemap-output", "$buildDir/intermediates/assets/release/index.android.bundle.map",
"--sourcemap-sources-root", "$rootDir/.."
]
]
And as of react-native 0.55, you can now do the same on iOS. In your XCode project file, update the Bundle React Native code and images build phase to this:
export NODE_BINARY=node
export EXTRA_PACKAGER_ARGS=\"--sourcemap-output $CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/main.jsbundle.map --sourcemap-sources-root $SRCROOT/..\"
../node_modules/react-native/scripts/react-native-xcode.sh
As you may have noticed see, you can also specify the option sourcemap-sources-root. When set correctly, the paths stored in the source-map file are much shorter, and therefore the source-map file becomes a lot smaller. I tested this extensively and in my case the source-map file went down from 17MB to 11MB and the stack-trace is better readable (paths all start from your project-root).
Cheers, Hein
Hi, I would like to share a better way to build source-maps for your App, without having to modify or copy any react-native scripts in the node_modules folder.
For android, add this to your
android/app/build.gradlefile.And as of react-native 0.55, you can now do the same on iOS. In your XCode project file, update the
Bundle React Native code and imagesbuild phase to this:As you may have noticed see, you can also specify the option
sourcemap-sources-root. When set correctly, the paths stored in the source-map file are much shorter, and therefore the source-map file becomes a lot smaller. I tested this extensively and in my case the source-map file went down from 17MB to 11MB and the stack-trace is better readable (paths all start from your project-root).Cheers, Hein