react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Wrong source map is generated

Open digeff opened this issue 10 years ago • 86 comments

The source maps generated by the react-native packager seem to not be generated properly. We've seen in several projects that the mapping to/from around the React Tags code seems to not be correct.

For example, a user reported this issue: https://github.com/Microsoft/vscode-react-native/issues/206#issuecomment-209109389 in our project, and the root cause of the issue is because the source map file generated by the react-native packager is not correctly mapping to the original source code (The original source code has 76 lines, and the .map files point to line 85 on that file).

digeff avatar Apr 12 '16 21:04 digeff

Could you provide an example repo where we can reproduce this issue?

satya164 avatar Apr 16 '16 20:04 satya164

Yes, @gilesbradshaw was having this issue on his app, and he told us we can install it by doing:

git clone https://github.com/gilesbradshaw/ua-ql-mobile.git awesome2
cd awesome2
npm i

In https://github.com/Microsoft/vscode-react-native/issues/206#issuecomment-209109389 he describes exactly where to put the breakpoint to reproduce this issue (Which is also where the source maps aren't being correctly generated).

digeff avatar Apr 18 '16 17:04 digeff

Thanks for looking let me know if you cannot replicate with that repo

gilesbradshaw avatar Apr 18 '16 21:04 gilesbradshaw

I also had this issue recently where sources maps were off by ~10-20 lines. It only happened in component files with jsx.

janicduplessis avatar Apr 19 '16 05:04 janicduplessis

The more import-statements, jsx-syntax or es6-classes in the module, the more difference is between correct lines and the generated source map.

mroswald avatar Apr 22 '16 14:04 mroswald

@satya164 Any updates on this?

digeff avatar May 10 '16 16:05 digeff

I've found a different symptom: the source maps are pointing to the entirely wrong files. Has anyone else experienced this?

spikebrehm avatar Jul 19 '16 18:07 spikebrehm

@spikebrehm we are experiencing the same. At first by combining some of the imports we could get it back to work, however when the project goes, we lost more and more correct file mapping when debugging in Chrome. We have to try debugging in Nuclide to get to the exact breakpoints in exact files in those cases but it's not as powerful as Chrome.

JaxGit avatar Aug 03 '16 01:08 JaxGit

@facebook-github-bot label Icebox

charpeni avatar Nov 16 '16 01:11 charpeni

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/wrong-source-map-is-generated

ProductPains helps the community prioritize the most important issues thanks to its voting feature. It is easy to use - just login with GitHub.

Also, if this issue is a bug, please consider sending a PR with a fix. We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.

charpeni avatar Nov 16 '16 01:11 charpeni

@facebook-github-bot close

charpeni avatar Nov 16 '16 01:11 charpeni

@charpeni tells me to close this issue. If you think it should still be opened let us know why.

facebook-github-bot avatar Nov 16 '16 01:11 facebook-github-bot

I also see this occurring. I'm getting completely wrong filenames from sourcemaps.

dbeard-groupon avatar Mar 01 '17 23:03 dbeard-groupon

I have the problem where iOS works, but android bundlemap is of with 10-20 lines. Is this a common issue around here? I created an issue on it: https://github.com/facebook/react-native

vongohren avatar Apr 27 '17 08:04 vongohren

I'm having this... rn 0.44

brunolemos avatar Jun 13 '17 18:06 brunolemos

I too am having this issue - has anyone else been able to solve it? @brunolemos @vongohren - thanks!

symptomatik avatar Sep 20 '17 00:09 symptomatik

Rn 0.48 still has this issue on android release build.

chefkefu avatar Oct 11 '17 15:10 chefkefu

I'm seeing something similar, but from my research I don't believe the issue is with the source maps rather the raw stack traces point to the wrong locations in the bundle. As an example if we do throw new Error('test'); at 479:1837 in our bundle the actual location in the stack trace is 479:2150 which has nothing to do with the code path that leads to the error being thrown

EDIT: This is specifically for Android. Testing on iOS both the location in the bundled file and the mapped location with source map is correct.

k0nserv avatar Nov 01 '17 14:11 k0nserv

@charpeni can we reopen this?

k0nserv avatar Nov 01 '17 14:11 k0nserv

@k0nserv Sure.

charpeni avatar Nov 01 '17 15:11 charpeni