Sunday, April 8, 2012

require()"ing a CoffeeScript file from a JavaScript file or REPL



I'm using Node.js and wanting to incorporate CoffeeScript into my workflow. I have two use-cases:





  1. I want to be able to write JavaScript files which require() CoffeeScript modules



  2. I want to be able to load CoffeeScript modules from within the node REPL







For case #1 I can just compile from .coffee to .js and require() the .js module, as a workaround. For case #2 right now I'm eval()'ing the output of coffee-script.compile().





Is there a better, more unified way to do this?



Source: Tips4all

No comments:

Post a Comment