typeoneerror typeoneerror - 1 month ago 10
CoffeeScript Question

Maintaining comments in .js files after compilation from .coffee

I'd like to keep the comments I write in my CoffeeScript files intact in the outputted JavaScript files. How can I do that?

#!/usr/bin/env bash

./node_modules/.bin/coffee --output lib/ --compile --bare --watch src/

Answer

From the coffee-script documentation:

Block comments, which mirror the syntax for heredocs, are preserved in the generated code.

This:

###
This will be preserved in a block comment in the javascript
###

Compiles to this:

/*
This will be preserved in a block comment in the javascript
*/