-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Sourcemap is not enabled in development? #139
Comments
I don't think there is one except it was an oversight, that should definitely be added!
I've never heard of this being done before to be honest, but I think we want to support everybody with |
We want to support any browsers currently supported by React (that includes >= IE 9). I wonder if this could be fixed on Webpack (or Chrome?) side in any way. |
What about using |
Same problem as I described in #109 (comment). |
This was a (bizarre) bug fixed in Chrome 53. We handle this with config = merge(config, {
devtool: 'cheap-module-source-map',
// TODO: Workaround for Chrome < 53. Remove once Chrome 53 hits stable.
output: {
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
},
}); per something cited on some webpack issue somewhere.
|
IMO the best balanced approach is to use |
This is super interesting, thank you for the info. We'll give it a try. |
I looked it again. There is however another (IMO rather big) usability problem: https://bugs.chromium.org/p/chromium/issues/detail?id=327092 I understand this is not Webpack’s issue, but not being able to inspect or reference some variables / import in console is very frustrating and completely non-obvious to the beginners. Canary shipped support for variable mappings but I don’t think Webpack or Babel support this sourcemap spec (I’m not even sure which spec Chrome is supporting.) So I’m not comfortable enabling sourcemaps in development until Babel and Webpack output them in a way that at least Canary can map the variable names correctly. |
I don't think the tradeoff is clearly in favor of "avoid unexpected variable names", BTW – the flip side is that the code you see in the debugger is not the code that you wrote, which also is confusing and strange. As a caveat, I think "variable bindings like |
Like specifically, at least as long as imports are transpiled with Babel and are not actually supported, something like: import Foo from './Foo'; needs to be something like |
Fair point about imports. In general though, I think it’s valuable to understand what the code looks like under the hood. When you see errors, you will see errors about the transpiled code anyway. It is useful to be able to look at the exact code that errored rather than a feel-good ES6 source. (And sometimes even Babel transforms are buggy.) There are other pain points, like when you click on the breakpoint pane but the breakpoint “falls through” many lines down. This is confusing. Still, I understand there are many ways to look at this. I’m not saying my opinion is final, but this is the decision I’m taking based on the issues I’ve seen so far. And Babel output can be improved when there is a desire for it. If there is enough feedback that this was a bad decision, we might change this to what you suggest. For now I’d propose to wait and see. |
That makes sense. Thanks. |
Closing as we can’t / won’t fix this now due to tradeoffs above. We might revisit this in the future. |
In case anybody is following this, the proper fix for sourcemaps landed in Chrome 52 (current stable), not 53. If you're tracking this to see how to get your source maps working, you can drop that workaround. |
I understand this project follows 0config philosophy but maybe enabling source maps (via |
Can you file a separate issue about this? Maybe we could try preserving the line numbers (I think Babel could do that). Or just reconsider and make a list of actionable issues in this or other products (Chrome, Webpack) that need to be solved for sourcemaps to become a better default. |
I'm sorry, but I can't seem to find any answer. Is there a way to enable source mapping with this project? How? Maybe it would be nice to add to the docs. |
Not currently. I’m reopening because it seems like a lot of people want sourcemaps despite their shortcomings. So we’ll probably add them before 1.0. |
@taion is there a way to use your workaround, without ejecting from CRA? |
Chrome 52 has been stable for ages now. That workaround is no longer relevant. |
@taion no, I mean setting webpack config, as you mentioned before: config = merge(config, {
devtool: 'cheap-module-source-map'
}); Not possible to enable sourcemaps without ejecting? |
@arteezy You can try to do next hook: |
Since people seem to prefer it I merged #924. |
Sorry, newby question: Thanks in advance. |
Hi! As I noted in the comment right above:
0.8.0 is not out yet so no. When it is out, yes, this will be enabled and you wouldn't need to eject. |
It would be good to enable source maps via an environment =variable rather than breaking zero configuration. for source maps: for no source maps: fiddling with configuration files is a very short road to JavaScript hell. The least worst option after that is environment variables that the knowledgeable can choose to set if they want, with zero impact on zero config. |
That’s often what we do, but in this case we just enabled them for everybody since most issues with sourcemaps were resolved. |
It seems like sourcemap is not enabled in development, is there some reason for that?
My normal workflow, is that if I see an error in the chrome console, I look up the file and line number of the error in my editor. But at this moment, the line numbers are not correct, because it doesn't use source mapping.
This leads to another question, why is ES6 transpiled to ES5 in development? Shouldn't it transpile to ES6 now that chrome, edge, safari and firefox all support more ES6 than babel itself support?
I think ES6 to ES5 transpiling is something only needed for production.
The text was updated successfully, but these errors were encountered: