In Chrome dev tools, how to find transpiled source corresponding to a (pre-transpilation) line of code?
Asked Answered
P

0

8

I'm troubleshooting a problem in my React.js app and I'd like to view the actual javascript being executed in the browser after it's been transpiled by Babel and bundled by Webpack. What's a good way to do this?

The app uses create-react-app so it has the default CRA configuration for Babel, webpack, etc. Source maps are working (good!) but what if I want to peek behind the source maps to find the real code being executed?

I know that I can find /static/js/bundle.js in Chrome Dev Tools' network pane, and then use Cmd+F to find a piece of code in that huge file. I also know that Chrome Dev Tools has an option to turn off source maps, but changing a persistent setting (even if I can do this without restarting debugging, which I'm not sure I can) doesn't seem any easier than the Cmd+F approach above, especially because I'll then have to remember to change it back (and restart debugging again?).

Instead, I'm just looking for a way to flip back and forth between actual generated (transpiled and bundled) code and my (source-mapped) code without interrupting my debugging workflow.

Is this do-able in Chrome?

Pancreatin answered 11/6, 2018 at 22:45 Comment(6)
Is it a prod bundle?Wiry
And also wanted to know is it uglified?Wiry
I don't think this is an option in Chrome at the moment. It will be nice to see this implemented. You can suggest it as a feature in crbug.comHedelman
@Shankar Shastri - it's a Dev bundle. Not uglified.Pancreatin
@JustinGrant, after digging different sources, I don't think there is any shortcut for this. And this does require a page reload. Also I doubt anyone would work on this feature request as the no. of people request such feature may be very fewCultivable
Bummer. I filed a new issue at crbug.com to try to get this on the radar of the DevTools maintainers. bugs.chromium.org/p/chromium/issues/detail?id=856322Pancreatin

© 2022 - 2024 — McMap. All rights reserved.