rspivak / slimit

SlimIt - a JavaScript minifier/parser in Python
MIT License
551 stars 94 forks source link

Comment Node support in parser and visitors #20

Closed piyagee closed 12 years ago

piyagee commented 12 years ago

Added partial support for LineComment and BlockComment Node(s) for parser and all visitors + fixed potentially broken lextab and yacctab modules generation (corner cases of missing modules and python egg as zip file)

Currently inline comments are not supported (it is not clear for me now where to put comment node if it's in the middle of some expression)

PS i wanted to make this pull request into develop branch, but looks like it was not merged with master for some time.

rspivak commented 12 years ago

Hi,

First of all thanks for the code. The problem with preserving comments is that too many rules in the parser will have to be changed to support that. It's a lot of work and doesn't benefit the minifier.

I checked both UglifyJS and Google Closure and they don't preserve comments either:

I like your idea to preserve a license header though and if you feel like adding support for that you're more than welcome. Feel free to ask me any question regarding that.

piyagee commented 12 years ago

The idea was to extend parser so it could potentially support not only license but commented code annotations + conceptually code prettifier is broken if it omits comments. But you are definitely right that this is out focus of this lib, so i'm closing this request. Thank you for looking into this )

gleber commented 12 years ago

This is a pretty useful thing. It would allow the library to be used as a dependency manager of JavaScript files, where dependencies are defined in JS comments