ndparker / rjsmin

Fast javascript minifier for Python
http://opensource.perlig.de/rjsmin/
Apache License 2.0
60 stars 15 forks source link

Generate sourcemaps when minifying #6

Open danielhers opened 8 years ago

danielhers commented 8 years ago

Sourcemaps are essential for being able to read and debug minified Javascript code: http://blog.teamtreehouse.com/introduction-source-maps There should be an option to generate one when minifying with rjsmin.

ndparker commented 8 years ago

Hi,

[ Side note: given the claim, that source maps are an essential tool, it's not helpful that there seems to be no canonical specification for them. (Everybody seems to link to some google docs, but they refuse to show in my browser - I didn't even verify that everybody links to the same document, the URLs are ... whatever) ]

However, what I've got from the linked blog post is that rjsmin would need to understand semantics of javascript. That is not how it works. rjsmin designed to be fast and to know about the semantics of the whitespaces in JS only (so basically everything in between the actual javascript code).

I need some convincing here, that a source map is even possible with rjsmin. If that's the case, then maybe it should be an option.

Cheers,

danielhers commented 8 years ago

I'm afraid I'm not an expert on the subject, just a user. But it seems to me that rjsmin works by substitution - e.g. substituting whitespace for the empty string. Every substitution can be automatically accompanied by a mapping back to the original character positions by shifting by the length difference of the substitution.

Thanks for taking this into consideration!

ndparker commented 8 years ago

Hmm. It seems the name mapping is optional, so one could get away without knowing too much.

Looks still quite complicated, in other words - this will probably take a while :/