map JS source coordinates to source language that was translated to JS

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
7 years ago
2 years ago

People

(Reporter: brendan, Assigned: jimb)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

7 years ago
We added

//@line n "f"

as a magic comment which, when JSOPTION_ATLINE is set, should cause the next line to be taken as line n of the file named "f". This seems to have been regressed by recent scanner changes, but I'll file that separately.

The idea here is to relieve the source-to-JS translator from having to spew such comments all over the place in generated JS. Instead, the generated JS would set an ideally more concise mapping up using, e.g., JSON.

This was proposed by Jeremy Ashkenas at http://intertwingly.net/blog/2010/11/25/Hobgoblin-of-Little-Minds#c1292138238.

/be
(Reporter)

Comment 1

7 years ago
See bug 618652 for an @line bug with patch and test (I hope it can be a Firefox 4 ride-along, since it is not a blocker).

/be
(Reporter)

Comment 2

7 years ago
In case my @line ref might mislead, source coordinates must be finer grained than lines in our minified world. Line and column, as jimb has planned already.

/be
(Assignee)

Updated

7 years ago
Assignee: general → jimb
(Reporter)

Comment 3

6 years ago
Mark Miller cited

http://blog.csdn.net/dollyn/archive/2009/09/01/4506156.aspx#sourcemapfile

just now. Syntax aside, the idea lines up with this bug.

/be
(Assignee)

Updated

6 years ago
Blocks: 560314

Comment 4

6 years ago
So, SourceMap Format-ish, in terms of the data model, but in say JSON format?

Guess someone can start hacking away at a document describing that.

Thoughts on how to link the SMAP file/data to the final generated source?

- comment at the bottom of the generated source points to a URL of the SMAP file
- SMAP data included literally as a comment in the generated file
- debugger loads the file using a path-math operation of the JS file URL (remove trailing ".js" if there, append ".smap")
(In reply to comment #4)
> - SMAP data included literally as a comment in the generated file

I'm not a fan of inlining the mapping data because this same source mapping protocol is going to be used to debug minified code as well as "transpiled" sources. Because of that, it makes sense to have the mapping data be located in a separate file, to keep the js file sizes as small as possible.

I think either of the other two options would be feasible, and don't have a strong opinion either way at this time.

Comment 6

6 years ago
Can anyone point to any other SMAP-like stories for debug?  I'm hesitant to even look at the JSR 45 stuff; the link Brendan pointed to in comment #3 appears to be a copy of the JSR 45 specification.  The "original" JSR 45 spec requires a click-through agreement to read, from the jcp site itself.  Would prefer to look at something "cleaner".
(In reply to comment #6)
> Can anyone point to any other SMAP-like stories for debug?

You could look at the way that Closure Compiler generates source maps. See the src/com/google/debugging/sourcemap directory in the source code.
(Reporter)

Comment 8

6 years ago
https://docs.google.com/document/d/14AWiLDDxEuLaWuyG0X6deLRufrvxRu8HBP0LNJwvRZw/edit?hl=en_US&pli=1

https://bugs.webkit.org/show_bug.cgi?id=63940 is moving.

/be
Depends on: 568142
Depends on: 669999
Depends on: 670002

Comment 9

5 years ago
Chrome 18 has sourcemap support - http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/

Comment 10

5 years ago
GWT 2.5 plugin-free debugger Super Dev Mode relies on Source Maps:

https://developers.google.com/web-toolkit/articles/superdevmode

Comment 11

3 years ago
Is this bug still valid?
Echoing Florian ^ Is this bug still valid?
Flags: needinfo?(nfitzgerald)
Yeah, we've been done here for years. For specific bugs related to source mapping, file bugs that block https://bugzilla.mozilla.org/show_bug.cgi?id=dbg-sourcemap.
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Flags: needinfo?(nfitzgerald)
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.