CoffeeScript 1.6.0 released with support for source maps
coffeescript.org
coffeescript.org
Please direct all thanks for this over to http://github.com/jwalton. He's been toiling away on these for a couple of months now, originally as a bit of a skunkworks. Managing to get them merged in cleanly to an oft-changing code generation codebase was no small feat.
Edit: If you're having any trouble getting these to work, `npm cache clean` and reinstall. I screwed up the initial publish.
Important Update: Just pushed out a 1.6.1 release which patches some bugs that snuck in this morning. Give it a spin.
It also makes it possible to generate source maps in the browser itself -- so if you're doing anything fancy with eval-ing CoffeeScript on the client side, you're in luck...
... now, time to hit the road.
Arrrrrrrrrrrgggggghhhh.....
Why do people insist on doing this feature creep nonsense? Just stop! The world doesn't need another build system. The fact that you personally don't understand make (or cmake, or autotools, or rake, or scons, or ant, or...) is not a good excuse for inflicting another one of these things on the rest of us.
Yes, I'm sure it meets the needs of the coffeescript project nicely. But what introducing it has actually done in build a brand new barrier to those who want to work on coffeescript. You're ghettoizing your project with this nonsense.
Also: just for the record, those "cakefile" examples look awful to me; modulo language syntax, it looks just like scons. Everyone who has ever tried to use it for something serious hates scons.
One thing to keep in mind is that Cake is tiny, the complete source shouldn't take more than a minute or 2 to read and understand[1] and is a nice example of CoffeeScript style.
Which allows me to pronounce that It's tiny because it's limited. What happens when the project bumps up against those limitations (parallel builds would be nice, or maybe default rules, or the ability to invoke and export environment variables to subprocesses, or...)? Will they abandon cake and move to a build system that already meets their more advanced needs?
Hell no. They'll add features. So the cake of 2019 will, assuming a still-robust coffeescript community, look a lot more like rake or ant or scons or cmake. It won't be tiny. It won't be easy to read. It will be yet another ridiculous build system.
[1] https://github.com/jashkenas/coffee-script/commits/master/sr...
Which you will be free not to use. Along with not using Coffeescript.
The only reason why `cake` exists is because at the time that CoffeeScript was first released, there wasn't a "standard" JavaScript build tool, and we wanted the "coffee-script" project to have as few dependencies as possible. Adding a simple way to expose functions to the command line made it possible for CoffeeScript to build itself, without relying on "make" (Windows), "jake" (very rare), or "rake" (a Ruby dependency).
Regarding your comment below -- it's definitely not going to grow. All it does is expose functions to the command-line. See a litany of "closed wontfix" tickets if you don't believe me ;)
Also -- and perhaps mainly -- releasing "coffee" and "cake" binaries together was too cute to resist.
When you're writing a node.js or browser project it's good to write build scripts in a language not too far from the main one, and it has the advantage of being able to use the whole node.js module ecosystem.
Take a look at this build script: https://github.com/ryejs/rye/blob/master/Cakefile#L52-L79 using flour[1]. I don't think you can get more succinct than that with any other build system, and it's blazing fast thanks to asynchronous I/O.
>The world doesn't need another build system.
Oh, but it does. Maybe not this one, but it sure needs a new build system.
From: The interwebs
Thank you for this! One of the biggest justifications for avoiding Coffee-Script has been the difficulty in debugging the translated code since there is (no longer) a 1-1 line mapping. This is now a thing of the past!
It took me all of 5 minutes to understand the new API for sourcemapping add support to Plunker. For those who are curious: https://github.com/filearts/plunker_run/commit/33eb3c5049b3e...
To me, this is the sign of a simple, but powerful API addition. Well done guys.
If you want an example of stepping through a sourcemapped coffee-script file, try adding a breakpoint to `app.coffee` on: http://beta.plnkr.co/edit/e5iLyQ?p=preview
[1] http://visualstudiogallery.msdn.microsoft.com/2b96d16a-c986-...
See:
https://github.com/jashkenas/coffee-script/pull/2751
https://github.com/jashkenas/coffee-script/issues/2765
https://github.com/jashkenas/coffee-script/issues/
If you've downloaded a prior version of version 1.6, you'll have to remove it from your `node_modules` folder and do an `npm cache clean` before reinstalling, as the version number is the same.
Once you have a grasp of JS (and the things you might not like about it), you can then move to CS. When something looks a bit off in CS, you'll probably be able to translate why it is that way due to the JS underpinning.
As a dev with maybe 1.5 years of JS experience, I've learned coffeescript in a week. I still don't have the coding style that my code reviewers want, but I'm writing functional code.
The biggest hurdle I've found is getting an auto-compiler for coffeescript. You don't want to do it manually:
coffee -c media/js/page.js media/js/page.coffee
everytime you want to recompile your code. But there are tools for that! https://github.com/gruntjs/grunt-contrib-coffee coffee --watch
... not working well enough for you? For fancier build processes, you certainly might want to use a fancier build tool.It's not suitable for large projects, but it is good enough for single file compilation.
See here for more options: http://coffeescript.org/#usage
People build amazing sites in both languages... so you can't go wrong... it's just a matter of what you want to learn on the way. Good luck!
Also, I'm not sure you can use these other languages' features judiciously without understanding their reasons for doing things a certain way. You will need to know how `this' and `prototype' are used and things of that nature, then you can decide if you find the abstractions and overhead of compile-to-JS languages useful.
CoffeeScript implements a classical OO system: http://www.crockford.com/javascript/inheritance.html
But I've only dabbled with CS so I'm sure like with anything, practice reduces this mental fatigue. I am bummed that CS went to camelcase, but the justification back then was a good one
You have to constantly be on the lookout for new tools that will give you new capabilities or make it easier for you to do the things you already do. So you should be willing to try something different like CS -- recognizing that it's a learning experience and it might not work out.
It's fine if you decide that CS isn't the best, and you want to stick to plain JS. Not every tool works well for every person. Sometimes everyone raves about the goodness of technology X, you try it and agree. Other times, you try it and hate it.
Sometimes you come back months or years later to a technology that gave you bad experiences, and due to changes in both you and the technology, you're pleasantly surprised. Or a long-proven technology that you've been using for years has slowly but surely been surpassed by something else, and is now nearly obsolete.
So it's not guaranteed that CS right now will work out for you, but you don't know until you try. And even if it doesn't, you should keep it in the back of your mind and take another look in a few months or years.
Good to know!
Does this deter him from completing that project? If not, what big features does Redux plan to offer that regular CoffeeScript does not? Using pegjs instead of jison?
We may merge the Redux version in and bless it as the "official" compiler some day, when it matches feature parity, and if the codebase ends up cleaner than the original (both very likely things to happen). Even in the worst case scenario, where no merge happens, we all benefit, both for learning, new features, and shared fixes for bugs, from having two independent compatible implementations of the language.
95% of the language features were supported during my funding period. Since then, it's nearly reached 100% feature parity, and the tooling/interfaces have been much improved. The code is a lot cleaner, a lot smaller, more modular, more extensible, and uses standard IRs.
If you want to try it out, see the online editor here: http://michaelficarra.github.com/CoffeeScriptRedux/ (shameless plug: it was built using my new browser bundler with full minified-JS to CoffeeScipt source map support: https://github.com/michaelficarra/commonjs-everywhere)
For anyone curious about the compiler implementation process, see this recent slide deck from my MLOC.js talk: https://speakerdeck.com/michaelficarra/an-analysis-of-the-re...
I think a huge benefit for Redux will be making the grammar very clean and extensible. I know it's on your roadmap to CS-ify it.
Edit: Oh, and if you're curious, I wanted to play around w/ translating the CS AST to TypeScript AST, but I'd obviously need to add more typing/declaration syntax to the grammar.
This is fantastic, thanks so much for the hard work :)
Thanks to all parties involved in producing this release.
Specifically, I tried this test.coffee:
throw new Error("Test")
Now running it with coffee test.coffee
still reports the wrong line number in the stack trace.There's supposedly node-source-map-support (https://github.com/evanw/node-source-map-support), but even installing that and adding "require 'source-map-support'" won't help.
test.coffee:
require 'source-map-support'
throw new Error("Test")
Now do: npm install source-map-support
coffee -c -m test.coffee
node test.js
This gets you the correct line numbers.I start it up with something like this:
nodemon -w . lib/start/web.coffee
or in production:
coffee lib/start/web.coffee
That web.coffee file then require's a chain of files.If I try to compile the source maps for all of my files first, using something like this:
mkdir .compile
coffee -m --output .compile --compile ./
In the .compile folder, there is a few oddly named subdirectories (d, b, rands, sc) with the compiled .js files in there and the respective .map files. This seems to totally break my require chain.Since I don't normally pre-compile all my coffee script files, I just run them directly using nodemon or coffee, how can I work the maps into my dev process?
TypeError: In test.coffee, Cannot call method 'indexOf' of undefined
The line in question calling _.indexOf() from the underscore library... It compiles just fine without the -m option. coffee --compile --map file.coffee
Should produce a "file.js" and a "file.map". $ coffee --version
CoffeeScript version 1.6.1
$ coffee --compile static/test.coffee
$ coffee --compile --map static/test.coffee
TypeError: In static/test.coffee, Cannot call method 'indexOf' of undefined
at Object.count (~/.npm/lib/node_modules/coffee-script/lib/coffee-script/helpers.js:33:29)
at Object.compile (~/.npm/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:72:30)
at ~/.npm/lib/node_modules/coffee-script/lib/coffee-script/command.js:171:33
at ~/.npm/lib/node_modules/coffee-script/lib/coffee-script/command.js:141:18
at [object Object].<anonymous> (fs.js:123:5)
at [object Object].emit (events.js:64:17)
at Object.oncomplete (fs.js:1181:12)
(Paths were full path names, I replaced my $HOME with ~ in the output for clarity and some security through obscurity)