Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CoffeeScript comments in JavaScript output

Is there out any flag in the CoffeeScript compiler to add single-line coffee comments to Javascript output? I read some time ago it would be supported but it turns out this option still remains unavailable.

like image 940
jarandaf Avatar asked Mar 04 '26 23:03

jarandaf


1 Answers

The easiest option is just to use block comments everywhere. A search/replace across your code base could take care of this in a trivially short time. You would change

# coffeescript one-line comment, not passed through to js

into this

### coffeescript block comment, which IS passed through to js ###

A harder option would be to mod coffeescript itself. For instance, the coffeescript lexer is very well documented, and shows that the logic used to identify block comments. By carefully modifying the lexer, I imagine you could convince it that your single line comments were block comments, which again, are already passed through to js. I haven't tried this, however.

like image 145
Chris Avatar answered Mar 07 '26 12:03

Chris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!