ClojureScript source maps

411 views
Skip to first unread message

John

unread,
Jul 24, 2011, 1:19:51 PM7/24/11
to Clojure
Is there any interest in having ClojureScript generate source maps?

http://code.google.com/p/closure-compiler/wiki/SourceMaps

There are a couple of ways to accomplish this.

David Nolen

unread,
Jul 24, 2011, 2:59:52 PM7/24/11
to clo...@googlegroups.com
I'm sure there is a considerable amount of interest in this.

David 

Brandon Bloom

unread,
Mar 22, 2012, 6:05:42 AM3/22/12
to clo...@googlegroups.com
SourceMap support is rapidly approaching general availability in Chrome and Firefox:


I'd love to see this happen and *may* be able to find time to help with implementation.

Any intel on existing attempts at this?

David Nolen

unread,
Mar 23, 2012, 12:53:41 AM3/23/12
to clo...@googlegroups.com
There are no existing attempts. The first step would be just to get the compiler to emit an optional source map. Bonus points if we can merge source maps from the ClojureScript compiler and Closure advanced compilation.

David

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Brandon Bloom

unread,
Mar 23, 2012, 10:51:53 PM3/23/12
to clo...@googlegroups.com
> The first step would be just to get the compiler to emit an optional source map.

That's definitely the first step! After that, there's going to need to be some way to serve those source maps via HTTP upon request from the browser.

However, there's a first step to the first step: Getting column data. The reader currently seems to only produce a :line key in the metadata map.

> Bonus points if we can merge source maps from the ClojureScript compiler and Closure advanced compilation.

Could you please clarify? Do you mean for multi-level mapping?

See the "Multi-level Mapping Notes" section in the v3 spec:

It seems like once they agree upon a header (as opposed to the javascript comment syntax) this would also be useful for providing pre-macro-expansion vs post-macro-expansion source maps.

David Nolen

unread,
Mar 24, 2012, 2:00:47 PM3/24/12
to clo...@googlegroups.com, cloju...@googlegroups.com
On Fri, Mar 23, 2012 at 10:51 PM, Brandon Bloom <snpr...@gmail.com> wrote:
> The first step would be just to get the compiler to emit an optional source map.

That's definitely the first step! After that, there's going to need to be some way to serve those source maps via HTTP upon request from the browser.

However, there's a first step to the first step: Getting column data. The reader currently seems to only produce a :line key in the metadata map.

Yep. This would require enhancing the Clojure reader. I don't think that's feasible for 1.4, but probably worth pursuing for 1.5. Even without it, we can still get line level debugging which is better than nothing and write the code to use :column data when available.
 
Could you please clarify? Do you mean for multi-level mapping?

Yes. Again this is really just bonus points. Priority 1 is just improving the development experience.
 
See the "Multi-level Mapping Notes" section in the v3 spec:

It seems like once they agree upon a header (as opposed to the javascript comment syntax) this would also be useful for providing pre-macro-expansion vs post-macro-expansion source maps.

 We could also decide to handle multi-mapping ourselves - that is write the code that can produce a merged source map.

David

Brandon Bloom

unread,
Mar 24, 2012, 4:40:40 PM3/24/12
to clo...@googlegroups.com, cloju...@googlegroups.com
 We could also decide to handle multi-mapping ourselves - that is write the code that can produce a merged source map.

It seems likely (already done?) for browsers to support the X-SourceMap header and //@ comments for the target use case of CoffeeScript -> Javascript -> Minified Javascript

Also, it seems preferable to let the browser do it, so their debugger can operate at various levels of source translation depending on your needs.

So why bother doing it ourselves? For the Rhino environment?

Sean Allen

unread,
Mar 24, 2012, 8:10:35 PM3/24/12
to clo...@googlegroups.com
On Sun, Jul 24, 2011 at 1:19 PM, John <conca...@gmail.com> wrote:
Lots of interest from me. 
Reply all
Reply to author
Forward
0 new messages