When react-native's normal bundle command is executed with --sourcemap-output, e.g:
$ react-native bundle \
--platform android \
--dev false \
--entry-file index.js \
--bundle-output android-release.bundle \
--sourcemap-output android-release.bundle.map
… the sourcesContent field of the source map is populated.
The default behaviour in Hermes is to not include the sourcesContent field in the output source map, and I can't see a way to enable it.
Having it on by default, or at least being able to include sources with an option, is a really useful feature that we (at Bugsnag) and our customers rely on. Can you let me know if there are plans to add this, or any objections to adding it?
Thanks!
Hi @bengourley! I think what you're describing is that the React Native Hermes integration doesn't preserve the sourcesContent field when it composes source maps from Metro and Hermes. I'll open a corresponding issue on the React Native repo for further discussion.
Let's have the discussion on that other issue
Looks like https://github.com/facebook/react-native/issues/26086 was marked resolved, but assuming this was just an automatic closure due to the issue going stale. Has there been any progress on this?
Out of curiosity, what is the use case for this? Is it for debugging or for something else?
Hermes itself could populate the sourcesContent field, but it wouldn't be very useful because Hermes consumes code that has already been transformed.
Another option is for Hermes to copy the sourceContent field of the input source map it is given. That should be pretty easy to do.
Would any of these two options address the need?
The latter would be the ideal solution – just preserving the orginal sourcesContent field, as @motiz88 mentioned.
The use case for us (there may be others) is for when users upload their source maps to Bugsnag. We can only show the original code to our users when it is included in the source map – without it we can show the orginal line/col but not what code was there.
Copying the sourceContent of the input source map, if present, should be easy.
However, right now in the build process I don't think Hermes is given an input source map at all. So something has to be done in the React Native integration anyway.
https://github.com/facebook/metro/pull/574 will fix this on the React Native side.
Most helpful comment
https://github.com/facebook/metro/pull/574 will fix this on the React Native side.