-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Implement basic source maps. Refs #1252. #1267
Conversation
Good start, some initial comments:
|
Initial comments have been addressed. |
Does the output work ok in both firefox and chrome? |
Ah. It only seems to work fully on Aurora. On both Firefox Nightly and Chrome, the line number mapping works, but the actual source doesn't get loaded in the debugger. Still trying to figure out if this is a bug in my code or in the browser(s). |
Tweak behavior of post_build; the `post2` hook now expects a function.
Okay, I found my very silly mistake. It works on Chrome and Firefox (Aurora and Nightly) now. |
Chrome and FF seem to be able to handle the extra empty lines, but no harm making things more accurate. One thing less to worry about when debugging.
How can i see this work in the browser? I added the .js file generated from the test here to a script tag, but don't seem to see source maps being used. |
Initial support is in Firefox 23 (Aurora, currently) with a bunch of improvements (and more to land) in Nightly. When the debugger is open, there is an options cog wheel in the top right corner, there should be a "show original sources" option which enables source maps. There are some pictures showing this process at the end of this article: https://hacks.mozilla.org/2013/05/compiling-to-javascript-and-debugging-with-source-maps/ |
As for Chrome, source map usage should be automatic. You should be able to see in work for uncaught exceptions, when breaking on exceptions, and when setting breakpoints in the sources panel of the debugger. Note that the point where the exception actually gets thrown is usually unmapped, because that's in runtime code; the mapped lines usually start 1 or 2 steps up on the stack trace. Some issues I've noticed upon further poking around:
I should probably file bugs against Chrome / FF devtools for some of those issues, once I'm sure it's not our fault. |
Hmm, I made a mistake in git apparently, and this is marked as merged even though it is not. I don't see a way to reopen it. Can you open another pull for this? Sorry about that. |
When I do "show original sources" it just says "loading.." and nothing seems to happen. In Chrome nothing happens either. Here are the files I have in |
Oops, it turns out that I was using Chrome Beta (28) instead of Stable (27). Sorry! (I wish they had different icons...) I can reproduce the issue with 27, but it works on 28. As for FF -- it seems like if the entries in the "sources" array use an absolute path name, and the "sourcesContent" entry is present, then we get that perma-loading issue. Making the path relative fixes things. (I think this is a bug in devtools.) I hadn't noticed it earlier as I was testing files compiled by passing Independent of the above issues, the JS should be included in Edit: I'll open a new PR once I fix the inline script bug, so that the user can get source maps working just by typing |
Apologies, I was incorrect and this is the expected behavior.
Are you using a |
Does the gist I pasted above work for either of you? Not sure if it should or shouldn't given the last few comments... |
In Chrome 28, there should be a |
I've separated out the addition of the source-map library as a separate commit, so you can review a cleaner diff by looking at the second commit alone.