I’m writing a javascript library and want to use the awesomeness that is CoffeeScript to keep the code clean while writing it, but i’d also like to use something like Node mainly for its require feature. The idea is to namespace my sub-objects under a global object, and each of the sub-objects defined in their own file for ease of development.
Maybe I am going about this the wrong way, I just need a clean way to write a client side javascript library with CoffeeScript?
Thanks! Example file structure below…
./twtmore.coffee
twtmore =
a: require('./twtmore/a.coffee').a
b: require('./twtmore/b.coffee').b
c: require('./twtmore/c.coffee').c
./twtmore/a.coffee
class a
...
exports.a = a
Yes, you are going about this the wrong way. Node.js is a server side technology. What you are looking for is using something like RequireJS or CommonJS modules (which is what node uses) in coffee script on the browser.
There is a plugin for using CoffeeScript with RequireJS which seems to do what you want but I have not used it and cannot vouch for it.