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

Source map support #260

Closed
pavelkukov opened this issue Jan 29, 2016 · 3 comments
Closed

Source map support #260

pavelkukov opened this issue Jan 29, 2016 · 3 comments

Comments

@pavelkukov
Copy link

This is not an issue, it is question.
Did Rhino support source maps?
If not, is it planned?

@gbrail
Copy link
Collaborator

gbrail commented Jan 29, 2016

There's not reason why we couldn't implement those in Rhino, but at the
same time we don't have any plans. There are only a few people working on
Rhino, and they're all working very sporadically, so any help is
appreciated and we take pull requests ;-)

With that said, as I understand it, the Closure Compiler supports source
maps, and furthermore the Closure Compiler is based on a fork of Rhino:

https://github.com/google/closure-compiler/wiki/Source-Maps

Perhaps someone from that team can help.

On Fri, Jan 29, 2016 at 5:33 AM, Pavel Kukov notifications@github.com
wrote:

This is not an issue, it is question
Did Rhino support source maps?
If not, is it planned?


Reply to this email directly or view it on GitHub
#260.

Greg Brail | apigee https://apigee.com/ | twitter @gbrail
http://twitter.com/gbrail @apigee https://twitter.com/apigee

@pavelkukov
Copy link
Author

Thank you @gbrail !
Very helpful info about closure compiler. I will check out what is possible.

@pastelmind
Copy link

pastelmind commented Jan 20, 2021

I landed here while looking for source map-driven exception stack traces, similar to node-source-map-support.

TL;DR: source map-driven stack traces are impossible in Rhino.

All source map-consuming tools need both the line and column numbers of the transformed code to retrieve the corresponding position from the original source. For example, Mozilla's own source-map expects the line and column parameters. However, Rhino does not provide a column number, even if V8-style stack traces are enabled. It simply prints a 0.

Rhino depends heavily on Java's own stack trace mechanism to generate JavaScript stack traces. See here where the built-in StackTraceElement object is used to create a ScriptStackTrace object. Unfortunately, Java doesn't support column numbers either.

To make source maps work for stack traces, I expect we'll need to somehow attach column numbers to every JavaScript function and extract that information when constructing a stack trace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants