We want to develop a browser (client side only) library using Coffeescript, and in particular, we tend to use the \"class\" capability of Coffeescript quite a bit, in addition t
First off, if you're using RequireJS you're going to have a not-easy time returning multiple "things" from a define function. RequireJS uses AMD (!NOT! CommonJS) format "standards", which doesn't contain a module.exports object for exporting "stuff" but instead relies on return something.
With that said, I'm not exactly sure what you're looking for here but having a class work with RequireJS is pretty easy. Something like this:
define ['my/required/module'], (myModule) ->
class MyOtherModule
privateField = 0
constructor: ->
publicMethod: ->
return MyOtherModule
This can be used in a require/define function just like any other script. Take this example:
require ['my/other/module'], (MyOtherModule) ->
instance = new MyOtherModule()
We can even use it with "extends"
define ['my/other/module'], (MyOtherModule) ->
class MyThirdModule extends MyOtherModule
...
Hopefully this helps!