Skip to content

Update, source-maps can now be built without modifying any react-native scripts + make them smaller #4

@IjzerenHein

Description

@IjzerenHein

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions