11 ms·
CoffeeScript 1.6.0 released with support for source maps
- aroman 14y agoI know I speak for many others when I say I have been waiting for this for a long time. This is fantastic, thanks so much for the hard work :)
- jashkenas 14y agoI hope some of you find 'em useful ;) Please direct all thanks for this over to http://github.com/jwalton 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.
- rdudekul 14y agoAbsolutely fantastic! Though it is fairly easy to manually map the javascript source line to coffeescript code, I am hoping this feature can somehow be embedded into editors to make it much easier to write large coffeescript modules (live coding).
- mikeknoop 14y agoCan source maps handle source files in a different location than the compiled JS file? In my few minutes after installing, I didn't immediately see a way to do this.
- jashkenas 14y agoCan't edit anymore, so I'll just reply to myself. 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.
- DanielRibeiro 14y agoThank you very much for this! Coffeescript has certainly come a long way since I started using it on version 0.9.4, 2 years ago. Congratulations!
- coldtea 14y agoWow, that's great. And merely a week since 1.5!
- chc 14y agoFor anyone wondering (since it's such a new thing that not a lot of people know much about it): Source maps are currently only supported in Chrome, but it's also implemented in recent WebKit nightlies and Firefox is actively working on support. In order to use source maps in Chrome, open the options panel on the dev tools and make sure the "Source maps" option is enabled.
- jashkenas 14y agoRight. As far as I know, they currently work in Chrome, in Node.js (with a library), in Webkit nightlies, and are getting close-ish in Firefox nightlies: http://fitzgeraldnick.com/weblog/45/ http://fitzgeraldnick.com/weblog/45/
- AdamTReineke 14y agoIf you have Visual Studio, they have source map debugging for TypeScript working. You can do CoffeeScript dev in Visual Studio [1], but I have no idea if source maps work with that. [1] http://visualstudiogallery.msdn.microsoft.com/2b96d16a-c986-4501-8f97-8008f9db141a http://visualstudiogallery.msdn.microsoft.com/2b96d16a-c986-...
- ahrjay 14y agoIt's supported in WebKit nightly too.
- chc 14y agoThanks for that! Added to my comment. I meant to mention WebKit initially, but I got so focused on double-checking that my Firefox information was current that I just stopped afterward.
- cabbeer 14y agoFor someone who is new to Javascript (and programming in general), how do you know when it'a ok to move on to coffeescript? (I started with ruby and I like how coffeescript has similar syntax)
- oseibonsu 14y agoAlthough it is a great idea to learn javascript first, you can move to Coffeescript at any time. Coffeescript compiles to javascript.
- Lewisham 14y agoAgreed. CoffeeScript is a leaky abstraction of JS; the underlying paradigm of JS still peeks out even though it's papered over (see the fat arrow =>). 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.
- jashkenas 14y agoIntentionally "leaky" ;) Martin Fowler has written a good post about how and why this is desirable: http://martinfowler.com/bliki/TransparentCompilation.html http://martinfowler.com/bliki/TransparentCompilation.html
- civilian 14y agoProbably right now. But that's a good question. As you've already seen, the documentation on http://coffeescript.org http://coffeescript.org is phenomenal. 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 https://github.com/gruntjs/grunt-contrib-coffee
- gbadman 14y agoTo: JAshkenas, JWalton 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/33eb3c5049b3ee5d497f80dea406deac328de8ba 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 http://beta.plnkr.co/edit/e5iLyQ?p=preview
- seoguru 14y agowhere/how do we add the breakpoint? plunker looks awesome btw.
- deleted 14y ago[deleted]
- ConstantineXVI 14y agoIn the case of Erlang, Elixr[0] is probably what you're looking for. [0] http://elixir-lang.org/ http://elixir-lang.org/
- chc 14y agoCoffeeScript is deliberately tied to JavaScript by design. Porting it to work with Erlang or C would be rather awkward. Outside the context of a JavaScript environment, CoffeeScript doesn't seem to offer enough benefits over, say, Python to be worth the massive amount of work this would entail. If you mean you want another language that can interact with Erlang or C code, those already exist (in fact, there are a lot of langauges that are C-compatible since it's the lingua franca of modern computing). And if you want an alternative Erlang, see Elixir (http://elixir-lang.org/ http://elixir-lang.org/), Joxa (http://joxa.org/ http://joxa.org/) and LFE (https://github.com/rvirding/lfe https://github.com/rvirding/lfe).
- roryokane 14y agoBy “CoffeeScript for C“, I think Onr means not supporting all of CoffeeScript’s features in C, but rather making a language that is very much like C, but better. So CoffeeScript for C wouldn’t try to implement `@foo` to mean `this.foo`, since there is no `this` in C. Rather, it would look at the common idioms in C that are more verbose than they need to be and shorten them. CoffeeScript for C would probably use semantic whitespace, like normal CoffeeScript. Maybe it would make writing types easier – it would support a syntax for types that doesn’t require the use of http://www.cdecl.org/ http://www.cdecl.org/. It would still try to be “just C”, so it wouldn’t support much higher-level features like function closures.
- tmzt 14y agoYou might consider something like Vala (valac), which produces glib/gobject c code from a c# like syntax.
- kodablah 14y agoIIRC, this is one of the big reasons behind CoffeeScriptRedux. In fact, I have been following development of it closely and he's been working hard. I know he's contributed lots to the standard CoffeeScript codebase. 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?
- jashkenas 14y agoYou'll have to get Michael to answer that question, but to clear the air a bit -- it's very nice to have two versions of the compiler that don't share a common ancestry (Redux is a complete rewrite). 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.
- michaelficarra 14y agoEverything Jeremy said. And my compiler isn't far away from being polished enough for me to consider it ready to be labelled 2.0. Check out the 2.0 roadmap: https://github.com/michaelficarra/CoffeeScriptRedux/wiki/Roadmap https://github.com/michaelficarra/CoffeeScriptRedux/wiki/Roa... 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/ 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 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-redesign-of-the-coffeescript-compiler https://speakerdeck.com/michaelficarra/an-analysis-of-the-re...
- mintplant 14y agoWatch out when updating to this. There are still some issues being resolved. See: https://github.com/jashkenas/coffee-script/pull/2751 https://github.com/jashkenas/coffee-script/pull/2751 https://github.com/jashkenas/coffee-script/issues/2765 https://github.com/jashkenas/coffee-script/issues/2765 https://github.com/jashkenas/coffee-script/issues/ 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.
- VeejayRampay 14y agoCongratulations on all this hard work. Source maps will CS an even more appealing alternative to plain Javascript and make my life as a developer better. Thanks to all parties involved in producing this release.
- nathan_f77 14y agoAbsolutely awesome! Am working on support for Errbit, so we can finally have usable JavaScript exception reporting.
- gbadman 14y ago@jashkenas: with the release of this surprise, 'skunkworks' feature, what do you see as the future for Coffee-Script-Redux? Does the project remain relevant despite the recent activity in the original Coffee-Script project?
- dakimov 14y agoIn TypeScript it works out-of-the-box, plus TypeScript compiles to idiomatic JavaScript and what you write is much closer to what you get, and the transition is much easier understandable.
- ajross 14y ago> CoffeeScript includes a (very) simple build system similar to Make and Rake. 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.
- almost 14y agoThis isn't new, CoffeeScript has included this for a while. 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. [1]: http://coffeescript.org/documentation/docs/cake.html http://coffeescript.org/documentation/docs/cake.html
- ajross 14y agoYou're right that it's not new in 1.6; I misread the page. It was new to me, however. And you're right that it's quite small, and easy to read. 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.
- heydenberk 14y agoThe history of cake.coffee[1] suggests otherwise. It's been edited relatively few times since the initial checkin, mostly to make it compatible with node.js API changes, and sometimes to pare it down and simplify it. It was hardly touched at all in 2012. It is small and mindful of feature creep. [1] https://github.com/jashkenas/coffee-script/commits/master/src/cake.coffee https://github.com/jashkenas/coffee-script/commits/master/sr...
- tolmark12 14y agoAnyone have a good example of using --map with --join?
- aes 14y agoSo is there a way to use the source maps with node.js stacktraces? 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 https://github.com/evanw/node-source-map-support), but even installing that and adding "require 'source-map-support'" won't help.
- aes 14y agoOk, you'll have to run it through the compiler first with the -m option: 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.
- latchkey 14y agoThe hard part for me to understand is that I've got way more than just a single file. I've got hundreds of coffee script files for a rather complex nodejs/express app. 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?
- __david__ 14y agoDoes it somehow require running the code to generate the maps? I'm asking because when I add the "-m" to my coffee compile line I get: 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.
- jashkenas 14y agoNo. coffee --compile --map file.coffee Should produce a "file.js" and a "file.map".
- __david__ 14y agoHmmm: $ 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)
- egeozcan 14y agoNot being able to use getters, setters and yield[1] is a big turnoff for me. I want to move towards ES6 as quickly as possible. [1] https://github.com/jashkenas/coffee-script/wiki/FAQ https://github.com/jashkenas/coffee-script/wiki/FAQ
- deepflame 14y agoWhat happened to CoffeeScript 2 that was funded over Kickstarter. Wasn't this supposed to bring source maps etc to CoffeeScript?