Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I debug source code instead of compiled one? #343

Closed
singno opened this issue Aug 3, 2016 · 6 comments
Closed

Can I debug source code instead of compiled one? #343

singno opened this issue Aug 3, 2016 · 6 comments

Comments

@singno
Copy link

singno commented Aug 3, 2016

Compiled code
image

@gaearon
Copy link
Contributor

gaearon commented Aug 3, 2016

Thanks for filing the issue. We previously had a discussion about this here: #139.

Unfortunately sourcemaps don’t currently work with variable bindings. So if we enabled sourcemaps, you would see React in your code, but it wouldn’t work in console, or in the paused functions. Similarly, you might try to use this inside an arrow function during a debugging session, but Babel would transpile it to _this, and you wouldn’t be able to find it.

I might be wrong but I think having code behave magically different in the debugger section is more confusing than seeing the real output. There are other benefits to seeing the real output too: you understand what code exactly is running, which features exactly get transpiled, breakpoints don’t “fall through” or fail to break, et cetera.

This is why I would rather see more work on making Babel output more readable. Here is an example of such issue: babel/babel#3585.

Let me know if you disagree. I understand it’s a polarizing topic, and different people will have different opinions on this. So far I have found that avoiding surprises is more important than exact sourcemaps, but maybe you can convince me I’m wrong.

@singno
Copy link
Author

singno commented Aug 3, 2016

I agree with you, @gaearon . Thanks for creating such an amazing tool, it really raises our developing efficiency.

@gaearon
Copy link
Contributor

gaearon commented Aug 3, 2016

👍

@marcosfede
Copy link

Would it be possible to have an easy toggle for this like an option on the package.json instead of modifying the config inside node_modules? perhaps an optional parameter on react-scripts like --sourcemap ? some es6/es7 code transpiled by babel is quite different from the original code so its hard to debug without sourcemaps

@rodislav
Copy link

rodislav commented Nov 7, 2016

is there another way to debug the js code itself with breakpoints ? // not the transpiled version

@gaearon
Copy link
Contributor

gaearon commented Nov 20, 2016

All right, I merged #924 and we'll ship with 0.8.0 with sourcemaps enabled per your feedback.
I'm sure this will introduce some confusion but this seems the way people prefer it.

jaydenseric added a commit to jaydenseric/svg-symbol-viewer that referenced this issue Nov 29, 2016
Relevent discussion in facebookincubator/create-react-app: facebook/create-react-app#343.
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants