Js2coffee 2.0 is a complete rewrite of js2coffee v0.3 started in 2014. It was released February 1, 2015 and features a new parser, Esprima, replacing the aging Narcissus build that has been in use since 2011.
The editor has been rebuilt and redesigned. It now features a new easy-to-use editor based on CodeMirror.
It also now lives in a new URL, js2.coffee, migrating away
from the old js2coffee.org
.
Constructs that are not available in CoffeeScript are marked with errors, such as:
- Reassignment of global variables
==
and!=
operators- Variable shadowing
See this demo for a few more.
The js2coffee compiler now produces a CoffeeScript AST (abstract syntax tree) before
rendering your input into code. The command-line client features an --ast
mode which lets you inspect the generated CoffeeScript AST.
Source maps are now generated. More info on this soon.
Js2coffee now features a compatibility mode (--compat
) to improve
reliability over generated CoffeeScript code (at the slight expense of elegance).
see the Compatibility mode documentation.
Try this demo — toggle the compatibility mode checkbox and see what happens.
The API has remained largely compatible with the 0.x series, but with improvements. The JavaScript API also reports the AST tree, source maps and warnings along with the output code. See the Migration guide for info on how the API has changed.
The 2.0 release closes a lot of bugs, including:
npm install js2coffee
not working (#324)- Empty if statements fail (#265)
- Variable scoping issues (#219)
- and many more
You can show share your JavaScript and CoffeeScript snippets—perfect for collaborating with coworkers or answering at StackOverflow.
The new js2.coffee features an improved CoffeeScript to JavaScript compilation UI. This makes it easier to see how Js2coffee-generated CoffeeScript looks like compared to your original code.