I was wondering if you are able to require a coffeescript from within another coffeescript.
My example code from file "user.coffee"
class UserObj
constructor: (@name) ->
console.log @name
My example code from main file
require "./user.coffee"
User = new UserObj "Example"
Is this possible from within a coffeescript file or just a js file?
Yes it is possible.
user.coffee:
exports.UserObj =
class UserObj
constructor: (@name) ->
console.log @name
main.coffee:
{UserObj} = require "./user"
User = new UserObj "Example"
Please follow this link for details:
http://coffeescript.org/documentation/docs/command.html
You can use this library coffee-stir to include other dependencies. Its a way around only using required from the web and it will add dependencies as you use it.
FYI i made the lib when i was facing similar problems