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 =
a: require('./twtmore/a.coffee').a
b: require('./twtmore/b.coffee').b
c: require('./twtmore/c.coffee').c
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.
As for using node.js to write a client-side JavaScript library, just use modul8 or browserify to compile it into a single JavaScript file.
If you value people using your library then No, don't do it.
The JavaScript community will hate you for publishing an open source javascript library who's source code is written in CoffeeScript
<aside>
CoffeeScript is a horrible language </aside>
Seriously though