Can I write a CoffeeScript lib the same way for the server and client?

I'm trying to write a modular library in CoffeeScript. I want to write the code once, and use it in the same way on the server (running Node in this case) and on the browser. How can I do this?

My code structure is like this...

  • src/a.coffee
  • src/b.coffee
  • src/c.coffee

And my dependencies are like this... a depends on b, c depends on a and b.

I've tried Browserify and requirejs, but I couldn't quite get there with it. I've also looked into Traceur but that's no use since I'm using CoffeeScript. I'm really at a loss, the only thing I can think of, is bundling it all up in one file and doing it traditionally as explained in this blog... https://alicoding.com/write-javascript-modules-that-works-both-in-nodejs-and-browser-with-requirejs/. I really don't want to do that, I'd probably just write it in Dart sooner than I would bundle it up like that. CoffeeScript is really letting me down with this particular issue.

I forgot to resolve this. I ended up using https://github.com/jrburke/amdefine.