question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Minified code gives wrong line of code

See original GitHub issue

Hi there,

I tried out the transformer and it works perfect in dev mode, so first: thanks a lot for that 😃 👍

Nonetheless: When not running in debug mode and let the code crash somewhere, the lines and colums are a little bit off.

Steps to reproduce (I forked git clone https://github.com/cbrevik/react-native-typescript-starter and did some changes to illustrate the problem):

https://github.com/hffmnn/react-native-typescript-starter
cd react-native-typescript-starter
git checkout --track origin/feature/ts_map
yarn
yarn bundle:ios:release

Open the iOS project with Xcode and press run.I modified:

  • index.tsx to crash after 3 seconds
  • the Xcode scheme to run in Release mode
  • the Xcode Build Phase to not start the bundling.

The app will crash. Press continue until Xcode spits out something useful like:

Exception: Can't find variable: doSomethingStupid, stack:
<unknown>@365:441
callTimer@31:626
callTimers@31:1010
value@29:2893
<unknown>@29:832
value@29:2294
value@29:804

Run

./symbolicate.js ios/main.jsbundle.map 365 441

Expected: The output is: <some_user_specific_path>/react-native-typescript-starter/src/index.tsx:19

Experienced: The output is: <some_user_specific_path>/react-native-typescript-starter/src/index.tsx:13 (Note the difference in the line number)

To verify that it has something to do with dev mode or maybe minify:

  • Delete the app from simulator!!!
  • Clean the Xcode project!!!
  • Run yarn bundle:ios:dev
  • Rerun the application

Experienced: The output is (as expected): <some_user_specific_path>/react-native-typescript-starter/src/index.tsx:19

I already verified, that the generated sourcemaps for JS based projects (so e.g. a default RN project) work in dev and release mode, so this issue is only valid for how we create the source maps for TS.

I already checked the docs for source-map (https://www.npmjs.com/package/source-map) but could not find any hint, why that should not work.

Any ideas what else might be the problem?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
ds300commented, Jun 14, 2017
1reaction
ds300commented, Feb 12, 2018

Cool beans. I’m gonna close this. Thanks @quincycs and @skellock

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting line number of an error from minified JavaScript files
You can beautify minified code. In the chrome inspector, it is the {} button and is called "pretty print". However, beautifying this code ......
Read more >
4 Reasons Why Your Source Maps are Broken - Sentry Blog
In a sense, source maps are the decoder ring to your secret (minified) code. However, they can be tricky to get working properly....
Read more >
415406 - Breakpoints in pretty print code are added to minified ...
Open up dev tools, find the 'chromium_issue_415406.small.min.js' file, enter 'pretty print' mode, put a breakpoint on the first line 'var a' in the...
Read more >
Why minify JavaScript code? | Cloudflare
Minification, also known as minimization, is the process of removing all unnecessary characters from JavaScript source code without altering its functionality.
Read more >
Debug a JavaScript or TypeScript app - Visual Studio (Windows)
Screenshot of the Visual Studio code window showing JavaScript code. ... (Set the breakpoint in a line of code that allows breakpoints, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found